@neuroinfoapi-client/core 2.7.0 → 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/LICENSE CHANGED
@@ -1,21 +1,21 @@
1
- MIT License
2
-
3
- Copyright (c) 2026 Appstun
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.
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Appstun
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 CHANGED
@@ -1,19 +1,19 @@
1
- # @neuroinfoapi-client/core
2
-
3
- Shared HTTP client, API types, utilities and WebSocket protocol logic for NeuroInfoAPI.
4
- Core has no WebSocket runtime dependency.
5
-
6
- **You can use this for HTTP only, but please consider using the other packages.**
7
-
8
- - [@neuroinfoapi-client/native](https://github.com/NeuroInfoAPI/NPM-Package/blob/master/packages/native/README.md): standard WebSocket in browsers and Node.js; ticket auth and JSON heartbeat.
9
- - [@neuroinfoapi-client/node](https://github.com/NeuroInfoAPI/NPM-Package/blob/master/packages/node/README.md): Node.js with `ws`; header auth and protocol heartbeat.
10
- - [@neuroinfoapi-client/bun](https://github.com/NeuroInfoAPI/NPM-Package/blob/master/packages/bun/README.md): Bun's native WebSocket; header auth and protocol heartbeat.
11
-
12
- ## Documentation
13
-
14
- - [Clients Repositories](https://github.com/NeuroInfoAPI/NPM-Package/tree/master/packages)
15
- - [API documentation](https://neuroinfoapi.dev/api/docs)
16
-
17
- ## License
18
-
19
- MIT
1
+ # @neuroinfoapi-client/core
2
+
3
+ Shared HTTP client, API types, utilities and WebSocket protocol logic for NeuroInfoAPI.
4
+ Core has no WebSocket runtime dependency.
5
+
6
+ **You can use this for HTTP only, but please consider using the other packages.**
7
+
8
+ - [@neuroinfoapi-client/native](https://github.com/NeuroInfoAPI/NPM-Package/blob/master/packages/native/README.md): standard WebSocket in browsers and Node.js; ticket auth and JSON heartbeat.
9
+ - [@neuroinfoapi-client/node](https://github.com/NeuroInfoAPI/NPM-Package/blob/master/packages/node/README.md): Node.js with `ws`; header auth and protocol heartbeat.
10
+ - [@neuroinfoapi-client/bun](https://github.com/NeuroInfoAPI/NPM-Package/blob/master/packages/bun/README.md): Bun's native WebSocket; header auth and protocol heartbeat.
11
+
12
+ ## Documentation
13
+
14
+ - [Clients Repositories](https://github.com/NeuroInfoAPI/NPM-Package/tree/master/packages)
15
+ - [API documentation](https://neuroinfoapi.dev/api/docs)
16
+
17
+ ## License
18
+
19
+ MIT
@@ -78,6 +78,11 @@ export declare class NeuroInfoApiClient {
78
78
  * @docs https://github.com/Appstun/NeuroInfoAPI-Docs/blob/master/twitch.md#current-stream-status-1
79
79
  */
80
80
  getCurrentStream: () => Promise<ApiResult<TwitchStreamState>>;
81
+ /**
82
+ * Fetches the channels that are watched right now because a schedule entry takes place on them.
83
+ * @docs https://github.com/Appstun/NeuroInfoAPI-Docs/blob/master/twitch.md#schedule-linked-streams-1
84
+ */
85
+ getScheduleLinkedStreams: () => Promise<ApiResult<ScheduleLinkedStreamInfo[]>>;
81
86
  /**
82
87
  * Fetches all VODs (Video on Demand).
83
88
  * @docs https://github.com/Appstun/NeuroInfoAPI-Docs/blob/master/twitch.md#all-vods-1
@@ -329,6 +334,52 @@ export declare namespace Utils {
329
334
  function isScheduleEntryOffline(entry: ScheduleEntry): boolean;
330
335
  function isScheduleEntryUnknown(entry: ScheduleEntry): boolean;
331
336
  function hasScheduleImage(entry: ScheduleData): boolean;
337
+ /** The schedule entry takes place on this channel instead of the main channel, e.g. `(on secretneuroaccount) Evil Stream`. */
338
+ function isLinkTypeOn(data: {
339
+ linkType: ScheduleLinkType;
340
+ }): boolean;
341
+ /** The channel is linked as a collab partner, e.g. `w/ [Filian](...)`. */
342
+ function isLinkTypeCollab(data: {
343
+ linkType: ScheduleLinkType;
344
+ }): boolean;
345
+ /** The channel went live while it was watched. */
346
+ function isTriggerStreamStart(data: {
347
+ trigger: ScheduleLinkedStreamOnlineTrigger;
348
+ }): boolean;
349
+ /** The channel was already live when watching started (e.g. it started early or the server restarted). */
350
+ function isTriggerFetch(data: {
351
+ trigger: ScheduleLinkedStreamOnlineTrigger;
352
+ }): boolean;
353
+ /** The scheduled time was reached. Sent once per entry whether the channel is live or not, see {@link isLinkedStreamLive}. */
354
+ function isTriggerScheduleTime(data: {
355
+ trigger: ScheduleLinkedStreamOnlineTrigger;
356
+ }): boolean;
357
+ /** The stream ended. */
358
+ function isReasonStreamEnd(data: {
359
+ reason: ScheduleLinkedStreamOfflineReason;
360
+ }): boolean;
361
+ /** The channel did not go live after the scheduled time (collabs: 15 minutes after the main stream ended, otherwise after 4 hours). */
362
+ function isReasonNoShow(data: {
363
+ reason: ScheduleLinkedStreamOfflineReason;
364
+ }): boolean;
365
+ /** The schedule entry was removed while the channel was not live. */
366
+ function isReasonScheduleRemoved(data: {
367
+ reason: ScheduleLinkedStreamOfflineReason;
368
+ }): boolean;
369
+ /** The channel was still live at the maximum watch time; the stream may continue without further events. */
370
+ function isReasonTimeout(data: {
371
+ reason: ScheduleLinkedStreamOfflineReason;
372
+ }): boolean;
373
+ /** The linked stream actually happened, i.e. it was live at some point (`streamEnd` or `timeout`). */
374
+ function didLinkedStreamHappen(data: {
375
+ reason: ScheduleLinkedStreamOfflineReason;
376
+ }): boolean;
377
+ /** The channel is live. Narrows `stream` to the live data, e.g. for `scheduleTime` events or `getScheduleLinkedStreams()` entries. */
378
+ function isLinkedStreamLive<T extends {
379
+ stream: WsStreamOnlineData | WsStreamOfflineData;
380
+ }>(data: T): data is T & {
381
+ stream: WsStreamOnlineData;
382
+ };
332
383
  }
333
384
  export interface NeuroInfoApiBaseOptions {
334
385
  /** Host and API path without protocol. HTTP(S)/WS(S) protocols are accepted temporarily for compatibility and will be removed in a future major version. Default: `neuroinfoapi.dev/api/v2`. */
@@ -412,6 +463,58 @@ export interface WsStreamOnlineData extends StreamMetadata {
412
463
  export interface WsStreamOfflineData {
413
464
  isLive: false;
414
465
  }
466
+ /** Twitch channel a schedule entry takes place on. */
467
+ export interface ScheduleLinkedChannel {
468
+ id: string;
469
+ name: string;
470
+ displayName: string;
471
+ }
472
+ /**
473
+ * How a channel is linked in a schedule entry.
474
+ * - `on`: the entry explicitly takes place on that channel, e.g. `(on [secretneuroaccount](...)) Evil Stream`
475
+ * - `collab`: any other Twitch link, usually a collab partner, e.g. `w/ [Filian](...)`
476
+ */
477
+ export type ScheduleLinkType = "on" | "collab";
478
+ /**
479
+ * Why `scheduleLinkedStreamOnline` was sent.
480
+ * - `streamStart`: the channel went live while it was watched
481
+ * - `fetch`: the channel was already live when watching started
482
+ * - `scheduleTime`: the scheduled time was reached; always sent once per entry, check `stream.isLive`
483
+ */
484
+ export type ScheduleLinkedStreamOnlineTrigger = "streamStart" | "scheduleTime" | "fetch";
485
+ /** Why `scheduleLinkedStreamOffline` was sent. */
486
+ export type ScheduleLinkedStreamOfflineReason = "streamEnd" | "noShow" | "scheduleRemoved" | "timeout";
487
+ /** Event data for scheduleLinkedStreamOnline event. */
488
+ export interface WsScheduleLinkedStreamOnlineData {
489
+ trigger: ScheduleLinkedStreamOnlineTrigger;
490
+ channel: ScheduleLinkedChannel;
491
+ linkType: ScheduleLinkType;
492
+ scheduleEntry: ScheduleEntry;
493
+ stream: WsStreamOnlineData | WsStreamOfflineData;
494
+ }
495
+ /** Event data for scheduleLinkedStreamUpdate event. */
496
+ export interface WsScheduleLinkedStreamUpdateData {
497
+ channel: ScheduleLinkedChannel;
498
+ linkType: ScheduleLinkType;
499
+ scheduleEntry: ScheduleEntry;
500
+ stream: StreamMetadata;
501
+ }
502
+ /** Event data for scheduleLinkedStreamOffline event. */
503
+ export interface WsScheduleLinkedStreamOfflineData {
504
+ reason: ScheduleLinkedStreamOfflineReason;
505
+ channel: ScheduleLinkedChannel;
506
+ linkType: ScheduleLinkType;
507
+ scheduleEntry: ScheduleEntry;
508
+ stream: WsStreamOfflineData;
509
+ }
510
+ /** Entry of `GET /twitch/scheduleLinkedStreams`. */
511
+ export interface ScheduleLinkedStreamInfo {
512
+ status: "live" | "waiting";
513
+ channel: ScheduleLinkedChannel;
514
+ linkType: ScheduleLinkType;
515
+ scheduleEntry: ScheduleEntry;
516
+ stream: WsStreamOnlineData | WsStreamOfflineData;
517
+ }
415
518
  /** Event data for raid events. */
416
519
  export interface WsStreamRaidData {
417
520
  channel: {
@@ -561,6 +664,9 @@ export interface WsEventDataMap {
561
664
  streamOffline: WsStreamOfflineData;
562
665
  streamUpdate: StreamMetadata;
563
666
  secretneuroaccountOnline: WsStreamOnlineData;
667
+ scheduleLinkedStreamOnline: WsScheduleLinkedStreamOnlineData;
668
+ scheduleLinkedStreamUpdate: WsScheduleLinkedStreamUpdateData;
669
+ scheduleLinkedStreamOffline: WsScheduleLinkedStreamOfflineData;
564
670
  streamRaidIncoming: WsStreamRaidData;
565
671
  streamRaidOutgoing: WsStreamRaidData;
566
672
  scheduleUpdate: ScheduleData;
@@ -1,5 +1,5 @@
1
1
  const apiVersion = "v2";
2
- const clientVersion = "2.7.0";
2
+ const clientVersion = "2.8.0";
3
3
  const userAgent = `niac_js@${clientVersion}`;
4
4
  const defaultApiBaseUrl = `neuroinfoapi.dev/api/${apiVersion}`;
5
5
  function invokeSafely(callback, ...args) {
@@ -187,6 +187,11 @@ export class NeuroInfoApiClient {
187
187
  * @docs https://github.com/Appstun/NeuroInfoAPI-Docs/blob/master/twitch.md#current-stream-status-1
188
188
  */
189
189
  this.getCurrentStream = () => this.request("/twitch/stream");
190
+ /**
191
+ * Fetches the channels that are watched right now because a schedule entry takes place on them.
192
+ * @docs https://github.com/Appstun/NeuroInfoAPI-Docs/blob/master/twitch.md#schedule-linked-streams-1
193
+ */
194
+ this.getScheduleLinkedStreams = () => this.request("/twitch/scheduleLinkedStreams");
190
195
  /**
191
196
  * Fetches all VODs (Video on Demand).
192
197
  * @docs https://github.com/Appstun/NeuroInfoAPI-Docs/blob/master/twitch.md#all-vods-1
@@ -1241,6 +1246,62 @@ export var Utils;
1241
1246
  return entry.imageUrl !== null && entry.imageUrl.trim() !== "";
1242
1247
  }
1243
1248
  Utils.hasScheduleImage = hasScheduleImage;
1249
+ // ----- Schedule-linked streams -----
1250
+ /** The schedule entry takes place on this channel instead of the main channel, e.g. `(on secretneuroaccount) Evil Stream`. */
1251
+ function isLinkTypeOn(data) {
1252
+ return data.linkType === "on";
1253
+ }
1254
+ Utils.isLinkTypeOn = isLinkTypeOn;
1255
+ /** The channel is linked as a collab partner, e.g. `w/ [Filian](...)`. */
1256
+ function isLinkTypeCollab(data) {
1257
+ return data.linkType === "collab";
1258
+ }
1259
+ Utils.isLinkTypeCollab = isLinkTypeCollab;
1260
+ /** The channel went live while it was watched. */
1261
+ function isTriggerStreamStart(data) {
1262
+ return data.trigger === "streamStart";
1263
+ }
1264
+ Utils.isTriggerStreamStart = isTriggerStreamStart;
1265
+ /** The channel was already live when watching started (e.g. it started early or the server restarted). */
1266
+ function isTriggerFetch(data) {
1267
+ return data.trigger === "fetch";
1268
+ }
1269
+ Utils.isTriggerFetch = isTriggerFetch;
1270
+ /** The scheduled time was reached. Sent once per entry whether the channel is live or not, see {@link isLinkedStreamLive}. */
1271
+ function isTriggerScheduleTime(data) {
1272
+ return data.trigger === "scheduleTime";
1273
+ }
1274
+ Utils.isTriggerScheduleTime = isTriggerScheduleTime;
1275
+ /** The stream ended. */
1276
+ function isReasonStreamEnd(data) {
1277
+ return data.reason === "streamEnd";
1278
+ }
1279
+ Utils.isReasonStreamEnd = isReasonStreamEnd;
1280
+ /** The channel did not go live after the scheduled time (collabs: 15 minutes after the main stream ended, otherwise after 4 hours). */
1281
+ function isReasonNoShow(data) {
1282
+ return data.reason === "noShow";
1283
+ }
1284
+ Utils.isReasonNoShow = isReasonNoShow;
1285
+ /** The schedule entry was removed while the channel was not live. */
1286
+ function isReasonScheduleRemoved(data) {
1287
+ return data.reason === "scheduleRemoved";
1288
+ }
1289
+ Utils.isReasonScheduleRemoved = isReasonScheduleRemoved;
1290
+ /** The channel was still live at the maximum watch time; the stream may continue without further events. */
1291
+ function isReasonTimeout(data) {
1292
+ return data.reason === "timeout";
1293
+ }
1294
+ Utils.isReasonTimeout = isReasonTimeout;
1295
+ /** The linked stream actually happened, i.e. it was live at some point (`streamEnd` or `timeout`). */
1296
+ function didLinkedStreamHappen(data) {
1297
+ return data.reason === "streamEnd" || data.reason === "timeout";
1298
+ }
1299
+ Utils.didLinkedStreamHappen = didLinkedStreamHappen;
1300
+ /** The channel is live. Narrows `stream` to the live data, e.g. for `scheduleTime` events or `getScheduleLinkedStreams()` entries. */
1301
+ function isLinkedStreamLive(data) {
1302
+ return data.stream.isLive;
1303
+ }
1304
+ Utils.isLinkedStreamLive = isLinkedStreamLive;
1244
1305
  })(Utils || (Utils = {}));
1245
1306
  const wsEventTypes = new Set([
1246
1307
  "shopProductsUpdate",
@@ -1254,6 +1315,9 @@ const wsEventTypes = new Set([
1254
1315
  "streamUpdate",
1255
1316
  "streamOffline",
1256
1317
  "secretneuroaccountOnline",
1318
+ "scheduleLinkedStreamOnline",
1319
+ "scheduleLinkedStreamUpdate",
1320
+ "scheduleLinkedStreamOffline",
1257
1321
  "streamRaidIncoming",
1258
1322
  "streamRaidOutgoing",
1259
1323
  ]);
package/package.json CHANGED
@@ -1,40 +1,39 @@
1
- {
2
- "name": "@neuroinfoapi-client/core",
3
- "version": "2.7.0",
4
- "description": "Shared HTTP client, types and WebSocket protocol logic for NeuroInfoAPI-Client (Bun, Node.js, Native)",
5
- "type": "module",
6
- "main": "./dist/index.js",
7
- "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.js"
12
- }
13
- },
14
- "files": [
15
- "dist/*.js",
16
- "dist/*.d.ts",
17
- "README.md",
18
- "LICENSE"
19
- ],
20
- "scripts": {
21
- "build": "tsc -b && node ../../scripts/helpers/setClientVersion.mjs",
22
- "typecheck": "tsc -p tsconfig.json --noEmit",
23
- "publishPackage": "powershell -NoProfile -ExecutionPolicy Bypass -File ../../scripts/publishAsk.ps1 -Package core",
24
- "deprecatePackage": "powershell -NoProfile -ExecutionPolicy Bypass -File ../../scripts/deprecateAsk.ps1 -Package core"
25
- },
26
- "publishConfig": {
27
- "access": "public"
28
- },
29
- "author": "Appstun",
30
- "license": "MIT",
31
- "repository": {
32
- "type": "git",
33
- "url": "https://github.com/NeuroInfoAPI/NPM-Packages.git",
34
- "directory": "packages/core"
35
- },
36
- "bugs": {
37
- "url": "https://github.com/NeuroInfoAPI/NPM-Packages/issues"
38
- },
39
- "homepage": "https://neuroinfoapi.dev/api/docs"
40
- }
1
+ {
2
+ "name": "@neuroinfoapi-client/core",
3
+ "version": "2.8.0",
4
+ "description": "Shared HTTP client, types and WebSocket protocol logic for NeuroInfoAPI-Client (Bun, Node.js, Native)",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist/*.js",
16
+ "dist/*.d.ts",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -b && node ../../scripts/helpers/setClientVersion.mjs",
22
+ "typecheck": "tsc -p tsconfig.json --noEmit",
23
+ "deprecatePackage": "powershell -NoProfile -ExecutionPolicy Bypass -File ../../scripts/deprecateAsk.ps1 -Package core"
24
+ },
25
+ "publishConfig": {
26
+ "access": "public"
27
+ },
28
+ "author": "Appstun",
29
+ "license": "MIT",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/NeuroInfoAPI/NPM-Packages.git",
33
+ "directory": "packages/core"
34
+ },
35
+ "bugs": {
36
+ "url": "https://github.com/NeuroInfoAPI/NPM-Packages/issues"
37
+ },
38
+ "homepage": "https://neuroinfoapi.dev/api/docs"
39
+ }