@neuroinfoapi-client/node 2.6.1 → 2.8.0
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.
- package/README.md +24 -1
- package/package.json +4 -5
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ A comprehensive TypeScript/JavaScript client that provides full access to NeuroI
|
|
|
9
9
|
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
|
-
- HTTP access to streams, VODs, schedules, subathons, blog and X feeds
|
|
12
|
+
- HTTP access to streams, VODs, schedules, subathons, shop products, blog and X feeds
|
|
13
13
|
- Full TypeScript support with typed API responses and event payloads
|
|
14
14
|
- HTTP Bearer authentication with an optional token in the constructor
|
|
15
15
|
- Type-safe HTTP error handling through `{ data, error }`
|
|
@@ -120,6 +120,7 @@ if (error) {
|
|
|
120
120
|
All methods below return `Promise<ApiResult<T>>`:
|
|
121
121
|
|
|
122
122
|
- `getCurrentStream()` — current Twitch stream state
|
|
123
|
+
- `getScheduleLinkedStreams()` — Twitch channels watched right now because a schedule entry takes place on them (e.g. `(on secretneuroaccount)` or collab partners)
|
|
123
124
|
- `getAllVods()` — all Twitch VODs
|
|
124
125
|
- `getVod(id)` — a VOD by stream ID
|
|
125
126
|
- `getSchedule(week, year?)` — schedule for a specific week and optional year
|
|
@@ -131,6 +132,8 @@ All methods below return `Promise<ApiResult<T>>`:
|
|
|
131
132
|
- `getSubathon(year)` — subathon data for a year
|
|
132
133
|
- `getSubathonYears()` — available subathon years
|
|
133
134
|
- `getBlogFeed(raw?)` — Neuro-sama blog feed; requires an API token
|
|
135
|
+
- `getShopProducts(currency?)` — shop catalog; requires an API token
|
|
136
|
+
- `getShopProduct(id, currency?)` — one shop product; requires an API token
|
|
134
137
|
- `getXFeed(user)` — cached X feed for `NeurosamaAI`, `EvilNeuroAI`, or `Vedal987`; requires an API token
|
|
135
138
|
|
|
136
139
|
## Schedule Search Pagination
|
|
@@ -233,15 +236,35 @@ Available WebSocket events:
|
|
|
233
236
|
- `streamOffline`
|
|
234
237
|
- `streamUpdate`
|
|
235
238
|
- `secretneuroaccountOnline`
|
|
239
|
+
- `scheduleLinkedStreamOnline`
|
|
240
|
+
- `scheduleLinkedStreamUpdate`
|
|
241
|
+
- `scheduleLinkedStreamOffline`
|
|
236
242
|
- `streamRaidIncoming`
|
|
237
243
|
- `streamRaidOutgoing`
|
|
238
244
|
- `scheduleUpdate`
|
|
239
245
|
- `subathonUpdate`
|
|
240
246
|
- `subathonGoalUpdate`
|
|
247
|
+
- `shopProductsUpdate`
|
|
241
248
|
- `blogFeedUpdate`
|
|
242
249
|
- `xFeedNewEntries`
|
|
243
250
|
- `xFeedUpdate` (deprecated alias for `xFeedNewEntries`)
|
|
244
251
|
|
|
252
|
+
The `scheduleLinkedStream*` events cover Twitch channels linked in schedule entries, e.g. `(on secretneuroaccount) Evil Stream` (`linkType: "on"`) or collab partners (`linkType: "collab"`); see the [WebSocket docs](https://github.com/Appstun/NeuroInfoAPI-Docs/blob/master/websocket.md#schedule-linked-stream-events).
|
|
253
|
+
Import `Utils` from the package to check their fields:
|
|
254
|
+
|
|
255
|
+
Helpers: `isLinkTypeOn`/`isLinkTypeCollab`, `isTriggerStreamStart`/`isTriggerFetch`/`isTriggerScheduleTime`, `isReasonStreamEnd`/`isReasonNoShow`/`isReasonScheduleRemoved`/`isReasonTimeout`, `didLinkedStreamHappen` (`streamEnd` or `timeout`) and `isLinkedStreamLive`, which also narrows `stream` to the live data.
|
|
256
|
+
|
|
257
|
+
```ts
|
|
258
|
+
wsClient.on("scheduleLinkedStreamOnline", (data) => {
|
|
259
|
+
if (Utils.isTriggerScheduleTime(data) && !Utils.isLinkedStreamLive(data)) return; // scheduled time reached, but not live yet
|
|
260
|
+
if (Utils.isLinkedStreamLive(data)) console.log(`${data.channel.displayName} is live: ${data.stream.title}`);
|
|
261
|
+
});
|
|
262
|
+
|
|
263
|
+
wsClient.on("scheduleLinkedStreamOffline", (data) => {
|
|
264
|
+
if (Utils.isReasonNoShow(data)) console.log(`${data.channel.displayName} did not stream`);
|
|
265
|
+
});
|
|
266
|
+
```
|
|
267
|
+
|
|
245
268
|
**Heartbeat:** The server must send WebSocket protocol ping frames. `ws` responds automatically with pong; this package sends no JSON heartbeat messages. The client waits a fixed **90 seconds** for the next server ping; each incoming protocol ping restarts that timer. If the ping is missing, the connection is terminated and automatic reconnect runs when enabled. Disable timeout monitoring with `heartbeatMonitoring: false`. `heartbeatIntervalMs` and `heartbeatTimeoutMs` apply only to Native and are ignored here, both in constructor options and when assigned on the client instance. Automatic protocol pongs remain active when `heartbeatMonitoring: false`. Ticket authentication does not change this heartbeat behavior. The `_pong` event reports heartbeat activity: an incoming server protocol ping that the runtime automatically answers, or an incoming JSON pong. It also fires with `heartbeatMonitoring: false`; that option disables timeout monitoring, not protocol replies or event notifications. This event does not confirm that the server received the reply.
|
|
246
269
|
|
|
247
270
|
## Unsubscribe and clean up
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neuroinfoapi-client/node",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.8.0",
|
|
4
4
|
"description": "A client for interacting with the NeuroInfoAPI (Node.js edition)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -20,7 +20,6 @@
|
|
|
20
20
|
"scripts": {
|
|
21
21
|
"build": "tsc -b",
|
|
22
22
|
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
23
|
-
"publishPackage": "powershell -NoProfile -ExecutionPolicy Bypass -File ../../scripts/publishAsk.ps1 -Package node",
|
|
24
23
|
"deprecatePackage": "powershell -NoProfile -ExecutionPolicy Bypass -File ../../scripts/deprecateAsk.ps1 -Package node"
|
|
25
24
|
},
|
|
26
25
|
"keywords": [
|
|
@@ -34,16 +33,16 @@
|
|
|
34
33
|
"author": "Appstun",
|
|
35
34
|
"license": "MIT",
|
|
36
35
|
"bugs": {
|
|
37
|
-
"url": "https://github.com/NeuroInfoAPI/NPM-
|
|
36
|
+
"url": "https://github.com/NeuroInfoAPI/NPM-Packages/issues"
|
|
38
37
|
},
|
|
39
38
|
"repository": {
|
|
40
39
|
"type": "git",
|
|
41
|
-
"url": "https://github.com/NeuroInfoAPI/NPM-
|
|
40
|
+
"url": "https://github.com/NeuroInfoAPI/NPM-Packages.git",
|
|
42
41
|
"directory": "packages/node"
|
|
43
42
|
},
|
|
44
43
|
"homepage": "https://neuroinfoapi.dev/api/docs",
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"@neuroinfoapi-client/core": "2.
|
|
45
|
+
"@neuroinfoapi-client/core": "2.8.0",
|
|
47
46
|
"ws": "^8.22.1"
|
|
48
47
|
},
|
|
49
48
|
"devDependencies": {
|