diff --git a/packages/video/__tests__/__dataSets__/video.ts b/packages/video/__tests__/__dataSets__/video.ts index f8dce119..0d728f09 100644 --- a/packages/video/__tests__/__dataSets__/video.ts +++ b/packages/video/__tests__/__dataSets__/video.ts @@ -1,7 +1,7 @@ import { ExperienceComposerResolution } from '../../lib/enums/ExperienceComposerResolution'; -import { ExperienceComposerOptions } from '../../lib/interfaces/ExperienceComposerOptions'; -import { CaptionOptions } from '../../lib/interfaces/CaptionOptions'; -import { SIPCallOptions } from '../../lib/interfaces/SIPCallOptions'; +import { ExperienceComposerOptions } from '../../lib/types/ExperienceComposerOptions'; +import { CaptionOptions } from '../../lib/types/CaptionOptions'; +import { SIPCallOptions } from '../../lib/types/SIPCallOptions'; const renderInformation = { id: '1248e7070b81464c9789f46ad10e7764', diff --git a/packages/video/__tests__/video.test.ts b/packages/video/__tests__/video.test.ts index c8e83627..bfc4c644 100644 --- a/packages/video/__tests__/video.test.ts +++ b/packages/video/__tests__/video.test.ts @@ -1,12 +1,12 @@ import nock from 'nock'; import fs from 'fs'; import { Video } from '../lib/video'; -import { decode } from 'jsonwebtoken' +import { decode } from 'jsonwebtoken'; import { LayoutType } from '../lib/enums/LayoutType'; -import { MediaMode } from '../lib/interfaces/MediaMode'; -import { ArchiveMode } from '../lib/interfaces/ArchiveMode'; +import { MediaMode } from '../lib/enums/MediaMode'; +import { ArchiveMode } from '../lib/types/ArchiveMode'; import { Auth } from '@vonage/auth'; -import testDataSets from './__dataSets__/index' +import testDataSets from './__dataSets__/index'; const BASE_URL = 'https://video.api.vonage.com/'.replace(/\/+$/, ''); @@ -18,16 +18,16 @@ describe.each(testDataSets)('$label', ({ tests }) => { client = new Video(new Auth({ applicationId: 'abcd-1234', privateKey: fs.readFileSync(`${__dirname}/private.test.key`).toString() })); scope = nock(BASE_URL, { reqheaders: { - authorization: value => value.startsWith('Bearer ') && value.length > 10 - } - }).persist() + authorization: value => value.startsWith('Bearer ') && value.length > 10, + }, + }).persist(); }); afterEach(() => { client = null; scope = null; nock.cleanAll(); - }) + }); test.each(tests)( 'Can $label using: $clientMethod', @@ -36,24 +36,24 @@ describe.each(testDataSets)('$label', ({ tests }) => { const results = await client[clientMethod](...parameters); expect(results).toEqual(expected); expect(nock.isDone()).toBeTruthy(); - } - ) -}) + }, + ); +}); // Legacy unit tests describe('video', () => { let client; beforeEach(() => { - client = new Video(new Auth({ applicationId: 'abcd-1234', privateKey: fs.readFileSync(`${__dirname}/private.test.key`).toString() })); + client = new Video(new Auth({ applicationId: 'abcd-1234', privateKey: fs.readFileSync(`${__dirname}/private.test.key`).toString() })); }); afterEach(() => { - client = null; + client = null; }); test("can create a server session", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/session/create', /archiveMode=manual&p2p.preference=disabled&location=/) .reply(200, [ @@ -61,8 +61,8 @@ describe('video', () => { "session_id": "the session ID", "project_id": "your OpenTok API key", "create_dt": "The creation date", - "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this" - } + "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this", + }, ]); const session = await client.createSession(); @@ -73,7 +73,7 @@ describe('video', () => { }); test("can creating a server session properly sets correct p2p preference for relayed", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/session/create', /archiveMode=manual&p2p.preference=enabled&location=/) .reply(200, [ @@ -81,11 +81,11 @@ describe('video', () => { "session_id": "the session ID", "project_id": "your OpenTok API key", "create_dt": "The creation date", - "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this" - } + "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this", + }, ]); - const session = await client.createSession({mediaMode: MediaMode.RELAYED}); + const session = await client.createSession({ mediaMode: MediaMode.RELAYED }); expect(session.sessionId).toEqual('the session ID'); expect(session.archiveMode).toEqual(ArchiveMode.MANUAL); expect(session.mediaMode).toEqual(MediaMode.RELAYED); @@ -93,7 +93,7 @@ describe('video', () => { }); test("can creating a server session properly sets correct p2p preference for routed", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/session/create', /archiveMode=manual&p2p.preference=disabled&location=/) .reply(200, [ @@ -101,11 +101,11 @@ describe('video', () => { "session_id": "the session ID", "project_id": "your OpenTok API key", "create_dt": "The creation date", - "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this" - } + "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this", + }, ]); - const session = await client.createSession({mediaMode: MediaMode.ROUTED}); + const session = await client.createSession({ mediaMode: MediaMode.ROUTED }); expect(session.sessionId).toEqual('the session ID'); expect(session.archiveMode).toEqual(ArchiveMode.MANUAL); expect(session.mediaMode).toEqual(MediaMode.ROUTED); @@ -113,7 +113,7 @@ describe('video', () => { }); test("can creating a server session properly sets correct archive mode for manual", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/session/create', /archiveMode=manual&p2p.preference=disabled&location=/) .reply(200, [ @@ -121,11 +121,11 @@ describe('video', () => { "session_id": "the session ID", "project_id": "your OpenTok API key", "create_dt": "The creation date", - "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this" - } + "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this", + }, ]); - const session = await client.createSession({ArchiveMode: ArchiveMode.MANUAL}); + const session = await client.createSession({ ArchiveMode: ArchiveMode.MANUAL }); expect(session.sessionId).toEqual('the session ID'); expect(session.archiveMode).toEqual(ArchiveMode.MANUAL); expect(session.mediaMode).toEqual(MediaMode.ROUTED); @@ -133,7 +133,7 @@ describe('video', () => { }); test("can creating a server session properly sets correct archive mode for always", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/session/create', /archiveMode=always&p2p.preference=disabled&location=/) .reply(200, [ @@ -141,11 +141,11 @@ describe('video', () => { "session_id": "the session ID", "project_id": "your OpenTok API key", "create_dt": "The creation date", - "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this" - } + "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this", + }, ]); - const session = await client.createSession({archiveMode: ArchiveMode.ALWAYS}); + const session = await client.createSession({ archiveMode: ArchiveMode.ALWAYS }); expect(session.sessionId).toEqual('the session ID'); expect(session.archiveMode).toEqual(ArchiveMode.ALWAYS); expect(session.mediaMode).toEqual(MediaMode.ROUTED); @@ -153,7 +153,7 @@ describe('video', () => { }); test("can creating a server session properly sets location", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/session/create', /archiveMode=manual&p2p.preference=disabled&location=10.0.1.2/) .reply(200, [ @@ -161,11 +161,11 @@ describe('video', () => { "session_id": "the session ID", "project_id": "your OpenTok API key", "create_dt": "The creation date", - "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this" - } + "media_server_url": "The URL of the OpenTok media router used by the session -- ignore this", + }, ]); - const session = await client.createSession({location: '10.0.1.2'}); + const session = await client.createSession({ location: '10.0.1.2' }); expect(session.sessionId).toEqual('the session ID'); expect(session.archiveMode).toEqual(ArchiveMode.MANUAL); expect(session.mediaMode).toEqual(MediaMode.ROUTED); @@ -174,13 +174,13 @@ describe('video', () => { test("can generate a client JWT token", async () => { const token = await client.generateClientToken('abcd'); - const decoded: any = decode(token, {json: true, complete: true}); + const decoded: any = decode(token, { json: true, complete: true }); expect(decoded.payload.application_id).toEqual('abcd-1234'); expect(decoded.payload.scope).toEqual('session.connect'); expect(decoded.payload.session_id).toEqual('abcd'); expect(decoded.payload.sub).toEqual('video'); - expect(decoded.payload.acl.paths).toEqual({'/session/**': {}}); + expect(decoded.payload.acl.paths).toEqual({ '/session/**': {} }); }); test("can generate a client JWT token with renamed values", async () => { @@ -188,9 +188,9 @@ describe('video', () => { const token = await client.generateClientToken('abcd', { data: 'test', expireTime: now + 500, - initialLayoutClassList: ['foo', 'bar'] + initialLayoutClassList: ['foo', 'bar'], }); - const decoded: any = decode(token, {json: true, complete: true}); + const decoded: any = decode(token, { json: true, complete: true }); expect(decoded.payload.application_id).toEqual('abcd-1234'); expect(decoded.payload.scope).toEqual('session.connect'); @@ -201,8 +201,8 @@ describe('video', () => { }); test("can generate a client JWT token with custom options", async () => { - const token = await client.generateClientToken('abcd', {role: 'publisher'}); - const decoded: any = decode(token, {json: true, complete: true}); + const token = await client.generateClientToken('abcd', { role: 'publisher' }); + const decoded: any = decode(token, { json: true, complete: true }); expect(decoded.payload.application_id).toEqual('abcd-1234'); expect(decoded.payload.scope).toEqual('session.connect'); @@ -211,21 +211,21 @@ describe('video', () => { }); test("can send a signal to everyone", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .post('/v2/project/abcd-1234/session/1234/signal', {type: "foo", data: "bar"}) + .post('/v2/project/abcd-1234/session/1234/signal', { type: "foo", data: "bar" }) .reply(200); - await client.sendSignal({type: "foo", data: "bar"}, "1234"); + await client.sendSignal({ type: "foo", data: "bar" }, "1234"); }); test("can send a signal to one connection", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .post('/v2/project/abcd-1234/session/1234/connection/qwer/signal', {type: "foo", data: "bar"}) + .post('/v2/project/abcd-1234/session/1234/connection/qwer/signal', { type: "foo", data: "bar" }) .reply(200); - await client.sendSignal({type: "foo", data: "bar"}, "1234", "qwer"); + await client.sendSignal({ type: "foo", data: "bar" }, "1234", "qwer"); }); test("can start an archive with no options", async () => { @@ -244,12 +244,12 @@ describe('video', () => { "size" : 0, "status" : "started", "streamMode" : "auto", - "url" : null + "url" : null, }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .post('/v2/project/abcd-1234/archive', {sessionId: '1234'}) + .post('/v2/project/abcd-1234/archive', { sessionId: '1234' }) .reply(200, expectedResponse); const resp = await client.startArchive("1234"); @@ -273,15 +273,15 @@ describe('video', () => { "size" : 0, "status" : "started", "streamMode" : "auto", - "url" : null + "url" : null, }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .post('/v2/project/abcd-1234/archive', {sessionId: '1234', name: 'test', hasVideo: false}) + .post('/v2/project/abcd-1234/archive', { sessionId: '1234', name: 'test', hasVideo: false }) .reply(200, expectedResponse); - const resp = await client.startArchive("1234", {name: 'test', hasVideo: false}); + const resp = await client.startArchive("1234", { name: 'test', hasVideo: false }); expect(resp.name).toEqual(expectedResponse.name); expect(resp.sessionId).toEqual(expectedResponse.sessionId); }); @@ -300,10 +300,10 @@ describe('video', () => { "sessionId" : "flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN", "size" : 0, "status" : "stopped", - "url" : null + "url" : null, }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/v2/project/abcd-1234/archive/b40ef09b-3811-4726-b508-e41a0f96c68f/stop') .reply(200, expectedResponse); @@ -331,7 +331,7 @@ describe('video', () => { "status" : "available", "streamMode" : "manual", "streams" : [], - "url" : "https://tokbox.com.archive2.s3.amazonaws.com/123456/09141e29-8770-439b-b180-337d7e637545/archive.mp4" + "url" : "https://tokbox.com.archive2.s3.amazonaws.com/123456/09141e29-8770-439b-b180-337d7e637545/archive.mp4", }, { "createdAt" : 1384221380000, "duration" : 328, @@ -347,10 +347,10 @@ describe('video', () => { "status" : "available", "streamMode" : "auto", "streams" : [], - "url" : "https://tokbox.com.archive2.s3.amazonaws.com/123456/b40ef09b-3811-4726-b508-e41a0f96c68f/archive.mp4" - } ]}; + "url" : "https://tokbox.com.archive2.s3.amazonaws.com/123456/b40ef09b-3811-4726-b508-e41a0f96c68f/archive.mp4", + } ] }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .get('/v2/project/abcd-1234/archive') .reply(200, expectedResponse); @@ -379,15 +379,15 @@ describe('video', () => { "status" : "available", "streamMode" : "manual", "streams" : [], - "url" : "https://tokbox.com.archive2.s3.amazonaws.com/123456/09141e29-8770-439b-b180-337d7e637545/archive.mp4" - }, ]}; + "url" : "https://tokbox.com.archive2.s3.amazonaws.com/123456/09141e29-8770-439b-b180-337d7e637545/archive.mp4", + } ] }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .get('/v2/project/abcd-1234/archive?sessionId=2_MX40NzIwMzJ-flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN-MC45NDQ2MzE2NH4') .reply(200, expectedResponse); - const resp = await client.searchArchives({sessionId: '2_MX40NzIwMzJ-flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN-MC45NDQ2MzE2NH4'}); + const resp = await client.searchArchives({ sessionId: '2_MX40NzIwMzJ-flR1ZSBPY3QgMjkgMTI6MTM6MjMgUERUIDIwMTN-MC45NDQ2MzE2NH4' }); expect(resp.count).toEqual(expectedResponse.count); expect(resp.items[0].sessionId).toEqual(expectedResponse.items[0].sessionId); }); @@ -409,10 +409,10 @@ describe('video', () => { "status" : "available", "streamMode" : "auto", "streams" : [], - "url" : "https://tokbox.com.archive2.s3.amazonaws.com/123456/09141e29-8770-439b-b180-337d7e637545/archive.mp4" + "url" : "https://tokbox.com.archive2.s3.amazonaws.com/123456/09141e29-8770-439b-b180-337d7e637545/archive.mp4", }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .get('/v2/project/abcd-1234/archive/b40ef09b-3811-4726-b508-e41a0f96c68f') .reply(200, expectedResponse); @@ -424,7 +424,7 @@ describe('video', () => { }); test("can delete an archive", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .delete('/v2/project/abcd-1234/archive/b40ef09b-3811-4726-b508-e41a0f96c68f') .reply(204); @@ -433,34 +433,34 @@ describe('video', () => { }); test("can update an archive layout", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .put('/v2/project/abcd-1234/archive/b40ef09b-3811-4726-b508-e41a0f96c68f/layout', {type: LayoutType.BEST_FIT}) + .put('/v2/project/abcd-1234/archive/b40ef09b-3811-4726-b508-e41a0f96c68f/layout', { type: LayoutType.BEST_FIT }) .reply(204); - await client.updateArchiveLayout('b40ef09b-3811-4726-b508-e41a0f96c68f', {type: LayoutType.BEST_FIT}); + await client.updateArchiveLayout('b40ef09b-3811-4726-b508-e41a0f96c68f', { type: LayoutType.BEST_FIT }); }); test("can add a stream to an archive", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .patch('/v2/project/abcd-1234/archive/b40ef09b-3811-4726-b508-e41a0f96c68f/stream', {addStream: 'test-1234', hasAudio: false, hasVideo: true}) + .patch('/v2/project/abcd-1234/archive/b40ef09b-3811-4726-b508-e41a0f96c68f/stream', { addStream: 'test-1234', hasAudio: false, hasVideo: true }) .reply(204); await client.addArchiveStream('b40ef09b-3811-4726-b508-e41a0f96c68f', 'test-1234', false); }); test("can remove a stream from an archive", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .patch('/v2/project/abcd-1234/archive/b40ef09b-3811-4726-b508-e41a0f96c68f/stream', {removeStream: 'test-1234'}) + .patch('/v2/project/abcd-1234/archive/b40ef09b-3811-4726-b508-e41a0f96c68f/stream', { removeStream: 'test-1234' }) .reply(204); await client.removeArchiveStream('b40ef09b-3811-4726-b508-e41a0f96c68f', 'test-1234'); }); test("can force disconnect a client", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .delete('/v2/project/abcd-1234/session/sess-1234/connection/conn-1234') .reply(204); @@ -473,9 +473,9 @@ describe('video', () => { "id": "8b732909-0a06-46a2-8ea8-074e64d43422", "videoType": "camera", "name": "", - "layoutClassList": ["full"] + "layoutClassList": ["full"], }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .get('/v2/project/abcd-1234/session/sess-1234/stream/8b732909-0a06-46a2-8ea8-074e64d43422') .reply(200, expectedResponse); @@ -492,11 +492,11 @@ describe('video', () => { "id": "8b732909-0a06-46a2-8ea8-074e64d43422", "videoType": "camera", "name": "", - "layoutClassList": ["full"] - } - ] + "layoutClassList": ["full"], + }, + ], }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .get('/v2/project/abcd-1234/session/sess-1234/stream') .reply(200, expectedResponse); @@ -513,11 +513,11 @@ describe('video', () => { "status": "ACTIVE", "name": "Joe Montana", "environment": "standard", - "createdAt": 1414642898000 // A UNIX timestamp (in milliseconds) + "createdAt": 1414642898000, // A UNIX timestamp (in milliseconds) }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .post('/v2/project/abcd-1234/session/sess-1234/mute', { active: true, excludedStreamIds: ['stream-pub-1234']}) + .post('/v2/project/abcd-1234/session/sess-1234/mute', { active: true, excludedStreamIds: ['stream-pub-1234'] }) .reply(200, expectedResponse); const resp = await client.forceMuteAll('sess-1234', ['stream-pub-1234']); @@ -531,11 +531,11 @@ describe('video', () => { "status": "ACTIVE", "name": "Joe Montana", "environment": "standard", - "createdAt": 1414642898000 // A UNIX timestamp (in milliseconds) + "createdAt": 1414642898000, // A UNIX timestamp (in milliseconds) }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .post('/v2/project/abcd-1234/session/sess-1234/mute', { active: false, excludedStreamIds: []}) + .post('/v2/project/abcd-1234/session/sess-1234/mute', { active: false, excludedStreamIds: [] }) .reply(200, expectedResponse); const resp = await client.disableForceMute('sess-1234'); @@ -549,9 +549,9 @@ describe('video', () => { "status": "ACTIVE", "name": "Joe Montana", "environment": "standard", - "createdAt": 1414642898000 // A UNIX timestamp (in milliseconds) + "createdAt": 1414642898000, // A UNIX timestamp (in milliseconds) }; - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/v2/project/abcd-1234/session/sess-1234/stream/stream-user-1234/mute') .reply(200, expectedResponse); @@ -561,21 +561,21 @@ describe('video', () => { }); test("can set class list for streams", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .put('/v2/project/abcd-1234/session/sess-1234/stream', {items: [{id: 'stream-1234', layoutClassList: ["full"]}]}) + .put('/v2/project/abcd-1234/session/sess-1234/stream', { items: [{ id: 'stream-1234', layoutClassList: ["full"] }] }) .reply(200); - await client.setStreamClassLists('sess-1234', [{id: 'stream-1234', layoutClassList: ["full"]}]); + await client.setStreamClassLists('sess-1234', [{ id: 'stream-1234', layoutClassList: ["full"] }]); }); test("can initiate a SIP call", async () => { const options = { token: client.generateClientToken(), sip: { - uri: 'sip:user@sip.partner.com;transport=tls' - } - } + uri: 'sip:user@sip.partner.com;transport=tls', + }, + }; const expectedResponse = { id: "b0a5a8c7-dc38-459f-a48d-a7f2008da853", @@ -585,7 +585,7 @@ describe('video', () => { const expectedBody = Object.assign({}, { sessionId: "2_MX40NTMyODc3Mn5-fg" }, options); - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/v2/project/abcd-1234/dial', expectedBody) .reply(200, expectedResponse); @@ -598,42 +598,42 @@ describe('video', () => { }); test("can play DTMF digits to everyone", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .post('/v2/project/abcd-1234/session/2_MX40NTMyODc3Mn5-fg/play-dtmf', { digits: '1234#'}) + .post('/v2/project/abcd-1234/session/2_MX40NTMyODc3Mn5-fg/play-dtmf', { digits: '1234#' }) .reply(200); await client.playDTMF("2_MX40NTMyODc3Mn5-fg", "1234#"); }); test("can play DTMF digits into one connection", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .post('/v2/project/abcd-1234/session/2_MX40NTMyODc3Mn5-fg/connection/396edda0-fc30-41fd-8e63/play-dtmf', {digits: "1234#"}) + .post('/v2/project/abcd-1234/session/2_MX40NTMyODc3Mn5-fg/connection/396edda0-fc30-41fd-8e63/play-dtmf', { digits: "1234#" }) .reply(200); - await client.playDTMF("2_MX40NTMyODc3Mn5-fg", "1234#", "396edda0-fc30-41fd-8e63"); + await client.playDTMF("2_MX40NTMyODc3Mn5-fg", "1234#", "396edda0-fc30-41fd-8e63"); }); test("can connect to a websocket", async () => { const token = client.generateClientToken(); - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() - .post('/v2/project/abcd-1234/connect', {sessionId: "2_MX40NTMyODc3Mn5-fg", token, websocket: {uri: 'wss://mydomain.com/websocket/'}}) - .reply(200, {id: 'CALLID', connectionId: 'CONNECTIONID'}); + .post('/v2/project/abcd-1234/connect', { sessionId: "2_MX40NTMyODc3Mn5-fg", token, websocket: { uri: 'wss://mydomain.com/websocket/' } }) + .reply(200, { id: 'CALLID', connectionId: 'CONNECTIONID' }); - const resp = await client.connectToWebsocket("2_MX40NTMyODc3Mn5-fg", token, {uri: 'wss://mydomain.com/websocket/'}); - expect(resp.id).toEqual('CALLID') - expect(resp.connectionId).toEqual('CONNECTIONID') + const resp = await client.connectToWebsocket("2_MX40NTMyODc3Mn5-fg", token, { uri: 'wss://mydomain.com/websocket/' }); + expect(resp.id).toEqual('CALLID'); + expect(resp.connectionId).toEqual('CONNECTIONID'); }); test("can disconnect a websocket", async () => { - nock(BASE_URL, {reqheaders: {'Authorization': value => value.startsWith('Bearer ') && value.length > 10 }}) + nock(BASE_URL, { reqheaders: { 'Authorization': value => value.startsWith('Bearer ') && value.length > 10 } }) .persist() .post('/v2/project/abcd-1234/connect/CALLID/stop') .reply(200); - await client.disconnectWebsocket('CALLID'); + await client.disconnectWebsocket('CALLID'); }); }); diff --git a/packages/video/lib/enums/ArchiveOutputMode.ts b/packages/video/lib/enums/ArchiveOutputMode.ts index b72aa090..827e4e9e 100644 --- a/packages/video/lib/enums/ArchiveOutputMode.ts +++ b/packages/video/lib/enums/ArchiveOutputMode.ts @@ -1,4 +1,14 @@ +/** + * Enum representing different output modes for video archives. + */ export enum ArchiveOutputMode { + /** + * Represents the composed output mode where all streams are mixed into one. + */ COMPOSED = 'composed', + + /** + * Represents the individual output mode where each stream is recorded separately. + */ INDIVIDUAL = 'individual', } diff --git a/packages/video/lib/enums/AudioRate.ts b/packages/video/lib/enums/AudioRate.ts index bc65adfa..bd989ccc 100644 --- a/packages/video/lib/enums/AudioRate.ts +++ b/packages/video/lib/enums/AudioRate.ts @@ -1,4 +1,14 @@ +/** + * Enum representing different audio sample rates. + */ export enum AudioRate { + /** + * Represents an audio sample rate of 16 kHz. + */ "16KHZ" = 16000, + + /** + * Represents an audio sample rate of 8 kHz. + */ "8KHZ" = 8000 -} \ No newline at end of file +} diff --git a/packages/video/lib/enums/CaptionStatus.ts b/packages/video/lib/enums/CaptionStatus.ts index 37d4c287..9abac180 100644 --- a/packages/video/lib/enums/CaptionStatus.ts +++ b/packages/video/lib/enums/CaptionStatus.ts @@ -1,6 +1,24 @@ +/** + * Enum representing different captioning status. + */ export enum CaptionStatus { - STARTED = "started", - STOPPED = "stopped", - PAUSED = "paused", - FAILED = "failed" -} \ No newline at end of file + /** + * Indicates that captioning has started. + */ + STARTED = "started", + + /** + * Indicates that captioning has stopped. + */ + STOPPED = "stopped", + + /** + * Indicates that captioning has been paused. + */ + PAUSED = "paused", + + /** + * Indicates that captioning has failed. + */ + FAILED = "failed" +} diff --git a/packages/video/lib/enums/ExperienceComposerResolution.ts b/packages/video/lib/enums/ExperienceComposerResolution.ts index b1fa27f9..167e88ea 100644 --- a/packages/video/lib/enums/ExperienceComposerResolution.ts +++ b/packages/video/lib/enums/ExperienceComposerResolution.ts @@ -1,8 +1,26 @@ import { Resolution } from "./Resolution"; +/** + * Enum representing different resolutions for an experience composer. + */ export enum ExperienceComposerResolution { - SD_LANDSCAPE = Resolution.SD_LANDSCAPE, - SD_PORTRAIT = Resolution.SD_PORTRAIT, - HD_LANDSCAPE = Resolution.HD_LANDSCAPE, - HD_PORTRAIT = Resolution.HD_PORTRAIT, -} \ No newline at end of file + /** + * Standard definition landscape resolution. + */ + SD_LANDSCAPE = Resolution.SD_LANDSCAPE, + + /** + * Standard definition portrait resolution. + */ + SD_PORTRAIT = Resolution.SD_PORTRAIT, + + /** + * High definition landscape resolution. + */ + HD_LANDSCAPE = Resolution.HD_LANDSCAPE, + + /** + * High definition portrait resolution. + */ + HD_PORTRAIT = Resolution.HD_PORTRAIT, +} diff --git a/packages/video/lib/enums/LayoutType.ts b/packages/video/lib/enums/LayoutType.ts index c8207d74..d2ff6696 100644 --- a/packages/video/lib/enums/LayoutType.ts +++ b/packages/video/lib/enums/LayoutType.ts @@ -1,7 +1,29 @@ +/** + * Enum representing different layout types for live streaming broadcasts. + */ export enum LayoutType { + /** + * Automatically determine the best fit layout. + */ BEST_FIT = 'bestFit', + + /** + * Use a custom layout for the broadcast. + */ CUSTOM = 'custom', + + /** + * Horizontal presentation layout. + */ HORIZONTAL_PRESENTATION = 'horizontalPresentation', + + /** + * Picture-in-picture (PIP) layout. + */ PIP = 'pip', + + /** + * Vertical presentation layout. + */ VERTICAL_PRESENTATION = 'verticalPresentation', } diff --git a/packages/video/lib/enums/MediaMode.ts b/packages/video/lib/enums/MediaMode.ts new file mode 100644 index 00000000..2c6ce43f --- /dev/null +++ b/packages/video/lib/enums/MediaMode.ts @@ -0,0 +1,14 @@ +/** + * Enum representing media modes for a session. + */ +export enum MediaMode { + /** + * Routed mode where media is disabled. + */ + ROUTED = 'disabled', + + /** + * Relayed mode where media is enabled. + */ + RELAYED = 'enabled', +} diff --git a/packages/video/lib/enums/Resolution.ts b/packages/video/lib/enums/Resolution.ts index 0c8dc110..13f02de6 100644 --- a/packages/video/lib/enums/Resolution.ts +++ b/packages/video/lib/enums/Resolution.ts @@ -1,8 +1,34 @@ +/** + * Enum representing different video resolutions for live streaming broadcasts. + */ export enum Resolution { + /** + * Full HD landscape resolution (1920x1080 pixels). + */ FHD_LANDSCAPE = '1920x1080', + + /** + * Full HD portrait resolution (1080x1920 pixels). + */ FHD_PORTRAIT = '1080x1920', + + /** + * HD landscape resolution (1280x720 pixels). + */ HD_LANDSCAPE = '1280x720', + + /** + * HD portrait resolution (720x1280 pixels). + */ HD_PORTRAIT = '720x1280', + + /** + * Standard definition landscape resolution (640x480 pixels). + */ SD_LANDSCAPE = '640x480', + + /** + * Standard definition portrait resolution (480x640 pixels). + */ SD_PORTRAIT = '480x640', } diff --git a/packages/video/lib/enums/StreamMode.ts b/packages/video/lib/enums/StreamMode.ts index 17886877..513b0016 100644 --- a/packages/video/lib/enums/StreamMode.ts +++ b/packages/video/lib/enums/StreamMode.ts @@ -1,4 +1,14 @@ +/** + * Enum representing different stream modes for live streaming broadcasts. + */ export enum StreamMode { + /** + * Streams are selected automatically based on session rules. + */ AUTO = 'auto', + + /** + * Streams are manually selected for inclusion in the broadcast. + */ MANUAL = 'manual', } diff --git a/packages/video/lib/enums/index.ts b/packages/video/lib/enums/index.ts index c42ec4ca..12428565 100644 --- a/packages/video/lib/enums/index.ts +++ b/packages/video/lib/enums/index.ts @@ -5,3 +5,4 @@ export * from './ExperienceComposerResolution'; export * from './LayoutType'; export * from './Resolution'; export * from './StreamMode'; +export * from './MediaMode'; diff --git a/packages/video/lib/index.ts b/packages/video/lib/index.ts index 0de80f0e..09d465c9 100644 --- a/packages/video/lib/index.ts +++ b/packages/video/lib/index.ts @@ -1,4 +1,4 @@ export * from './enums'; -export * from './interfaces'; +export * from './types'; export * from './parameters'; export * from './video'; diff --git a/packages/video/lib/interfaces/ArchiveLayout.ts b/packages/video/lib/interfaces/ArchiveLayout.ts deleted file mode 100644 index defd26cf..00000000 --- a/packages/video/lib/interfaces/ArchiveLayout.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { LayoutType } from '../enums/LayoutType'; - -export interface ArchiveLayout { - type: LayoutType; - stylesheet?: string; - screenshareType?: string; -} diff --git a/packages/video/lib/interfaces/ArchiveMode.ts b/packages/video/lib/interfaces/ArchiveMode.ts deleted file mode 100644 index 86901f89..00000000 --- a/packages/video/lib/interfaces/ArchiveMode.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum ArchiveMode { - MANUAL = 'manual', - ALWAYS = 'always', -} diff --git a/packages/video/lib/interfaces/ArchiveOptions.ts b/packages/video/lib/interfaces/ArchiveOptions.ts deleted file mode 100644 index fa167f7f..00000000 --- a/packages/video/lib/interfaces/ArchiveOptions.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ArchiveOutputMode } from '../enums/ArchiveOutputMode'; -import { Resolution } from '../enums/Resolution'; -import { StreamMode } from '../enums/StreamMode'; -import { ArchiveLayout } from './ArchiveLayout'; - -export interface ArchiveOptions { - hasAudio?: boolean; - hasVideo?: boolean; - layout?: ArchiveLayout; - name?: string; - outputMode?: ArchiveOutputMode; - resolution?: Resolution; - streamMode?: StreamMode; -} diff --git a/packages/video/lib/interfaces/ArchiveSearchFilter.ts b/packages/video/lib/interfaces/ArchiveSearchFilter.ts deleted file mode 100644 index ea48f8ce..00000000 --- a/packages/video/lib/interfaces/ArchiveSearchFilter.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface ArchiveSearchFilter { - offset?: number; - count?: number; - sessionId?: string; -} diff --git a/packages/video/lib/interfaces/BroadcastConfig.ts b/packages/video/lib/interfaces/BroadcastConfig.ts deleted file mode 100644 index 44f1bac9..00000000 --- a/packages/video/lib/interfaces/BroadcastConfig.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { LayoutType } from '../enums/LayoutType'; -import { Resolution } from '../enums/Resolution'; -import { StreamMode } from '../enums/StreamMode'; -import { RTMPStream } from './RTMPStream'; - -export interface BroadcastConfig { - multiBroadcastTag?: string; - maxDuration?: number; - maxBitrate?: number; - layout?: LayoutType; - hasAudio?: boolean; - hasVideo?: boolean; - outputs: { - hls?: { - lowLatency?: boolean; - dvr?: boolean; - }; - rtmp: RTMPStream[]; - }; - streamMode?: StreamMode; - resolution?: Resolution; -} diff --git a/packages/video/lib/interfaces/BroadcastSearchFilter.ts b/packages/video/lib/interfaces/BroadcastSearchFilter.ts deleted file mode 100644 index c671deb4..00000000 --- a/packages/video/lib/interfaces/BroadcastSearchFilter.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface BroadcastSearchFilter { - offset?: number; - count?: number; - sessionId?: string; -} diff --git a/packages/video/lib/interfaces/BroadcastUpdateConfig.ts b/packages/video/lib/interfaces/BroadcastUpdateConfig.ts deleted file mode 100644 index 4171cb1e..00000000 --- a/packages/video/lib/interfaces/BroadcastUpdateConfig.ts +++ /dev/null @@ -1,7 +0,0 @@ -export interface BroadcastUpdateConfig { - broadcastId: string; - hasAudio?: boolean; - hasVideo?: boolean; - addStream?: string; - removeStream?: string; -} diff --git a/packages/video/lib/interfaces/CaptionOptions.ts b/packages/video/lib/interfaces/CaptionOptions.ts deleted file mode 100644 index e24146b1..00000000 --- a/packages/video/lib/interfaces/CaptionOptions.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface CaptionOptions { - languageCode?: "en-us" - maxDuration?: number - partialCaptions?: "true" | "false" - statusCallbackUrl?: string -} \ No newline at end of file diff --git a/packages/video/lib/interfaces/ClientTokenClaims.ts b/packages/video/lib/interfaces/ClientTokenClaims.ts deleted file mode 100644 index 147a01bf..00000000 --- a/packages/video/lib/interfaces/ClientTokenClaims.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface ClientTokenClaims { - scope: string, - session_id: string, - role: string, - initial_layout_class_list: string - data?: string - exp?: number - connection_data?: string - sub: string, - acl: { - paths: { - [key: string]: object - } - } -} \ No newline at end of file diff --git a/packages/video/lib/interfaces/ClientTokenOptions.ts b/packages/video/lib/interfaces/ClientTokenOptions.ts deleted file mode 100644 index cfb050ec..00000000 --- a/packages/video/lib/interfaces/ClientTokenOptions.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface ClientTokenOptions { - role?: string; - data?: string; - expireTime?: number; - initialLayoutClassList?: string[]; -} diff --git a/packages/video/lib/interfaces/ExperienceComposerListFilter.ts b/packages/video/lib/interfaces/ExperienceComposerListFilter.ts deleted file mode 100644 index 95825226..00000000 --- a/packages/video/lib/interfaces/ExperienceComposerListFilter.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface ExperienceComposerListFilter { - offset?: number; - count?: number; -} diff --git a/packages/video/lib/interfaces/ExperienceComposerOptions.ts b/packages/video/lib/interfaces/ExperienceComposerOptions.ts deleted file mode 100644 index e8f50278..00000000 --- a/packages/video/lib/interfaces/ExperienceComposerOptions.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { ExperienceComposerResolution } from "../enums/ExperienceComposerResolution"; - -export interface ExperienceComposerOptions { - url: string - properties?: { - name?: string - } - maxDuration?: number - resolution?: ExperienceComposerResolution - statusCallbackUrl?: string -} \ No newline at end of file diff --git a/packages/video/lib/interfaces/MediaMode.ts b/packages/video/lib/interfaces/MediaMode.ts deleted file mode 100644 index 3dea0abf..00000000 --- a/packages/video/lib/interfaces/MediaMode.ts +++ /dev/null @@ -1,4 +0,0 @@ -export enum MediaMode { - ROUTED = 'disabled', - RELAYED = 'enabled', -} diff --git a/packages/video/lib/interfaces/RTMPStream.ts b/packages/video/lib/interfaces/RTMPStream.ts deleted file mode 100644 index 08a9cda2..00000000 --- a/packages/video/lib/interfaces/RTMPStream.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface RTMPStream { - id?: string; - serverUrl: string; - streamName: string; -} diff --git a/packages/video/lib/interfaces/Request/InitiateSIPCallRequest.ts b/packages/video/lib/interfaces/Request/InitiateSIPCallRequest.ts deleted file mode 100644 index 7909b929..00000000 --- a/packages/video/lib/interfaces/Request/InitiateSIPCallRequest.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { SIPCallOptions } from '../SIPCallOptions'; - -export interface InitiateSIPCallRequest extends SIPCallOptions { - sessionId: string -} diff --git a/packages/video/lib/interfaces/Response/BroadcastDetailsResponse.ts b/packages/video/lib/interfaces/Response/BroadcastDetailsResponse.ts deleted file mode 100644 index 62a353f6..00000000 --- a/packages/video/lib/interfaces/Response/BroadcastDetailsResponse.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { Resolution } from '../../enums/Resolution'; -import { StreamMode } from '../../enums/StreamMode'; -import { RTMPStream } from '../RTMPStream'; - -export interface BroadcastDetailsResponse { - id: string; - sessionId: string; - multiBroadcasTag?: string; - applicationId: string; - createdAt: number; - updatedAt: number; - maxDuration?: number; - maxBitrate?: number; - broadcastUrls: { - hls?: string; - rtmp: RTMPStream[]; - }; - settings?: { - hls?: { - lowLatency?: boolean; - }; - }; - resolution?: Resolution; - hasVideo: boolean; - hasAudio: boolean; - streamMode: StreamMode; -} diff --git a/packages/video/lib/interfaces/Response/CaptionStatusResponse.ts b/packages/video/lib/interfaces/Response/CaptionStatusResponse.ts deleted file mode 100644 index 6ad78e11..00000000 --- a/packages/video/lib/interfaces/Response/CaptionStatusResponse.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { CaptionStatus } from "../../enums/CaptionStatus"; - -export interface CaptionStatusResponse { - captionId: string - applicationId: string - sessionId: string - status: CaptionStatus - createdAt: number - updatedAt: number - duration: number - languageCode: "en-us" - provider: "aws-transcribe" - reason?: string -} \ No newline at end of file diff --git a/packages/video/lib/interfaces/Response/CreateSessionResponse.ts b/packages/video/lib/interfaces/Response/CreateSessionResponse.ts deleted file mode 100644 index 5aadbe24..00000000 --- a/packages/video/lib/interfaces/Response/CreateSessionResponse.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface CreateSessionResponse { - session_id: string; - project_id: string; - create_dt: string; - media_server_url: string; -} diff --git a/packages/video/lib/interfaces/Response/EnableCaptionResponse.ts b/packages/video/lib/interfaces/Response/EnableCaptionResponse.ts deleted file mode 100644 index 0d5f0961..00000000 --- a/packages/video/lib/interfaces/Response/EnableCaptionResponse.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface EnableCaptionResponse { - captionsId: string -} \ No newline at end of file diff --git a/packages/video/lib/interfaces/Response/ExperienceComposerResponse.ts b/packages/video/lib/interfaces/Response/ExperienceComposerResponse.ts deleted file mode 100644 index 96389474..00000000 --- a/packages/video/lib/interfaces/Response/ExperienceComposerResponse.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { ExperienceComposerResolution } from "../../enums/ExperienceComposerResolution"; - -export interface ExperienceComposerResponse { - id: string - sessionId: string - applicationId: string - createdAt: number - updatedAt: number - url: string - resolution: ExperienceComposerResolution - status: "starting" | "started" | "stopped" | "failed" - streamId: string - reason?: string -} \ No newline at end of file diff --git a/packages/video/lib/interfaces/Response/MultiArchiveResponse.ts b/packages/video/lib/interfaces/Response/MultiArchiveResponse.ts deleted file mode 100644 index 01c86331..00000000 --- a/packages/video/lib/interfaces/Response/MultiArchiveResponse.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { SingleArchiveResponse } from './SingleArchiveResponse'; - -export interface MultiArchiveResponse { - count: number; - items: SingleArchiveResponse[]; -} diff --git a/packages/video/lib/interfaces/Response/MultiBroadcastResponse.ts b/packages/video/lib/interfaces/Response/MultiBroadcastResponse.ts deleted file mode 100644 index 12f87dc3..00000000 --- a/packages/video/lib/interfaces/Response/MultiBroadcastResponse.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { BroadcastDetailsResponse } from './BroadcastDetailsResponse'; - -export interface MultiBroadcastResponse { - count: number; - items: BroadcastDetailsResponse[]; -} diff --git a/packages/video/lib/interfaces/Response/MultiExperienceComposerResponse.ts b/packages/video/lib/interfaces/Response/MultiExperienceComposerResponse.ts deleted file mode 100644 index b054a1e8..00000000 --- a/packages/video/lib/interfaces/Response/MultiExperienceComposerResponse.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { ExperienceComposerResponse } from "./ExperienceComposerResponse"; - -export interface MultiExperienceComposerResponse { - count: number - items: ExperienceComposerResponse[] -} \ No newline at end of file diff --git a/packages/video/lib/interfaces/Response/MultiStreamLayoutResponse.ts b/packages/video/lib/interfaces/Response/MultiStreamLayoutResponse.ts deleted file mode 100644 index 5ef095c7..00000000 --- a/packages/video/lib/interfaces/Response/MultiStreamLayoutResponse.ts +++ /dev/null @@ -1,6 +0,0 @@ -import { SingleStreamLayoutResponse } from './SingleStreamLayoutResponse'; - -export interface MultiStreamLayoutResponse { - count: number; - items: SingleStreamLayoutResponse[]; -} diff --git a/packages/video/lib/interfaces/Response/ProjectDetailsResponse.ts b/packages/video/lib/interfaces/Response/ProjectDetailsResponse.ts deleted file mode 100644 index 22bec231..00000000 --- a/packages/video/lib/interfaces/Response/ProjectDetailsResponse.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface ProjectDetailsResponse { - id: string; - secret: string; - status: string; - name: string; - environment: string; - createdAt: number; -} diff --git a/packages/video/lib/interfaces/Response/SIPCallResponse.ts b/packages/video/lib/interfaces/Response/SIPCallResponse.ts deleted file mode 100644 index 8e8cfb34..00000000 --- a/packages/video/lib/interfaces/Response/SIPCallResponse.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface SIPCallResponse { - id: string; - connectionId: string; - streamId: string; -} diff --git a/packages/video/lib/interfaces/Response/SingleArchiveResponse.ts b/packages/video/lib/interfaces/Response/SingleArchiveResponse.ts deleted file mode 100644 index 60e4cc38..00000000 --- a/packages/video/lib/interfaces/Response/SingleArchiveResponse.ts +++ /dev/null @@ -1,18 +0,0 @@ -export interface SingleArchiveResponse { - createdAt: number; - duration: number; - hasAudio: boolean; - hasVideo: boolean; - id: string; - name: string; - outputMode: string; - projectId: string; - reason: string; - resolution: string; - sessionId: string; - size: number; - status: string; - streamMode: string; - url?: string; - streams?: string[]; -} diff --git a/packages/video/lib/interfaces/Response/SingleStreamLayoutResponse.ts b/packages/video/lib/interfaces/Response/SingleStreamLayoutResponse.ts deleted file mode 100644 index 36460743..00000000 --- a/packages/video/lib/interfaces/Response/SingleStreamLayoutResponse.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface SingleStreamLayoutResponse { - id: string; - videoType: string; - name: string; - layoutClassList: string[]; -} diff --git a/packages/video/lib/interfaces/Response/WebSocketConnectResponse.ts b/packages/video/lib/interfaces/Response/WebSocketConnectResponse.ts deleted file mode 100644 index c4ce5601..00000000 --- a/packages/video/lib/interfaces/Response/WebSocketConnectResponse.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface WebSocketConnectResponse { - id: string - connectionId: string -} diff --git a/packages/video/lib/interfaces/SIPCallOptions.ts b/packages/video/lib/interfaces/SIPCallOptions.ts deleted file mode 100644 index 80ee092b..00000000 --- a/packages/video/lib/interfaces/SIPCallOptions.ts +++ /dev/null @@ -1,17 +0,0 @@ -export interface SIPCallOptions { - token: string; - sip: { - uri: string; - from?: string; - headers?: { - [key: string]: string; - }, - auth?: { - username: string; - password: string; - } - secure?: boolean; - video?: boolean; - observeForceMute?: boolean; - } -} diff --git a/packages/video/lib/interfaces/Session.ts b/packages/video/lib/interfaces/Session.ts deleted file mode 100644 index 66fc215e..00000000 --- a/packages/video/lib/interfaces/Session.ts +++ /dev/null @@ -1,6 +0,0 @@ -export interface Session { - sessionId: string; - location: string; - mediaMode: string; - archiveMode: string; -} diff --git a/packages/video/lib/interfaces/StreamClassList.ts b/packages/video/lib/interfaces/StreamClassList.ts deleted file mode 100644 index f37c3e68..00000000 --- a/packages/video/lib/interfaces/StreamClassList.ts +++ /dev/null @@ -1,4 +0,0 @@ -export interface StreamClassList { - id: string; - layoutClassList: string[]; -} diff --git a/packages/video/lib/interfaces/VideoResponse.ts b/packages/video/lib/interfaces/VideoResponse.ts deleted file mode 100644 index 62f85a7d..00000000 --- a/packages/video/lib/interfaces/VideoResponse.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { VetchResponse } from '@vonage/vetch'; - -export type VideoResponse = VetchResponse diff --git a/packages/video/lib/interfaces/WebSocketConfig.ts b/packages/video/lib/interfaces/WebSocketConfig.ts deleted file mode 100644 index 6169134c..00000000 --- a/packages/video/lib/interfaces/WebSocketConfig.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { AudioRate } from '../enums/AudioRate'; - -export interface WebSocketConfig { - uri: string - streams?: string[] - headers?: { - [key: string]: string - } - audioRate?: AudioRate -} diff --git a/packages/video/lib/parameters/VideoClassParameters.ts b/packages/video/lib/parameters/VideoClassParameters.ts index be903ea6..93037e37 100644 --- a/packages/video/lib/parameters/VideoClassParameters.ts +++ b/packages/video/lib/parameters/VideoClassParameters.ts @@ -1,10 +1,24 @@ -import { AuthOpts } from '@vonage/auth'; +import { AuthParams } from '@vonage/auth'; import { AuthInterface } from '@vonage/auth'; import { VetchOptions } from '@vonage/vetch'; -export type VideoClassParameters = AuthOpts & +/** + * Parameters required to initialize the Video class. + */ +export type VideoClassParameters = AuthParams & VetchOptions & { - applicationId: string; - privateKey: string; - auth?: AuthInterface; - }; + /** + * The unique identifier for the application. + */ + applicationId: string; + + /** + * The private key used for authentication. + */ + privateKey: string; + + /** + * Optional authentication interface to use for custom authentication. + */ + auth?: AuthInterface; +}; diff --git a/packages/video/lib/types/ArchiveLayout.ts b/packages/video/lib/types/ArchiveLayout.ts new file mode 100644 index 00000000..094c864d --- /dev/null +++ b/packages/video/lib/types/ArchiveLayout.ts @@ -0,0 +1,23 @@ +import { LayoutType } from "../enums"; + +/** + * Represents the layout configuration for an archive. + */ +export type ArchiveLayout = { + /** + * The type of layout to be used for the archive. + */ + type: LayoutType; + + /** + * Optional: The stylesheet used for custom layout (only applicable if type is 'custom'). + */ + stylesheet?: string; + + /** + * Optional: The screenshare layout type to use when there is a screen-sharing + * stream in the archive (only applicable if type is 'bestFit' and + * screenshareType is set). + */ + screenshareType?: string; +} diff --git a/packages/video/lib/types/ArchiveMode.ts b/packages/video/lib/types/ArchiveMode.ts new file mode 100644 index 00000000..5d2ded90 --- /dev/null +++ b/packages/video/lib/types/ArchiveMode.ts @@ -0,0 +1,14 @@ +/** + * Enum representing different archive modes. + */ +export enum ArchiveMode { + /** + * Archive mode set to 'manual', where archives are started and stopped manually. + */ + MANUAL = 'manual', + + /** + * Archive mode set to 'always', where archives are continuously recorded. + */ + ALWAYS = 'always', +} diff --git a/packages/video/lib/types/ArchiveOptions.ts b/packages/video/lib/types/ArchiveOptions.ts new file mode 100644 index 00000000..f7f387dc --- /dev/null +++ b/packages/video/lib/types/ArchiveOptions.ts @@ -0,0 +1,42 @@ +import { ArchiveOutputMode, Resolution, StreamMode } from '../enums'; +import { ArchiveLayout } from './ArchiveLayout'; + +/** + * Interface representing options for creating an archive. + */ +export type ArchiveOptions = { + /** + * Flag indicating whether audio should be included in the archive. + */ + hasAudio?: boolean; + + /** + * Flag indicating whether video should be included in the archive. + */ + hasVideo?: boolean; + + /** + * Layout configuration for the archive. + */ + layout?: ArchiveLayout; + + /** + * Name of the archive. + */ + name?: string; + + /** + * Output mode for the archive. + */ + outputMode?: ArchiveOutputMode; + + /** + * Resolution for the archive. + */ + resolution?: Resolution; + + /** + * Stream mode for the archive. + */ + streamMode?: StreamMode; +} diff --git a/packages/video/lib/types/ArchiveSearchFilter.ts b/packages/video/lib/types/ArchiveSearchFilter.ts new file mode 100644 index 00000000..4d3e4248 --- /dev/null +++ b/packages/video/lib/types/ArchiveSearchFilter.ts @@ -0,0 +1,19 @@ +/** + * Interface representing filters for searching archives. + */ +export type ArchiveSearchFilter = { + /** + * The start offset in the list of existing archives. + */ + offset?: number; + + /** + * The number of archives to retrieve starting at the offset. Default is 50, with a maximum of 1000. + */ + count?: number; + + /** + * Retrieve archives for a specific session ID. + */ + sessionId?: string; +} diff --git a/packages/video/lib/types/BroadcastConfig.ts b/packages/video/lib/types/BroadcastConfig.ts new file mode 100644 index 00000000..592315b9 --- /dev/null +++ b/packages/video/lib/types/BroadcastConfig.ts @@ -0,0 +1,83 @@ +import { LayoutType, Resolution, StreamMode } from '../enums'; +import { RTMPStream } from './RTMPStream'; + +/** + * Interface representing configuration options for HLS streaming. + */ +export type HLSConfig = { + /** + * Whether to enable low-latency mode for the HLS stream. + */ + lowLatency?: boolean; + + /** + * Whether to enable DVR functionality (rewinding, pausing, and resuming) in players that support it. + */ + dvr?: boolean; +} + +/** + * Interface representing configuration options for different types of broadcast streams (HLS and RTMP). + */ +export type BroadcastOutputs = { + /** + * Configuration options for HLS streaming. + */ + hls?: HLSConfig; + + /** + * Configuration options for RTMP streaming. + */ + rtmp: RTMPStream[]; +} + +/** + * Interface representing configuration options for a live streaming broadcast. + */ +export type BroadcastConfig = { + /** + * The unique tag for simultaneous broadcasts (if one was set). + */ + multiBroadcastTag?: string; + + /** + * The maximum duration for the broadcast, in seconds. The broadcast will + * automatically stop when the maximum duration is reached. + */ + maxDuration?: number; + + /** + * The maximum bitrate for the stream. + */ + maxBitrate?: number; + + /** + * The layout type for the broadcast. + */ + layout?: LayoutType; + + /** + * Whether the broadcast has audio. + */ + hasAudio?: boolean; + + /** + * Whether the broadcast has video. + */ + hasVideo?: boolean; + + /** + * Configuration options for different types of broadcast streams (HLS and RTMP). + */ + outputs: BroadcastOutputs; + + /** + * The stream mode for the broadcast. + */ + streamMode?: StreamMode; + + /** + * The resolution of the broadcast. + */ + resolution?: Resolution; +} diff --git a/packages/video/lib/types/BroadcastSearchFilter.ts b/packages/video/lib/types/BroadcastSearchFilter.ts new file mode 100644 index 00000000..88717378 --- /dev/null +++ b/packages/video/lib/types/BroadcastSearchFilter.ts @@ -0,0 +1,19 @@ +/** + * Interface representing a filter for searching broadcasts. + */ +export type BroadcastSearchFilter = { + /** + * The offset for paginating the results. + */ + offset?: number; + + /** + * The maximum number of items to return. + */ + count?: number; + + /** + * The session ID to filter broadcasts by. + */ + sessionId?: string; +} diff --git a/packages/video/lib/types/BroadcastUpdateConfig.ts b/packages/video/lib/types/BroadcastUpdateConfig.ts new file mode 100644 index 00000000..3fe95d5d --- /dev/null +++ b/packages/video/lib/types/BroadcastUpdateConfig.ts @@ -0,0 +1,29 @@ +/** + * Interface representing the configuration for updating a broadcast. + */ +export type BroadcastUpdateConfig = { + /** + * The ID of the broadcast to update. + */ + broadcastId: string; + + /** + * Whether to include audio in the broadcast. + */ + hasAudio?: boolean; + + /** + * Whether to include video in the broadcast. + */ + hasVideo?: boolean; + + /** + * The ID of a stream to add to the broadcast. + */ + addStream?: string; + + /** + * The ID of a stream to remove from the broadcast. + */ + removeStream?: string; +} diff --git a/packages/video/lib/types/CaptionOptions.ts b/packages/video/lib/types/CaptionOptions.ts new file mode 100644 index 00000000..199ab93e --- /dev/null +++ b/packages/video/lib/types/CaptionOptions.ts @@ -0,0 +1,24 @@ +/** + * Interface representing options for captions. + */ +export type CaptionOptions = { + /** + * The language code for captions (e.g., "en-us"). + */ + languageCode?: "en-us"; + + /** + * The maximum duration for captions. + */ + maxDuration?: number; + + /** + * Whether to generate partial captions. + */ + partialCaptions?: "true" | "false"; + + /** + * The URL for the status callback of captions. + */ + statusCallbackUrl?: string; +} diff --git a/packages/video/lib/types/ClientTokenClaims.ts b/packages/video/lib/types/ClientTokenClaims.ts new file mode 100644 index 00000000..b135e245 --- /dev/null +++ b/packages/video/lib/types/ClientTokenClaims.ts @@ -0,0 +1,56 @@ +/** + * Interface representing claims for a client token. + */ +export type ClientTokenClaims = { + /** + * The scope of the token. + */ + scope: string; + + /** + * The session ID associated with the token. + */ + session_id: string; + + /** + * The role of the token. + */ + role: string; + + /** + * The initial layout class list. + */ + initial_layout_class_list: string; + + /** + * Additional data for the token (optional). + */ + data?: string; + + /** + * The expiration time of the token (optional). + */ + exp?: number; + + /** + * Connection data associated with the token (optional). + */ + connection_data?: string; + + /** + * The subject of the token. + */ + sub: string; + + /** + * Access control list (ACL) for paths. + */ + acl: { + /** + * Paths and associated objects in the ACL. + */ + paths: { + [key: string]: object; + }; + }; +} diff --git a/packages/video/lib/types/ClientTokenOptions.ts b/packages/video/lib/types/ClientTokenOptions.ts new file mode 100644 index 00000000..37701358 --- /dev/null +++ b/packages/video/lib/types/ClientTokenOptions.ts @@ -0,0 +1,24 @@ +/** + * Interface representing options for generating a client token. + */ +export type ClientTokenOptions = { + /** + * The role associated with the client token (optional). + */ + role?: string; + + /** + * Additional data for the client token (optional). + */ + data?: string; + + /** + * The expiration time of the client token in seconds (optional). + */ + expireTime?: number; + + /** + * An array of initial layout class list for the client token (optional). + */ + initialLayoutClassList?: string[]; +} diff --git a/packages/video/lib/types/ExperienceComposerListFilter.ts b/packages/video/lib/types/ExperienceComposerListFilter.ts new file mode 100644 index 00000000..4efa3023 --- /dev/null +++ b/packages/video/lib/types/ExperienceComposerListFilter.ts @@ -0,0 +1,14 @@ +/** + * Interface representing filters for listing Experience Composer items. + */ +export type ExperienceComposerListFilter = { + /** + * The offset for paginating through the list (optional). + */ + offset?: number; + + /** + * The maximum number of items to retrieve (optional). + */ + count?: number; +} diff --git a/packages/video/lib/types/ExperienceComposerOptions.ts b/packages/video/lib/types/ExperienceComposerOptions.ts new file mode 100644 index 00000000..dcfaa713 --- /dev/null +++ b/packages/video/lib/types/ExperienceComposerOptions.ts @@ -0,0 +1,36 @@ +import { ExperienceComposerResolution } from "../enums"; + +/** + * Interface representing options for creating an Experience Composer. + */ +export type ExperienceComposerOptions = { + /** + * The URL of the Experience Composer. + */ + url: string; + + /** + * Optional properties for the Experience Composer. + */ + properties?: { + /** + * The name of the Experience Composer. + */ + name?: string; + }; + + /** + * The maximum duration for the Experience Composer (optional). + */ + maxDuration?: number; + + /** + * The resolution of the Experience Composer (optional). + */ + resolution?: ExperienceComposerResolution; + + /** + * The callback URL for status updates (optional). + */ + statusCallbackUrl?: string; +} diff --git a/packages/video/lib/types/RTMPStream.ts b/packages/video/lib/types/RTMPStream.ts new file mode 100644 index 00000000..ddef6451 --- /dev/null +++ b/packages/video/lib/types/RTMPStream.ts @@ -0,0 +1,19 @@ +/** + * Interface representing an RTMP stream configuration. + */ +export type RTMPStream = { + /** + * Optional unique identifier for the RTMP stream. + */ + id?: string; + + /** + * The RTMP server URL to which the stream will be sent. + */ + serverUrl: string; + + /** + * The name of the stream on the RTMP server. + */ + streamName: string; +} diff --git a/packages/video/lib/types/Request/InitiateSIPCallRequest.ts b/packages/video/lib/types/Request/InitiateSIPCallRequest.ts new file mode 100644 index 00000000..4edfe48b --- /dev/null +++ b/packages/video/lib/types/Request/InitiateSIPCallRequest.ts @@ -0,0 +1,11 @@ +import { SIPCallOptions } from '../SIPCallOptions'; + +/** + * Represents the request to initiate a SIP call with additional session information. + */ +export type InitiateSIPCallRequest = SIPCallOptions & { + /** + * The session ID of the Vonage Video session to associate with the SIP call. + */ + sessionId: string; +}; diff --git a/packages/video/lib/types/Response/BroadcastDetailsResponse.ts b/packages/video/lib/types/Response/BroadcastDetailsResponse.ts new file mode 100644 index 00000000..ee9dac81 --- /dev/null +++ b/packages/video/lib/types/Response/BroadcastDetailsResponse.ts @@ -0,0 +1,102 @@ +import { StreamMode, Resolution } from '../../enums'; +import { RTMPStream } from '../RTMPStream'; + +/** + * Represents HLS settings for a live streaming broadcast. + */ +export type HlsSettings = { + /** + * Whether to enable low-latency mode for the HLS stream. + */ + lowLatency?: boolean; +}; + +/** + * Represents the response containing details about a live streaming broadcast. + */ +export type BroadcastDetailsResponse = { + /** + * The unique ID for the broadcast. + */ + id: string; + + /** + * The Vonage Video session ID associated with the broadcast. + */ + sessionId: string; + + /** + * The unique tag for simultaneous broadcasts (if one was set). + */ + multiBroadcasTag?: string; + + /** + * The Vonage Application UUID. + */ + applicationId: string; + + /** + * The time the broadcast started, expressed in milliseconds since the Unix epoch (January 1, 1970, 00:00:00 UTC). + */ + createdAt: number; + + /** + * The timestamp when the broadcast was last updated, expressed in milliseconds since the Unix epoch. + */ + updatedAt: number; + + /** + * The maximum duration for the broadcast (if one was set), in seconds. + */ + maxDuration?: number; + + /** + * The maximum bitrate for the stream. + */ + maxBitrate?: number; + + /** + * An object containing details about the HLS and RTMP broadcasts. + */ + broadcastUrls: { + /** + * The URL for the HLS broadcast. + */ + hls?: string; + + /** + * An array of RTMP streams. + */ + rtmp: RTMPStream[]; + }; + + /** + * An object containing settings for HLS. + */ + settings?: { + /** + * HLS settings. + */ + hls?: HlsSettings; + }; + + /** + * The resolution of the broadcast, if set. + */ + resolution?: Resolution; + + /** + * Indicates whether the broadcast has video. + */ + hasVideo: boolean; + + /** + * Indicates whether the broadcast has audio. + */ + hasAudio: boolean; + + /** + * The stream mode for the broadcast. + */ + streamMode: StreamMode; +}; diff --git a/packages/video/lib/types/Response/CaptionStatusResponse.ts b/packages/video/lib/types/Response/CaptionStatusResponse.ts new file mode 100644 index 00000000..2082f9c0 --- /dev/null +++ b/packages/video/lib/types/Response/CaptionStatusResponse.ts @@ -0,0 +1,57 @@ +import { CaptionStatus } from "../../enums"; + +/** + * Represents a response containing the status of captions for a live streaming broadcast. + */ +export type CaptionStatusResponse = { + /** + * The unique ID for the caption. + */ + captionId: string; + + /** + * The Vonage Application UUID. + */ + applicationId: string; + + /** + * The Vonage Video session ID associated with the broadcast. + */ + sessionId: string; + + /** + * The status of the captions. + */ + status: CaptionStatus; + + /** + * The time when the caption was created, expressed in milliseconds since the + * Unix epoch (January 1, 1970, 00:00:00 UTC). + */ + createdAt: number; + + /** + * The timestamp when the caption was last updated, expressed in milliseconds since the Unix epoch. + */ + updatedAt: number; + + /** + * The duration of the caption, in seconds. + */ + duration: number; + + /** + * The language code of the captions (e.g., "en-us" for English, US). + */ + languageCode: "en-us"; + + /** + * The caption provider (e.g., "aws-transcribe"). + */ + provider: "aws-transcribe"; + + /** + * An optional reason for the caption status. + */ + reason?: string; +}; diff --git a/packages/video/lib/types/Response/CreateSessionResponse.ts b/packages/video/lib/types/Response/CreateSessionResponse.ts new file mode 100644 index 00000000..3ce3ad1f --- /dev/null +++ b/packages/video/lib/types/Response/CreateSessionResponse.ts @@ -0,0 +1,24 @@ +/** + * Represents a response containing the details of a created session. + */ +export type CreateSessionResponse = { + /** + * The unique session ID. + */ + session_id: string; + + /** + * The project ID associated with the session. + */ + project_id: string; + + /** + * The creation date and time of the session in string format. + */ + create_dt: string; + + /** + * The URL of the media server associated with the session. + */ + media_server_url: string; +}; diff --git a/packages/video/lib/types/Response/EnableCaptionResponse.ts b/packages/video/lib/types/Response/EnableCaptionResponse.ts new file mode 100644 index 00000000..c65e115b --- /dev/null +++ b/packages/video/lib/types/Response/EnableCaptionResponse.ts @@ -0,0 +1,9 @@ +/** + * Represents a response indicating the ID of the enabled caption. + */ +export type EnableCaptionResponse = { + /** + * The unique ID of the enabled caption. + */ + captionsId: string; +} diff --git a/packages/video/lib/types/Response/ExperienceComposerResponse.ts b/packages/video/lib/types/Response/ExperienceComposerResponse.ts new file mode 100644 index 00000000..b4fb3eb5 --- /dev/null +++ b/packages/video/lib/types/Response/ExperienceComposerResponse.ts @@ -0,0 +1,56 @@ +import { ExperienceComposerResolution } from "../../enums"; + +/** + * Represents a response from the Experience Composer. + */ +export type ExperienceComposerResponse = { + /** + * The unique ID of the response. + */ + id: string; + + /** + * The session ID associated with the response. + */ + sessionId: string; + + /** + * The application ID associated with the response. + */ + applicationId: string; + + /** + * The timestamp when the response was created (milliseconds since the Unix epoch). + */ + createdAt: number; + + /** + * The timestamp when the response was last updated (milliseconds since the Unix epoch). + */ + updatedAt: number; + + /** + * The URL associated with the response. + */ + url: string; + + /** + * The resolution used by the Experience Composer. + */ + resolution: ExperienceComposerResolution; + + /** + * The status of the response, which can be one of: "starting", "started", "stopped", "failed". + */ + status: "starting" | "started" | "stopped" | "failed"; + + /** + * The stream ID associated with the response. + */ + streamId: string; + + /** + * An optional reason for the status, if available. + */ + reason?: string; +} diff --git a/packages/video/lib/types/Response/MultiArchiveResponse.ts b/packages/video/lib/types/Response/MultiArchiveResponse.ts new file mode 100644 index 00000000..be411866 --- /dev/null +++ b/packages/video/lib/types/Response/MultiArchiveResponse.ts @@ -0,0 +1,16 @@ +import { SingleArchiveResponse } from './SingleArchiveResponse'; + +/** + * Represents a response containing multiple archive items. + */ +export type MultiArchiveResponse = { + /** + * The count of archive items in the response. + */ + count: number; + + /** + * An array of SingleArchiveResponse objects representing individual archive items. + */ + items: SingleArchiveResponse[]; +} diff --git a/packages/video/lib/types/Response/MultiBroadcastResponse.ts b/packages/video/lib/types/Response/MultiBroadcastResponse.ts new file mode 100644 index 00000000..a02b7e3c --- /dev/null +++ b/packages/video/lib/types/Response/MultiBroadcastResponse.ts @@ -0,0 +1,16 @@ +import { BroadcastDetailsResponse } from './BroadcastDetailsResponse'; + +/** + * Represents a response containing multiple broadcast details items. + */ +export type MultiBroadcastResponse = { + /** + * The count of broadcast details items in the response. + */ + count: number; + + /** + * An array of BroadcastDetailsResponse objects representing individual broadcast details items. + */ + items: BroadcastDetailsResponse[]; +} diff --git a/packages/video/lib/types/Response/MultiExperienceComposerResponse.ts b/packages/video/lib/types/Response/MultiExperienceComposerResponse.ts new file mode 100644 index 00000000..2ec4f0a5 --- /dev/null +++ b/packages/video/lib/types/Response/MultiExperienceComposerResponse.ts @@ -0,0 +1,16 @@ +import { ExperienceComposerResponse } from './ExperienceComposerResponse'; + +/** + * Represents a response containing multiple ExperienceComposerResponse items. + */ +export type MultiExperienceComposerResponse = { + /** + * The count of ExperienceComposerResponse items in the response. + */ + count: number; + + /** + * An array of ExperienceComposerResponse objects representing individual items. + */ + items: ExperienceComposerResponse[]; +} diff --git a/packages/video/lib/types/Response/MultiStreamLayoutResponse.ts b/packages/video/lib/types/Response/MultiStreamLayoutResponse.ts new file mode 100644 index 00000000..995db4e9 --- /dev/null +++ b/packages/video/lib/types/Response/MultiStreamLayoutResponse.ts @@ -0,0 +1,16 @@ +import { SingleStreamLayoutResponse } from './SingleStreamLayoutResponse'; + +/** + * Represents a response containing multiple SingleStreamLayoutResponse items. + */ +export type MultiStreamLayoutResponse = { + /** + * The count of SingleStreamLayoutResponse items in the response. + */ + count: number; + + /** + * An array of SingleStreamLayoutResponse objects representing individual items. + */ + items: SingleStreamLayoutResponse[]; +} diff --git a/packages/video/lib/types/Response/ProjectDetailsResponse.ts b/packages/video/lib/types/Response/ProjectDetailsResponse.ts new file mode 100644 index 00000000..333b934c --- /dev/null +++ b/packages/video/lib/types/Response/ProjectDetailsResponse.ts @@ -0,0 +1,34 @@ +/** + * Represents the details of a project. + */ +export type ProjectDetailsResponse = { + /** + * The unique identifier of the project. + */ + id: string; + + /** + * The secret associated with the project. + */ + secret: string; + + /** + * The status of the project. + */ + status: string; + + /** + * The name of the project. + */ + name: string; + + /** + * The environment of the project. + */ + environment: string; + + /** + * The timestamp when the project was created, expressed in milliseconds since the Unix epoch. + */ + createdAt: number; +} diff --git a/packages/video/lib/types/Response/SIPCallResponse.ts b/packages/video/lib/types/Response/SIPCallResponse.ts new file mode 100644 index 00000000..cf5499f2 --- /dev/null +++ b/packages/video/lib/types/Response/SIPCallResponse.ts @@ -0,0 +1,19 @@ +/** + * Represents the response for a SIP call initiation. + */ +export type SIPCallResponse = { + /** + * The unique identifier of the SIP call. + */ + id: string; + + /** + * The connection identifier associated with the SIP call. + */ + connectionId: string; + + /** + * The stream identifier associated with the SIP call. + */ + streamId: string; +} diff --git a/packages/video/lib/types/Response/SingleArchiveResponse.ts b/packages/video/lib/types/Response/SingleArchiveResponse.ts new file mode 100644 index 00000000..108516b3 --- /dev/null +++ b/packages/video/lib/types/Response/SingleArchiveResponse.ts @@ -0,0 +1,84 @@ +/** + * Represents the details of a single archive. + */ +export type SingleArchiveResponse = { + /** + * The timestamp when the archive was created, expressed in milliseconds since the Unix epoch. + */ + createdAt: number; + + /** + * The duration of the archive in seconds. + */ + duration: number; + + /** + * Indicates whether the archive has audio. + */ + hasAudio: boolean; + + /** + * Indicates whether the archive has video. + */ + hasVideo: boolean; + + /** + * The unique identifier of the archive. + */ + id: string; + + /** + * The name of the archive. + */ + name: string; + + /** + * The output mode of the archive. + */ + outputMode: string; + + /** + * The unique identifier of the project to which the archive belongs. + */ + projectId: string; + + /** + * The reason for the archive status. + */ + reason: string; + + /** + * The resolution of the archive. + */ + resolution: string; + + /** + * The unique identifier of the session associated with the archive. + */ + sessionId: string; + + /** + * The size of the archive in bytes. + */ + size: number; + + /** + * The status of the archive. + */ + status: string; + + /** + * The stream mode of the archive. + */ + streamMode: string; + + /** + * The URL of the archive. + */ + url?: string; + + /** + * An array of stream identifiers associated with the archive. + */ + streams?: string[]; +} diff --git a/packages/video/lib/types/Response/SingleStreamLayoutResponse.ts b/packages/video/lib/types/Response/SingleStreamLayoutResponse.ts new file mode 100644 index 00000000..da7fd112 --- /dev/null +++ b/packages/video/lib/types/Response/SingleStreamLayoutResponse.ts @@ -0,0 +1,24 @@ +/** + * Represents the details of a single stream layout. + */ +export type SingleStreamLayoutResponse = { + /** + * The unique identifier of the stream layout. + */ + id: string; + + /** + * The type of video associated with the stream layout. + */ + videoType: string; + + /** + * The name of the stream layout. + */ + name: string; + + /** + * An array of CSS class names associated with the layout. + */ + layoutClassList: string[]; +} diff --git a/packages/video/lib/types/Response/WebSocketConnectResponse.ts b/packages/video/lib/types/Response/WebSocketConnectResponse.ts new file mode 100644 index 00000000..95a15799 --- /dev/null +++ b/packages/video/lib/types/Response/WebSocketConnectResponse.ts @@ -0,0 +1,14 @@ +/** + * Represents the response for a WebSocket connection. + */ +export type WebSocketConnectResponse = { + /** + * The unique identifier of the WebSocket connection. + */ + id: string; + + /** + * The connection identifier associated with the WebSocket connection. + */ + connectionId: string; +} diff --git a/packages/video/lib/interfaces/Response/index.ts b/packages/video/lib/types/Response/index.ts similarity index 100% rename from packages/video/lib/interfaces/Response/index.ts rename to packages/video/lib/types/Response/index.ts diff --git a/packages/video/lib/types/SIPCallOptions.ts b/packages/video/lib/types/SIPCallOptions.ts new file mode 100644 index 00000000..49fe2653 --- /dev/null +++ b/packages/video/lib/types/SIPCallOptions.ts @@ -0,0 +1,66 @@ +/** + * Configuration options for a SIP call. + */ +export type SIPCallSIPConfig = { + /** + * The SIP URI to initiate the call. + */ + uri: string; + + /** + * The optional "from" field for the SIP call. + */ + from?: string; + + /** + * Custom headers to be included in the SIP call. + */ + headers?: { + [key: string]: string; + }; + + /** + * Authentication credentials for the SIP call. + */ + auth?: { + /** + * The username for SIP authentication. + */ + username: string; + + /** + * The password for SIP authentication. + */ + password: string; + }; + + /** + * Indicates whether the SIP call should be secure. + */ + secure?: boolean; + + /** + * Indicates whether video is enabled for the SIP call. + */ + video?: boolean; + + /** + * Indicates whether to observe and force mute for the SIP call. + */ + observeForceMute?: boolean; +} + +/** + * Interface representing options for initiating a SIP call. + */ +export type SIPCallOptions = { + /** + * The authentication token for the SIP call. + */ + token: string; + + /** + * Configuration options for the SIP call. + */ + sip: SIPCallSIPConfig; +} diff --git a/packages/video/lib/types/Session.ts b/packages/video/lib/types/Session.ts new file mode 100644 index 00000000..3c551af0 --- /dev/null +++ b/packages/video/lib/types/Session.ts @@ -0,0 +1,24 @@ +/** + * Interface representing a session configuration. + */ +export type Session = { + /** + * The unique identifier for the session. + */ + sessionId: string; + + /** + * The location of the session. + */ + location: string; + + /** + * The media mode for the session (e.g., "ROUTED" or "RELAYED"). + */ + mediaMode: string; + + /** + * The archive mode for the session (e.g., "MANUAL" or "ALWAYS"). + */ + archiveMode: string; +} diff --git a/packages/video/lib/types/Singal.ts b/packages/video/lib/types/Singal.ts new file mode 100644 index 00000000..09fc1c1d --- /dev/null +++ b/packages/video/lib/types/Singal.ts @@ -0,0 +1,14 @@ +/** + * Represents a signal containing type and data properties. + */ +export type Signal = { + /** + * The type of the signal, which can be a custom string identifying the signal type. + */ + type: string; + + /** + * The data associated with the signal, which can be any string data related to the signal. + */ + data: string; +} diff --git a/packages/video/lib/types/StreamClassList.ts b/packages/video/lib/types/StreamClassList.ts new file mode 100644 index 00000000..6d414db2 --- /dev/null +++ b/packages/video/lib/types/StreamClassList.ts @@ -0,0 +1,14 @@ +/** + * Represents a stream with associated layout class list. + */ +export type StreamClassList = { + /** + * The ID of the stream. + */ + id: string; + + /** + * An array of layout class names associated with the stream. + */ + layoutClassList: string[]; +} diff --git a/packages/video/lib/types/VideoResponse.ts b/packages/video/lib/types/VideoResponse.ts new file mode 100644 index 00000000..b3ffdb57 --- /dev/null +++ b/packages/video/lib/types/VideoResponse.ts @@ -0,0 +1,6 @@ +import { VetchResponse } from '@vonage/vetch'; + +/** + * Represents a video response that wraps a Vetch response. + */ +export type VideoResponse = VetchResponse; diff --git a/packages/video/lib/types/WebSocketConfig.ts b/packages/video/lib/types/WebSocketConfig.ts new file mode 100644 index 00000000..d3b78224 --- /dev/null +++ b/packages/video/lib/types/WebSocketConfig.ts @@ -0,0 +1,28 @@ +import { AudioRate } from '../enums'; + +/** + * Configuration options for establishing a WebSocket connection. + */ +export type WebSocketConfig = { + /** + * The URI to connect to the WebSocket server. + */ + uri: string; + + /** + * An array of stream IDs to associate with the WebSocket connection. + */ + streams?: string[]; + + /** + * Optional headers to include in the WebSocket request. + */ + headers?: { + [key: string]: string; + }; + + /** + * The audio rate to be used for the WebSocket connection. + */ + audioRate?: AudioRate; +} diff --git a/packages/video/lib/interfaces/index.ts b/packages/video/lib/types/index.ts similarity index 89% rename from packages/video/lib/interfaces/index.ts rename to packages/video/lib/types/index.ts index 9c2e0889..2a4563c4 100644 --- a/packages/video/lib/interfaces/index.ts +++ b/packages/video/lib/types/index.ts @@ -10,10 +10,11 @@ export * from './ClientTokenClaims'; export * from './ClientTokenOptions'; export * from './ExperienceComposerListFilter'; export * from './ExperienceComposerOptions'; -export * from './MediaMode'; export * from './Response'; +export * from './Request/InitiateSIPCallRequest'; export * from './RTMPStream'; export * from './Session'; +export * from './Singal'; export * from './SIPCallOptions'; export * from './StreamClassList'; export * from './VideoResponse'; diff --git a/packages/video/lib/video.ts b/packages/video/lib/video.ts index 5ea65dae..d99c6eb0 100644 --- a/packages/video/lib/video.ts +++ b/packages/video/lib/video.ts @@ -1,41 +1,54 @@ import { tokenGenerate } from '@vonage/jwt'; -import { VideoResponse } from './interfaces/VideoResponse'; -import { MultiStreamLayoutResponse } from './interfaces/Response/MultiStreamLayoutResponse'; -import { SingleStreamLayoutResponse } from './interfaces/Response/SingleStreamLayoutResponse'; -import { ProjectDetailsResponse } from './interfaces/Response/ProjectDetailsResponse'; -import { ArchiveOptions } from './interfaces/ArchiveOptions'; -import { SingleArchiveResponse } from './interfaces/Response/SingleArchiveResponse'; -import { MultiArchiveResponse } from './interfaces/Response/MultiArchiveResponse'; -import { ArchiveSearchFilter } from './interfaces/ArchiveSearchFilter'; -import { ArchiveLayout } from './interfaces/ArchiveLayout'; -import { MediaMode } from './interfaces/MediaMode'; -import { ArchiveMode } from './interfaces/ArchiveMode'; -import { Session } from './interfaces/Session'; -import { StreamClassList } from './interfaces/StreamClassList'; -import { ClientTokenOptions } from './interfaces/ClientTokenOptions'; import { AuthenticationType, Client } from '@vonage/server-client'; -import { BroadcastConfig } from './interfaces/BroadcastConfig'; -import { BroadcastDetailsResponse } from './interfaces/Response/BroadcastDetailsResponse'; -import { BroadcastSearchFilter } from './interfaces/BroadcastSearchFilter'; -import { MultiBroadcastResponse } from './interfaces/Response/MultiBroadcastResponse'; -import { BroadcastUpdateConfig } from './interfaces/BroadcastUpdateConfig'; -import { SIPCallOptions } from './interfaces/SIPCallOptions'; -import { SIPCallResponse } from './interfaces/Response/SIPCallResponse'; -import { WebSocketConfig } from './interfaces/WebSocketConfig'; -import { WebSocketConnectResponse } from './interfaces/Response/WebSocketConnectResponse'; -import { MultiExperienceComposerResponse } from './interfaces/Response/MultiExperienceComposerResponse'; -import { ExperienceComposerResponse } from './interfaces/Response/ExperienceComposerResponse'; -import { ExperienceComposerOptions } from './interfaces/ExperienceComposerOptions'; -import { ExperienceComposerListFilter } from './interfaces/ExperienceComposerListFilter'; -import { ClientTokenClaims } from './interfaces/ClientTokenClaims'; -import { CaptionOptions } from './interfaces/CaptionOptions'; -import { EnableCaptionResponse } from './interfaces/Response/EnableCaptionResponse'; -import { CaptionStatusResponse } from './interfaces/Response/CaptionStatusResponse'; -import { InitiateSIPCallRequest } from './interfaces/Request/InitiateSIPCallRequest'; +import { MediaMode } from './enums'; +import { + ArchiveLayout , + ArchiveMode , + ArchiveOptions , + ArchiveSearchFilter , + BroadcastConfig , + BroadcastDetailsResponse , + BroadcastSearchFilter , + BroadcastUpdateConfig , + CaptionOptions , + CaptionStatusResponse , + ClientTokenClaims , + ClientTokenOptions , + EnableCaptionResponse , + ExperienceComposerListFilter , + ExperienceComposerOptions , + ExperienceComposerResponse , + InitiateSIPCallRequest, + MultiArchiveResponse , + MultiBroadcastResponse , + MultiExperienceComposerResponse , + MultiStreamLayoutResponse , + ProjectDetailsResponse , + SIPCallOptions , + SIPCallResponse , + Session , + Signal, + SingleArchiveResponse , + SingleStreamLayoutResponse , + StreamClassList , + VideoResponse, + WebSocketConfig , + WebSocketConnectResponse , +} from './types'; export class Video extends Client { - protected authType = AuthenticationType.JWT; - + public authType = AuthenticationType.JWT; + + /** + * Adds a stream to an existing archive, allowing you to include additional streams in the archive recording. + * + * @param {string} archiveId - The ID of the archive to which you want to add a stream. + * @param {string} streamId - The ID of the stream you want to add to the archive. + * @param {boolean} [audio=true] - Whether to include audio from the added stream (default: true). + * @param {boolean} [video=true] - Whether to include video from the added stream (default: true). + * @return {Promise} A promise that resolves when the stream has been successfully added to the archive. + * @throws {Error} If an error occurs while adding the stream to the archive. + */ public async addArchiveStream( archiveId: string, streamId: string, @@ -54,6 +67,14 @@ export class Video extends Client { ); } + /** + * Adds a stream to an existing broadcast, allowing you to include additional streams in the live broadcast. + * + * @param {string} broadcastId - The ID of the broadcast to which you want to add a stream. + * @param {string} streamId - The ID of the stream you want to add to the broadcast. + * @return {Promise} A promise that resolves when the stream has been successfully added to the broadcast. + * @throws {Error} If an error occurs while adding the stream to the broadcast. + */ public async addStreamToBroadcast( broadcastId: string, streamId: string, @@ -61,6 +82,15 @@ export class Video extends Client { await this.updateBroadcast({ broadcastId, addStream: streamId }); } + /** + * Connects to a WebSocket for a specified session using the provided client token and WebSocket configuration. + * + * @param {string} sessionId - The ID of the session to which you want to connect via WebSocket. + * @param {string} clientToken - The client token generated for authentication. + * @param {WebSocketConfig} config - The WebSocket configuration specifying the URI and optional parameters. + * @return {Promise} A promise that resolves with WebSocket connection details upon successful connection. + * @throws {Error} If an error occurs during the WebSocket connection process. + */ public async connectToWebsocket( sessionId: string, clientToken: string, @@ -79,6 +109,16 @@ export class Video extends Client { return resp.data; } + /** + * Creates a new session with the specified options. + * + * @param {Object} [sessionOptions] - Optional session configuration options. + * @param {ArchiveMode} [sessionOptions.archiveMode=ArchiveMode.MANUAL] - The archive mode for the session. + * @param {MediaMode} [sessionOptions.mediaMode=MediaMode.ROUTED] - The media mode for the session. + * @param {string} [sessionOptions.location] - The location for the session. + * @return {Promise} A promise that resolves with details of the newly created session. + * @throws {Error} If an error occurs during the session creation process. + */ public async createSession(sessionOptions?: { archiveMode?: ArchiveMode location?: string @@ -88,7 +128,7 @@ export class Video extends Client { archiveMode: sessionOptions?.archiveMode ?? ArchiveMode.MANUAL, 'p2p.preference': sessionOptions?.mediaMode ?? MediaMode.ROUTED, location: sessionOptions?.location ?? null, - }; + } as Record; const resp = await this.sendFormSubmitRequest( `${this.config.videoHost}/session/create`, @@ -103,18 +143,40 @@ export class Video extends Client { }; } + /** + * Deletes an archive with the specified archive ID. + * + * @param {string} archiveId - The ID of the archive to delete. + * @return {Promise} A promise that resolves when the archive is successfully deleted. + * @throws {Error} If an error occurs while deleting the archive or if the archive with the given ID does not exist. + */ public async deleteArchive(archiveId: string): Promise { await this.sendDeleteRequest( `${this.config.videoHost}/v2/project/${this.auth.applicationId}/archive/${archiveId}`, ); } + /** + * Disables captions for a specific caption ID. + * + * @param {string} captionId - The ID of the caption to disable. + * @return {Promise} A promise that resolves when the captions are successfully disabled. + * @throws {Error} If an error occurs while disabling captions or if the caption with the given ID does not exist. + */ public async disableCaptions(captionId: string): Promise { await this.sendPostRequest( `${this.config.videoHost}/v2/project/${this.auth.applicationId}/captions/${captionId}/stop`, ); } + /** + * Disables force mute for a session, allowing audio for all streams. + * + * @param {string} sessionId - The ID of the session for which to disable force mute. + * @param {string[]} excludedStreamIds - An optional array of stream IDs to exclude from the force mute operation. + * @return {Promise} A promise that resolves when the force mute is successfully disabled for the session. + * @throws {Error} If an error occurs while disabling force mute or if the session with the given ID does not exist. + */ public async disableForceMute( sessionId: string, excludedStreamIds: string[] = [], @@ -122,6 +184,14 @@ export class Video extends Client { return this.muteAllStreams(sessionId, false, excludedStreamIds); } + /** + * Disconnects a client from a session. + * + * @param {string} sessionId - The ID of the session from which to disconnect the client. + * @param {string} connectionId - The ID of the client's connection to disconnect. + * @return {Promise} A promise that resolves when the client is successfully disconnected from the session. + * @throws {Error} If an error occurs while disconnecting the client or if the session or connection with the given IDs do not exist. + */ public async disconnectClient( sessionId: string, connectionId: string, @@ -131,12 +201,28 @@ export class Video extends Client { ); } + /** + * Disconnects a WebSocket connection associated with a call or session. + * + * @param {string} callId - The ID of the call or session to which the WebSocket connection is associated. + * @return {Promise} A promise that resolves when the WebSocket connection is successfully disconnected. + * @throws {Error} If an error occurs while disconnecting the WebSocket connection or if the call or session with the given ID does not exist. + */ public async disconnectWebsocket(callId: string): Promise { await this.sendPostRequest( `${this.config.videoHost}/v2/project/${this.auth.applicationId}/connect/${callId}/stop`, ); } + /** + * Enables captions for a session using the specified client token and caption options. + * + * @param {string} sessionId - The ID of the session to enable captions for. + * @param {string} clientToken - The client token associated with the session, used for authentication. + * @param {CaptionOptions} [captionOptions] - Optional caption options to configure caption behavior. + * @return {Promise} A promise that resolves with an `EnableCaptionResponse` containing information about the enabled captions. + * @throws {Error} If an error occurs while enabling captions or if the session with the given ID does not exist. + */ public async enableCaptions( sessionId: string, clientToken: string, @@ -154,6 +240,14 @@ export class Video extends Client { return resp.data; } + /** + * Forces muting of all streams in a session, except those specified in the `excludedStreamIds` array. + * + * @param {string} sessionId - The ID of the session in which to force mute streams. + * @param {string[]} [excludedStreamIds] - An optional array of stream IDs to exclude from muting. + * @return {Promise} A promise that resolves with a `ProjectDetailsResponse` containing updated session details after muting. + * @throws {Error} If an error occurs while muting the streams or if the session with the given ID does not exist. + */ public async forceMuteAll( sessionId: string, excludedStreamIds: string[] = [], @@ -161,6 +255,13 @@ export class Video extends Client { return this.muteAllStreams(sessionId, true, excludedStreamIds); } + /** + * Generates a client token for connecting to a session with the specified options. + * + * @param {string} sessionId - The ID of the session to generate the client token for. + * @param {ClientTokenOptions} [tokenOptions] - Optional token options including role, data, and expiration time. + * @return {string} A client token that can be used for authentication when connecting to a session. + */ public generateClientToken( sessionId: string, tokenOptions?: ClientTokenOptions, @@ -194,12 +295,18 @@ export class Video extends Client { } return tokenGenerate( - this.auth.applicationId, - this.auth.privateKey, + this.auth.applicationId as string, + this.auth.privateKey as string | Buffer, claims, ); } + /** + * Retrieves information about a specific archive by its ID. + * + * @param {string} archiveId - The ID of the archive to retrieve. + * @return {Promise} A promise that resolves to the details of the requested archive. + */ public async getArchive(archiveId: string): Promise { const resp = await this.sendGetRequest( `${this.config.videoHost}/v2/project/${this.auth.applicationId}/archive/${archiveId}`, @@ -207,6 +314,12 @@ export class Video extends Client { return resp.data; } + /** + * Retrieves information about a specific broadcast by its ID. + * + * @param {string} broadcastId - The ID of the broadcast to retrieve. + * @return {Promise} A promise that resolves to the details of the requested broadcast. + */ public async getBroadcast( broadcastId: string, ): Promise { @@ -216,6 +329,12 @@ export class Video extends Client { return resp.data; } + /** + * Retrieves the status of a caption by its ID. + * + * @param {string} captionId - The ID of the caption to retrieve the status for. + * @return {Promise} A promise that resolves to the status of the requested caption. + */ public async getCaptionStatus( captionId: string, ): Promise { @@ -225,6 +344,12 @@ export class Video extends Client { return resp.data; } + /** + * Retrieves the details of an Experience Composer render by its ID. + * + * @param {string} renderId - The ID of the Experience Composer render to retrieve. + * @return {Promise} A promise that resolves to the details of the requested Experience Composer render. + */ public async getExperienceComposerRender( renderId: string, ): Promise { @@ -234,6 +359,13 @@ export class Video extends Client { return resp.data; } + /** + * Retrieves information about one or more streams in a session. + * + * @param {string} sessionId - The ID of the session to retrieve stream information from. + * @param {string | undefined} [streamId] - Optional. The ID of a specific stream to retrieve information for. + * @return {Promise} A promise that resolves to stream information. If a specific `streamId` is provided, it resolves to a single stream's information (SingleStreamLayoutResponse), otherwise, it resolves to multiple streams' information (MultiStreamLayoutResponse). + */ public async getStreamInfo( sessionId: string, streamId?: string, @@ -255,6 +387,7 @@ export class Video extends Client { return resp.data; } + private stripBlankValues(obj: T): T { for (const key in obj) { if (typeof obj[key] === 'object' && obj[key] !== null) { @@ -266,6 +399,13 @@ export class Video extends Client { return obj; } + /** + * Initiates a SIP call within a session. + * + * @param {string} sessionId - The ID of the session in which to initiate the SIP call. + * @param {SIPCallOptions} options - The options for initiating the SIP call. + * @return {Promise} A promise that resolves to the SIP call response, including the call ID and other details. + */ public async intiateSIPCall( sessionId: string, options: SIPCallOptions, @@ -285,6 +425,12 @@ export class Video extends Client { return resp.data; } + /** + * Lists Experience Composer renders based on the specified filter criteria. + * + * @param {ExperienceComposerListFilter} filter - An optional filter to apply when listing Experience Composer renders. + * @return {Promise} A promise that resolves to a list of Experience Composer renders matching the filter criteria. + */ public async listExperienceComposerRenders( filter: ExperienceComposerListFilter, ): Promise { @@ -295,6 +441,14 @@ export class Video extends Client { return resp.data; } + /** + * Mutes or unmutes all streams in a session, optionally excluding specific stream IDs from muting. + * + * @param {string} sessionId - The ID of the session in which to mute or unmute streams. + * @param {boolean} active - `true` to mute all streams, `false` to unmute all streams. + * @param {string[]} excludedStreamIds - An optional array of stream IDs to exclude from muting/unmuting. + * @return {Promise} A promise that resolves to the updated session details. + */ protected async muteAllStreams( sessionId: string, active: boolean, @@ -310,6 +464,13 @@ export class Video extends Client { return resp.data; } + /** + * Mutes or unmutes a specific stream in a session. + * + * @param {string} sessionId - The ID of the session containing the stream. + * @param {string} streamId - The ID of the stream to mute or unmute. + * @return {Promise} A promise that resolves to the updated session details. + */ public async muteStream( sessionId: string, streamId: string, @@ -320,6 +481,14 @@ export class Video extends Client { return resp.data; } + /** + * Sends DTMF (Dual-Tone Multi-Frequency) tones to a specific session or connection. + * + * @param {string} sessionId - The ID of the session to send DTMF tones to. + * @param {string} digits - The DTMF tones to play. + * @param {string} [connectionId] - Optional. The ID of the connection within the session to send DTMF tones to. + * @return {Promise} A promise that resolves when the DTMF tones have been played. + */ public async playDTMF( sessionId: string, digits: string, @@ -333,6 +502,13 @@ export class Video extends Client { await this.sendPostRequest(url, { digits }); } + /** + * Removes a stream from an archive. + * + * @param {string} archiveId - The ID of the archive from which to remove the stream. + * @param {string} streamId - The ID of the stream to remove from the archive. + * @return {Promise} A promise that resolves when the stream has been successfully removed from the archive. + */ public async removeArchiveStream( archiveId: string, streamId: string, @@ -343,6 +519,13 @@ export class Video extends Client { ); } + /** + * Removes a stream from a broadcast. + * + * @param {string} broadcastId - The ID of the broadcast from which to remove the stream. + * @param {string} streamId - The ID of the stream to remove from the broadcast. + * @return {Promise} A promise that resolves when the stream has been successfully removed from the broadcast. + */ public async removeStreamFromBroadcast( broadcastId: string, streamId: string, @@ -350,6 +533,12 @@ export class Video extends Client { await this.updateBroadcast({ broadcastId, removeStream: streamId }); } + /** + * Searches for archives based on the specified filter criteria. + * + * @param {ArchiveSearchFilter} [filter] - Optional filter criteria to narrow down the search. + * @return {Promise} A promise that resolves with the search results, including multiple archive items. + */ public async searchArchives( filter?: ArchiveSearchFilter, ): Promise { @@ -360,6 +549,12 @@ export class Video extends Client { return resp.data; } + /** + * Searches for broadcasts based on the specified filter criteria. + * + * @param {BroadcastSearchFilter} [filter] - Optional filter criteria to narrow down the search. + * @return {Promise} A promise that resolves with the search results, including multiple broadcast items. + */ public async searchBroadcasts( filter?: BroadcastSearchFilter, ): Promise { @@ -370,8 +565,16 @@ export class Video extends Client { return resp.data; } + /** + * Sends a signal to a session or a specific connection within a session. + * + * @param {Signal} signal - The signal to send, including a type and data. + * @param {string} sessionId - The ID of the session to which the signal will be sent. + * @param {string} [connectionId] - Optional. The ID of the connection within the session to which the signal will be sent. If not provided, the signal will be sent to the entire session. + * @return {Promise} A promise that resolves when the signal is successfully sent. + */ public async sendSignal( - signal: { type: string; data: string }, + signal: Signal, sessionId: string, connectionId?: string, ): Promise { @@ -383,6 +586,13 @@ export class Video extends Client { await this.sendPostRequest(url, signal); } + /** + * Sets the stream class lists for one or more streams within a session. + * + * @param {string} sessionId - The ID of the session for which stream class lists will be set. + * @param {StreamClassList[]} settings - An array of objects specifying the stream ID and corresponding class lists to be set. + * @return {Promise} A promise that resolves when the stream class lists are successfully set. + */ public async setStreamClassLists( sessionId: string, settings: StreamClassList[], @@ -393,6 +603,13 @@ export class Video extends Client { ); } + /** + * Starts an archive for a given session with optional configuration. + * + * @param {string} sessionId - The ID of the session to archive. + * @param {ArchiveOptions} [options] - Optional configuration for the archive, such as audio/video settings, layout, and more. + * @return {Promise} A promise that resolves with information about the started archive. + */ public async startArchive( sessionId: string, options?: ArchiveOptions, @@ -406,6 +623,13 @@ export class Video extends Client { return resp.data; } + /** + * Starts a broadcast for a given session with the specified configuration. + * + * @param {string} sessionId - The ID of the session to start broadcasting. + * @param {BroadcastConfig} config - Configuration for the broadcast, including stream settings, layout, and more. + * @return {Promise} A promise that resolves with information about the started broadcast. + */ public async startBroadcast( sessionId: string, config: BroadcastConfig, @@ -418,6 +642,14 @@ export class Video extends Client { return resp.data; } + /** + * Starts rendering an experience composer with the provided configuration. + * + * @param {string} sessionId - The ID of the session associated with the experience composer. + * @param {string} token - The client token for authentication. + * @param {ExperienceComposerOptions} config - Configuration options for the experience composer rendering. + * @return {Promise} A promise that resolves with information about the started experience composer rendering. + */ public async startExperienceComposerRender( sessionId: string, token: string, @@ -431,6 +663,12 @@ export class Video extends Client { return resp.data; } + /** + * Stops an archive with the given archive ID. + * + * @param {string} archiveId - The ID of the archive to stop. + * @return {Promise} A promise that resolves with information about the stopped archive. + */ public async stopArchive( archiveId: string, ): Promise { @@ -440,6 +678,12 @@ export class Video extends Client { return resp.data; } + /** + * Stops a broadcast with the given broadcast ID. + * + * @param {string} broadcastId - The ID of the broadcast to stop. + * @return {Promise} A promise that resolves with information about the stopped broadcast. + */ public async stopBroadcast( broadcastId: string, ): Promise { @@ -449,12 +693,25 @@ export class Video extends Client { return resp.data; } + /** + * Stops an Experience Composer render with the given render ID. + * + * @param {string} renderId - The ID of the Experience Composer render to stop. + * @return {Promise} A promise that resolves when the render is successfully stopped. + */ public async stopExperienceComposerRender(renderId: string): Promise { await this.sendDeleteRequest( `${this.config.videoHost}/v2/project/${this.auth.applicationId}/render/${renderId}`, ); } + /** + * Updates the layout of an archive with the given archive ID. + * + * @param {string} archiveId - The ID of the archive to update the layout for. + * @param {ArchiveLayout} layout - The new layout configuration to set for the archive. + * @return {Promise} A promise that resolves when the layout is successfully updated. + */ public async updateArchiveLayout(archiveId: string, layout: ArchiveLayout) { const resp = await this.sendPutRequest( `${this.config.videoHost}/v2/project/${this.auth.applicationId}/archive/${archiveId}/layout`, @@ -463,6 +720,12 @@ export class Video extends Client { return resp.data; } + /** + * Updates the configuration of a broadcast with the given broadcast ID. + * + * @param {BroadcastUpdateConfig} config - The configuration options to update the broadcast. + * @return {Promise} A promise that resolves when the broadcast is successfully updated. + */ public async updateBroadcast(config: BroadcastUpdateConfig): Promise { await this.sendPatchRequest( `${this.config.videoHost}/v2/project/${this.auth.applicationId}/broadcast/${config.broadcastId}/streams`, diff --git a/packages/video/package.json b/packages/video/package.json index 22aac306..ec09f688 100644 --- a/packages/video/package.json +++ b/packages/video/package.json @@ -1,4 +1,5 @@ { + "$schema": "https://json.schemastore.org/package.json", "name": "@vonage/video", "version": "1.12.0", "description": "Package to interact with the Vonage Video API (Not OpenTok Compatible)", @@ -15,7 +16,16 @@ "url": "git+https://github.com/Vonage/vonage-node-sdk.git" }, "license": "Apache-2.0", - "author": "Chris Tankersley ", + "contributors": [ + { + "name": "Chris Tankersley", + "email": "chris@ctankersley.com" + }, + { + "name": "Chuck MANCHUCK Reeves", + "email": "chuck@manchuck.com" + } + ], "main": "dist/index.js", "types": "dist/index.d.ts", "directories": { @@ -28,7 +38,8 @@ "scripts": { "build": "npm run clean && npm run compile", "clean": "npx shx rm -rf dist tsconfig.tsbuildinfo", - "compile": "npx tsc --build --verbose" + "compile": "npx tsc --build --verbose", + "prepublishOnly": "npm run build" }, "dependencies": { "@vonage/auth": "^1.7.0", @@ -42,6 +53,5 @@ }, "publishConfig": { "directory": "dist" - }, - "gitHead": "328f18e5c8a458cb4d06d7955ec2399a6ce6f5d8" + } } diff --git a/packages/video/tsconfig.json b/packages/video/tsconfig.json index 8a781439..eede6e8e 100644 --- a/packages/video/tsconfig.json +++ b/packages/video/tsconfig.json @@ -1,25 +1,27 @@ { - "extends": "../../tsconfig.json", + "$schema": "https://json.schemastore.org/tsconfig", - "compilerOptions": { - "rootDir": "lib", - "outDir": "dist" - }, + "extends": "../../tsconfig.json", - "exclude": [ - "__tests__", - "jest.config.js", - "dist" - ], + "compilerOptions": { + "rootDir": "lib", + "outDir": "dist" + }, - "references": [ - { "path": "../auth" }, - { "path": "../jwt" }, - { "path": "../server-client" }, - { "path": "../vetch" } - ], + "exclude": [ + "__tests__", + "jest.config.js", + "dist" + ], - "ts-node": { - "esm": true - } + "references": [ + { "path": "../auth" }, + { "path": "../jwt" }, + { "path": "../server-client" }, + { "path": "../vetch" } + ], + + "ts-node": { + "esm": true + } } diff --git a/packages/video/typedoc.json b/packages/video/typedoc.json new file mode 100644 index 00000000..0dfd9e71 --- /dev/null +++ b/packages/video/typedoc.json @@ -0,0 +1,6 @@ +{ + "$schema": "https://typedoc.org/schema.json", + "extends": ["../../typedoc.base.json"], + "entryPoints": ["lib/index.ts"], + "name": "Vonage Video" +}