@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,184 @@
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: "Games",
24
+ propagate: "w3c",
25
+ } as const;
26
+
27
+ export type GetGamesRequestIdList = Array<string>;
28
+ export type GetGamesRequestNameList = Array<string>;
29
+ export type GetGamesRequestIgdbIdList = Array<string>;
30
+ export interface GetGamesRequest {
31
+ /** The ID of the category or game to get. Include this parameter for each category or game you want to get. For example, '&id=1234&id=5678'. You may specify a maximum of 100 IDs. The endpoint ignores duplicate and invalid IDs or IDs that weren't found. */
32
+ id?: GetGamesRequestIdList | undefined;
33
+ /** The name of the category or game to get. The name must exactly match the category's or game's title. Include this parameter for each category or game you want to get. For example, '&name=foo&name=bar'. You may specify a maximum of 100 names. The endpoint ignores duplicate names and names that weren't found. */
34
+ name?: GetGamesRequestNameList | undefined;
35
+ /** The [IGDB](https://www.igdb.com/) ID of the game to get. Include this parameter for each game you want to get. For example, '&igdb_id=1234&igdb_id=5678'. You may specify a maximum of 100 IDs. The endpoint ignores duplicate and invalid IDs or IDs that weren't found. */
36
+ igdb_id?: GetGamesRequestIgdbIdList | undefined;
37
+ }
38
+ export interface GetGamesResponseDataItem {
39
+ /** An ID that identifies the category or game. */
40
+ id?: string | undefined;
41
+ /** The category's or game's name. */
42
+ name?: string | undefined;
43
+ /** A URL to the category's or game's box art. You must replace the '{width}x{height}' placeholder with the size of image you want. */
44
+ box_art_url?: string | undefined;
45
+ /** The ID that [IGDB](https://www.igdb.com/)uses to identify this game. If the IGDB ID is not available to Twitch, this field is set to an empty string. */
46
+ igdb_id?: string | undefined;
47
+ }
48
+ /** The list of categories and games. The list is empty if the specified categories and games weren't found. */
49
+ export type GetGamesResponseDataList = Array<GetGamesResponseDataItem>;
50
+ export interface GetGamesResponse {
51
+ /** The list of categories and games. The list is empty if the specified categories and games weren't found. */
52
+ data?: GetGamesResponseDataList | undefined;
53
+ }
54
+ export interface GetTopGamesRequest {
55
+ /** 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. */
56
+ first?: number | undefined;
57
+ /** 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) */
58
+ after?: string | undefined;
59
+ }
60
+ export type GetTopGamesResponseDataItem = GetGamesResponseDataItem;
61
+ /** The list of categories and games. The list is sorted by the number of viewers, with the most popular first. A page may contain fewer than *first* items even if more pages remain. */
62
+ export type GetTopGamesResponseDataList = Array<GetGamesResponseDataItem>;
63
+ /** 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) */
64
+ export interface GetTopGamesResponsePagination {
65
+ /** The cursor used to get the next page of results. Use the cursor to set the request's *after* query parameter. */
66
+ cursor?: string | undefined;
67
+ }
68
+ export interface GetTopGamesResponse {
69
+ /** The list of categories and games. The list is sorted by the number of viewers, with the most popular first. A page may contain fewer than *first* items even if more pages remain. */
70
+ data: GetTopGamesResponseDataList;
71
+ /** 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) */
72
+ pagination?: GetTopGamesResponsePagination | undefined;
73
+ }
74
+ export type GetGamesError = TwitchOpError;
75
+ /** Get Games Gets information about specified categories or games. You may get up to 100 categories or games by specifying their ID or name. You may specify all IDs, all names, or a combination of IDs and names. If you specify a combination of IDs and names, the total number of IDs and names must not exceed 100. You must specify at least one *id*, *name*, or *igdb_id* query parameter. 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/games/#get-games */
76
+ export const getGames: API.OperationMethod<
77
+ GetGamesRequest,
78
+ GetGamesResponse,
79
+ GetGamesError,
80
+ TwitchOpContext
81
+ > = /*@__PURE__*/ API.make(() => ({
82
+ input: __S(1, __c0, 1) as any as S.Schema<GetGamesRequest>,
83
+ output: __S(2, __c0, 2) as any as S.Schema<GetGamesResponse>,
84
+ errors: [],
85
+ serviceErrors: TwitchServiceErrors,
86
+ protocol: TwitchProtocol,
87
+ retry: Retry.Retry,
88
+ telemetry: TELEMETRY,
89
+ span: "GetGames",
90
+ }));
91
+
92
+ export type GetTopGamesError = TwitchOpError;
93
+ /** Get Top Games Gets information about the categories and games that have the most viewers on Twitch. 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/games/#get-top-games */
94
+ export const getTopGames: API.PaginatedOperationMethod<
95
+ GetTopGamesRequest,
96
+ GetTopGamesResponse,
97
+ GetTopGamesError,
98
+ TwitchOpContext,
99
+ GetGamesResponseDataItem
100
+ > = /*@__PURE__*/ API.makePaginated(
101
+ () => ({
102
+ input: __S(8, __c2, 0) as any as S.Schema<GetTopGamesRequest>,
103
+ output: __S(10, __c2, 2) as any as S.Schema<GetTopGamesResponse>,
104
+ errors: [],
105
+ serviceErrors: TwitchServiceErrors,
106
+ protocol: TwitchProtocol,
107
+ retry: Retry.Retry,
108
+ telemetry: TELEMETRY,
109
+ span: "GetTopGames",
110
+ pagination: {
111
+ mode: "cursor",
112
+ inputToken: "after",
113
+ outputToken: "pagination.cursor",
114
+ items: "data",
115
+ pageSize: "first",
116
+ } as const,
117
+ }),
118
+ paginateCursor,
119
+ ) as any;
120
+
121
+ // Schema builders: each runs one schema initializer, on that schema's first use.
122
+ function __c0(j: number): any {
123
+ switch (j) {
124
+ case 0:
125
+ return S.Array(S.String);
126
+ case 1:
127
+ return S.suspend(() =>
128
+ S.Struct({
129
+ id: S.optional(__S(0, __c0, 0).pipe(T.Query())),
130
+ name: S.optional(__S(0, __c0, 0).pipe(T.Query())),
131
+ igdb_id: S.optional(__S(0, __c0, 0).pipe(T.Query())),
132
+ }).pipe(T.Http({ method: "GET", uri: "/games", code: 200 })),
133
+ ).annotate({ identifier: "GetGamesRequest" });
134
+ case 2:
135
+ return S.suspend(() =>
136
+ S.Struct({
137
+ data: S.optional(__S(5, __c1, 1)),
138
+ }),
139
+ ).annotate({ identifier: "GetGamesResponse" });
140
+ }
141
+ }
142
+ function __c1(j: number): any {
143
+ switch (j) {
144
+ case 0:
145
+ return S.suspend(() =>
146
+ S.Struct({
147
+ id: S.optional(S.String),
148
+ name: S.optional(S.String),
149
+ box_art_url: S.optional(S.String),
150
+ igdb_id: S.optional(S.String),
151
+ }),
152
+ ).annotate({ identifier: "GetGamesResponseDataItem" });
153
+ case 1:
154
+ return S.Array(__S(4, __c1, 0));
155
+ }
156
+ }
157
+ function __c2(j: number): any {
158
+ switch (j) {
159
+ case 0:
160
+ return S.suspend(() =>
161
+ S.Struct({
162
+ first: S.optional(S.Number.pipe(T.Query())),
163
+ after: S.optional(S.String.pipe(T.Query())),
164
+ }).pipe(T.Http({ method: "GET", uri: "/games/top", code: 200 })),
165
+ ).annotate({ identifier: "GetTopGamesRequest" });
166
+ case 1:
167
+ return S.suspend(() =>
168
+ S.Struct({
169
+ cursor: S.optional(S.String),
170
+ }),
171
+ ).annotate({ identifier: "GetTopGamesResponsePagination" });
172
+ case 2:
173
+ return S.suspend(() =>
174
+ S.Struct({
175
+ data: __S(5, __c1, 1),
176
+ pagination: S.optional(__S(9, __c2, 1)),
177
+ }),
178
+ ).annotate({ identifier: "GetTopGamesResponse" });
179
+ }
180
+ }
181
+ // Schema table: entry i is schema j of builder f, made on first reach.
182
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
183
+ return (__s[i] ??= __L.at(f, j));
184
+ }
@@ -0,0 +1,110 @@
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: "Goals",
23
+ propagate: "w3c",
24
+ } as const;
25
+
26
+ export interface GetCreatorGoalsRequest {
27
+ /** The ID of the broadcaster that created the goals. This ID must match the user ID in the user access token. */
28
+ broadcaster_id: string;
29
+ }
30
+ export interface GetCreatorGoalsResponseDataItem {
31
+ /** An ID that identifies this goal. */
32
+ id?: string | undefined;
33
+ /** An ID that identifies the broadcaster that created the goal. */
34
+ broadcaster_id?: string | undefined;
35
+ /** The broadcaster's display name. */
36
+ broadcaster_name?: string | undefined;
37
+ /** The broadcaster's login name. */
38
+ broadcaster_login?: string | undefined;
39
+ /** The type of goal. Possible values: - `follower`: The goal is to increase followers. - `subscription`: The goal is to increase subscriptions. This type shows the broadcaster's total tier points from subscriptions, which increase and decrease as users subscribe and unsubscribe. - `subscription_count`: The goal is to increase subscriptions. This type shows the broadcaster's total number of subscriptions, which increases and decreases as users subscribe and unsubscribe. - `new_subscription`: The goal is to increase subscriptions. This type shows only the net increase in tier points associated with the subscriptions (it does not account for users that unsubscribed since the goal started). - `new_subscription_count`: The goal is to increase subscriptions. This type shows only the net increase in the number of subscriptions (it does not account for users that unsubscribed since the goal started). - `new_bit`: The goal is to increase the amount of Bits used on the channel. - `new_cheerer`: The goal is to increase the amount of unique Cheerers on to Cheer on the channel. */
40
+ type?: string | undefined;
41
+ /** A description of the goal. Is an empty string if not specified. */
42
+ description?: string | undefined;
43
+ /** The goal's current value. The goal's `type` determines how this value is increased or decreased. - If `type` is follower, this field is set to the broadcaster's current number of followers. This number increases with new followers and decreases when users unfollow the broadcaster. - If `type` is subscription, this field is increased and decreased by the points value associated with the subscription tier. For example, if a tier-two subscription is worth 2 points, this field is increased or decreased by 2, not 1. - If `type` is subscription_count, this field is increased by 1 for each new subscription and decreased by 1 for each user that unsubscribes. - If `type` is new_subscription, this field is increased by the points value associated with the subscription tier. For example, if a tier-two subscription is worth 2 points, this field is increased by 2, not 1. - If `type` is new_subscription_count, this field is increased by 1 for each new subscription. - If `type` is new_bit, this field is increased by the number of Bits used on the channel. - If `type` is new_cheerer, this field is increased by 1 the first time each user Cheers on the channel after the goal starts. Other ways of using Bits don't count. */
44
+ current_amount?: number | undefined;
45
+ /** The goal's target value. For example, if the broadcaster has 200 followers before creating the goal, and their goal is to double that number, this field is set to 400. */
46
+ target_amount?: number | undefined;
47
+ /** The UTC date and time (in RFC3339 format) that the broadcaster created the goal. */
48
+ created_at?: string | undefined;
49
+ }
50
+ /** The list of goals. The list is empty if the broadcaster hasn't created goals. */
51
+ export type GetCreatorGoalsResponseDataList = Array<GetCreatorGoalsResponseDataItem>;
52
+ export interface GetCreatorGoalsResponse {
53
+ /** The list of goals. The list is empty if the broadcaster hasn't created goals. */
54
+ data?: GetCreatorGoalsResponseDataList | undefined;
55
+ }
56
+ export type GetCreatorGoalsError = TwitchOpError;
57
+ /** Get Creator Goals Gets the broadcaster's list of active goals. Use this endpoint to get the current progress of each goal. Instead of polling for the progress of a goal, consider [subscribing](https://dev.twitch.tv/docs/eventsub/manage-subscriptions.md) to receive notifications when a goal makes progress using the [channel.goal.progress](https://dev.twitch.tv/docs/eventsub/reference/goal.md#channel-goal-progress) subscription type. [Read More](https://dev.twitch.tv/docs/api/goals.md#requesting-event-notifications) 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:goals** scope. Reference: https://dev.twitch.tv/docs/api/reference/goals/#get-creator-goals */
58
+ export const getCreatorGoals: API.OperationMethod<
59
+ GetCreatorGoalsRequest,
60
+ GetCreatorGoalsResponse,
61
+ GetCreatorGoalsError,
62
+ TwitchOpContext
63
+ > = /*@__PURE__*/ API.make(() => ({
64
+ input: __S(0, __c0, 0) as any as S.Schema<GetCreatorGoalsRequest>,
65
+ output: __S(3, __c0, 3) as any as S.Schema<GetCreatorGoalsResponse>,
66
+ errors: [],
67
+ serviceErrors: TwitchServiceErrors,
68
+ protocol: TwitchProtocol,
69
+ retry: Retry.Retry,
70
+ telemetry: TELEMETRY,
71
+ span: "GetCreatorGoals",
72
+ }));
73
+
74
+ // Schema builders: each runs one schema initializer, on that schema's first use.
75
+ function __c0(j: number): any {
76
+ switch (j) {
77
+ case 0:
78
+ return S.suspend(() =>
79
+ S.Struct({
80
+ broadcaster_id: S.String.pipe(T.Query()),
81
+ }).pipe(T.Http({ method: "GET", uri: "/goals", code: 200 })),
82
+ ).annotate({ identifier: "GetCreatorGoalsRequest" });
83
+ case 1:
84
+ return S.suspend(() =>
85
+ S.Struct({
86
+ id: S.optional(S.String),
87
+ broadcaster_id: S.optional(S.String),
88
+ broadcaster_name: S.optional(S.String),
89
+ broadcaster_login: S.optional(S.String),
90
+ type: S.optional(S.String),
91
+ description: S.optional(S.String),
92
+ current_amount: S.optional(S.Number),
93
+ target_amount: S.optional(S.Number),
94
+ created_at: S.optional(S.String),
95
+ }),
96
+ ).annotate({ identifier: "GetCreatorGoalsResponseDataItem" });
97
+ case 2:
98
+ return S.Array(__S(1, __c0, 1));
99
+ case 3:
100
+ return S.suspend(() =>
101
+ S.Struct({
102
+ data: S.optional(__S(2, __c0, 2)),
103
+ }),
104
+ ).annotate({ identifier: "GetCreatorGoalsResponse" });
105
+ }
106
+ }
107
+ // Schema table: entry i is schema j of builder f, made on first reach.
108
+ function __S(i: number, f: (j: number) => unknown, j: number): any {
109
+ return (__s[i] ??= __L.at(f, j));
110
+ }