tentacle-sdk 0.0.1

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 (77) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +169 -0
  3. package/dist/index.cjs +889 -0
  4. package/dist/index.cjs.map +1 -0
  5. package/dist/index.d.cts +1562 -0
  6. package/dist/index.d.ts +1562 -0
  7. package/dist/index.js +884 -0
  8. package/dist/index.js.map +1 -0
  9. package/docs/api/classes/DeviceAuthFlow.md +107 -0
  10. package/docs/api/classes/FileCredentialStore.md +95 -0
  11. package/docs/api/classes/TentacleClient.md +118 -0
  12. package/docs/api/classes/TentacleError.md +69 -0
  13. package/docs/api/index.md +117 -0
  14. package/docs/api/interfaces/AppJson.md +20 -0
  15. package/docs/api/interfaces/ChatMessageEmoji.md +16 -0
  16. package/docs/api/interfaces/ChatMessageEmote.md +16 -0
  17. package/docs/api/interfaces/ChatMessagePosition.md +14 -0
  18. package/docs/api/interfaces/CommonChatMessage.md +27 -0
  19. package/docs/api/interfaces/CommonEventJson.md +32 -0
  20. package/docs/api/interfaces/CredentialStore.md +55 -0
  21. package/docs/api/interfaces/DeviceAuthInitResult.md +17 -0
  22. package/docs/api/interfaces/DeviceAuthOptions.md +18 -0
  23. package/docs/api/interfaces/DeviceAuthPollResult.md +14 -0
  24. package/docs/api/interfaces/DonationUnlock.md +16 -0
  25. package/docs/api/interfaces/FileCredentialStoreOptions.md +13 -0
  26. package/docs/api/interfaces/GiftedSubUnlock.md +15 -0
  27. package/docs/api/interfaces/KickBadge.md +15 -0
  28. package/docs/api/interfaces/KickChatMessageJson.md +35 -0
  29. package/docs/api/interfaces/KickEventJson_ChannelFollow.md +25 -0
  30. package/docs/api/interfaces/KickEventJson_ChannelSubscriptionGifts.md +25 -0
  31. package/docs/api/interfaces/KickEventJson_ChannelSubscriptionNew.md +25 -0
  32. package/docs/api/interfaces/KickEventJson_ChannelSubscriptionRenewal.md +25 -0
  33. package/docs/api/interfaces/KickEventJson_LivestreamStatusUpdated.md +24 -0
  34. package/docs/api/interfaces/RealtimeEvent_StreamChatMessage.md +14 -0
  35. package/docs/api/interfaces/RealtimeEvent_StreamEvent.md +14 -0
  36. package/docs/api/interfaces/RealtimeEvent_StreamViewerActivity.md +14 -0
  37. package/docs/api/interfaces/RealtimeSubscribeOptions.md +16 -0
  38. package/docs/api/interfaces/StreamViewerActivityJson.md +16 -0
  39. package/docs/api/interfaces/SubUnlock.md +15 -0
  40. package/docs/api/interfaces/SubathonStats_Donations.md +23 -0
  41. package/docs/api/interfaces/SubathonStats_GiftedSubscriptions.md +22 -0
  42. package/docs/api/interfaces/SubathonStats_Subscriptions.md +20 -0
  43. package/docs/api/interfaces/TentacleClientConfig.md +14 -0
  44. package/docs/api/interfaces/TentacleClientCreateOptions.md +15 -0
  45. package/docs/api/interfaces/TwitchChatMessageJson.md +41 -0
  46. package/docs/api/interfaces/TwitchEventJson_Cheer.md +29 -0
  47. package/docs/api/interfaces/TwitchEventJson_Follow.md +27 -0
  48. package/docs/api/interfaces/TwitchEventJson_Raid.md +27 -0
  49. package/docs/api/interfaces/TwitchEventJson_RedemptionAdd.md +34 -0
  50. package/docs/api/interfaces/TwitchEventJson_StreamOnline.md +26 -0
  51. package/docs/api/interfaces/TwitchEventJson_Subscription.md +28 -0
  52. package/docs/api/interfaces/TwitchEventJson_SubscriptionGift.md +30 -0
  53. package/docs/api/interfaces/TwitchUserInfo.md +24 -0
  54. package/docs/api/interfaces/ViewerActionJson.md +18 -0
  55. package/docs/api/interfaces/ViewerJson.md +23 -0
  56. package/docs/api/interfaces/ViewerKickJson.md +25 -0
  57. package/docs/api/interfaces/ViewerMiniJson.md +21 -0
  58. package/docs/api/interfaces/ViewerPropertyJsonBase.md +22 -0
  59. package/docs/api/interfaces/ViewerPropertyJson_Bool.md +22 -0
  60. package/docs/api/interfaces/ViewerPropertyJson_Number.md +22 -0
  61. package/docs/api/interfaces/ViewerPropertyJson_String.md +22 -0
  62. package/docs/api/interfaces/ViewerTwitchJson.md +24 -0
  63. package/docs/api/interfaces/ViewersByPropertyOutput.md +17 -0
  64. package/docs/api/type-aliases/DateIsoString.md +9 -0
  65. package/docs/api/type-aliases/KickEventJson.md +9 -0
  66. package/docs/api/type-aliases/OrderDirection.md +9 -0
  67. package/docs/api/type-aliases/RealtimeEvent.md +36 -0
  68. package/docs/api/type-aliases/StreamChatMessageJson.md +9 -0
  69. package/docs/api/type-aliases/StreamEventJson.md +9 -0
  70. package/docs/api/type-aliases/StreamPlatform.md +9 -0
  71. package/docs/api/type-aliases/TwitchEventJson.md +9 -0
  72. package/docs/api/type-aliases/TwitchEventType.md +9 -0
  73. package/docs/api/type-aliases/UnsubscribeFunction.md +22 -0
  74. package/docs/api/type-aliases/ViewerPropertyJson.md +9 -0
  75. package/docs/api/type-aliases/ViewerPropertyType.md +9 -0
  76. package/docs/overview.md +160 -0
  77. package/package.json +54 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Tentacle
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,169 @@
1
+ # Tentacle SDK
2
+
3
+ TypeScript SDK for the Tentacle streaming platform API. Provides type-safe access to Twitch and Kick events in real-time.
4
+
5
+ > **Note:** This SDK is currently in alpha. The API may change between versions.
6
+
7
+ ## Installation
8
+
9
+ ```bash
10
+ # Install the latest alpha release
11
+ npm install tentacle-sdk@alpha
12
+
13
+ # Or with a specific version
14
+ npm install tentacle-sdk@0.1.0-alpha.1
15
+ ```
16
+
17
+ The SDK works with both ESM and CommonJS projects, and includes full TypeScript type definitions.
18
+
19
+ ## Quick Start
20
+
21
+ ```typescript
22
+ import { TentacleClient } from 'tentacle-sdk'
23
+
24
+ const client = new TentacleClient({
25
+ baseUrl: 'https://api.tentacle.live',
26
+ accessToken: 'your-access-token',
27
+ })
28
+
29
+ // Subscribe to realtime Twitch/Kick events
30
+ const unsubscribe = client.realtime.subscribe({
31
+ onEvent: (event) => {
32
+ switch (event.kind) {
33
+ case 'StreamChatMessage':
34
+ // Chat message from Twitch or Kick
35
+ const msg = event.payload
36
+ console.log(`[${msg.$platform}] ${msg.$text}`)
37
+ console.log(`Viewer ID: ${msg.$viewerId}`)
38
+ break
39
+
40
+ case 'StreamEvent':
41
+ // Stream event (follow, sub, raid, cheer, etc.)
42
+ const evt = event.payload
43
+ if (evt.$platform === 'twitch') {
44
+ switch (evt.$type) {
45
+ case 'channel.follow':
46
+ console.log(`New Twitch follower: ${evt.userDisplayName}`)
47
+ break
48
+ case 'channel.subscribe':
49
+ console.log(`New Twitch sub: ${evt.userDisplayName}`)
50
+ break
51
+ case 'channel.raid':
52
+ console.log(`Raid from ${evt.fromBroadcasterUserDisplayName} with ${evt.viewers} viewers`)
53
+ break
54
+ case 'channel.cheer':
55
+ console.log(`Cheer: ${evt.bits} bits from ${evt.userDisplayName}`)
56
+ break
57
+ }
58
+ } else if (evt.$platform === 'kick') {
59
+ switch (evt.$type) {
60
+ case 'channel.followed':
61
+ console.log(`New Kick follower: ${evt.username}`)
62
+ break
63
+ case 'channel.subscription.new':
64
+ console.log(`New Kick sub: ${evt.username}`)
65
+ break
66
+ }
67
+ }
68
+ break
69
+
70
+ case 'StreamViewerActivity':
71
+ console.log(`Viewer activity: ${event.payload.viewerId}`)
72
+ break
73
+ }
74
+ },
75
+ onError: (error) => console.error('Connection error:', error),
76
+ onOpen: () => console.log('Connected to realtime events!'),
77
+ onClose: () => console.log('Disconnected'),
78
+ })
79
+
80
+ // When done, unsubscribe:
81
+ unsubscribe()
82
+ ```
83
+
84
+ ## API Overview
85
+
86
+ The SDK provides access to the following APIs:
87
+
88
+ - **realtime** - Subscribe to live Twitch and Kick events via SSE
89
+ - **apps** - Manage apps and viewer properties
90
+ - **stream** - Access chat messages and events history
91
+ - **subathon** - Access subathon statistics
92
+ - **viewer** - Access viewer data
93
+
94
+ ## REST API Examples
95
+
96
+ ```typescript
97
+ // Get recent chat messages
98
+ const messages = await client.stream.getChatMessages({ take: 50 })
99
+
100
+ // Get recent stream events
101
+ const events = await client.stream.getEvents({ take: 20 })
102
+
103
+ // List apps
104
+ const { apps } = await client.apps.list()
105
+
106
+ // Get subathon stats
107
+ const subs = await client.subathon.getSubs()
108
+ const donations = await client.subathon.getDonations()
109
+
110
+ // Get viewer data
111
+ const viewer = await client.viewer.get({ viewerId: 'v1' })
112
+ ```
113
+
114
+ ## Event Types
115
+
116
+ ### Twitch Events
117
+ - `channel.follow` - New follower
118
+ - `channel.subscribe` - New subscription
119
+ - `channel.subscription.gift` - Gift subscription
120
+ - `channel.cheer` - Bits cheer
121
+ - `channel.raid` - Incoming raid
122
+ - `channel.channel_points_custom_reward_redemption.add` - Channel point redemption
123
+ - `stream.online` - Stream started
124
+ - `stream.offline` - Stream ended
125
+
126
+ ### Kick Events
127
+ - `channel.followed` - New follower
128
+ - `channel.subscription.new` - New subscription
129
+ - `channel.subscription.renewal` - Subscription renewal
130
+ - `channel.subscription.gifts` - Gift subscriptions
131
+ - `livestream.status.updated` - Stream status change
132
+
133
+ ## Type Imports
134
+
135
+ ```typescript
136
+ import type {
137
+ // Realtime events
138
+ RealtimeEvent,
139
+
140
+ // Chat messages
141
+ StreamChatMessageJson,
142
+ TwitchChatMessageJson,
143
+ KickChatMessageJson,
144
+
145
+ // Stream events
146
+ StreamEventJson,
147
+ TwitchEventJson,
148
+ KickEventJson,
149
+ TwitchEventJson_Follow,
150
+ TwitchEventJson_Subscription,
151
+ TwitchEventJson_Cheer,
152
+ TwitchEventJson_Raid,
153
+
154
+ // App and viewer types
155
+ AppJson,
156
+ ViewerJson,
157
+ ViewerMiniJson,
158
+ } from 'tentacle-sdk'
159
+ ```
160
+
161
+ ## Building from Source
162
+
163
+ ```bash
164
+ cd packages/sdk
165
+ pnpm install
166
+ pnpm build
167
+ ```
168
+
169
+ The built SDK will be in `dist/`.