@distilled.cloud/twitch 0.0.0-stage → 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 +83 -2
  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 +88 -3
  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
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md CHANGED
@@ -1,3 +1,84 @@
1
- # Temporary Holding Version
1
+ # @distilled.cloud/twitch
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Effect-native [Twitch API (Helix)](https://dev.twitch.tv/docs/api/) SDK, generated from the official
4
+ [API reference](https://dev.twitch.tv/docs/api/reference/).
5
+
6
+ Twitch publishes no machine-readable description of the API, so the reference is the spec: its Markdown
7
+ pages are mirrored daily and every operation, parameter and response field is read from them. There are
8
+ 147 operations in 29 modules, one per reference page.
9
+
10
+ ## Installation
11
+
12
+ ```bash
13
+ npm install @distilled.cloud/twitch effect
14
+ ```
15
+
16
+ ## Quick start
17
+
18
+ ```ts
19
+ import { Effect, Layer } from "effect";
20
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
21
+ import * as Twitch from "@distilled.cloud/twitch";
22
+ import * as Channels from "@distilled.cloud/twitch/channels";
23
+ import * as Users from "@distilled.cloud/twitch/users";
24
+
25
+ const program = Effect.gen(function* () {
26
+ const { data: users = [] } = yield* Users.getUsers({ login: ["twitchdev"] });
27
+ const { data: channels = [] } = yield* Channels.getChannelInformation({
28
+ broadcaster_id: users.map((user) => user.id!),
29
+ });
30
+ return channels.map((channel) => ({ name: channel.broadcaster_name, game: channel.game_name }));
31
+ });
32
+
33
+ const Live = Layer.mergeAll(
34
+ FetchHttpClient.layer,
35
+ Twitch.CredentialsFromEnv,
36
+ );
37
+
38
+ program.pipe(Effect.provide(Live), Effect.runPromise).then(console.log);
39
+ ```
40
+
41
+ Sending a chat message:
42
+
43
+ ```ts
44
+ import * as Chat from "@distilled.cloud/twitch/chat";
45
+
46
+ const sent = Chat.sendChatMessage({
47
+ broadcaster_id: "12826",
48
+ sender_id: "141981764",
49
+ message: "Hello, world!",
50
+ });
51
+ ```
52
+
53
+ ## Pagination
54
+
55
+ The 32 operations that page take a cursor in `after` and return the next one in `pagination`; each has
56
+ `.pages()` and `.items()`:
57
+
58
+ ```ts
59
+ import { Stream } from "effect";
60
+ import * as Streams from "@distilled.cloud/twitch/streams";
61
+
62
+ const live = Streams.getStreams.items({ first: 100 }).pipe(Stream.take(500), Stream.runCollect);
63
+ ```
64
+
65
+ ## Auth
66
+
67
+ Every call sends `TWITCH_ACCESS_TOKEN` as `Authorization: Bearer` and `TWITCH_CLIENT_ID` as `Client-Id`;
68
+ the client ID must be the one the token was issued to. The token is a user access token or an app access
69
+ token ([Twitch's guide](https://dev.twitch.tv/docs/authentication/)); each operation's documentation says
70
+ which it accepts and which scopes it needs. Optional `TWITCH_API_BASE_URL` (default
71
+ `https://api.twitch.tv/helix`).
72
+
73
+ ```ts
74
+ import { Redacted } from "effect";
75
+ import * as Twitch from "@distilled.cloud/twitch";
76
+
77
+ const Auth = Twitch.credentials({
78
+ accessToken: Redacted.make(token),
79
+ clientId: "your-client-id",
80
+ });
81
+ ```
82
+
83
+ Failures are typed by HTTP status (`Unauthorized`, `Forbidden`, `TooManyRequests`, ...); a status
84
+ without a class, such as `425 Too Early`, is `UnknownTwitchError`.
package/lib/.lazy.json ADDED
@@ -0,0 +1 @@
1
+ {"serviceDirs":["services"],"twins":[]}
@@ -0,0 +1,4 @@
1
+ import*as $0 from"./sdk.js";
2
+ import{api$lazyService as L}from"@distilled.cloud/core/_bundle/base";
3
+ const u=import.meta.url,N=[$0];
4
+ export const $L=(s,k,a,l,x)=>L(u,s,k,a===void 0?void 0:x?N.concat(x):N,a,l);
@@ -0,0 +1,2 @@
1
+ import{api$D as e,api$call as t,api$named as ee,api$op as n,api$opPaginated as r,category$withParseError as i,config$Redacted as a,config$String as o,config$all as te,config$withDefault as ne,pagination$paginateCursor as re,retry$capped as ie,retry$jittered as ae,retry$makeDefault as s,retry$throttlingFactory as c,retry$throttlingOptions as l,retry$transientFactory as u,retry$transientOptions as d,schema_lite_typed$TaggedError as f,schema_lite_typed$Unknown as p,trait$Body as m,trait$FormDataFile as h,trait$Header as g,trait$Http as _,trait$HttpBody as v,trait$KeyDictionary as y,trait$Label as b,trait$Query as x,trait$ResponseCode as S,trait$UnionCases as C,trait$applyErrorMatchers as w,trait$bodySymbol as T,trait$errorMatchersSymbol as E,trait$formDataFileSymbol as D,trait$getErrorMatchers as O,trait$headerSymbol as k,trait$httpBodySymbol as A,trait$httpSymbol as j,trait$keyDictionarySymbol as M,trait$labelSymbol as N,trait$querySymbol as P,trait$responseCodeSymbol as F,trait$unionCasesSymbol as I}from"@distilled.cloud/core/_bundle/base";import{errors$API_ERRORS as L,errors$BadGateway as R,errors$BadRequest as z,errors$ConfigError as B,errors$Conflict as V,errors$DEFAULT_ERRORS as H,errors$Forbidden as U,errors$GatewayTimeout as W,errors$HTTP_STATUS_MAP as G,errors$InternalServerError as K,errors$Locked as q,errors$NotFound as J,errors$ServiceUnavailable as oe,errors$TooManyRequests as se,errors$Unauthorized as ce,errors$UnknownErrorFields as le,errors$UnprocessableEntity as ue,protocol_rest$BinaryResponse as de,protocol_rest$RawResponse as fe,protocol_rest$RawResponseRoot as pe,protocol_rest$SensitiveValue as me,protocol_rest$binaryResponseSymbol as he,protocol_rest$rawResponseRootSymbol as ge,protocol_rest$rawResponseSymbol as _e,protocol_rest$restProtocol as ve,protocol_rest$sensitiveValueSymbol as ye,protocol_rest$unknownErrorProps as be,schema_lite$Array as xe,schema_lite$Boolean as Se,schema_lite$NullOr as Ce,schema_lite$Number as we,schema_lite$Record as Te,schema_lite$String as Ee,schema_lite$Struct as De,schema_lite$Unknown as Oe,schema_lite$at as ke,schema_lite$optional as Ae,schema_lite$suspend as je}from"@distilled.cloud/core/_bundle/rest";import*as Y from"effect/Context";import*as X from"effect/Effect";import*as Z from"effect/Layer";import*as Me from"effect/Redacted";const Q=`https://api.twitch.tv/helix`;var Credentials=class extends (/*@__PURE__*/ Y.Service()(`TwitchCredentials`)){};const Ne=/*@__PURE__*/ te({accessToken:/*@__PURE__*/ a(`TWITCH_ACCESS_TOKEN`),clientId:/*@__PURE__*/ o(`TWITCH_CLIENT_ID`),apiBaseUrl:/*@__PURE__*/ o(`TWITCH_API_BASE_URL`).pipe(/*@__PURE__*/ ne(Q))});const Pe=/*@__PURE__*/ Z.effect(Credentials,/*@__PURE__*/ X.map(/*@__PURE__*/ Ne.pipe(/*@__PURE__*/ X.mapError(()=>new B({message:`TWITCH_ACCESS_TOKEN and TWITCH_CLIENT_ID environment variables are required`}))),e=>X.succeed(e)));const credentials=e=>Z.succeed(Credentials,X.succeed({accessToken:e.accessToken,clientId:e.clientId,apiBaseUrl:e.apiBaseUrl??`https://api.twitch.tv/helix`}));var UnknownTwitchError=class extends (/*@__PURE__*/ f()(`UnknownTwitchError`,le)){};var TwitchParseError=class extends (/*@__PURE__*/ f()(`TwitchParseError`,{body:p,cause:p}).pipe(i)){};const $=L;const Fe=/*@__PURE__*/ ve({credentials:/*@__PURE__*/ X.flatten(Credentials),baseUrl:e=>e.apiBaseUrl.replace(/\/+$/,``),headers:e=>({Authorization:`Bearer ${Me.value(e.accessToken)}`,"Client-Id":e.clientId}),unknownError:e=>new UnknownTwitchError(be(e)),parseError:({body:e,cause:t})=>new TwitchParseError({body:e,cause:t})});var Retry=class extends (/*@__PURE__*/ Y.Service()(`TwitchRetry`)){};const policy=e=>X.provide(Z.succeed(Retry,e));const Ie=/*@__PURE__*/ X.provide(/*@__PURE__*/ Z.succeed(Retry,{while:()=>false}));const Le=s;const Re=ae;const ze=ie;const Be=l;const Ve=/*@__PURE__*/ policy(c);const He=d;const Ue=/*@__PURE__*/ policy(u);export{Ce as Fc,we as Gc,Te as Hc,Ee as Jc,De as Kc,Oe as Pc,ke as Rc,Ae as Wc,je as Xc,e as a,t as b,Credentials as credentials$Credentials,Pe as credentials$CredentialsFromEnv,Q as credentials$DEFAULT_API_BASE_URL,credentials as credentials$credentials,L as errors$API_ERRORS,R as errors$BadGateway,z as errors$BadRequest,B as errors$ConfigError,V as errors$Conflict,H as errors$DEFAULT_ERRORS,U as errors$Forbidden,W as errors$GatewayTimeout,G as errors$HTTP_STATUS_MAP,K as errors$InternalServerError,q as errors$Locked,J as errors$NotFound,oe as errors$ServiceUnavailable,se as errors$TooManyRequests,TwitchParseError as errors$TwitchParseError,$ as errors$TwitchServiceErrors,ce as errors$Unauthorized,UnknownTwitchError as errors$UnknownTwitchError,ue as errors$UnprocessableEntity,ee as l,n,r as o,re as pagination$paginateCursor,Fe as protocol$TwitchProtocol,Retry as retry$Retry,ze as retry$capped,Re as retry$jittered,Le as retry$makeDefault,Ie as retry$none,policy as retry$policy,Ve as retry$throttling,Be as retry$throttlingOptions,Ue as retry$transient,He as retry$transientOptions,de as traits$BinaryResponse,m as traits$Body,h as traits$FormDataFile,g as traits$Header,_ as traits$Http,v as traits$HttpBody,y as traits$KeyDictionary,b as traits$Label,x as traits$Query,fe as traits$RawResponse,pe as traits$RawResponseRoot,S as traits$ResponseCode,me as traits$SensitiveValue,C as traits$UnionCases,w as traits$applyErrorMatchers,he as traits$binaryResponseSymbol,T as traits$bodySymbol,E as traits$errorMatchersSymbol,D as traits$formDataFileSymbol,O as traits$getErrorMatchers,k as traits$headerSymbol,A as traits$httpBodySymbol,j as traits$httpSymbol,M as traits$keyDictionarySymbol,N as traits$labelSymbol,P as traits$querySymbol,ge as traits$rawResponseRootSymbol,_e as traits$rawResponseSymbol,F as traits$responseCodeSymbol,ye as traits$sensitiveValueSymbol,I as traits$unionCasesSymbol,xe as wc,Se as xc};
2
+ //# sourceMappingURL=sdk.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.js","names":["Schema.Unknown","Category.withParseError","Retries.makeDefault","Retries.jittered","Retries.capped","Retries.throttlingOptions","Retries.throttlingFactory","Retries.transientOptions","Retries.transientFactory","D","call","named","op","opPaginated","withParseError","Redacted$3","String$2","all$1","withDefault","paginateCursor","capped$1","jittered$1","makeDefault$1","throttlingFactory","throttlingOptions$1","transientFactory","transientOptions$1","TaggedError$1","Unknown$1","Body","FormDataFile","Header","Http","HttpBody","KeyDictionary","Label","Query","ResponseCode","UnionCases","applyErrorMatchers","bodySymbol","errorMatchersSymbol","formDataFileSymbol","getErrorMatchers","headerSymbol","httpBodySymbol","httpSymbol","keyDictionarySymbol","labelSymbol","querySymbol","responseCodeSymbol","unionCasesSymbol","API_ERRORS","BadGateway","BadRequest","ConfigError","Conflict","DEFAULT_ERRORS","Forbidden","GatewayTimeout","HTTP_STATUS_MAP","InternalServerError","Locked","NotFound","ServiceUnavailable","TooManyRequests","Unauthorized","UnknownErrorFields","UnprocessableEntity","BinaryResponse","RawResponse","RawResponseRoot","SensitiveValue","binaryResponseSymbol","rawResponseRootSymbol","rawResponseSymbol","restProtocol","sensitiveValueSymbol","unknownErrorProps","Array","Boolean","NullOr","Number","Record","String","Struct","Unknown","at","optional","suspend","Context","Effect","Layer","Redacted","DEFAULT_API_BASE_URL","envConfig","CredentialsFromEnv","config","TwitchServiceErrors","TwitchProtocol","creds","info","optionsOrFactory","none","makeDefault","jittered","capped","throttlingOptions","throttling","transientOptions","transient"],"sources":["../../src/credentials.ts","../../src/errors.ts","../../src/protocol.ts","../../src/retry.ts"],"mappings":"kxEAsBA,MAAa8F,EAAuB,8BASpC,IAAa,YAAb,eACwB,gBAAQ,QAA4C,CAAC,CACzE,mBACF,EAAA,AAAE,CAAC,EAEL,MAAMC,GAA0B,iBAAiB,CAC/C,YAA2B,gBAAsB,qBAAqB,EACtE,SAAwB,gBAAoB,kBAAkB,EAC9D,WAA0B,gBAAoB,qBAAqB,CAAC,CAAC,KACrD,iBAAyBD,CAAoB,CAC7D,CACF,CAAC,EAQD,MAAaE,GAAmC,gBAAM,OACpD,YACc,gBAAO,IACL,iBAAU,KACR,gBAAO,aAEjB,IAAIzC,EAAY,CACd,QAAS,6EACX,CAAC,CACL,CACF,EACC,GAAWoC,EAAO,QAAQM,CAAM,CACnC,CACF,EAGA,MAAa,YAAe,GAK1BL,EAAM,QACJ,YACAD,EAAO,QAAQ,CACb,YAAaM,EAAO,YACpB,SAAUA,EAAO,SACjB,WAAYA,EAAO,YAAA,6BACrB,CAAC,CACH,ECrCF,IAAa,mBAAb,eACwB,gBAAuC,CAAC,CAC5D,qBACA9B,EACF,EAAA,AAAE,CAAC,EAGL,IAAa,iBAAb,eACwB,gBAAqC,CAAC,CAAC,mBAAoB,CAC/E,KAAMnE,EACN,MAAOA,CACT,CAAC,CAAC,CAAC,KAAKC,CAAuB,EAAA,AAAE,CAAC,EAwBpC,MAAaiG,EAAsB9C,EC7CnC,MAAa+C,GAA+B,iBAAa,CAGvD,YAA2B,gBAAO,QAAQ,WAAW,EACrD,QAAU,GAAUC,EAAM,WAAW,QAAQ,OAAQ,EAAE,EACvD,QAAU,IAAW,CACnB,cAAe,UAAUP,GAAS,MAAMO,EAAM,WAAW,IACzD,YAAaA,EAAM,QACrB,GACA,aAAe,GAAS,IAAI,mBAAmBtB,GAAkBuB,CAAI,CAAC,EACtE,YAAa,CAAE,OAAM,WAAY,IAAI,iBAAiB,CAAE,OAAM,OAAM,CAAC,CACvE,CAAC,ECjBD,IAAa,MAAb,eAAyC,gBAAQ,QAAuB,CAAC,CAAC,aAAa,EAAA,AAAE,CAAC,EAG1F,MAAa,OAOR,GAAwCV,EAAO,QAAQC,EAAM,QAAQ,MAAOU,CAAgB,CAAC,EAGlG,MAAaC,GAE+C,gBAAO,QACnD,gBAAM,QAAQ,MAAO,CAAE,UAAa,KAAM,CAAC,CAC3D,EAOA,MAAaC,GAAuBtG,EAEpC,MAAauG,GAAWtG,GACxB,MAAauG,GAAStG,GAGtB,MAAauG,GAA6BtG,EAG1C,MAAauG,GAE+C,qBAAOtG,CAAyB,EAG5F,MAAauG,GAA4BtG,EAGzC,MAAauG,GAE+C,qBAAOtG,CAAwB"}
@@ -0,0 +1,31 @@
1
+ import { ConfigError } from "@distilled.cloud/core/errors";
2
+ import * as Context from "effect/Context";
3
+ import * as Effect from "effect/Effect";
4
+ import * as Layer from "effect/Layer";
5
+ import type * as Redacted from "effect/Redacted";
6
+ /** The Helix API host. */
7
+ export declare const DEFAULT_API_BASE_URL = "https://api.twitch.tv/helix";
8
+ export interface Config {
9
+ readonly accessToken: Redacted.Redacted<string>;
10
+ /** The client ID of the app the token belongs to. */
11
+ readonly clientId: string;
12
+ readonly apiBaseUrl: string;
13
+ }
14
+ declare const Credentials_base: Context.ServiceClass<Credentials, "TwitchCredentials", Effect.Effect<Config, never, never>>;
15
+ export declare class Credentials extends /*@__PURE__*/ Credentials_base {
16
+ }
17
+ /**
18
+ * Reads `TWITCH_ACCESS_TOKEN`, `TWITCH_CLIENT_ID` and, optionally, `TWITCH_API_BASE_URL`.
19
+ *
20
+ * Its configuration is read and checked once, when the layer is built: a
21
+ * problem there fails the layer with `ConfigError`.
22
+ */
23
+ export declare const CredentialsFromEnv: Layer.Layer<Credentials, ConfigError, never>;
24
+ /** Credentials from a redacted access token and its app's client ID. */
25
+ export declare const credentials: (config: {
26
+ readonly accessToken: Redacted.Redacted<string>;
27
+ readonly clientId: string;
28
+ readonly apiBaseUrl?: string;
29
+ }) => Layer.Layer<Credentials>;
30
+ export {};
31
+ //# sourceMappingURL=credentials.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.d.ts","sources":["../src/credentials.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAEjD,0BAA0B;AAC1B,eAAO,MAAM,oBAAoB,gCAAgC,CAAC;AAElE,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChD,qDAAqD;IACrD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WACX,SAAQ,aAAa,CAAC,gBAErB;CAAG;AAUN;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,8CAa9B,CAAC;AAEF,wEAAwE;AACxE,eAAO,MAAM,WAAW,WAAY;IAClC,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChD,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,KAAG,KAAK,CAAC,KAAK,CAAC,WAAW,CAQxB,CAAC"}
@@ -0,0 +1 @@
1
+ export { credentials$Credentials as Credentials, credentials$CredentialsFromEnv as CredentialsFromEnv, credentials$DEFAULT_API_BASE_URL as DEFAULT_API_BASE_URL, credentials$credentials as credentials } from "./_bundle/sdk.js";
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Twitch error types.
3
+ *
4
+ * Helix answers a failure with `{ "error": "<status text>", "status": <code>,
5
+ * "message": "<why>" }`, and its reference documents failures per operation
6
+ * only as status lists (`400`, `401`, `403`, `404`, `409`, `422`, `425`,
7
+ * `429`, `5xx`). The SDK dispatches on the status with core's shared classes;
8
+ * a status nothing maps (`425 Too Early`, for one) comes back as
9
+ * {@link UnknownTwitchError} with the body.
10
+ */
11
+ export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
12
+ import type { BadRequest as CoreBadRequest, Conflict as CoreConflict, DefaultErrors as CoreDefaultErrors, Forbidden as CoreForbidden, NotFound as CoreNotFound, UnprocessableEntity as CoreUnprocessableEntity } from "@distilled.cloud/core/errors";
13
+ import * as Schema from "@distilled.cloud/core/schema-lite-typed";
14
+ declare const UnknownTwitchError_base: Schema.TaggedErrorClass<"UnknownTwitchError", {
15
+ status: import("effect/Schema").Number;
16
+ code: import("effect/Schema").optional<import("effect/Schema").String>;
17
+ message: import("effect/Schema").optional<import("effect/Schema").String>;
18
+ body: import("effect/Schema").Unknown;
19
+ }>;
20
+ /** Unknown Twitch error -- a failed response whose status has no mapped class. */
21
+ export declare class UnknownTwitchError extends /*@__PURE__*/ UnknownTwitchError_base {
22
+ }
23
+ declare const TwitchParseError_base: Schema.TaggedErrorClass<"TwitchParseError", {
24
+ readonly body: import("effect/Schema").Unknown;
25
+ readonly cause: import("effect/Schema").Unknown;
26
+ }> & (new (...args: any[]) => {
27
+ "@distilled.cloud/error/categories": {
28
+ ParseError: true;
29
+ };
30
+ });
31
+ /** A 2xx body that did not match the operation's output (validating modes only). */
32
+ export declare class TwitchParseError extends /*@__PURE__*/ TwitchParseError_base {
33
+ }
34
+ /** Errors any Twitch operation may surface besides the shared HTTP status errors. */
35
+ export type ClientErrors = UnknownTwitchError | TwitchParseError;
36
+ /**
37
+ * Default Twitch operation errors. Every operation carries the whole set: the
38
+ * reference's status lists are documentation, and any of these statuses can
39
+ * come back from any call.
40
+ */
41
+ export type DefaultErrors = CoreDefaultErrors | CoreBadRequest | CoreForbidden | CoreNotFound | CoreConflict | CoreUnprocessableEntity | ClientErrors;
42
+ /**
43
+ * The errors declared on the Twitch service: any operation can return them,
44
+ * and every generated operation lists them as its `serviceErrors`. Today that
45
+ * is each of core's status classes (401, 403, 404, 429, the 5xx ...).
46
+ */
47
+ export declare const TwitchServiceErrors: readonly [typeof import("@distilled.cloud/core/errors").Unauthorized, typeof CoreForbidden, typeof CoreNotFound, typeof CoreBadRequest, typeof CoreConflict, typeof CoreUnprocessableEntity, typeof import("@distilled.cloud/core/errors").TooManyRequests, typeof import("@distilled.cloud/core/errors").Locked, typeof import("@distilled.cloud/core/errors").InternalServerError, typeof import("@distilled.cloud/core/errors").BadGateway, typeof import("@distilled.cloud/core/errors").ServiceUnavailable, typeof import("@distilled.cloud/core/errors").GatewayTimeout];
48
+ export type TwitchServiceError = InstanceType<(typeof TwitchServiceErrors)[number]>;
49
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EACV,UAAU,IAAI,cAAc,EAC5B,QAAQ,IAAI,YAAY,EACxB,aAAa,IAAI,iBAAiB,EAClC,SAAS,IAAI,aAAa,EAC1B,QAAQ,IAAI,YAAY,EACxB,mBAAmB,IAAI,uBAAuB,EAC/C,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,MAAM,MAAM,yCAAyC,CAAC;;;;;;;AAElE,kFAAkF;AAClF,qBAAa,kBACX,SAAQ,aAAa,CAAC,uBAGrB;CAAG;;;;;;;;;AAEN,oFAAoF;AACpF,qBAAa,gBACX,SAAQ,aAAa,CAAC,qBAGU;CAAG;AAErC,qFAAqF;AACrF,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAEjE;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,iBAAiB,GACjB,cAAc,GACd,aAAa,GACb,YAAY,GACZ,YAAY,GACZ,uBAAuB,GACvB,YAAY,CAAC;AAEjB;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,gjBAAa,CAAC;AAC9C,MAAM,MAAM,kBAAkB,GAAG,YAAY,CAAC,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC"}
package/lib/errors.js ADDED
@@ -0,0 +1 @@
1
+ export { errors$API_ERRORS as API_ERRORS, errors$BadGateway as BadGateway, errors$BadRequest as BadRequest, errors$ConfigError as ConfigError, errors$Conflict as Conflict, errors$DEFAULT_ERRORS as DEFAULT_ERRORS, errors$Forbidden as Forbidden, errors$GatewayTimeout as GatewayTimeout, errors$HTTP_STATUS_MAP as HTTP_STATUS_MAP, errors$InternalServerError as InternalServerError, errors$Locked as Locked, errors$NotFound as NotFound, errors$ServiceUnavailable as ServiceUnavailable, errors$TooManyRequests as TooManyRequests, errors$TwitchParseError as TwitchParseError, errors$TwitchServiceErrors as TwitchServiceErrors, errors$Unauthorized as Unauthorized, errors$UnknownTwitchError as UnknownTwitchError, errors$UnprocessableEntity as UnprocessableEntity } from "./_bundle/sdk.js";
package/lib/index.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * @distilled.cloud/twitch -- Twitch API (Helix) SDK for Effect.
3
+ *
4
+ * `./services` is generated by `scripts/generate.ts` from the Smithy models
5
+ * that `scripts/convert.ts` reads out of Twitch's API reference, mirrored as
6
+ * Markdown under `specs/spec-mirror-twitch/specs/api/reference`. Everything
7
+ * else in this folder is hand-written.
8
+ *
9
+ * One module per reference page: `ads`, `analytics`, `bits`, `ccls`,
10
+ * `channel_points`, `channels`, `charity`, `chat`, `clips`, `conduits`,
11
+ * `entitlements`, `eventsub`, `extensions`, `games`, `goals`, `guest_star`,
12
+ * `hype_train`, `moderation`, `polls`, `predictions`, `raids`, `schedule`,
13
+ * `search`, `streams`, `subscriptions`, `teams`, `users`, `videos` and
14
+ * `whispers`. Import each from its subpath.
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { Effect, Layer } from "effect";
19
+ * import * as FetchHttpClient from "effect/http/FetchHttpClient";
20
+ * import * as Twitch from "@distilled.cloud/twitch";
21
+ * import * as Channels from "@distilled.cloud/twitch/channels";
22
+ * import * as Users from "@distilled.cloud/twitch/users";
23
+ *
24
+ * const program = Effect.gen(function* () {
25
+ * const { data: users = [] } = yield* Users.getUsers({ login: ["twitchdev"] });
26
+ * const { data: channels = [] } = yield* Channels.getChannelInformation({
27
+ * broadcaster_id: users.map((user) => user.id!),
28
+ * });
29
+ * return channels.map((channel) => ({ name: channel.broadcaster_name, game: channel.game_name }));
30
+ * });
31
+ *
32
+ * const Live = Layer.mergeAll(
33
+ * FetchHttpClient.layer,
34
+ * Twitch.CredentialsFromEnv,
35
+ * );
36
+ *
37
+ * program.pipe(Effect.provide(Live), Effect.runPromise).then(console.log);
38
+ * ```
39
+ */
40
+ export * from "./credentials.ts";
41
+ export * from "./errors.ts";
42
+ export * as T from "./traits.ts";
43
+ export { TwitchProtocol, type TwitchOpError, type TwitchOpContext } from "./protocol.ts";
44
+ export * as Retry from "./retry.ts";
45
+ export { paginateCursor } from "./pagination.ts";
46
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsCG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,cAAc,EAAE,KAAK,aAAa,EAAE,KAAK,eAAe,EAAE,MAAM,eAAe,CAAC;AACzF,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,6 @@
1
+ export * from "./credentials.js";
2
+ export * from "./errors.js";
3
+ export * as T from "./traits.js";
4
+ export { TwitchProtocol } from "./protocol.js";
5
+ export * as Retry from "./retry.js";
6
+ export { paginateCursor } from "./pagination.js";
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Twitch pagination -- hand-written.
3
+ *
4
+ * Helix pages by cursor: the `after` query parameter in, the next cursor in
5
+ * the response's `pagination.cursor` (on a few endpoints, a bare `pagination`
6
+ * string), absent or empty on the last page. Generated operations pass core's
7
+ * cursor strategy to `API.makePaginated`.
8
+ */
9
+ export { paginateCursor } from "@distilled.cloud/core/pagination";
10
+ //# sourceMappingURL=pagination.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pagination.d.ts","sources":["../src/pagination.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC"}
@@ -0,0 +1 @@
1
+ export { pagination$paginateCursor as paginateCursor } from "./_bundle/sdk.js";
@@ -0,0 +1,19 @@
1
+ import type { ErrorOf } from "@distilled.cloud/core/protocol";
2
+ import type * as HttpClient from "effect/http/HttpClient";
3
+ import { Credentials } from "./credentials.ts";
4
+ import { TwitchParseError, UnknownTwitchError, type TwitchServiceError } from "./errors.ts";
5
+ /**
6
+ * What every generated Twitch operation fails with besides its own errors: the
7
+ * errors declared on the service, and the errors declared on the protocol.
8
+ * Nobody lists the protocol's: its type carries what its code fails with (a
9
+ * response that does not match its schema, a failed response nothing declares,
10
+ * core's REST errors, and what resolving the credentials fails with).
11
+ * Generated service files annotate operations with `API.OperationMethod<I, O,
12
+ * TwitchOpError, TwitchOpContext>` explicitly so the compiler never infers
13
+ * these back out of the schema generics.
14
+ */
15
+ export type TwitchOpError = TwitchServiceError | ErrorOf<typeof TwitchProtocol>;
16
+ /** Context (requirements) shared by every generated Twitch operation. */
17
+ export type TwitchOpContext = Credentials | HttpClient.HttpClient;
18
+ export declare const TwitchProtocol: import("@distilled.cloud/core/protocol").Protocol<TwitchParseError | UnknownTwitchError | import("@distilled.cloud/core/protocol-rest").RestProtocolError, Credentials>;
19
+ //# sourceMappingURL=protocol.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.d.ts","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,gCAAgC,CAAC;AAW9D,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAE5F;;;;;;;;;GASG;AACH,MAAM,MAAM,aAAa,GAAG,kBAAkB,GAAG,OAAO,CAAC,OAAO,cAAc,CAAC,CAAC;AAEhF,yEAAyE;AACzE,MAAM,MAAM,eAAe,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAElE,eAAO,MAAM,cAAc,yKAWzB,CAAC"}
@@ -0,0 +1 @@
1
+ export { protocol$TwitchProtocol as TwitchProtocol } from "./_bundle/sdk.js";
package/lib/retry.d.ts ADDED
@@ -0,0 +1,50 @@
1
+ import * as Retries from "@distilled.cloud/core/retry";
2
+ /**
3
+ * Twitch retry surface -- a veneer over `@distilled.cloud/core/retry`.
4
+ *
5
+ * The `Retry` service tag is threaded into every generated operation via
6
+ * `API.make({ retry: Retry })`, so a caller-installed policy applies to all
7
+ * Twitch calls below it and core's `makeDefault` is the fallback when none is
8
+ * provided.
9
+ *
10
+ * @example
11
+ * ```ts
12
+ * import * as Twitch from "@distilled.cloud/twitch";
13
+ *
14
+ * myEffect.pipe(Twitch.Retry.transient);
15
+ * ```
16
+ */
17
+ import * as Context from "effect/Context";
18
+ import * as Effect from "effect/Effect";
19
+ export type Options = Retries.Options;
20
+ export type Factory = Retries.Factory;
21
+ export type Policy = Retries.Policy;
22
+ declare const Retry_base: Context.ServiceClass<Retry, "TwitchRetry", Retries.Policy>;
23
+ /** Context tag for configuring retry behavior of Twitch API calls. */
24
+ export declare class Retry extends /*@__PURE__*/ Retry_base {
25
+ }
26
+ /** Provides a custom retry policy to every Twitch API call below it. */
27
+ export declare const policy: {
28
+ (options: Options): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
29
+ (factory: Factory): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
30
+ };
31
+ /** Disables all automatic retries. */
32
+ export declare const none: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
33
+ /**
34
+ * The default retry policy (core's): transient/throttling/retryable errors,
35
+ * capped exponential backoff with jitter, server `retryAfter` hints honored
36
+ * with precedence.
37
+ */
38
+ export declare const makeDefault: Factory;
39
+ export declare const jittered: <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
40
+ export declare const capped: (max: import("effect/Duration").Duration) => <Error, Env>(self: import("effect/Schedule").Schedule<unknown, unknown, Error, Env>) => import("effect/Schedule").Schedule<unknown, unknown, Error, Env>;
41
+ /** Retry options that retry all throttling errors indefinitely. */
42
+ export declare const throttlingOptions: Options;
43
+ /** Retries all throttling errors indefinitely (honoring server hints). */
44
+ export declare const throttling: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
45
+ /** Retry options that retry all transient errors indefinitely. */
46
+ export declare const transientOptions: Options;
47
+ /** Retries all transient errors indefinitely. */
48
+ export declare const transient: <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, Exclude<R, Retry>>;
49
+ export {};
50
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,6BAA6B,CAAC;AACvD;;;;;;;;;;;;;;GAcG;AACH,OAAO,KAAK,OAAO,MAAM,gBAAgB,CAAC;AAC1C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAGxC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;AACtC,MAAM,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;;AAEpC,sEAAsE;AACtE,qBAAa,KAAM,SAAQ,aAAa,CAAC,UAA+C;CAAG;AAE3F,wEAAwE;AACxE,eAAO,MAAM,MAAM,EAAE;IACnB,CACE,OAAO,EAAE,OAAO,GACf,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;IACvF,CACE,OAAO,EAAE,OAAO,GACf,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAAK,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC;CACU,CAAC;AAEpG,sCAAsC;AACtC,eAAO,MAAM,IAAI,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EACzB,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAEzC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,WAAW,EAAE,OAA6B,CAAC;AAExD,eAAO,MAAM,QAAQ,0JAAmB,CAAC;AACzC,eAAO,MAAM,MAAM,uMAAiB,CAAC;AAErC,mEAAmE;AACnE,eAAO,MAAM,iBAAiB,EAAE,OAAmC,CAAC;AAEpE,0EAA0E;AAC1E,eAAO,MAAM,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC/B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAmD,CAAC;AAE9F,kEAAkE;AAClE,eAAO,MAAM,gBAAgB,EAAE,OAAkC,CAAC;AAElE,iDAAiD;AACjD,eAAO,MAAM,SAAS,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,KAC3B,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,EAAE,KAAK,CAAC,CAAkD,CAAC"}
package/lib/retry.js ADDED
@@ -0,0 +1 @@
1
+ export { retry$Retry as Retry, retry$capped as capped, retry$jittered as jittered, retry$makeDefault as makeDefault, retry$none as none, retry$policy as policy, retry$throttling as throttling, retry$throttlingOptions as throttlingOptions, retry$transient as transient, retry$transientOptions as transientOptions } from "./_bundle/sdk.js";