@streamfarm/sdk 0.0.0-stage → 0.1.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 (69) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +21 -0
  3. package/README.md +291 -2
  4. package/dist/cjs/chat.d.ts +51 -0
  5. package/dist/cjs/chat.js +224 -0
  6. package/dist/cjs/client.d.ts +44 -0
  7. package/dist/cjs/client.js +64 -0
  8. package/dist/cjs/errors.d.ts +86 -0
  9. package/dist/cjs/errors.js +110 -0
  10. package/dist/cjs/generated/openapi.d.ts +4127 -0
  11. package/dist/cjs/generated/openapi.js +7 -0
  12. package/dist/cjs/http.d.ts +81 -0
  13. package/dist/cjs/http.js +304 -0
  14. package/dist/cjs/index.d.ts +10 -0
  15. package/dist/cjs/index.js +22 -0
  16. package/dist/cjs/package.json +3 -0
  17. package/dist/cjs/pagination.d.ts +9 -0
  18. package/dist/cjs/pagination.js +22 -0
  19. package/dist/cjs/resources/account.d.ts +32 -0
  20. package/dist/cjs/resources/account.js +58 -0
  21. package/dist/cjs/resources/ads.d.ts +25 -0
  22. package/dist/cjs/resources/ads.js +46 -0
  23. package/dist/cjs/resources/base.d.ts +12 -0
  24. package/dist/cjs/resources/base.js +23 -0
  25. package/dist/cjs/resources/comments.d.ts +27 -0
  26. package/dist/cjs/resources/comments.js +46 -0
  27. package/dist/cjs/resources/platforms.d.ts +24 -0
  28. package/dist/cjs/resources/platforms.js +41 -0
  29. package/dist/cjs/resources/streams.d.ts +39 -0
  30. package/dist/cjs/resources/streams.js +76 -0
  31. package/dist/cjs/resources/studio.d.ts +20 -0
  32. package/dist/cjs/resources/studio.js +39 -0
  33. package/dist/cjs/types.d.ts +124 -0
  34. package/dist/cjs/types.js +2 -0
  35. package/dist/cjs/version.d.ts +2 -0
  36. package/dist/cjs/version.js +5 -0
  37. package/dist/esm/chat.d.ts +51 -0
  38. package/dist/esm/chat.js +220 -0
  39. package/dist/esm/client.d.ts +44 -0
  40. package/dist/esm/client.js +60 -0
  41. package/dist/esm/errors.d.ts +86 -0
  42. package/dist/esm/errors.js +94 -0
  43. package/dist/esm/generated/openapi.d.ts +4127 -0
  44. package/dist/esm/generated/openapi.js +6 -0
  45. package/dist/esm/http.d.ts +81 -0
  46. package/dist/esm/http.js +297 -0
  47. package/dist/esm/index.d.ts +10 -0
  48. package/dist/esm/index.js +4 -0
  49. package/dist/esm/pagination.d.ts +9 -0
  50. package/dist/esm/pagination.js +19 -0
  51. package/dist/esm/resources/account.d.ts +32 -0
  52. package/dist/esm/resources/account.js +50 -0
  53. package/dist/esm/resources/ads.d.ts +25 -0
  54. package/dist/esm/resources/ads.js +41 -0
  55. package/dist/esm/resources/base.d.ts +12 -0
  56. package/dist/esm/resources/base.js +19 -0
  57. package/dist/esm/resources/comments.d.ts +27 -0
  58. package/dist/esm/resources/comments.js +42 -0
  59. package/dist/esm/resources/platforms.d.ts +24 -0
  60. package/dist/esm/resources/platforms.js +37 -0
  61. package/dist/esm/resources/streams.d.ts +39 -0
  62. package/dist/esm/resources/streams.js +72 -0
  63. package/dist/esm/resources/studio.d.ts +20 -0
  64. package/dist/esm/resources/studio.js +35 -0
  65. package/dist/esm/types.d.ts +124 -0
  66. package/dist/esm/types.js +1 -0
  67. package/dist/esm/version.d.ts +2 -0
  68. package/dist/esm/version.js +2 -0
  69. package/package.json +75 -4
@@ -0,0 +1,42 @@
1
+ import { watchChat } from '../chat.js';
2
+ import { segment } from '../http.js';
3
+ import { Resource } from './base.js';
4
+ const commentsPath = (streamId) => `/streams/${segment(streamId, 'streamId')}/comments`;
5
+ /** A stream's chat: comments from every platform. The unified chat comes with the Pro tariff. */
6
+ export class Comments extends Resource {
7
+ /**
8
+ * Comments, oldest first (`comments:read`). Without `after` or `since`,
9
+ * the latest `limit`. To follow the chat, use `watch`, or pass the last
10
+ * comment's `uuid` as `after` and drop the ones you have.
11
+ */
12
+ async list(streamId, params = {}, options) {
13
+ const { after, since, limit, platformTypes } = params;
14
+ return this.items({ method: 'GET', path: commentsPath(streamId), query: { after, since, limit, platformType: platformTypes } }, options);
15
+ }
16
+ /** Comments the streamer deleted, to drop them from a copy of the chat (`comments:read`). */
17
+ async listDeleted(streamId, params = {}, options) {
18
+ const { since, limit } = params;
19
+ return this.items({ method: 'GET', path: `${commentsPath(streamId)}/deleted`, query: { since, limit } }, options);
20
+ }
21
+ /** How many comments the chat has, in all and by kind of platform (`comments:read`). */
22
+ async counts(streamId, params = {}, options) {
23
+ const { since, platformTypes } = params;
24
+ return this.transport.request({ method: 'GET', path: `${commentsPath(streamId)}/counts`, query: { since, platformType: platformTypes } }, options);
25
+ }
26
+ /** Deletes a comment on its platform and returns it, deleted (`comments:moderate`). */
27
+ async delete(streamId, commentId, options) {
28
+ return this.item({ method: 'DELETE', path: `${commentsPath(streamId)}/${segment(commentId, 'commentId')}` }, options);
29
+ }
30
+ /** Bans the comment's author on its platform: for `durationSec` (a timeout), or for good without it (`comments:moderate`). */
31
+ async ban(streamId, commentId, params = {}, options) {
32
+ return this.none({ method: 'POST', path: `${commentsPath(streamId)}/${segment(commentId, 'commentId')}/ban`, body: params }, options);
33
+ }
34
+ /**
35
+ * Follows the chat: `for await (const event of sf.comments.watch(id))`
36
+ * gives each new comment once and the streamer's deletions, until you
37
+ * break out or `signal` aborts (`comments:read`).
38
+ */
39
+ watch(streamId, options = {}) {
40
+ return watchChat(this, streamId, options);
41
+ }
42
+ }
@@ -0,0 +1,24 @@
1
+ import { type RequestOptions } from '../http.js';
2
+ import type { Platform, PlatformCreateParams, PlatformDestinationParams } from '../types.js';
3
+ import { Resource } from './base.js';
4
+ /** Where a stream is pushed: social platforms and RTMP servers. */
5
+ export declare class Platforms extends Resource {
6
+ /** The stream's platforms and their state, without keys (`platforms:read`). */
7
+ list(streamId: string, options?: RequestOptions): Promise<Platform[]>;
8
+ /**
9
+ * Adds a platform (`platforms:write`); a live stream starts pushing to it
10
+ * at once. VK, VK Видео Live and YouTube take nothing but `type` (they use
11
+ * the account's connection), Telegram takes `chat`, OK, Twitch and
12
+ * GoodGame may take `key` (else the one saved in the account), the others
13
+ * need `server` and `key`.
14
+ */
15
+ add(streamId: string, params: PlatformCreateParams, options?: RequestOptions): Promise<Platform>;
16
+ /** A new server and key; a live platform restarts on them (`platforms:write`). */
17
+ setDestination(streamId: string, platformId: string, params: PlatformDestinationParams, options?: RequestOptions): Promise<Platform>;
18
+ /** Pushes to the platform whenever the stream is live (`platforms:write`). */
19
+ enable(streamId: string, platformId: string, options?: RequestOptions): Promise<Platform>;
20
+ /** Stops pushing to the platform; it stays in the list (`platforms:write`). */
21
+ disable(streamId: string, platformId: string, options?: RequestOptions): Promise<Platform>;
22
+ /** Removes the platform from the stream (`platforms:write`). */
23
+ delete(streamId: string, platformId: string, options?: RequestOptions): Promise<void>;
24
+ }
@@ -0,0 +1,37 @@
1
+ import { segment } from '../http.js';
2
+ import { Resource } from './base.js';
3
+ const path = (streamId, platformId) => `/streams/${segment(streamId, 'streamId')}/platforms`
4
+ + (platformId === undefined ? '' : `/${segment(platformId, 'platformId')}`);
5
+ /** Where a stream is pushed: social platforms and RTMP servers. */
6
+ export class Platforms extends Resource {
7
+ /** The stream's platforms and their state, without keys (`platforms:read`). */
8
+ async list(streamId, options) {
9
+ return this.items({ method: 'GET', path: path(streamId) }, options);
10
+ }
11
+ /**
12
+ * Adds a platform (`platforms:write`); a live stream starts pushing to it
13
+ * at once. VK, VK Видео Live and YouTube take nothing but `type` (they use
14
+ * the account's connection), Telegram takes `chat`, OK, Twitch and
15
+ * GoodGame may take `key` (else the one saved in the account), the others
16
+ * need `server` and `key`.
17
+ */
18
+ async add(streamId, params, options) {
19
+ return this.item({ method: 'POST', path: path(streamId), body: params }, options);
20
+ }
21
+ /** A new server and key; a live platform restarts on them (`platforms:write`). */
22
+ async setDestination(streamId, platformId, params, options) {
23
+ return this.item({ method: 'PUT', path: `${path(streamId, platformId)}/destination`, body: params }, options);
24
+ }
25
+ /** Pushes to the platform whenever the stream is live (`platforms:write`). */
26
+ async enable(streamId, platformId, options) {
27
+ return this.item({ method: 'POST', path: `${path(streamId, platformId)}/enable` }, options);
28
+ }
29
+ /** Stops pushing to the platform; it stays in the list (`platforms:write`). */
30
+ async disable(streamId, platformId, options) {
31
+ return this.item({ method: 'POST', path: `${path(streamId, platformId)}/disable` }, options);
32
+ }
33
+ /** Removes the platform from the stream (`platforms:write`). */
34
+ async delete(streamId, platformId, options) {
35
+ return this.none({ method: 'DELETE', path: path(streamId, platformId) }, options);
36
+ }
37
+ }
@@ -0,0 +1,39 @@
1
+ import { type RequestOptions } from '../http.js';
2
+ import type { Credentials, Page, Stream, StreamCreateParams, StreamListParams, StreamUpdateParams } from '../types.js';
3
+ import { Resource } from './base.js';
4
+ export interface WaitUntilLiveOptions {
5
+ /** How long to wait, ms; 5 minutes by default. */
6
+ timeout?: number;
7
+ /** How often to look, ms; 5 seconds by default. */
8
+ interval?: number;
9
+ signal?: AbortSignal;
10
+ }
11
+ /** The account's streams. */
12
+ export declare class Streams extends Resource {
13
+ /** A page of the streams the key reaches, newest first (`streams:read`). */
14
+ list(params?: StreamListParams, options?: RequestOptions): Promise<Page<Stream>>;
15
+ /** Every stream the key reaches, page after page: `for await (const stream of sf.streams.all())`. */
16
+ all(params?: Omit<StreamListParams, 'page'>, options?: RequestOptions): AsyncGenerator<Stream, void, undefined>;
17
+ /** Makes a stream (`streams:write`; not with a key limited to some streams). */
18
+ create(params: StreamCreateParams, options?: RequestOptions): Promise<Stream>;
19
+ /** The stream: settings, whether it is live, its limits and figures (`streams:read`). */
20
+ get(streamId: string, options?: RequestOptions): Promise<Stream>;
21
+ /** Changes the given fields only (`streams:write`). The region doesn't change. */
22
+ update(streamId: string, params: StreamUpdateParams, options?: RequestOptions): Promise<Stream>;
23
+ /** Deletes the stream, stopping its broadcast (`streams:write`). */
24
+ delete(streamId: string, options?: RequestOptions): Promise<void>;
25
+ /** Makes a stream frozen past the tariff's the active one (`streams:write`). */
26
+ activate(streamId: string, options?: RequestOptions): Promise<Stream>;
27
+ /**
28
+ * What an encoder publishes with: the RTMP server and key, and WHIP's
29
+ * address and token (`streams:credentials`). With them one broadcasts as
30
+ * the owner: keep them secret.
31
+ */
32
+ credentials(streamId: string, options?: RequestOptions): Promise<Credentials>;
33
+ /**
34
+ * Waits until the encoder publishes to the stream (`live`) and returns
35
+ * it; WaitTimeoutError if it doesn't in time (`streams:read`). No answer,
36
+ * a server error or the request limit don't end the wait: it looks again.
37
+ */
38
+ waitUntilLive(streamId: string, options?: WaitUntilLiveOptions): Promise<Stream>;
39
+ }
@@ -0,0 +1,72 @@
1
+ import { ConnectionError, RateLimitError, ServerError, WaitTimeoutError } from '../errors.js';
2
+ import { segment, sleep } from '../http.js';
3
+ import { paginate } from '../pagination.js';
4
+ import { Resource } from './base.js';
5
+ /** The account's streams. */
6
+ export class Streams extends Resource {
7
+ /** A page of the streams the key reaches, newest first (`streams:read`). */
8
+ async list(params = {}, options) {
9
+ const { page, size, search } = params;
10
+ return this.transport.request({ method: 'GET', path: '/streams', query: { page, size, search } }, options);
11
+ }
12
+ /** Every stream the key reaches, page after page: `for await (const stream of sf.streams.all())`. */
13
+ all(params = {}, options) {
14
+ return paginate((page) => this.list({ ...params, page }, options));
15
+ }
16
+ /** Makes a stream (`streams:write`; not with a key limited to some streams). */
17
+ async create(params, options) {
18
+ return this.item({ method: 'POST', path: '/streams', body: params }, options);
19
+ }
20
+ /** The stream: settings, whether it is live, its limits and figures (`streams:read`). */
21
+ async get(streamId, options) {
22
+ return this.item({ method: 'GET', path: `/streams/${segment(streamId, 'streamId')}` }, options);
23
+ }
24
+ /** Changes the given fields only (`streams:write`). The region doesn't change. */
25
+ async update(streamId, params, options) {
26
+ return this.item({ method: 'PATCH', path: `/streams/${segment(streamId, 'streamId')}`, body: params }, options);
27
+ }
28
+ /** Deletes the stream, stopping its broadcast (`streams:write`). */
29
+ async delete(streamId, options) {
30
+ return this.none({ method: 'DELETE', path: `/streams/${segment(streamId, 'streamId')}` }, options);
31
+ }
32
+ /** Makes a stream frozen past the tariff's the active one (`streams:write`). */
33
+ async activate(streamId, options) {
34
+ return this.item({ method: 'POST', path: `/streams/${segment(streamId, 'streamId')}/activate` }, options);
35
+ }
36
+ /**
37
+ * What an encoder publishes with: the RTMP server and key, and WHIP's
38
+ * address and token (`streams:credentials`). With them one broadcasts as
39
+ * the owner: keep them secret.
40
+ */
41
+ async credentials(streamId, options) {
42
+ return this.item({ method: 'GET', path: `/streams/${segment(streamId, 'streamId')}/credentials` }, options);
43
+ }
44
+ /**
45
+ * Waits until the encoder publishes to the stream (`live`) and returns
46
+ * it; WaitTimeoutError if it doesn't in time (`streams:read`). No answer,
47
+ * a server error or the request limit don't end the wait: it looks again.
48
+ */
49
+ async waitUntilLive(streamId, options = {}) {
50
+ const { timeout = 300_000, interval = 5_000, signal } = options;
51
+ const deadline = Date.now() + timeout;
52
+ for (;;) {
53
+ const left = deadline - Date.now();
54
+ try {
55
+ // Each look within what is left of the wait, and at most 30 s.
56
+ const stream = await this.get(streamId, { signal, maxRetries: 0, timeout: Math.max(1, Math.min(left, 30_000)) });
57
+ if (stream.live)
58
+ return stream;
59
+ }
60
+ catch (error) {
61
+ if (signal?.aborted)
62
+ throw signal.reason;
63
+ if (!(error instanceof ConnectionError || error instanceof ServerError || error instanceof RateLimitError))
64
+ throw error;
65
+ }
66
+ const now = deadline - Date.now();
67
+ if (now <= 0)
68
+ throw new WaitTimeoutError(`The stream didn't go live within ${timeout} ms`);
69
+ await sleep(Math.min(interval, now), signal);
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,20 @@
1
+ import { type RequestOptions } from '../http.js';
2
+ import type { RoomToken, Studio as StudioRoom, StudioInvite, StudioInviteCreateParams, StudioInviteCreated, StudioParticipant } from '../types.js';
3
+ import { Resource } from './base.js';
4
+ /** A stream's studio room: guests and their invitations. */
5
+ export declare class Studio extends Resource {
6
+ /** Whether the room can have guests, who is in it and the invitations (`studio:read`). */
7
+ get(streamId: string, options?: RequestOptions): Promise<StudioRoom>;
8
+ /** Who is in the room, on stage and backstage (`studio:read`). */
9
+ participants(streamId: string, options?: RequestOptions): Promise<StudioParticipant[]>;
10
+ /** Removes a guest from the room; a personal link is revoked with them (`studio:write`). */
11
+ removeParticipant(streamId: string, identity: string, options?: RequestOptions): Promise<void>;
12
+ /** The invitations; their links only for a key with `studio:write` (`studio:read`). */
13
+ invites(streamId: string, options?: RequestOptions): Promise<StudioInvite[]>;
14
+ /** Makes an invitation and returns it with the guest's link (`studio:write`). */
15
+ createInvite(streamId: string, params?: StudioInviteCreateParams, options?: RequestOptions): Promise<StudioInviteCreated>;
16
+ /** Revokes an invitation: its link lets nobody in any more (`studio:write`). */
17
+ revokeInvite(streamId: string, inviteId: string, options?: RequestOptions): Promise<void>;
18
+ /** The host's token for the room, for a program that makes the frame itself (`studio:write`). */
19
+ hostToken(streamId: string, options?: RequestOptions): Promise<RoomToken>;
20
+ }
@@ -0,0 +1,35 @@
1
+ import { segment } from '../http.js';
2
+ import { Resource } from './base.js';
3
+ const studioPath = (streamId) => `/streams/${segment(streamId, 'streamId')}/studio`;
4
+ /** A stream's studio room: guests and their invitations. */
5
+ export class Studio extends Resource {
6
+ /** Whether the room can have guests, who is in it and the invitations (`studio:read`). */
7
+ async get(streamId, options) {
8
+ return this.transport.request({ method: 'GET', path: studioPath(streamId) }, options);
9
+ }
10
+ /** Who is in the room, on stage and backstage (`studio:read`). */
11
+ async participants(streamId, options) {
12
+ return this.items({ method: 'GET', path: `${studioPath(streamId)}/participants` }, options);
13
+ }
14
+ /** Removes a guest from the room; a personal link is revoked with them (`studio:write`). */
15
+ async removeParticipant(streamId, identity, options) {
16
+ return this.none({ method: 'DELETE', path: `${studioPath(streamId)}/participants/${segment(identity, 'identity')}` }, options);
17
+ }
18
+ /** The invitations; their links only for a key with `studio:write` (`studio:read`). */
19
+ async invites(streamId, options) {
20
+ return this.items({ method: 'GET', path: `${studioPath(streamId)}/invites` }, options);
21
+ }
22
+ /** Makes an invitation and returns it with the guest's link (`studio:write`). */
23
+ async createInvite(streamId, params = {}, options) {
24
+ const { item, url } = await this.transport.request({ method: 'POST', path: `${studioPath(streamId)}/invites`, body: params }, options);
25
+ return { invite: item, url };
26
+ }
27
+ /** Revokes an invitation: its link lets nobody in any more (`studio:write`). */
28
+ async revokeInvite(streamId, inviteId, options) {
29
+ return this.none({ method: 'DELETE', path: `${studioPath(streamId)}/invites/${segment(inviteId, 'inviteId')}` }, options);
30
+ }
31
+ /** The host's token for the room, for a program that makes the frame itself (`studio:write`). */
32
+ async hostToken(streamId, options) {
33
+ return this.item({ method: 'POST', path: `${studioPath(streamId)}/token` }, options);
34
+ }
35
+ }
@@ -0,0 +1,124 @@
1
+ /**
2
+ * The API's objects and request bodies, named for programs. They come from
3
+ * the API's OpenAPI document (src/generated/openapi.ts, made from
4
+ * spec/openapi.json), so they are exactly what the API sends and takes; the
5
+ * field descriptions are the documentation's. Times are ISO 8601 strings in
6
+ * UTC, ids are UUIDs.
7
+ */
8
+ import type { components, operations } from './generated/openapi.js';
9
+ type Schemas = components['schemas'];
10
+ type Body<Op extends keyof operations> = NonNullable<operations[Op]['requestBody']>['content']['application/json'];
11
+ /** The key the client works with: its name, scopes, streams and expiry. */
12
+ export type ApiKeyInfo = Schemas['KeyInfo']['key'];
13
+ export type Region = Schemas['Region'];
14
+ /** A social network connection of the account (no tokens). */
15
+ export type Connection = Schemas['Connection'];
16
+ export type Stream = Schemas['Stream'];
17
+ export type StreamSession = Stream['session'];
18
+ export type StreamStats = Stream['stats'];
19
+ /** What an encoder publishes with: RTMP, and WHIP where the region takes it. */
20
+ export type Credentials = Schemas['Credentials'];
21
+ export type Platform = Schemas['Platform'];
22
+ export type Ad = Schemas['Ad'];
23
+ /** The ad overlay of a live, transcoded stream. */
24
+ export type Overlay = Schemas['Overlay'];
25
+ export type Comment = Schemas['Comment'];
26
+ export type CommentFragment = NonNullable<Comment['fragments']>[number];
27
+ export type DeletedComment = Schemas['DeletedComment'];
28
+ export type CommentCounts = Schemas['CommentCounts'];
29
+ /** The studio's room: whether it can have guests, who is in it, the invitations. */
30
+ export type Studio = Schemas['Studio'];
31
+ export type StudioParticipant = Schemas['StudioParticipant'];
32
+ export type StudioInvite = Schemas['StudioInvite'];
33
+ /** The host's token for the studio's room (LiveKit). */
34
+ export type RoomToken = Schemas['RoomToken'];
35
+ export type Stats = Schemas['Stats'];
36
+ export type Broadcast = Schemas['Broadcast'];
37
+ export type Plan = Schemas['Plan'];
38
+ export type Payment = Schemas['Payment'];
39
+ export type Pagination = Schemas['Pagination'];
40
+ export type PlatformType = NonNullable<Platform['type']>;
41
+ export type StreamCategory = NonNullable<Stream['category']>;
42
+ export type Scope = ApiKeyInfo['scopes'][number];
43
+ /** How an encoder publishes: `rtmp` (or SRT) or `webrtc` (WHIP). */
44
+ export type PublishSource = NonNullable<Stream['source']>;
45
+ export type StreamCreateParams = Body<'postStreams'>;
46
+ /** Only the fields to change. */
47
+ export type StreamUpdateParams = Body<'patchStreamsByStreamId'>;
48
+ export type PlatformCreateParams = Body<'postStreamsByStreamIdPlatforms'>;
49
+ export type PlatformDestinationParams = Body<'putStreamsByStreamIdPlatformsByPlatformIdDestination'>;
50
+ export type AdCreateParams = Body<'postStreamsByStreamIdAds'>;
51
+ /** Only the fields to change; `null` clears the advertiser or the ERID. */
52
+ export type AdUpdateParams = Body<'patchStreamsByStreamIdAdsByAdId'>;
53
+ export type OverlayShowParams = Body<'postStreamsByStreamIdOverlayShow'>;
54
+ export type CommentBanParams = Body<'postStreamsByStreamIdCommentsByCommentIdBan'>;
55
+ export type StudioInviteCreateParams = Body<'postStreamsByStreamIdStudioInvites'>;
56
+ /** A page of a list: its items and where it is among the pages. */
57
+ export interface Page<T> {
58
+ items: T[];
59
+ pagination: Pagination;
60
+ }
61
+ export interface PageParams {
62
+ /** From 1. */
63
+ page?: number;
64
+ /** Up to 100; 20 by default. */
65
+ size?: number;
66
+ }
67
+ export interface StreamListParams extends PageParams {
68
+ /** By name. */
69
+ search?: string;
70
+ }
71
+ export interface CommentListParams {
72
+ /**
73
+ * The last comment's `uuid` of the previous answer: the answer is then in
74
+ * the order StreamFarm got the comments (`receivedAt`) — up to 50 stored
75
+ * 5 seconds before it, itself, and up to `limit` after it. Drop the ones
76
+ * you have; the answer's last comment is the next `after`. The cursor for
77
+ * following the chat; `comments.watch` does it for you.
78
+ */
79
+ after?: string;
80
+ /** Only those published after it (by `publishedAt`, the platform's time). Not with `after`. */
81
+ since?: string | Date;
82
+ /** Up to 500; 100 by default. */
83
+ limit?: number;
84
+ /** Only from these kinds of platform. */
85
+ platformTypes?: readonly PlatformType[];
86
+ }
87
+ export interface CommentCountParams {
88
+ /** Count those published from then on, e.g. the broadcast's `session.startedAt`. */
89
+ since?: string | Date;
90
+ platformTypes?: readonly PlatformType[];
91
+ }
92
+ export interface DeletedCommentListParams {
93
+ /** Only those deleted after it: pass the last `deletedAt` you got. */
94
+ since?: string | Date;
95
+ /** Up to 500; 100 by default. */
96
+ limit?: number;
97
+ }
98
+ export interface StatsParams {
99
+ /** The first day, `YYYY-MM-DD`; by default 30 days (12 months by month) before `to`. */
100
+ from?: string;
101
+ /** The last day, included; today by default. */
102
+ to?: string;
103
+ /** By `day` (up to 400) or `month` (up to 60); `day` by default. */
104
+ interval?: 'day' | 'month';
105
+ /** An IANA time zone for the days, e.g. `Europe/Moscow`; UTC by default. */
106
+ timeZone?: string;
107
+ /** Only this stream. */
108
+ streamUuid?: string;
109
+ }
110
+ export interface BroadcastListParams extends PageParams {
111
+ /** Only this stream's. */
112
+ streamUuid?: string;
113
+ /** Only those started from then on. */
114
+ from?: string | Date;
115
+ /** Only those started before then. */
116
+ to?: string | Date;
117
+ }
118
+ /** An invitation just made: the invitation and the guest's link. */
119
+ export interface StudioInviteCreated {
120
+ invite: StudioInvite;
121
+ /** `https://studio.streamfarm.ru/join/<token>`: give it to the guest. */
122
+ url: string;
123
+ }
124
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ /** The SDK's version: sent in the User-Agent. test/resources.test.ts keeps it equal to package.json's. */
2
+ export declare const VERSION = "0.1.1";
@@ -0,0 +1,2 @@
1
+ /** The SDK's version: sent in the User-Agent. test/resources.test.ts keeps it equal to package.json's. */
2
+ export const VERSION = '0.1.1';
package/package.json CHANGED
@@ -1,6 +1,77 @@
1
1
  {
2
2
  "name": "@streamfarm/sdk",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.1",
4
+ "description": "Библиотека для публичного API StreamFarm: трансляции, площадки, реклама, чат и студия из Node.js",
5
+ "license": "MIT",
6
+ "author": "StreamFarm",
7
+ "homepage": "https://github.com/streamfarm/nodejs-sdk#readme",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/streamfarm/nodejs-sdk.git"
11
+ },
12
+ "bugs": "https://github.com/streamfarm/nodejs-sdk/issues",
13
+ "keywords": [
14
+ "streamfarm",
15
+ "restream",
16
+ "multistream",
17
+ "live-streaming",
18
+ "rtmp",
19
+ "api",
20
+ "sdk"
21
+ ],
22
+ "type": "module",
23
+ "main": "./dist/cjs/index.js",
24
+ "module": "./dist/esm/index.js",
25
+ "types": "./dist/esm/index.d.ts",
26
+ "exports": {
27
+ ".": {
28
+ "import": {
29
+ "types": "./dist/esm/index.d.ts",
30
+ "default": "./dist/esm/index.js"
31
+ },
32
+ "require": {
33
+ "types": "./dist/cjs/index.d.ts",
34
+ "default": "./dist/cjs/index.js"
35
+ }
36
+ },
37
+ "./package.json": "./package.json"
38
+ },
39
+ "files": [
40
+ "dist",
41
+ "README.md",
42
+ "CHANGELOG.md",
43
+ "LICENSE"
44
+ ],
45
+ "sideEffects": false,
46
+ "engines": {
47
+ "node": ">=20"
48
+ },
49
+ "scripts": {
50
+ "build": "node scripts/clean.mjs && tsc -p tsconfig.build.json && tsc -p tsconfig.cjs.json && node scripts/cjs-package.mjs",
51
+ "typecheck": "tsc --noEmit",
52
+ "lint": "eslint .",
53
+ "test": "vitest run",
54
+ "test:live": "vitest run --config vitest.live.config.ts",
55
+ "spec:update": "node scripts/spec.mjs update && npm run spec:types",
56
+ "spec:types": "openapi-typescript spec/openapi.json -o src/generated/openapi.ts && node scripts/spec.mjs banner",
57
+ "spec:check": "node scripts/spec.mjs check",
58
+ "check:package": "npm run build && publint && attw --pack . --profile node16",
59
+ "prepublishOnly": "npm run build"
60
+ },
61
+ "publishConfig": {
62
+ "access": "public"
63
+ },
64
+ "devDependencies": {
65
+ "@arethetypeswrong/cli": "^0.18.5",
66
+ "@eslint/js": "^9.39.5",
67
+ "@types/node": "^20.19.43",
68
+ "ajv": "^8.20.0",
69
+ "ajv-formats": "^3.0.1",
70
+ "eslint": "^9.39.5",
71
+ "openapi-typescript": "^7.13.0",
72
+ "publint": "^0.3.25",
73
+ "typescript": "^5.9.3",
74
+ "typescript-eslint": "^8.74.0",
75
+ "vitest": "^4.1.12"
76
+ }
77
+ }