@nomad-media/full 1.1.19-alpha.3 → 1.1.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/nomad-media-sdk-debug.js +1424 -1290
- package/dist/nomad-media-sdk.min.js +2 -2
- package/package.json +3 -3
|
@@ -133,6 +133,9 @@
|
|
|
133
133
|
|
|
134
134
|
|
|
135
135
|
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
|
|
136
139
|
|
|
137
140
|
|
|
138
141
|
|
|
@@ -273,8 +276,6 @@
|
|
|
273
276
|
|
|
274
277
|
|
|
275
278
|
|
|
276
|
-
import path from 'path';
|
|
277
|
-
|
|
278
279
|
/**
|
|
279
280
|
* @class NomadSDK
|
|
280
281
|
* @classdesc This class is used to interact with the Nomad API.
|
|
@@ -578,7 +579,7 @@ class NomadMediaSDK {
|
|
|
578
579
|
let startUploadInfo = null;
|
|
579
580
|
try
|
|
580
581
|
{
|
|
581
|
-
const
|
|
582
|
+
const FILE_PROPS = await _processFile(FILE);
|
|
582
583
|
|
|
583
584
|
startUploadInfo = await _startRelatedAssetUpload(this, EXISTING_ASSET_ID,
|
|
584
585
|
RELATED_ASSET_ID, NEW_RELATED_ASSET_METADATA_TYPE, UPLOAD_OVERWRITE_OPTION,
|
|
@@ -593,7 +594,7 @@ class NomadMediaSDK {
|
|
|
593
594
|
|
|
594
595
|
const DETAILS = await _getAssetDetails(this, EXISTING_ASSET_ID);
|
|
595
596
|
|
|
596
|
-
const ASSET_INFO = DETAILS.relatedAssets.find(asset => asset.url.includes(
|
|
597
|
+
const ASSET_INFO = DETAILS.relatedAssets.find(asset => asset.url.includes(FILE_PROPS.originalName));
|
|
597
598
|
if (!ASSET_INFO) throw new Error("Asset ID not found");
|
|
598
599
|
return ASSET_INFO.id;
|
|
599
600
|
}
|
|
@@ -1762,6 +1763,11 @@ class NomadMediaSDK {
|
|
|
1762
1763
|
await this._init();
|
|
1763
1764
|
}
|
|
1764
1765
|
|
|
1766
|
+
if (this.config.apiType !== "admin")
|
|
1767
|
+
{
|
|
1768
|
+
throw new Error ("This function is only available for admin API type.");
|
|
1769
|
+
}
|
|
1770
|
+
|
|
1765
1771
|
_printDatetime(`Getting Live Schedule of Event: ${EVENT_ID}`);
|
|
1766
1772
|
|
|
1767
1773
|
try
|
|
@@ -1793,6 +1799,11 @@ class NomadMediaSDK {
|
|
|
1793
1799
|
await this._init();
|
|
1794
1800
|
}
|
|
1795
1801
|
|
|
1802
|
+
if (this.config.apiType !== "admin")
|
|
1803
|
+
{
|
|
1804
|
+
throw new Error ("This function is only available for admin API type.");
|
|
1805
|
+
}
|
|
1806
|
+
|
|
1796
1807
|
_printDatetime(`Starting Live Schedule of Event: ${EVENT_ID}`);
|
|
1797
1808
|
|
|
1798
1809
|
try
|
|
@@ -1822,6 +1833,11 @@ class NomadMediaSDK {
|
|
|
1822
1833
|
{
|
|
1823
1834
|
await this._init();
|
|
1824
1835
|
}
|
|
1836
|
+
|
|
1837
|
+
if (this.config.apiType !== "admin")
|
|
1838
|
+
{
|
|
1839
|
+
throw new Error ("This function is only available for admin API type.");
|
|
1840
|
+
}
|
|
1825
1841
|
|
|
1826
1842
|
_printDatetime(`Stopping Live Schedule of Event: ${EVENT_ID}`);
|
|
1827
1843
|
|
|
@@ -1837,6 +1853,87 @@ class NomadMediaSDK {
|
|
|
1837
1853
|
}
|
|
1838
1854
|
}
|
|
1839
1855
|
|
|
1856
|
+
// job functions
|
|
1857
|
+
/**
|
|
1858
|
+
* @function createJob
|
|
1859
|
+
* @async
|
|
1860
|
+
* @description Creates a job.
|
|
1861
|
+
* @param {string} BUCKET_NAME - The name of the bucket to create the job in.
|
|
1862
|
+
* @param {string} OBJECT_KEY - The object key of the job.
|
|
1863
|
+
* @param {string} NOTIFICATION_CALLBACK_URL - The url to send the job notification to.
|
|
1864
|
+
* @param {string | null} EXTERNAL_ID - The external id of the job.
|
|
1865
|
+
* @param {boolean | null} REPLACE_EXISTING_JOB - Whether to replace an existing job.
|
|
1866
|
+
* @param {string | null} ASSET_URL - The asset url of the job.
|
|
1867
|
+
* @param {Array<string> | null} REQUESTED_TASKS - The tasks to request for the job.
|
|
1868
|
+
* @param {Array<string> | null} REQUESTED_TRANSCODE_PROFILES - The transcode profiles to request for the job.
|
|
1869
|
+
* @returns {Promise<JSON>} - A promise that resolves when the job is created.
|
|
1870
|
+
* Returns the id of the asset created.
|
|
1871
|
+
* @throws {Error} - An error is thrown if the job fails to create.
|
|
1872
|
+
* @throws {Error} - An error is thrown if the API type is not admin.
|
|
1873
|
+
*/
|
|
1874
|
+
async createJob(
|
|
1875
|
+
BUCKET_NAME, OBJECT_KEY, NOTIFICATION_CALLBACK_URL, EXTERNAL_ID,
|
|
1876
|
+
REPLACE_EXISTING_JOB, ASSET_URL, REQUESTED_TASKS, REQUESTED_TRANSCODE_PROFILES)
|
|
1877
|
+
{
|
|
1878
|
+
if (this.token === null)
|
|
1879
|
+
{
|
|
1880
|
+
await this._init();
|
|
1881
|
+
}
|
|
1882
|
+
|
|
1883
|
+
if (this.config.apiType !== "admin")
|
|
1884
|
+
{
|
|
1885
|
+
throw new Error("This function is only available for admin API type.");
|
|
1886
|
+
}
|
|
1887
|
+
|
|
1888
|
+
_printDatetime(`Creating job: ${BUCKET_NAME}`);
|
|
1889
|
+
|
|
1890
|
+
try
|
|
1891
|
+
{
|
|
1892
|
+
const CREATE_JOB_RESULT = await _createJob(
|
|
1893
|
+
this, BUCKET_NAME, OBJECT_KEY, NOTIFICATION_CALLBACK_URL, REPLACE_EXISTING_JOB,
|
|
1894
|
+
REQUESTED_TASKS, REQUESTED_TRANSCODE_PROFILES, EXTERNAL_ID, ASSET_URL);
|
|
1895
|
+
if (CREATE_JOB_RESULT) _printDatetime(`Job created: ${BUCKET_NAME}`);
|
|
1896
|
+
return CREATE_JOB_RESULT;
|
|
1897
|
+
} catch (error) {
|
|
1898
|
+
_printDatetime(`Job failed: ${BUCKET_NAME}`);
|
|
1899
|
+
throw error;
|
|
1900
|
+
}
|
|
1901
|
+
}
|
|
1902
|
+
|
|
1903
|
+
/**
|
|
1904
|
+
* @function createJobId
|
|
1905
|
+
* @async
|
|
1906
|
+
* @description Creates a job.
|
|
1907
|
+
* @param {string} ASSET_ID - The asset id of the job.
|
|
1908
|
+
* @param {string} JOB_RESULTS_URL - The job results url of the job.
|
|
1909
|
+
* @param {string | null} EXTERNAL_ID - The external id of the job.
|
|
1910
|
+
* @throws {Error} - An error is thrown if the create job fails.
|
|
1911
|
+
* @throws {Error} - An error is thrown if the API type is not admin.
|
|
1912
|
+
*/
|
|
1913
|
+
async createJobId(ASSET_ID, JOB_RESULTS_URL, EXTERNAL_ID)
|
|
1914
|
+
{
|
|
1915
|
+
if (this.token === null)
|
|
1916
|
+
{
|
|
1917
|
+
await this._init();
|
|
1918
|
+
}
|
|
1919
|
+
|
|
1920
|
+
if (this.config.apiType !== "admin")
|
|
1921
|
+
{
|
|
1922
|
+
throw new Error("This function is only available for admin API type.");
|
|
1923
|
+
}
|
|
1924
|
+
|
|
1925
|
+
_printDatetime(`Creating job: ${ASSET_ID}`);
|
|
1926
|
+
|
|
1927
|
+
try
|
|
1928
|
+
{
|
|
1929
|
+
await _createJob(
|
|
1930
|
+
this, ASSET_ID, JOB_RESULTS_URL, EXTERNAL_ID);
|
|
1931
|
+
_printDatetime(`Job created: ${ASSET_ID}`);
|
|
1932
|
+
} catch (error) {
|
|
1933
|
+
_printDatetime(`Job failed: ${ASSET_ID}`);
|
|
1934
|
+
throw error;
|
|
1935
|
+
}
|
|
1936
|
+
}
|
|
1840
1937
|
|
|
1841
1938
|
// live channel functions
|
|
1842
1939
|
/**
|
|
@@ -10435,65 +10532,65 @@ async function _getContent(instance, CONTENT_ID, CONTENT_DEFINITION_ID, IS_REVIS
|
|
|
10435
10532
|
}
|
|
10436
10533
|
|
|
10437
10534
|
|
|
10438
|
-
|
|
10439
|
-
|
|
10440
|
-
import deepEqual from "deep-equal";
|
|
10441
|
-
|
|
10442
|
-
async function _updateContent(instance, CONTENT_ID, CONTENT_DEFINITION_ID, PROPERTIES, LANGUAGE_ID)
|
|
10443
|
-
{
|
|
10444
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/content/${CONTENT_ID}`;
|
|
10445
|
-
|
|
10446
|
-
let body = null;
|
|
10447
|
-
try
|
|
10448
|
-
{
|
|
10449
|
-
body = await _getContent(instance, CONTENT_ID, CONTENT_DEFINITION_ID, null);
|
|
10450
|
-
|
|
10451
|
-
if (body.contentDefinitionId !== CONTENT_DEFINITION_ID) body.contentDefinitionId = CONTENT_DEFINITION_ID;
|
|
10452
|
-
if (body.contentId !== CONTENT_ID) body.contentId = CONTENT_ID;
|
|
10453
|
-
if (body.language !== LANGUAGE_ID) body.language = LANGUAGE_ID;
|
|
10454
|
-
|
|
10455
|
-
_updateProperties(body, PROPERTIES);
|
|
10456
|
-
}
|
|
10457
|
-
catch (error)
|
|
10458
|
-
{
|
|
10459
|
-
body = {
|
|
10460
|
-
contentDefinitionId: CONTENT_DEFINITION_ID,
|
|
10461
|
-
contentId: CONTENT_ID,
|
|
10462
|
-
language: LANGUAGE_ID,
|
|
10463
|
-
properties: PROPERTIES
|
|
10464
|
-
}
|
|
10465
|
-
}
|
|
10466
|
-
|
|
10467
|
-
return await _sendRequest(instance, "Update Content", API_URL, "PUT", undefined, body);
|
|
10468
|
-
}
|
|
10469
|
-
|
|
10470
|
-
function _updateProperties(body, properties) {
|
|
10471
|
-
for (const property in properties) {
|
|
10472
|
-
if (Array.isArray(properties[property]))
|
|
10473
|
-
{
|
|
10474
|
-
for (let i = 0; i < properties[property].length; ++i)
|
|
10475
|
-
{
|
|
10476
|
-
if (!deepEqual(body.properties[property][i], properties[property][i]))
|
|
10477
|
-
{
|
|
10478
|
-
body.properties[property][i] = properties[property][i];
|
|
10479
|
-
}
|
|
10480
|
-
}
|
|
10481
|
-
}
|
|
10482
|
-
else if (typeof properties[property] === 'object')
|
|
10483
|
-
{
|
|
10484
|
-
if (!deepEqual(body.properties[property], properties[property]))
|
|
10485
|
-
{
|
|
10486
|
-
body.properties[property] = properties[property];
|
|
10487
|
-
}
|
|
10488
|
-
}
|
|
10489
|
-
else if (body.properties[property] !== properties[property])
|
|
10490
|
-
{
|
|
10491
|
-
body.properties[property] = properties[property];
|
|
10492
|
-
}
|
|
10493
|
-
}
|
|
10494
|
-
}
|
|
10495
|
-
|
|
10496
|
-
|
|
10535
|
+
|
|
10536
|
+
|
|
10537
|
+
import deepEqual from "deep-equal";
|
|
10538
|
+
|
|
10539
|
+
async function _updateContent(instance, CONTENT_ID, CONTENT_DEFINITION_ID, PROPERTIES, LANGUAGE_ID)
|
|
10540
|
+
{
|
|
10541
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/content/${CONTENT_ID}`;
|
|
10542
|
+
|
|
10543
|
+
let body = null;
|
|
10544
|
+
try
|
|
10545
|
+
{
|
|
10546
|
+
body = await _getContent(instance, CONTENT_ID, CONTENT_DEFINITION_ID, null);
|
|
10547
|
+
|
|
10548
|
+
if (body.contentDefinitionId !== CONTENT_DEFINITION_ID) body.contentDefinitionId = CONTENT_DEFINITION_ID;
|
|
10549
|
+
if (body.contentId !== CONTENT_ID) body.contentId = CONTENT_ID;
|
|
10550
|
+
if (body.language !== LANGUAGE_ID) body.language = LANGUAGE_ID;
|
|
10551
|
+
|
|
10552
|
+
_updateProperties(body, PROPERTIES);
|
|
10553
|
+
}
|
|
10554
|
+
catch (error)
|
|
10555
|
+
{
|
|
10556
|
+
body = {
|
|
10557
|
+
contentDefinitionId: CONTENT_DEFINITION_ID,
|
|
10558
|
+
contentId: CONTENT_ID,
|
|
10559
|
+
language: LANGUAGE_ID,
|
|
10560
|
+
properties: PROPERTIES
|
|
10561
|
+
}
|
|
10562
|
+
}
|
|
10563
|
+
|
|
10564
|
+
return await _sendRequest(instance, "Update Content", API_URL, "PUT", undefined, body);
|
|
10565
|
+
}
|
|
10566
|
+
|
|
10567
|
+
function _updateProperties(body, properties) {
|
|
10568
|
+
for (const property in properties) {
|
|
10569
|
+
if (Array.isArray(properties[property]))
|
|
10570
|
+
{
|
|
10571
|
+
for (let i = 0; i < properties[property].length; ++i)
|
|
10572
|
+
{
|
|
10573
|
+
if (!deepEqual(body.properties[property][i], properties[property][i]))
|
|
10574
|
+
{
|
|
10575
|
+
body.properties[property][i] = properties[property][i];
|
|
10576
|
+
}
|
|
10577
|
+
}
|
|
10578
|
+
}
|
|
10579
|
+
else if (typeof properties[property] === 'object')
|
|
10580
|
+
{
|
|
10581
|
+
if (!deepEqual(body.properties[property], properties[property]))
|
|
10582
|
+
{
|
|
10583
|
+
body.properties[property] = properties[property];
|
|
10584
|
+
}
|
|
10585
|
+
}
|
|
10586
|
+
else if (body.properties[property] !== properties[property])
|
|
10587
|
+
{
|
|
10588
|
+
body.properties[property] = properties[property];
|
|
10589
|
+
}
|
|
10590
|
+
}
|
|
10591
|
+
}
|
|
10592
|
+
|
|
10593
|
+
|
|
10497
10594
|
|
|
10498
10595
|
|
|
10499
10596
|
|
|
@@ -10624,6 +10721,43 @@ async function _stopLiveSchedule(instance, EVENT_ID)
|
|
|
10624
10721
|
|
|
10625
10722
|
|
|
10626
10723
|
|
|
10724
|
+
async function _createJobId(instance, assetId, jobResultsUrl, externalId)
|
|
10725
|
+
{
|
|
10726
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/job/${assetId}`;
|
|
10727
|
+
|
|
10728
|
+
const body = {
|
|
10729
|
+
jobResultsUrl: jobResultsUrl,
|
|
10730
|
+
externalId: externalId
|
|
10731
|
+
};
|
|
10732
|
+
|
|
10733
|
+
return await _sendRequest(instance, "Create Job Id", API_URL, "POST", undefined, body);
|
|
10734
|
+
}
|
|
10735
|
+
|
|
10736
|
+
|
|
10737
|
+
|
|
10738
|
+
|
|
10739
|
+
async function _createJob(instance, bucketName, objectKey, notificationCallbackUrl, externalId,
|
|
10740
|
+
replaceExistingJob, assetUrl, requestedTasks, requestedTranscodeProfiles)
|
|
10741
|
+
{
|
|
10742
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/job`;
|
|
10743
|
+
|
|
10744
|
+
const body = {
|
|
10745
|
+
bucketName: bucketName,
|
|
10746
|
+
objectKey: objectKey,
|
|
10747
|
+
notificationCallbackUrl: notificationCallbackUrl,
|
|
10748
|
+
externalId: externalId,
|
|
10749
|
+
replaceExistingJob: replaceExistingJob,
|
|
10750
|
+
assetUrl: assetUrl,
|
|
10751
|
+
requestedTasks: requestedTasks,
|
|
10752
|
+
requestedTranscodeProfiles: requestedTranscodeProfiles
|
|
10753
|
+
};
|
|
10754
|
+
|
|
10755
|
+
return await _sendRequest(instance, "Create Job", API_URL, "POST", undefined, body);
|
|
10756
|
+
}
|
|
10757
|
+
|
|
10758
|
+
|
|
10759
|
+
|
|
10760
|
+
|
|
10627
10761
|
async function _clipLiveChannel(instance, CHANNEL_ID, START_TIME_CODE, END_TIME_CODE,
|
|
10628
10762
|
TITLE, OUTPUT_FOLDER_ID, TAGS, COLLECTIONS, RELATED_CONTENTS, VIDEO_BITRATE,
|
|
10629
10763
|
AUDIO_TRACKS)
|
|
@@ -10646,64 +10780,64 @@ async function _clipLiveChannel(instance, CHANNEL_ID, START_TIME_CODE, END_TIME_
|
|
|
10646
10780
|
}
|
|
10647
10781
|
|
|
10648
10782
|
|
|
10649
|
-
|
|
10650
|
-
|
|
10651
|
-
|
|
10652
|
-
|
|
10653
|
-
|
|
10654
|
-
|
|
10655
|
-
async function _createLiveChannel(instance, NAME, THUMBNAIL_IMAGE_ID, ARCHIVE_FOLDER_ASSET_ID,
|
|
10656
|
-
ENABLE_HIGH_AVAILABILITY, ENABLE_LIVE_CLIPPING, IS_SECURE_OUTPUT, IS_OUTPUT_SCREENSHOTS,
|
|
10657
|
-
TYPE, EXTERNAL_URL, EXTERNAL_OUTPUT_PROFILES, SECURITY_GROUPS)
|
|
10658
|
-
{
|
|
10659
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel`;
|
|
10660
|
-
|
|
10661
|
-
const BODY = {
|
|
10662
|
-
name: NAME,
|
|
10663
|
-
routeName: _slugify(NAME),
|
|
10664
|
-
enableHighAvailability: ENABLE_HIGH_AVAILABILITY,
|
|
10665
|
-
enableLiveClipping: ENABLE_LIVE_CLIPPING,
|
|
10666
|
-
externalOutputProfiles: EXTERNAL_OUTPUT_PROFILES,
|
|
10667
|
-
isSecureOutput: IS_SECURE_OUTPUT,
|
|
10668
|
-
outputScreenshots: IS_OUTPUT_SCREENSHOTS,
|
|
10669
|
-
type: {
|
|
10670
|
-
id: _LIVE_CHANNEL_TYPES[TYPE],
|
|
10671
|
-
descrption: TYPE
|
|
10672
|
-
}
|
|
10673
|
-
};
|
|
10674
|
-
|
|
10675
|
-
|
|
10676
|
-
if (THUMBNAIL_IMAGE_ID)
|
|
10677
|
-
{
|
|
10678
|
-
BODY.thumbnailImage = { id: THUMBNAIL_IMAGE_ID };
|
|
10679
|
-
}
|
|
10680
|
-
|
|
10681
|
-
if (ARCHIVE_FOLDER_ASSET_ID)
|
|
10682
|
-
{
|
|
10683
|
-
BODY.archiveFolderAsset = { id: ARCHIVE_FOLDER_ASSET_ID };
|
|
10684
|
-
}
|
|
10685
|
-
|
|
10686
|
-
// Set the appropriate fields based on the channel type
|
|
10687
|
-
if (TYPE === "External")
|
|
10688
|
-
{
|
|
10689
|
-
BODY.externalUrl = EXTERNAL_URL;
|
|
10690
|
-
}
|
|
10691
|
-
|
|
10692
|
-
if (SECURITY_GROUPS) {
|
|
10693
|
-
const NOMAD_SECURITY_GROUPS = await _getSecurityGroups(instance);
|
|
10694
|
-
|
|
10695
|
-
BODY.securityGroups = NOMAD_SECURITY_GROUPS.items
|
|
10696
|
-
.filter(group => SECURITY_GROUPS.includes(group.description))
|
|
10697
|
-
.map(group => ({
|
|
10698
|
-
description: group.description,
|
|
10699
|
-
id: group.id
|
|
10700
|
-
}));
|
|
10701
|
-
}
|
|
10702
|
-
|
|
10703
|
-
return await _sendRequest(instance, "Create Live Channel", API_URL, "POST", undefined, BODY);
|
|
10704
|
-
}
|
|
10705
|
-
|
|
10706
|
-
|
|
10783
|
+
|
|
10784
|
+
|
|
10785
|
+
|
|
10786
|
+
|
|
10787
|
+
|
|
10788
|
+
|
|
10789
|
+
async function _createLiveChannel(instance, NAME, THUMBNAIL_IMAGE_ID, ARCHIVE_FOLDER_ASSET_ID,
|
|
10790
|
+
ENABLE_HIGH_AVAILABILITY, ENABLE_LIVE_CLIPPING, IS_SECURE_OUTPUT, IS_OUTPUT_SCREENSHOTS,
|
|
10791
|
+
TYPE, EXTERNAL_URL, EXTERNAL_OUTPUT_PROFILES, SECURITY_GROUPS)
|
|
10792
|
+
{
|
|
10793
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel`;
|
|
10794
|
+
|
|
10795
|
+
const BODY = {
|
|
10796
|
+
name: NAME,
|
|
10797
|
+
routeName: _slugify(NAME),
|
|
10798
|
+
enableHighAvailability: ENABLE_HIGH_AVAILABILITY,
|
|
10799
|
+
enableLiveClipping: ENABLE_LIVE_CLIPPING,
|
|
10800
|
+
externalOutputProfiles: EXTERNAL_OUTPUT_PROFILES,
|
|
10801
|
+
isSecureOutput: IS_SECURE_OUTPUT,
|
|
10802
|
+
outputScreenshots: IS_OUTPUT_SCREENSHOTS,
|
|
10803
|
+
type: {
|
|
10804
|
+
id: _LIVE_CHANNEL_TYPES[TYPE],
|
|
10805
|
+
descrption: TYPE
|
|
10806
|
+
}
|
|
10807
|
+
};
|
|
10808
|
+
|
|
10809
|
+
|
|
10810
|
+
if (THUMBNAIL_IMAGE_ID)
|
|
10811
|
+
{
|
|
10812
|
+
BODY.thumbnailImage = { id: THUMBNAIL_IMAGE_ID };
|
|
10813
|
+
}
|
|
10814
|
+
|
|
10815
|
+
if (ARCHIVE_FOLDER_ASSET_ID)
|
|
10816
|
+
{
|
|
10817
|
+
BODY.archiveFolderAsset = { id: ARCHIVE_FOLDER_ASSET_ID };
|
|
10818
|
+
}
|
|
10819
|
+
|
|
10820
|
+
// Set the appropriate fields based on the channel type
|
|
10821
|
+
if (TYPE === "External")
|
|
10822
|
+
{
|
|
10823
|
+
BODY.externalUrl = EXTERNAL_URL;
|
|
10824
|
+
}
|
|
10825
|
+
|
|
10826
|
+
if (SECURITY_GROUPS) {
|
|
10827
|
+
const NOMAD_SECURITY_GROUPS = await _getSecurityGroups(instance);
|
|
10828
|
+
|
|
10829
|
+
BODY.securityGroups = NOMAD_SECURITY_GROUPS.items
|
|
10830
|
+
.filter(group => SECURITY_GROUPS.includes(group.description))
|
|
10831
|
+
.map(group => ({
|
|
10832
|
+
description: group.description,
|
|
10833
|
+
id: group.id
|
|
10834
|
+
}));
|
|
10835
|
+
}
|
|
10836
|
+
|
|
10837
|
+
return await _sendRequest(instance, "Create Live Channel", API_URL, "POST", undefined, BODY);
|
|
10838
|
+
}
|
|
10839
|
+
|
|
10840
|
+
|
|
10707
10841
|
|
|
10708
10842
|
|
|
10709
10843
|
|
|
@@ -10746,38 +10880,38 @@ async function _deleteLiveChannel(instance, CHANNEL_ID, DELETE_INPUTS)
|
|
|
10746
10880
|
}
|
|
10747
10881
|
|
|
10748
10882
|
|
|
10749
|
-
|
|
10750
|
-
|
|
10751
|
-
async function _getLiveChannelInputsIds(instance, CHANNEL_ID)
|
|
10752
|
-
{
|
|
10753
|
-
// Declare empty array for the IDs
|
|
10754
|
-
const INPUT_IDS = [];
|
|
10755
|
-
|
|
10756
|
-
// Get all the schedule events for the channel
|
|
10757
|
-
if (instance.debug) console.log(`Getting Live Channel Schedule Events...`);
|
|
10758
|
-
|
|
10759
|
-
const CHANNEL_EVENTS = await _getLiveChannelScheduleEvents(instance, CHANNEL_ID);
|
|
10760
|
-
|
|
10761
|
-
// If there are schedule events
|
|
10762
|
-
if (CHANNEL_EVENTS && CHANNEL_EVENTS.length > 0) {
|
|
10763
|
-
// Loop schedule events
|
|
10764
|
-
CHANNEL_EVENTS.forEach((SCHEDULE_EVENT) =>
|
|
10765
|
-
{
|
|
10766
|
-
// Check if schedule event is input type
|
|
10767
|
-
if (SCHEDULE_EVENT && SCHEDULE_EVENT.liveInput && SCHEDULE_EVENT.liveInput != null) {
|
|
10768
|
-
// If it has a valid lookupId add it to the array
|
|
10769
|
-
if (SCHEDULE_EVENT.liveInput.lookupId) {
|
|
10770
|
-
INPUT_IDS.push(SCHEDULE_EVENT.liveInput.lookupId);
|
|
10771
|
-
}
|
|
10772
|
-
}
|
|
10773
|
-
});
|
|
10774
|
-
}
|
|
10775
|
-
|
|
10776
|
-
// Return the array of inputs IDs
|
|
10777
|
-
return INPUT_IDS;
|
|
10778
|
-
}
|
|
10779
|
-
|
|
10780
|
-
|
|
10883
|
+
|
|
10884
|
+
|
|
10885
|
+
async function _getLiveChannelInputsIds(instance, CHANNEL_ID)
|
|
10886
|
+
{
|
|
10887
|
+
// Declare empty array for the IDs
|
|
10888
|
+
const INPUT_IDS = [];
|
|
10889
|
+
|
|
10890
|
+
// Get all the schedule events for the channel
|
|
10891
|
+
if (instance.debug) console.log(`Getting Live Channel Schedule Events...`);
|
|
10892
|
+
|
|
10893
|
+
const CHANNEL_EVENTS = await _getLiveChannelScheduleEvents(instance, CHANNEL_ID);
|
|
10894
|
+
|
|
10895
|
+
// If there are schedule events
|
|
10896
|
+
if (CHANNEL_EVENTS && CHANNEL_EVENTS.length > 0) {
|
|
10897
|
+
// Loop schedule events
|
|
10898
|
+
CHANNEL_EVENTS.forEach((SCHEDULE_EVENT) =>
|
|
10899
|
+
{
|
|
10900
|
+
// Check if schedule event is input type
|
|
10901
|
+
if (SCHEDULE_EVENT && SCHEDULE_EVENT.liveInput && SCHEDULE_EVENT.liveInput != null) {
|
|
10902
|
+
// If it has a valid lookupId add it to the array
|
|
10903
|
+
if (SCHEDULE_EVENT.liveInput.lookupId) {
|
|
10904
|
+
INPUT_IDS.push(SCHEDULE_EVENT.liveInput.lookupId);
|
|
10905
|
+
}
|
|
10906
|
+
}
|
|
10907
|
+
});
|
|
10908
|
+
}
|
|
10909
|
+
|
|
10910
|
+
// Return the array of inputs IDs
|
|
10911
|
+
return INPUT_IDS;
|
|
10912
|
+
}
|
|
10913
|
+
|
|
10914
|
+
|
|
10781
10915
|
|
|
10782
10916
|
|
|
10783
10917
|
|
|
@@ -10789,52 +10923,52 @@ async function _getLiveChannelScheduleEvents(instance, CHANNEL_ID)
|
|
|
10789
10923
|
}
|
|
10790
10924
|
|
|
10791
10925
|
|
|
10792
|
-
|
|
10793
|
-
|
|
10794
|
-
async function _getLiveChannelStatusMessage(instance, CHANNEL_ID) {
|
|
10795
|
-
// Get the live channel
|
|
10796
|
-
if (instance.debug)
|
|
10797
|
-
{
|
|
10798
|
-
console.log(`Getting Live Channel...`);
|
|
10799
|
-
}
|
|
10800
|
-
const CHANNEL = await _getLiveChannel(instance, CHANNEL_ID);
|
|
10801
|
-
|
|
10802
|
-
// Check if channel was found
|
|
10803
|
-
if (CHANNEL) {
|
|
10804
|
-
// Check if there are status messages
|
|
10805
|
-
if (CHANNEL.statusMessages && CHANNEL.statusMessages.length > 0) {
|
|
10806
|
-
// Return the first status message
|
|
10807
|
-
return CHANNEL.statusMessages[0];
|
|
10808
|
-
}
|
|
10809
|
-
}
|
|
10810
|
-
|
|
10811
|
-
// There are no status messages
|
|
10812
|
-
return false;
|
|
10813
|
-
}
|
|
10814
|
-
|
|
10815
|
-
|
|
10816
|
-
|
|
10817
|
-
|
|
10818
|
-
|
|
10819
|
-
async function _getLiveChannelStatus(instance, CHANNEL_ID) {
|
|
10820
|
-
// Get the live channel
|
|
10821
|
-
if (instance.debug)
|
|
10822
|
-
{
|
|
10823
|
-
console.log(`Getting Live Channel...`);
|
|
10824
|
-
}
|
|
10825
|
-
const CHANNEL = await _getLiveChannel(instance, CHANNEL_ID);
|
|
10826
|
-
|
|
10827
|
-
// Check if live channel was found
|
|
10828
|
-
if (CHANNEL) {
|
|
10829
|
-
// Return the status of the live channel
|
|
10830
|
-
return CHANNEL.status.description;
|
|
10831
|
-
}
|
|
10832
|
-
|
|
10833
|
-
// Live channel was not found
|
|
10834
|
-
return "Deleted";
|
|
10835
|
-
}
|
|
10836
|
-
|
|
10837
|
-
|
|
10926
|
+
|
|
10927
|
+
|
|
10928
|
+
async function _getLiveChannelStatusMessage(instance, CHANNEL_ID) {
|
|
10929
|
+
// Get the live channel
|
|
10930
|
+
if (instance.debug)
|
|
10931
|
+
{
|
|
10932
|
+
console.log(`Getting Live Channel...`);
|
|
10933
|
+
}
|
|
10934
|
+
const CHANNEL = await _getLiveChannel(instance, CHANNEL_ID);
|
|
10935
|
+
|
|
10936
|
+
// Check if channel was found
|
|
10937
|
+
if (CHANNEL) {
|
|
10938
|
+
// Check if there are status messages
|
|
10939
|
+
if (CHANNEL.statusMessages && CHANNEL.statusMessages.length > 0) {
|
|
10940
|
+
// Return the first status message
|
|
10941
|
+
return CHANNEL.statusMessages[0];
|
|
10942
|
+
}
|
|
10943
|
+
}
|
|
10944
|
+
|
|
10945
|
+
// There are no status messages
|
|
10946
|
+
return false;
|
|
10947
|
+
}
|
|
10948
|
+
|
|
10949
|
+
|
|
10950
|
+
|
|
10951
|
+
|
|
10952
|
+
|
|
10953
|
+
async function _getLiveChannelStatus(instance, CHANNEL_ID) {
|
|
10954
|
+
// Get the live channel
|
|
10955
|
+
if (instance.debug)
|
|
10956
|
+
{
|
|
10957
|
+
console.log(`Getting Live Channel...`);
|
|
10958
|
+
}
|
|
10959
|
+
const CHANNEL = await _getLiveChannel(instance, CHANNEL_ID);
|
|
10960
|
+
|
|
10961
|
+
// Check if live channel was found
|
|
10962
|
+
if (CHANNEL) {
|
|
10963
|
+
// Return the status of the live channel
|
|
10964
|
+
return CHANNEL.status.description;
|
|
10965
|
+
}
|
|
10966
|
+
|
|
10967
|
+
// Live channel was not found
|
|
10968
|
+
return "Deleted";
|
|
10969
|
+
}
|
|
10970
|
+
|
|
10971
|
+
|
|
10838
10972
|
|
|
10839
10973
|
|
|
10840
10974
|
|
|
@@ -10885,33 +11019,33 @@ const _SECURITY_GROUPS = {
|
|
|
10885
11019
|
}
|
|
10886
11020
|
|
|
10887
11021
|
|
|
10888
|
-
const _LIVE_CHANNEL_STATUSES = {
|
|
10889
|
-
CreateFailed: "Create Failed",
|
|
10890
|
-
Creating: "Creating",
|
|
10891
|
-
Deleted: "Deleted",
|
|
10892
|
-
Deleting: "Deleting",
|
|
10893
|
-
Error: "Error",
|
|
10894
|
-
Idle: "Idle",
|
|
10895
|
-
New: "New",
|
|
10896
|
-
Pause: "Pause",
|
|
10897
|
-
Recovering: "Recovering",
|
|
10898
|
-
Running: "Running",
|
|
10899
|
-
Starting: "Starting",
|
|
10900
|
-
Stopping: "Stopping",
|
|
10901
|
-
Unmanaged: "Unmanaged",
|
|
10902
|
-
UpdateFailed: "Update Failed",
|
|
10903
|
-
Updating: "Updating"
|
|
10904
|
-
};
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10908
|
-
const _LIVE_CHANNEL_TYPES = {
|
|
10909
|
-
External: "2bf01dd4-0a9c-4168-a61b-27e135732103",
|
|
10910
|
-
IVS: "2bf01dd4-0a9c-4168-a61b-27e135732102",
|
|
10911
|
-
Normal: "2bf01dd4-0a9c-4168-a61b-27e135732100",
|
|
10912
|
-
Realtime: "2bf01dd4-0a9c-4168-a61b-27e135732104"
|
|
10913
|
-
};
|
|
10914
|
-
|
|
11022
|
+
const _LIVE_CHANNEL_STATUSES = {
|
|
11023
|
+
CreateFailed: "Create Failed",
|
|
11024
|
+
Creating: "Creating",
|
|
11025
|
+
Deleted: "Deleted",
|
|
11026
|
+
Deleting: "Deleting",
|
|
11027
|
+
Error: "Error",
|
|
11028
|
+
Idle: "Idle",
|
|
11029
|
+
New: "New",
|
|
11030
|
+
Pause: "Pause",
|
|
11031
|
+
Recovering: "Recovering",
|
|
11032
|
+
Running: "Running",
|
|
11033
|
+
Starting: "Starting",
|
|
11034
|
+
Stopping: "Stopping",
|
|
11035
|
+
Unmanaged: "Unmanaged",
|
|
11036
|
+
UpdateFailed: "Update Failed",
|
|
11037
|
+
Updating: "Updating"
|
|
11038
|
+
};
|
|
11039
|
+
|
|
11040
|
+
|
|
11041
|
+
|
|
11042
|
+
const _LIVE_CHANNEL_TYPES = {
|
|
11043
|
+
External: "2bf01dd4-0a9c-4168-a61b-27e135732103",
|
|
11044
|
+
IVS: "2bf01dd4-0a9c-4168-a61b-27e135732102",
|
|
11045
|
+
Normal: "2bf01dd4-0a9c-4168-a61b-27e135732100",
|
|
11046
|
+
Realtime: "2bf01dd4-0a9c-4168-a61b-27e135732104"
|
|
11047
|
+
};
|
|
11048
|
+
|
|
10915
11049
|
|
|
10916
11050
|
|
|
10917
11051
|
|
|
@@ -10923,317 +11057,47 @@ async function _nextEvent(instance, CHANNEL_ID)
|
|
|
10923
11057
|
}
|
|
10924
11058
|
|
|
10925
11059
|
|
|
10926
|
-
|
|
10927
|
-
|
|
10928
|
-
|
|
10929
|
-
|
|
10930
|
-
async function _startLiveChannel(instance, CHANNEL_ID, WAIT_FOR_START)
|
|
10931
|
-
{
|
|
10932
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/start`
|
|
10933
|
-
|
|
10934
|
-
await _sendRequest(instance, "Start Live Channel", API_URL, "POST", undefined, undefined);
|
|
10935
|
-
|
|
10936
|
-
if (!WAIT_FOR_START) return;
|
|
10937
|
-
await _waitForLiveChannelStatus(instance, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Running, 1200, 20);
|
|
10938
|
-
}
|
|
10939
|
-
|
|
10940
11060
|
|
|
10941
11061
|
|
|
10942
11062
|
|
|
10943
|
-
|
|
11063
|
+
|
|
11064
|
+
async function _startLiveChannel(instance, CHANNEL_ID, WAIT_FOR_START)
|
|
10944
11065
|
{
|
|
10945
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/
|
|
11066
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/start`
|
|
10946
11067
|
|
|
10947
|
-
|
|
10948
|
-
}
|
|
11068
|
+
await _sendRequest(instance, "Start Live Channel", API_URL, "POST", undefined, undefined);
|
|
10949
11069
|
|
|
11070
|
+
if (!WAIT_FOR_START) return;
|
|
11071
|
+
await _waitForLiveChannelStatus(instance, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Running, 1200, 20);
|
|
11072
|
+
}
|
|
10950
11073
|
|
|
10951
|
-
|
|
10952
|
-
|
|
10953
|
-
|
|
10954
|
-
|
|
10955
|
-
async function _stopLiveChannel(instance, CHANNEL_ID, WAIT_FOR_STOP)
|
|
10956
|
-
{
|
|
10957
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/stop`
|
|
10958
|
-
|
|
10959
|
-
await _sendRequest(instance, "Stop Live Channel", API_URL, "POST", undefined, undefined);
|
|
10960
|
-
|
|
10961
|
-
if (!WAIT_FOR_STOP) return;
|
|
10962
|
-
await _waitForLiveChannelStatus(instance, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Idle, 1200, 20);
|
|
10963
|
-
}
|
|
10964
|
-
|
|
10965
|
-
|
|
10966
|
-
|
|
10967
|
-
|
|
10968
|
-
|
|
10969
|
-
|
|
10970
|
-
|
|
10971
|
-
|
|
10972
|
-
|
|
10973
|
-
|
|
10974
|
-
|
|
10975
|
-
async function _updateLiveChannel(instance, ID, NAME, THUMBNAIL_IMAGE_ID, ARCHIVE_FOLDER_ASSET_ID,
|
|
10976
|
-
ENABLE_HIGH_AVAILABILITY, ENABLE_LIVE_CLIPPING, IS_SECURE_OUTPUT, OUTPUT_SCREENSHOTS, TYPE,
|
|
10977
|
-
EXTERNAL_URL, EXTERNAL_OUTPUT_PROFILES, SECURITY_GROUPS)
|
|
10978
|
-
{
|
|
10979
|
-
const BODY = await _getLiveChannel(instance, ID);
|
|
10980
|
-
|
|
10981
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel`;
|
|
10982
|
-
|
|
10983
|
-
if (NAME && NAME !== BODY.name)
|
|
10984
|
-
{
|
|
10985
|
-
BODY.name = NAME;
|
|
10986
|
-
BODY.routeName = _slugify(NAME);
|
|
10987
|
-
}
|
|
10988
|
-
if (THUMBNAIL_IMAGE_ID && THUMBNAIL_IMAGE_ID !== BODY.thumbnailImage) BODY.thumbnailImage = { id: THUMBNAIL_IMAGE_ID };
|
|
10989
|
-
if (ARCHIVE_FOLDER_ASSET_ID && ARCHIVE_FOLDER_ASSET_ID !== BODY.archiveFolderAsset.id) BODY.archiveFolderAsset = { id: ARCHIVE_FOLDER_ASSET_ID };
|
|
10990
|
-
if (ENABLE_HIGH_AVAILABILITY && ENABLE_HIGH_AVAILABILITY !== BODY.enableHighAvailability) BODY.enableHighAvailability = ENABLE_HIGH_AVAILABILITY;
|
|
10991
|
-
if (ENABLE_LIVE_CLIPPING && ENABLE_LIVE_CLIPPING !== BODY.enableLiveClipping) BODY.enableLiveClipping = ENABLE_LIVE_CLIPPING;
|
|
10992
|
-
if (IS_SECURE_OUTPUT && IS_SECURE_OUTPUT !== BODY.isSecureOutput) BODY.isSecureOutput = IS_SECURE_OUTPUT;
|
|
10993
|
-
if (OUTPUT_SCREENSHOTS && OUTPUT_SCREENSHOTS !== BODY.outputScreenshots) BODY.outputScreenshots = OUTPUT_SCREENSHOTS;
|
|
10994
|
-
if (TYPE && _LIVE_CHANNEL_STATUSES[TYPE] !== BODY.type.id) BODY.type = { id: _LIVE_CHANNEL_TYPES[TYPE] };
|
|
10995
|
-
if (EXTERNAL_OUTPUT_PROFILES && EXTERNAL_OUTPUT_PROFILES !== BODY.externalOutputProfiles) BODY.externalOutputProfiles = EXTERNAL_OUTPUT_PROFILES;
|
|
10996
|
-
|
|
10997
|
-
|
|
10998
|
-
// Set the appropriate fields based on the channel type
|
|
10999
|
-
if (TYPE === "External") {
|
|
11000
|
-
if (EXTERNAL_URL && EXTERNAL_URL !== BODY.externalUrl) BODY.externalUrl = EXTERNAL_URL;
|
|
11001
|
-
}
|
|
11002
|
-
else
|
|
11003
|
-
{
|
|
11004
|
-
if (EXTERNAL_URL && BODY.externalUrl) delete BODY.externalUrl;
|
|
11005
|
-
}
|
|
11006
|
-
|
|
11007
|
-
if (SECURITY_GROUPS) {
|
|
11008
|
-
const NOMAD_SECURITY_GROUPS = await _getSecurityGroups(instance);
|
|
11009
|
-
|
|
11010
|
-
const FILTERED_SECURITY_GROUPS = NOMAD_SECURITY_GROUPS
|
|
11011
|
-
.filter(group => SECURITY_GROUPS.includes(group.description))
|
|
11012
|
-
.map(group => ({
|
|
11013
|
-
description: group.description,
|
|
11014
|
-
id: group.id
|
|
11015
|
-
}));
|
|
11016
|
-
|
|
11017
|
-
if (FILTERED_SECURITY_GROUPS !== BODY.securityGroups) BODY.securityGroups = FILTERED_SECURITY_GROUPS;
|
|
11018
|
-
}
|
|
11019
|
-
|
|
11020
|
-
const INFO = await _sendRequest(instance, "Update Live Channel", API_URL, "PUT", undefined, BODY);
|
|
11021
|
-
|
|
11022
|
-
await _waitForLiveChannelStatus(instance, INFO.id, _LIVE_CHANNEL_STATUSES.Idle, 120, 2);
|
|
11023
|
-
|
|
11024
|
-
return INFO;
|
|
11025
|
-
}
|
|
11026
|
-
|
|
11027
|
-
|
|
11028
|
-
|
|
11029
|
-
|
|
11030
|
-
|
|
11031
|
-
|
|
11032
|
-
|
|
11033
|
-
|
|
11034
|
-
async function _waitForLiveChannelStatus(instance, CHANNEL_ID, STATUS_TO_WAIT_FOR, TIMEOUT = 30,
|
|
11035
|
-
POLL_INTERVAL = 2)
|
|
11036
|
-
{
|
|
11037
|
-
const startingTime = new Date().getTime();
|
|
11038
|
-
|
|
11039
|
-
// Elapsed time in seconds
|
|
11040
|
-
let elapsedTime = 0;
|
|
11041
|
-
|
|
11042
|
-
while (elapsedTime < TIMEOUT)
|
|
11043
|
-
{
|
|
11044
|
-
// Get the Live Channel status
|
|
11045
|
-
const CHANNEL_STATUS = await _getLiveChannelStatus(instance, CHANNEL_ID);
|
|
11046
|
-
|
|
11047
|
-
// If channel is in statusToWaitFor return
|
|
11048
|
-
if (CHANNEL_STATUS === STATUS_TO_WAIT_FOR)
|
|
11049
|
-
{
|
|
11050
|
-
// Give feedback to the console
|
|
11051
|
-
if (instance.debug)
|
|
11052
|
-
{
|
|
11053
|
-
console.log(`Live Channel [${CHANNEL_ID}] transitioned to status [${STATUS_TO_WAIT_FOR}]`);
|
|
11054
|
-
}
|
|
11055
|
-
return;
|
|
11056
|
-
}
|
|
11057
|
-
|
|
11058
|
-
// Give feedback to the console
|
|
11059
|
-
console.log(`Live Channel [${CHANNEL_ID}] current status is [${CHANNEL_STATUS}]`);
|
|
11060
|
-
|
|
11061
|
-
// Check for Error status
|
|
11062
|
-
if (CHANNEL_STATUS === "Error")
|
|
11063
|
-
{
|
|
11064
|
-
// Get the error message
|
|
11065
|
-
const CHANNEL_STATUS_MESSAGE = await _getLiveChannelStatusMessage(instance,
|
|
11066
|
-
CHANNEL_ID);
|
|
11067
|
-
|
|
11068
|
-
// Can't continue if Live Channel is in error status
|
|
11069
|
-
throw new Error(`Live Channel [${CHANNEL_ID}] is in [Error] status: ${CHANNEL_STATUS_MESSAGE}`);
|
|
11070
|
-
}
|
|
11071
|
-
|
|
11072
|
-
// Calculate elapsed time in seconds
|
|
11073
|
-
elapsedTime = (new Date().getTime() - startingTime) / 1000;
|
|
11074
|
-
|
|
11075
|
-
// Give feedback to the console
|
|
11076
|
-
if (instance.debug)
|
|
11077
|
-
{
|
|
11078
|
-
console.log(`Waiting for Live Channel [${CHANNEL_ID}] to transition to status [${STATUS_TO_WAIT_FOR}]... [${Math.round(elapsedTime)}/${TIMEOUT}]`);
|
|
11079
|
-
}
|
|
11080
|
-
|
|
11081
|
-
// Check for timeout
|
|
11082
|
-
if (elapsedTime > TIMEOUT)
|
|
11083
|
-
{
|
|
11084
|
-
break;
|
|
11085
|
-
}
|
|
11086
|
-
|
|
11087
|
-
// Wait poll interval
|
|
11088
|
-
await _sleep(POLL_INTERVAL);
|
|
11089
|
-
}
|
|
11090
|
-
|
|
11091
|
-
throw new Error(`Waiting for Live Channel [${CHANNEL_ID}] to transition to status [${STATUS_TO_WAIT_FOR}] timed out`);
|
|
11092
|
-
}
|
|
11093
|
-
|
|
11094
|
-
|
|
11095
|
-
|
|
11096
|
-
|
|
11097
|
-
|
|
11098
|
-
|
|
11099
|
-
|
|
11100
|
-
|
|
11101
|
-
async function _createLiveInput(instance, NAME, SOURCE, TYPE, IS_STANDARD, VIDEO_ASSET_ID,
|
|
11102
|
-
DESTINATIONS, SOURCES)
|
|
11103
|
-
{
|
|
11104
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/liveInput`;
|
|
11105
|
-
|
|
11106
|
-
const BODY = {
|
|
11107
|
-
name: NAME,
|
|
11108
|
-
internalName: _slugify(NAME),
|
|
11109
|
-
type: {
|
|
11110
|
-
id: _LIVE_INPUT_TYPES[TYPE],
|
|
11111
|
-
description: TYPE
|
|
11112
|
-
}
|
|
11113
|
-
};
|
|
11114
|
-
|
|
11115
|
-
// Set the appropriate fields based on the type
|
|
11116
|
-
if (TYPE == "RTMP_PUSH")
|
|
11117
|
-
{
|
|
11118
|
-
if (SOURCE) BODY["sourceCidr"] = SOURCE
|
|
11119
|
-
}
|
|
11120
|
-
else if (TYPE === "RTMP_PULL" || TYPE === "RTP_PUSH" || TYPE === "URL_PULL")
|
|
11121
|
-
{
|
|
11122
|
-
if (SOURCE) BODY["sources"] = [{ "url": SOURCE }]
|
|
11123
|
-
}
|
|
11124
|
-
|
|
11125
|
-
if (IS_STANDARD) BODY["isStandard"] = IS_STANDARD;
|
|
11126
|
-
if (VIDEO_ASSET_ID) BODY["videoAsset"] = { id: VIDEO_ASSET_ID };
|
|
11127
|
-
if (DESTINATIONS) BODY["destinations"] = DESTINATIONS;
|
|
11128
|
-
if (SOURCES) BODY["sources"] = SOURCES;
|
|
11129
|
-
|
|
11130
|
-
return await _sendRequest(instance, "Creating Live Input", API_URL, "POST", undefined, BODY);
|
|
11131
|
-
}
|
|
11132
|
-
|
|
11133
|
-
|
|
11134
11074
|
|
|
11135
11075
|
|
|
11136
11076
|
|
|
11137
|
-
async function
|
|
11077
|
+
async function _startOutputTracking(instance, CHANNEL_ID)
|
|
11138
11078
|
{
|
|
11139
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/
|
|
11079
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/startOutputTracking`;
|
|
11140
11080
|
|
|
11141
|
-
return await _sendRequest(instance, "
|
|
11081
|
+
return await _sendRequest(instance, "Start Output Tracking", API_URL, "POST", undefined, undefined);
|
|
11142
11082
|
}
|
|
11143
11083
|
|
|
11144
11084
|
|
|
11145
11085
|
|
|
11146
|
-
|
|
11147
|
-
|
|
11148
|
-
|
|
11149
|
-
async function _getLiveInputStatusMessage(instance, INPUT_ID)
|
|
11150
|
-
{
|
|
11151
|
-
// Get the live input
|
|
11152
|
-
if (instance.debug) console.log(`Getting Live Input...`);
|
|
11153
|
-
const INPUT = await _getLiveInput(instance, INPUT_ID);
|
|
11154
|
-
|
|
11155
|
-
// Check if input was found
|
|
11156
|
-
if (INPUT)
|
|
11157
|
-
{
|
|
11158
|
-
// Check if there is status message
|
|
11159
|
-
if (INPUT.statusMessage && INPUT.statusMessage)
|
|
11160
|
-
{
|
|
11161
|
-
// Return input status message
|
|
11162
|
-
return INPUT.statusMessage;
|
|
11163
|
-
}
|
|
11164
|
-
}
|
|
11165
|
-
|
|
11166
|
-
// There is no status message
|
|
11167
|
-
return "";
|
|
11168
|
-
}
|
|
11169
|
-
|
|
11170
|
-
|
|
11171
|
-
|
|
11172
|
-
|
|
11173
|
-
|
|
11174
|
-
async function _getLiveInputStatus(instance, INPUT_ID)
|
|
11175
|
-
{
|
|
11176
|
-
// Get the live input
|
|
11177
|
-
if (instance.debug) console.log(`Getting Live Input...`);
|
|
11178
|
-
const INPUT = await _getLiveInput(instance, INPUT_ID);
|
|
11179
|
-
|
|
11180
|
-
// Check if input was found
|
|
11181
|
-
if (INPUT)
|
|
11182
|
-
{
|
|
11183
|
-
// Return the status of the input
|
|
11184
|
-
return INPUT.status.description;
|
|
11185
|
-
}
|
|
11186
|
-
|
|
11187
|
-
// Input was not found
|
|
11188
|
-
return "Deleted";
|
|
11189
|
-
}
|
|
11190
|
-
|
|
11191
11086
|
|
|
11192
11087
|
|
|
11193
11088
|
|
|
11194
|
-
async function
|
|
11089
|
+
async function _stopLiveChannel(instance, CHANNEL_ID, WAIT_FOR_STOP)
|
|
11195
11090
|
{
|
|
11196
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/
|
|
11197
|
-
|
|
11198
|
-
return await _sendRequest(instance, "Get Live Input", API_URL, "GET", undefined, undefined);
|
|
11199
|
-
}
|
|
11200
|
-
|
|
11201
|
-
|
|
11202
|
-
|
|
11091
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/stop`
|
|
11203
11092
|
|
|
11204
|
-
|
|
11205
|
-
{
|
|
11206
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/liveInput`;
|
|
11093
|
+
await _sendRequest(instance, "Stop Live Channel", API_URL, "POST", undefined, undefined);
|
|
11207
11094
|
|
|
11208
|
-
|
|
11095
|
+
if (!WAIT_FOR_STOP) return;
|
|
11096
|
+
await _waitForLiveChannelStatus(instance, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Idle, 1200, 20);
|
|
11209
11097
|
}
|
|
11210
11098
|
|
|
11211
11099
|
|
|
11212
|
-
const _LIVE_INPUT_STATUSES = {
|
|
11213
|
-
Attached: "Attached",
|
|
11214
|
-
Attaching: "Attaching",
|
|
11215
|
-
CreateFailed: "Create Failed",
|
|
11216
|
-
Creating: "Creating",
|
|
11217
|
-
Deleted: "Deleted",
|
|
11218
|
-
Deleting: "Deleting",
|
|
11219
|
-
Detached: "Detached",
|
|
11220
|
-
Detaching: "Detaching",
|
|
11221
|
-
Error: "Error",
|
|
11222
|
-
Paused: "Paused",
|
|
11223
|
-
Updating: "Updating"
|
|
11224
|
-
};
|
|
11225
|
-
|
|
11226
|
-
|
|
11227
11100
|
|
|
11228
|
-
const _LIVE_INPUT_TYPES = {
|
|
11229
|
-
RTMP_PULL: "78acb07d-ba87-48fa-ad8f-c00e318a1254",
|
|
11230
|
-
RTMP_PUSH: "78acb07d-ba87-48fa-ad8f-c00e318a1253",
|
|
11231
|
-
RTP_PUSH: "78acb07d-ba87-48fa-ad8f-c00e318a1252",
|
|
11232
|
-
UDP_PUSH: "78acb07d-ba87-48fa-ad8f-c00e318a1251",
|
|
11233
|
-
URL_PULL: "78acb07d-ba87-48fa-ad8f-c00e318a1255"
|
|
11234
|
-
};
|
|
11235
|
-
|
|
11236
|
-
|
|
11237
11101
|
|
|
11238
11102
|
|
|
11239
11103
|
|
|
@@ -11242,282 +11106,110 @@ const _LIVE_INPUT_TYPES = {
|
|
|
11242
11106
|
|
|
11243
11107
|
|
|
11244
11108
|
|
|
11245
|
-
async function
|
|
11246
|
-
|
|
11109
|
+
async function _updateLiveChannel(instance, ID, NAME, THUMBNAIL_IMAGE_ID, ARCHIVE_FOLDER_ASSET_ID,
|
|
11110
|
+
ENABLE_HIGH_AVAILABILITY, ENABLE_LIVE_CLIPPING, IS_SECURE_OUTPUT, OUTPUT_SCREENSHOTS, TYPE,
|
|
11111
|
+
EXTERNAL_URL, EXTERNAL_OUTPUT_PROFILES, SECURITY_GROUPS)
|
|
11247
11112
|
{
|
|
11248
|
-
const
|
|
11249
|
-
|
|
11250
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/liveInput`;
|
|
11113
|
+
const BODY = await _getLiveChannel(instance, ID);
|
|
11251
11114
|
|
|
11252
|
-
const
|
|
11115
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel`;
|
|
11253
11116
|
|
|
11254
11117
|
if (NAME && NAME !== BODY.name)
|
|
11255
11118
|
{
|
|
11256
11119
|
BODY.name = NAME;
|
|
11257
|
-
BODY.
|
|
11120
|
+
BODY.routeName = _slugify(NAME);
|
|
11258
11121
|
}
|
|
11259
|
-
if (
|
|
11122
|
+
if (THUMBNAIL_IMAGE_ID && THUMBNAIL_IMAGE_ID !== BODY.thumbnailImage) BODY.thumbnailImage = { id: THUMBNAIL_IMAGE_ID };
|
|
11123
|
+
if (ARCHIVE_FOLDER_ASSET_ID && ARCHIVE_FOLDER_ASSET_ID !== BODY.archiveFolderAsset.id) BODY.archiveFolderAsset = { id: ARCHIVE_FOLDER_ASSET_ID };
|
|
11124
|
+
if (ENABLE_HIGH_AVAILABILITY && ENABLE_HIGH_AVAILABILITY !== BODY.enableHighAvailability) BODY.enableHighAvailability = ENABLE_HIGH_AVAILABILITY;
|
|
11125
|
+
if (ENABLE_LIVE_CLIPPING && ENABLE_LIVE_CLIPPING !== BODY.enableLiveClipping) BODY.enableLiveClipping = ENABLE_LIVE_CLIPPING;
|
|
11126
|
+
if (IS_SECURE_OUTPUT && IS_SECURE_OUTPUT !== BODY.isSecureOutput) BODY.isSecureOutput = IS_SECURE_OUTPUT;
|
|
11127
|
+
if (OUTPUT_SCREENSHOTS && OUTPUT_SCREENSHOTS !== BODY.outputScreenshots) BODY.outputScreenshots = OUTPUT_SCREENSHOTS;
|
|
11128
|
+
if (TYPE && _LIVE_CHANNEL_STATUSES[TYPE] !== BODY.type.id) BODY.type = { id: _LIVE_CHANNEL_TYPES[TYPE] };
|
|
11129
|
+
if (EXTERNAL_OUTPUT_PROFILES && EXTERNAL_OUTPUT_PROFILES !== BODY.externalOutputProfiles) BODY.externalOutputProfiles = EXTERNAL_OUTPUT_PROFILES;
|
|
11260
11130
|
|
|
11261
|
-
|
|
11262
|
-
|
|
11263
|
-
{
|
|
11264
|
-
if (
|
|
11265
|
-
if (BODY.sources) delete BODY.sources;
|
|
11266
|
-
}
|
|
11267
|
-
else if (TYPE === "RTMP_PULL" || TYPE === "RTP_PUSH" || TYPE === "URL_PULL")
|
|
11268
|
-
{
|
|
11269
|
-
if (SOURCE && SOURCE !== BODY.sources) BODY["sources"] = [{ "url": SOURCE }]
|
|
11270
|
-
if (BODY.sourceCidr) delete BODY.sourceCidr;
|
|
11131
|
+
|
|
11132
|
+
// Set the appropriate fields based on the channel type
|
|
11133
|
+
if (TYPE === "External") {
|
|
11134
|
+
if (EXTERNAL_URL && EXTERNAL_URL !== BODY.externalUrl) BODY.externalUrl = EXTERNAL_URL;
|
|
11271
11135
|
}
|
|
11272
|
-
else
|
|
11136
|
+
else
|
|
11273
11137
|
{
|
|
11274
|
-
if (BODY.
|
|
11275
|
-
if (BODY.sources) delete BODY.sources;
|
|
11138
|
+
if (EXTERNAL_URL && BODY.externalUrl) delete BODY.externalUrl;
|
|
11276
11139
|
}
|
|
11277
11140
|
|
|
11278
|
-
if (
|
|
11279
|
-
|
|
11280
|
-
if (DESTINATIONS && DESTINATIONS !== BODY.destinations) BODY.destinations = DESTINATIONS;
|
|
11281
|
-
if (SOURCES && SOURCES !== BODY.SOURCES) BODY.sources = SOURCES;
|
|
11282
|
-
|
|
11283
|
-
const INFO = await _sendRequest(instance, "Updating Live Input", API_URL, "PUT", undefined, BODY);
|
|
11284
|
-
await _waitForLiveInputStatus(instance, INFO.id, _LIVE_INPUT_STATUSES.Detached, 15, 1);
|
|
11285
|
-
}
|
|
11286
|
-
|
|
11287
|
-
|
|
11288
|
-
|
|
11289
|
-
|
|
11290
|
-
|
|
11291
|
-
|
|
11292
|
-
|
|
11293
|
-
async function _waitForLiveInputStatus(instance, INPUT_ID, STATUS_TO_WAIT_FOR, TIMEOUT = 30,
|
|
11294
|
-
POLL_INTERVAL = 2)
|
|
11295
|
-
{
|
|
11296
|
-
// Set the starting time
|
|
11297
|
-
const STARTING_TIME = new Date().getTime();
|
|
11298
|
-
|
|
11299
|
-
// Elapsed time in seconds
|
|
11300
|
-
let elapsedTime = 0;
|
|
11301
|
-
|
|
11302
|
-
while (elapsedTime < TIMEOUT)
|
|
11303
|
-
{
|
|
11304
|
-
// Get the Live Input status
|
|
11305
|
-
const INPUT_STATUS = await _getLiveInputStatus(instance, INPUT_ID);
|
|
11306
|
-
|
|
11307
|
-
// If Live Input is in statusToWaitFor return
|
|
11308
|
-
if (INPUT_STATUS === STATUS_TO_WAIT_FOR)
|
|
11309
|
-
{
|
|
11310
|
-
// Give feedback to the console
|
|
11311
|
-
if (instance.debug)
|
|
11312
|
-
{
|
|
11313
|
-
console.log(`Live Input ${INPUT_ID} transitioned to status ${STATUS_TO_WAIT_FOR}`);
|
|
11314
|
-
}
|
|
11315
|
-
return;
|
|
11316
|
-
}
|
|
11317
|
-
|
|
11318
|
-
// Give feedback to the console
|
|
11319
|
-
console.log(`Live Input [${INPUT_ID}] is in status [${INPUT_STATUS}]`);
|
|
11320
|
-
|
|
11321
|
-
// Check for Error status
|
|
11322
|
-
if (INPUT_STATUS === "Error")
|
|
11323
|
-
{
|
|
11324
|
-
// Get the error message
|
|
11325
|
-
const INPUT_STATUS_MESSAGE = await _getLiveInputStatusMessage(instance, INPUT_ID);
|
|
11326
|
-
|
|
11327
|
-
// Can't continue if Live Input is in error status
|
|
11328
|
-
throw new Error(`Live Input ${INPUT_ID} is in Error status: ${INPUT_STATUS_MESSAGE}`);
|
|
11329
|
-
}
|
|
11330
|
-
|
|
11331
|
-
// Calculate elapsed time in seconds
|
|
11332
|
-
elapsedTime = (new Date().getTime() - STARTING_TIME) / 1000;
|
|
11333
|
-
|
|
11334
|
-
// Give feedback to the console
|
|
11335
|
-
if (instance.debug)
|
|
11336
|
-
{
|
|
11337
|
-
console.log(`Waiting for Live Input [${INPUT_ID}] to transition to status [${STATUS_TO_WAIT_FOR}]... [${Math.round(elapsedTime)}/${TIMEOUT}]`);
|
|
11338
|
-
}
|
|
11339
|
-
|
|
11340
|
-
// Check for timeout
|
|
11341
|
-
if (elapsedTime > TIMEOUT)
|
|
11342
|
-
{
|
|
11343
|
-
break;
|
|
11344
|
-
}
|
|
11345
|
-
|
|
11346
|
-
// Wait poll interval
|
|
11347
|
-
await _sleep(POLL_INTERVAL);
|
|
11348
|
-
}
|
|
11349
|
-
|
|
11350
|
-
throw new Error(`Waiting for Live Input [${INPUT_ID}] to transition to status [${STATUS_TO_WAIT_FOR}] timed out`);
|
|
11351
|
-
}
|
|
11352
|
-
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
11356
|
-
|
|
11357
|
-
|
|
11358
|
-
async function _cancelBroadcast(instance, ID)
|
|
11359
|
-
{
|
|
11360
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/cancel`;
|
|
11361
|
-
|
|
11362
|
-
return await _sendRequest(instance, "Cancel Broadcast", API_URL, "POST", undefined, undefined);
|
|
11363
|
-
}
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
async function _cancelSegment(instance, ID)
|
|
11369
|
-
{
|
|
11370
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/cancelSegment`;
|
|
11371
|
-
|
|
11372
|
-
return await _sendRequest(instance, "Cancel Segment", API_URL, "POST", undefined, undefined);
|
|
11373
|
-
}
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
|
|
11377
|
-
|
|
11378
|
-
async function _completeSegment(instance, ID, RELATED_CONTENT_IDS, TAG_IDS)
|
|
11379
|
-
{
|
|
11380
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/completeSegment`;
|
|
11381
|
-
|
|
11382
|
-
const BODY = {
|
|
11383
|
-
liveOperatorId: ID
|
|
11384
|
-
};
|
|
11385
|
-
|
|
11386
|
-
if (RELATED_CONTENT_IDS && Array.isArray(RELATED_CONTENT_IDS) && RELATED_CONTENT_IDS.length > 0) {
|
|
11387
|
-
BODY.relatedContent = RELATED_CONTENT_IDS.map(id => ({ id }));
|
|
11388
|
-
}
|
|
11389
|
-
if (TAG_IDS && Array.isArray(TAG_IDS) && TAG_IDS.length > 0) {
|
|
11390
|
-
BODY.tags = TAG_IDS.map(id => ({ id }));
|
|
11391
|
-
}
|
|
11392
|
-
|
|
11393
|
-
return await _sendRequest(instance, "Complete Segment", API_URL, "POST", undefined, BODY);
|
|
11394
|
-
}
|
|
11395
|
-
|
|
11396
|
-
|
|
11397
|
-
|
|
11398
|
-
|
|
11399
|
-
async function _getCompletedSegments(instance, ID)
|
|
11400
|
-
{
|
|
11401
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/segments`;
|
|
11402
|
-
|
|
11403
|
-
return await _sendRequest(instance, "Get Completed Segments", API_URL, "GET", undefined, undefined);
|
|
11404
|
-
}
|
|
11141
|
+
if (SECURITY_GROUPS) {
|
|
11142
|
+
const NOMAD_SECURITY_GROUPS = await _getSecurityGroups(instance);
|
|
11405
11143
|
|
|
11144
|
+
const FILTERED_SECURITY_GROUPS = NOMAD_SECURITY_GROUPS
|
|
11145
|
+
.filter(group => SECURITY_GROUPS.includes(group.description))
|
|
11146
|
+
.map(group => ({
|
|
11147
|
+
description: group.description,
|
|
11148
|
+
id: group.id
|
|
11149
|
+
}));
|
|
11406
11150
|
|
|
11151
|
+
if (FILTERED_SECURITY_GROUPS !== BODY.securityGroups) BODY.securityGroups = FILTERED_SECURITY_GROUPS;
|
|
11152
|
+
}
|
|
11407
11153
|
|
|
11154
|
+
const INFO = await _sendRequest(instance, "Update Live Channel", API_URL, "PUT", undefined, BODY);
|
|
11408
11155
|
|
|
11409
|
-
|
|
11410
|
-
{
|
|
11411
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}`;
|
|
11156
|
+
await _waitForLiveChannelStatus(instance, INFO.id, _LIVE_CHANNEL_STATUSES.Idle, 120, 2);
|
|
11412
11157
|
|
|
11413
|
-
return
|
|
11158
|
+
return INFO;
|
|
11414
11159
|
}
|
|
11415
11160
|
|
|
11416
11161
|
|
|
11417
11162
|
|
|
11418
11163
|
|
|
11419
|
-
async function _getLiveOperators(instance)
|
|
11420
|
-
{
|
|
11421
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator`;
|
|
11422
|
-
|
|
11423
|
-
return await _sendRequest(instance, "Get Live Operators", API_URL, "GET", undefined, undefined);
|
|
11424
|
-
}
|
|
11425
|
-
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
async function _startBroadcast(instance, ID, PREROLL_ASSET_ID, POSTROLL_ASSET_ID, LIVE_INPUT_ID,
|
|
11431
|
-
RELATED_CONTENT_IDS, TAG_IDS)
|
|
11432
|
-
{
|
|
11433
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/start`;
|
|
11434
|
-
|
|
11435
|
-
const BODY = {
|
|
11436
|
-
id: ID
|
|
11437
|
-
};
|
|
11438
|
-
|
|
11439
|
-
if (PREROLL_ASSET_ID) { BODY.prerollAsset = { id: PREROLL_ASSET_ID }; }
|
|
11440
|
-
if (POSTROLL_ASSET_ID) { BODY.postrollAsset = { id: POSTROLL_ASSET_ID }; }
|
|
11441
|
-
if (LIVE_INPUT_ID) { BODY.liveInput = { id: LIVE_INPUT_ID }; }
|
|
11442
|
-
|
|
11443
|
-
if (RELATED_CONTENT_IDS && Array.isArray(RELATED_CONTENT_IDS) && RELATED_CONTENT_IDS.length > 0) {
|
|
11444
|
-
BODY.relatedContent = RELATED_CONTENT_IDS.map(id => ({ id }));
|
|
11445
|
-
}
|
|
11446
|
-
if (TAG_IDS && Array.isArray(TAG_IDS) && TAG_IDS.length > 0) {
|
|
11447
|
-
BODY.tags = TAG_IDS.map(id => ({ id }));
|
|
11448
|
-
}
|
|
11449
|
-
|
|
11450
|
-
return await _sendRequest(instance, "Start Broadcast", API_URL, "POST", undefined, BODY);
|
|
11451
|
-
}
|
|
11452
|
-
|
|
11453
|
-
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
async function _startSegment(instance, ID)
|
|
11457
|
-
{
|
|
11458
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/startSegment`;
|
|
11459
|
-
|
|
11460
|
-
return await _sendRequest(instance, "Start Segment", API_URL, "POST", undefined, undefined);
|
|
11461
|
-
}
|
|
11462
|
-
|
|
11463
|
-
|
|
11464
|
-
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
async function _stopBroadcast(instance, ID)
|
|
11468
|
-
{
|
|
11469
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/stop`;
|
|
11470
|
-
|
|
11471
|
-
return await _sendRequest(instance, "Stop Broadcast", API_URL, "POST", undefined, undefined);
|
|
11472
|
-
}
|
|
11473
|
-
|
|
11474
11164
|
|
|
11475
11165
|
|
|
11476
11166
|
|
|
11477
11167
|
|
|
11478
|
-
async function
|
|
11168
|
+
async function _waitForLiveChannelStatus(instance, CHANNEL_ID, STATUS_TO_WAIT_FOR, TIMEOUT = 30,
|
|
11479
11169
|
POLL_INTERVAL = 2)
|
|
11480
11170
|
{
|
|
11481
|
-
|
|
11482
|
-
const STARTING_TIME = new Date().getTime();
|
|
11171
|
+
const startingTime = new Date().getTime();
|
|
11483
11172
|
|
|
11484
11173
|
// Elapsed time in seconds
|
|
11485
11174
|
let elapsedTime = 0;
|
|
11486
11175
|
|
|
11487
11176
|
while (elapsedTime < TIMEOUT)
|
|
11488
11177
|
{
|
|
11489
|
-
|
|
11490
|
-
|
|
11491
|
-
const OPERATOR_STATUS = OPERATOR.liveChannelStatus.description;
|
|
11178
|
+
// Get the Live Channel status
|
|
11179
|
+
const CHANNEL_STATUS = await _getLiveChannelStatus(instance, CHANNEL_ID);
|
|
11492
11180
|
|
|
11493
|
-
// If
|
|
11494
|
-
if (
|
|
11181
|
+
// If channel is in statusToWaitFor return
|
|
11182
|
+
if (CHANNEL_STATUS === STATUS_TO_WAIT_FOR)
|
|
11495
11183
|
{
|
|
11496
11184
|
// Give feedback to the console
|
|
11497
11185
|
if (instance.debug)
|
|
11498
11186
|
{
|
|
11499
|
-
console.log(`Live
|
|
11187
|
+
console.log(`Live Channel [${CHANNEL_ID}] transitioned to status [${STATUS_TO_WAIT_FOR}]`);
|
|
11500
11188
|
}
|
|
11501
11189
|
return;
|
|
11502
11190
|
}
|
|
11503
11191
|
|
|
11504
11192
|
// Give feedback to the console
|
|
11505
|
-
console.log(`Live
|
|
11193
|
+
console.log(`Live Channel [${CHANNEL_ID}] current status is [${CHANNEL_STATUS}]`);
|
|
11506
11194
|
|
|
11507
11195
|
// Check for Error status
|
|
11508
|
-
if (
|
|
11196
|
+
if (CHANNEL_STATUS === "Error")
|
|
11509
11197
|
{
|
|
11510
|
-
//
|
|
11511
|
-
|
|
11198
|
+
// Get the error message
|
|
11199
|
+
const CHANNEL_STATUS_MESSAGE = await _getLiveChannelStatusMessage(instance,
|
|
11200
|
+
CHANNEL_ID);
|
|
11201
|
+
|
|
11202
|
+
// Can't continue if Live Channel is in error status
|
|
11203
|
+
throw new Error(`Live Channel [${CHANNEL_ID}] is in [Error] status: ${CHANNEL_STATUS_MESSAGE}`);
|
|
11512
11204
|
}
|
|
11513
11205
|
|
|
11514
11206
|
// Calculate elapsed time in seconds
|
|
11515
|
-
elapsedTime = (new Date().getTime() -
|
|
11207
|
+
elapsedTime = (new Date().getTime() - startingTime) / 1000;
|
|
11516
11208
|
|
|
11517
11209
|
// Give feedback to the console
|
|
11518
11210
|
if (instance.debug)
|
|
11519
11211
|
{
|
|
11520
|
-
console.log(`Waiting for Live
|
|
11212
|
+
console.log(`Waiting for Live Channel [${CHANNEL_ID}] to transition to status [${STATUS_TO_WAIT_FOR}]... [${Math.round(elapsedTime)}/${TIMEOUT}]`);
|
|
11521
11213
|
}
|
|
11522
11214
|
|
|
11523
11215
|
// Check for timeout
|
|
@@ -11530,22 +11222,464 @@ async function _waitForLiveOperatorStatus(instance, OPERATOR_ID, STATUS_TO_WAIT_
|
|
|
11530
11222
|
await _sleep(POLL_INTERVAL);
|
|
11531
11223
|
}
|
|
11532
11224
|
|
|
11533
|
-
throw new Error(`Waiting for Live
|
|
11225
|
+
throw new Error(`Waiting for Live Channel [${CHANNEL_ID}] to transition to status [${STATUS_TO_WAIT_FOR}] timed out`);
|
|
11534
11226
|
}
|
|
11535
11227
|
|
|
11536
11228
|
|
|
11537
11229
|
|
|
11538
11230
|
|
|
11539
11231
|
|
|
11540
|
-
async function _createLiveOutputProfileGroup(instance, NAME, IS_ENABLED, MANIFEST_TYPE, IS_DEFAULT_GROUP,
|
|
11541
|
-
LIVE_OUTPUT_TYPE, ARCHIVE_LIVE_OUTPUT_PROFILE, LIVE_OUTPUT_PROFILES)
|
|
11542
|
-
{
|
|
11543
11232
|
|
|
11544
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/liveOutputProfileGroup`;
|
|
11545
11233
|
|
|
11546
|
-
|
|
11547
|
-
|
|
11548
|
-
|
|
11234
|
+
|
|
11235
|
+
async function _createLiveInput(instance, NAME, SOURCE, TYPE, IS_STANDARD, VIDEO_ASSET_ID,
|
|
11236
|
+
DESTINATIONS, SOURCES)
|
|
11237
|
+
{
|
|
11238
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveInput`;
|
|
11239
|
+
|
|
11240
|
+
const BODY = {
|
|
11241
|
+
name: NAME,
|
|
11242
|
+
internalName: _slugify(NAME),
|
|
11243
|
+
type: {
|
|
11244
|
+
id: _LIVE_INPUT_TYPES[TYPE],
|
|
11245
|
+
description: TYPE
|
|
11246
|
+
}
|
|
11247
|
+
};
|
|
11248
|
+
|
|
11249
|
+
// Set the appropriate fields based on the type
|
|
11250
|
+
if (TYPE == "RTMP_PUSH")
|
|
11251
|
+
{
|
|
11252
|
+
if (SOURCE) BODY["sourceCidr"] = SOURCE
|
|
11253
|
+
}
|
|
11254
|
+
else if (TYPE === "RTMP_PULL" || TYPE === "RTP_PUSH" || TYPE === "URL_PULL")
|
|
11255
|
+
{
|
|
11256
|
+
if (SOURCE) BODY["sources"] = [{ "url": SOURCE }]
|
|
11257
|
+
}
|
|
11258
|
+
|
|
11259
|
+
if (IS_STANDARD) BODY["isStandard"] = IS_STANDARD;
|
|
11260
|
+
if (VIDEO_ASSET_ID) BODY["videoAsset"] = { id: VIDEO_ASSET_ID };
|
|
11261
|
+
if (DESTINATIONS) BODY["destinations"] = DESTINATIONS;
|
|
11262
|
+
if (SOURCES) BODY["sources"] = SOURCES;
|
|
11263
|
+
|
|
11264
|
+
return await _sendRequest(instance, "Creating Live Input", API_URL, "POST", undefined, BODY);
|
|
11265
|
+
}
|
|
11266
|
+
|
|
11267
|
+
|
|
11268
|
+
|
|
11269
|
+
|
|
11270
|
+
|
|
11271
|
+
async function _deleteLiveInput(instance, INPUT_ID)
|
|
11272
|
+
{
|
|
11273
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveInput/${INPUT_ID}`;
|
|
11274
|
+
|
|
11275
|
+
return await _sendRequest(instance, "Delete Live Input", API_URL, "DELETE", undefined, undefined);
|
|
11276
|
+
}
|
|
11277
|
+
|
|
11278
|
+
|
|
11279
|
+
|
|
11280
|
+
|
|
11281
|
+
|
|
11282
|
+
|
|
11283
|
+
async function _getLiveInputStatusMessage(instance, INPUT_ID)
|
|
11284
|
+
{
|
|
11285
|
+
// Get the live input
|
|
11286
|
+
if (instance.debug) console.log(`Getting Live Input...`);
|
|
11287
|
+
const INPUT = await _getLiveInput(instance, INPUT_ID);
|
|
11288
|
+
|
|
11289
|
+
// Check if input was found
|
|
11290
|
+
if (INPUT)
|
|
11291
|
+
{
|
|
11292
|
+
// Check if there is status message
|
|
11293
|
+
if (INPUT.statusMessage && INPUT.statusMessage)
|
|
11294
|
+
{
|
|
11295
|
+
// Return input status message
|
|
11296
|
+
return INPUT.statusMessage;
|
|
11297
|
+
}
|
|
11298
|
+
}
|
|
11299
|
+
|
|
11300
|
+
// There is no status message
|
|
11301
|
+
return "";
|
|
11302
|
+
}
|
|
11303
|
+
|
|
11304
|
+
|
|
11305
|
+
|
|
11306
|
+
|
|
11307
|
+
|
|
11308
|
+
async function _getLiveInputStatus(instance, INPUT_ID)
|
|
11309
|
+
{
|
|
11310
|
+
// Get the live input
|
|
11311
|
+
if (instance.debug) console.log(`Getting Live Input...`);
|
|
11312
|
+
const INPUT = await _getLiveInput(instance, INPUT_ID);
|
|
11313
|
+
|
|
11314
|
+
// Check if input was found
|
|
11315
|
+
if (INPUT)
|
|
11316
|
+
{
|
|
11317
|
+
// Return the status of the input
|
|
11318
|
+
return INPUT.status.description;
|
|
11319
|
+
}
|
|
11320
|
+
|
|
11321
|
+
// Input was not found
|
|
11322
|
+
return "Deleted";
|
|
11323
|
+
}
|
|
11324
|
+
|
|
11325
|
+
|
|
11326
|
+
|
|
11327
|
+
|
|
11328
|
+
async function _getLiveInput(instance, INPUT_ID)
|
|
11329
|
+
{
|
|
11330
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveInput/${INPUT_ID}`;
|
|
11331
|
+
|
|
11332
|
+
return await _sendRequest(instance, "Get Live Input", API_URL, "GET", undefined, undefined);
|
|
11333
|
+
}
|
|
11334
|
+
|
|
11335
|
+
|
|
11336
|
+
|
|
11337
|
+
|
|
11338
|
+
async function _getLiveInputs(instance)
|
|
11339
|
+
{
|
|
11340
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveInput`;
|
|
11341
|
+
|
|
11342
|
+
return await _sendRequest(instance, "Get Live Inputs", API_URL, "GET", undefined, undefined);
|
|
11343
|
+
}
|
|
11344
|
+
|
|
11345
|
+
|
|
11346
|
+
const _LIVE_INPUT_STATUSES = {
|
|
11347
|
+
Attached: "Attached",
|
|
11348
|
+
Attaching: "Attaching",
|
|
11349
|
+
CreateFailed: "Create Failed",
|
|
11350
|
+
Creating: "Creating",
|
|
11351
|
+
Deleted: "Deleted",
|
|
11352
|
+
Deleting: "Deleting",
|
|
11353
|
+
Detached: "Detached",
|
|
11354
|
+
Detaching: "Detaching",
|
|
11355
|
+
Error: "Error",
|
|
11356
|
+
Paused: "Paused",
|
|
11357
|
+
Updating: "Updating"
|
|
11358
|
+
};
|
|
11359
|
+
|
|
11360
|
+
|
|
11361
|
+
|
|
11362
|
+
const _LIVE_INPUT_TYPES = {
|
|
11363
|
+
RTMP_PULL: "78acb07d-ba87-48fa-ad8f-c00e318a1254",
|
|
11364
|
+
RTMP_PUSH: "78acb07d-ba87-48fa-ad8f-c00e318a1253",
|
|
11365
|
+
RTP_PUSH: "78acb07d-ba87-48fa-ad8f-c00e318a1252",
|
|
11366
|
+
UDP_PUSH: "78acb07d-ba87-48fa-ad8f-c00e318a1251",
|
|
11367
|
+
URL_PULL: "78acb07d-ba87-48fa-ad8f-c00e318a1255"
|
|
11368
|
+
};
|
|
11369
|
+
|
|
11370
|
+
|
|
11371
|
+
|
|
11372
|
+
|
|
11373
|
+
|
|
11374
|
+
|
|
11375
|
+
|
|
11376
|
+
|
|
11377
|
+
|
|
11378
|
+
|
|
11379
|
+
async function _updateLiveInput(instance, ID, NAME, SOURCE, TYPE, IS_STANDARD, VIDEO_ASSET_ID,
|
|
11380
|
+
DESTINATIONS, SOURCES)
|
|
11381
|
+
{
|
|
11382
|
+
const INPUT_INFO = await _getLiveInput(instance, ID);
|
|
11383
|
+
|
|
11384
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveInput`;
|
|
11385
|
+
|
|
11386
|
+
const BODY = INPUT_INFO
|
|
11387
|
+
|
|
11388
|
+
if (NAME && NAME !== BODY.name)
|
|
11389
|
+
{
|
|
11390
|
+
BODY.name = NAME;
|
|
11391
|
+
BODY.internalName = _slugify(NAME);
|
|
11392
|
+
}
|
|
11393
|
+
if (TYPE && _LIVE_INPUT_TYPES[TYPE] !== BODY.type.id) BODY.type = { id: _LIVE_INPUT_TYPES[TYPE] };
|
|
11394
|
+
|
|
11395
|
+
// Set the appropriate fields based on the type
|
|
11396
|
+
if (TYPE == "RTMP_PUSH")
|
|
11397
|
+
{
|
|
11398
|
+
if (SOURCE && SOURCE !== BODY.sourceCidr) BODY["sourceCidr"] = SOURCE
|
|
11399
|
+
if (BODY.sources) delete BODY.sources;
|
|
11400
|
+
}
|
|
11401
|
+
else if (TYPE === "RTMP_PULL" || TYPE === "RTP_PUSH" || TYPE === "URL_PULL")
|
|
11402
|
+
{
|
|
11403
|
+
if (SOURCE && SOURCE !== BODY.sources) BODY["sources"] = [{ "url": SOURCE }]
|
|
11404
|
+
if (BODY.sourceCidr) delete BODY.sourceCidr;
|
|
11405
|
+
}
|
|
11406
|
+
else
|
|
11407
|
+
{
|
|
11408
|
+
if (BODY.sourceCidr) delete BODY.sourceCidr;
|
|
11409
|
+
if (BODY.sources) delete BODY.sources;
|
|
11410
|
+
}
|
|
11411
|
+
|
|
11412
|
+
if (IS_STANDARD && IS_STANDARD !== BODY.isStandard) BODY.isStandard = IS_STANDARD;
|
|
11413
|
+
if (VIDEO_ASSET_ID && VIDEO_ASSET_ID !== BODY.videoAsset.id) BODY.videoAsset = { id: VIDEO_ASSET_ID };
|
|
11414
|
+
if (DESTINATIONS && DESTINATIONS !== BODY.destinations) BODY.destinations = DESTINATIONS;
|
|
11415
|
+
if (SOURCES && SOURCES !== BODY.SOURCES) BODY.sources = SOURCES;
|
|
11416
|
+
|
|
11417
|
+
const INFO = await _sendRequest(instance, "Updating Live Input", API_URL, "PUT", undefined, BODY);
|
|
11418
|
+
await _waitForLiveInputStatus(instance, INFO.id, _LIVE_INPUT_STATUSES.Detached, 15, 1);
|
|
11419
|
+
}
|
|
11420
|
+
|
|
11421
|
+
|
|
11422
|
+
|
|
11423
|
+
|
|
11424
|
+
|
|
11425
|
+
|
|
11426
|
+
|
|
11427
|
+
async function _waitForLiveInputStatus(instance, INPUT_ID, STATUS_TO_WAIT_FOR, TIMEOUT = 30,
|
|
11428
|
+
POLL_INTERVAL = 2)
|
|
11429
|
+
{
|
|
11430
|
+
// Set the starting time
|
|
11431
|
+
const STARTING_TIME = new Date().getTime();
|
|
11432
|
+
|
|
11433
|
+
// Elapsed time in seconds
|
|
11434
|
+
let elapsedTime = 0;
|
|
11435
|
+
|
|
11436
|
+
while (elapsedTime < TIMEOUT)
|
|
11437
|
+
{
|
|
11438
|
+
// Get the Live Input status
|
|
11439
|
+
const INPUT_STATUS = await _getLiveInputStatus(instance, INPUT_ID);
|
|
11440
|
+
|
|
11441
|
+
// If Live Input is in statusToWaitFor return
|
|
11442
|
+
if (INPUT_STATUS === STATUS_TO_WAIT_FOR)
|
|
11443
|
+
{
|
|
11444
|
+
// Give feedback to the console
|
|
11445
|
+
if (instance.debug)
|
|
11446
|
+
{
|
|
11447
|
+
console.log(`Live Input ${INPUT_ID} transitioned to status ${STATUS_TO_WAIT_FOR}`);
|
|
11448
|
+
}
|
|
11449
|
+
return;
|
|
11450
|
+
}
|
|
11451
|
+
|
|
11452
|
+
// Give feedback to the console
|
|
11453
|
+
console.log(`Live Input [${INPUT_ID}] is in status [${INPUT_STATUS}]`);
|
|
11454
|
+
|
|
11455
|
+
// Check for Error status
|
|
11456
|
+
if (INPUT_STATUS === "Error")
|
|
11457
|
+
{
|
|
11458
|
+
// Get the error message
|
|
11459
|
+
const INPUT_STATUS_MESSAGE = await _getLiveInputStatusMessage(instance, INPUT_ID);
|
|
11460
|
+
|
|
11461
|
+
// Can't continue if Live Input is in error status
|
|
11462
|
+
throw new Error(`Live Input ${INPUT_ID} is in Error status: ${INPUT_STATUS_MESSAGE}`);
|
|
11463
|
+
}
|
|
11464
|
+
|
|
11465
|
+
// Calculate elapsed time in seconds
|
|
11466
|
+
elapsedTime = (new Date().getTime() - STARTING_TIME) / 1000;
|
|
11467
|
+
|
|
11468
|
+
// Give feedback to the console
|
|
11469
|
+
if (instance.debug)
|
|
11470
|
+
{
|
|
11471
|
+
console.log(`Waiting for Live Input [${INPUT_ID}] to transition to status [${STATUS_TO_WAIT_FOR}]... [${Math.round(elapsedTime)}/${TIMEOUT}]`);
|
|
11472
|
+
}
|
|
11473
|
+
|
|
11474
|
+
// Check for timeout
|
|
11475
|
+
if (elapsedTime > TIMEOUT)
|
|
11476
|
+
{
|
|
11477
|
+
break;
|
|
11478
|
+
}
|
|
11479
|
+
|
|
11480
|
+
// Wait poll interval
|
|
11481
|
+
await _sleep(POLL_INTERVAL);
|
|
11482
|
+
}
|
|
11483
|
+
|
|
11484
|
+
throw new Error(`Waiting for Live Input [${INPUT_ID}] to transition to status [${STATUS_TO_WAIT_FOR}] timed out`);
|
|
11485
|
+
}
|
|
11486
|
+
|
|
11487
|
+
|
|
11488
|
+
|
|
11489
|
+
|
|
11490
|
+
|
|
11491
|
+
|
|
11492
|
+
async function _cancelBroadcast(instance, ID)
|
|
11493
|
+
{
|
|
11494
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/cancel`;
|
|
11495
|
+
|
|
11496
|
+
return await _sendRequest(instance, "Cancel Broadcast", API_URL, "POST", undefined, undefined);
|
|
11497
|
+
}
|
|
11498
|
+
|
|
11499
|
+
|
|
11500
|
+
|
|
11501
|
+
|
|
11502
|
+
async function _cancelSegment(instance, ID)
|
|
11503
|
+
{
|
|
11504
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/cancelSegment`;
|
|
11505
|
+
|
|
11506
|
+
return await _sendRequest(instance, "Cancel Segment", API_URL, "POST", undefined, undefined);
|
|
11507
|
+
}
|
|
11508
|
+
|
|
11509
|
+
|
|
11510
|
+
|
|
11511
|
+
|
|
11512
|
+
async function _completeSegment(instance, ID, RELATED_CONTENT_IDS, TAG_IDS)
|
|
11513
|
+
{
|
|
11514
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/completeSegment`;
|
|
11515
|
+
|
|
11516
|
+
const BODY = {
|
|
11517
|
+
liveOperatorId: ID
|
|
11518
|
+
};
|
|
11519
|
+
|
|
11520
|
+
if (RELATED_CONTENT_IDS && Array.isArray(RELATED_CONTENT_IDS) && RELATED_CONTENT_IDS.length > 0) {
|
|
11521
|
+
BODY.relatedContent = RELATED_CONTENT_IDS.map(id => ({ id }));
|
|
11522
|
+
}
|
|
11523
|
+
if (TAG_IDS && Array.isArray(TAG_IDS) && TAG_IDS.length > 0) {
|
|
11524
|
+
BODY.tags = TAG_IDS.map(id => ({ id }));
|
|
11525
|
+
}
|
|
11526
|
+
|
|
11527
|
+
return await _sendRequest(instance, "Complete Segment", API_URL, "POST", undefined, BODY);
|
|
11528
|
+
}
|
|
11529
|
+
|
|
11530
|
+
|
|
11531
|
+
|
|
11532
|
+
|
|
11533
|
+
async function _getCompletedSegments(instance, ID)
|
|
11534
|
+
{
|
|
11535
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/segments`;
|
|
11536
|
+
|
|
11537
|
+
return await _sendRequest(instance, "Get Completed Segments", API_URL, "GET", undefined, undefined);
|
|
11538
|
+
}
|
|
11539
|
+
|
|
11540
|
+
|
|
11541
|
+
|
|
11542
|
+
|
|
11543
|
+
async function _getLiveOperator(instance, ID)
|
|
11544
|
+
{
|
|
11545
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}`;
|
|
11546
|
+
|
|
11547
|
+
return await _sendRequest(instance, "Get Live Operator", API_URL, "GET", undefined, undefined);
|
|
11548
|
+
}
|
|
11549
|
+
|
|
11550
|
+
|
|
11551
|
+
|
|
11552
|
+
|
|
11553
|
+
async function _getLiveOperators(instance)
|
|
11554
|
+
{
|
|
11555
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator`;
|
|
11556
|
+
|
|
11557
|
+
return await _sendRequest(instance, "Get Live Operators", API_URL, "GET", undefined, undefined);
|
|
11558
|
+
}
|
|
11559
|
+
|
|
11560
|
+
|
|
11561
|
+
|
|
11562
|
+
|
|
11563
|
+
|
|
11564
|
+
async function _startBroadcast(instance, ID, PREROLL_ASSET_ID, POSTROLL_ASSET_ID, LIVE_INPUT_ID,
|
|
11565
|
+
RELATED_CONTENT_IDS, TAG_IDS)
|
|
11566
|
+
{
|
|
11567
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/start`;
|
|
11568
|
+
|
|
11569
|
+
const BODY = {
|
|
11570
|
+
id: ID
|
|
11571
|
+
};
|
|
11572
|
+
|
|
11573
|
+
if (PREROLL_ASSET_ID) { BODY.prerollAsset = { id: PREROLL_ASSET_ID }; }
|
|
11574
|
+
if (POSTROLL_ASSET_ID) { BODY.postrollAsset = { id: POSTROLL_ASSET_ID }; }
|
|
11575
|
+
if (LIVE_INPUT_ID) { BODY.liveInput = { id: LIVE_INPUT_ID }; }
|
|
11576
|
+
|
|
11577
|
+
if (RELATED_CONTENT_IDS && Array.isArray(RELATED_CONTENT_IDS) && RELATED_CONTENT_IDS.length > 0) {
|
|
11578
|
+
BODY.relatedContent = RELATED_CONTENT_IDS.map(id => ({ id }));
|
|
11579
|
+
}
|
|
11580
|
+
if (TAG_IDS && Array.isArray(TAG_IDS) && TAG_IDS.length > 0) {
|
|
11581
|
+
BODY.tags = TAG_IDS.map(id => ({ id }));
|
|
11582
|
+
}
|
|
11583
|
+
|
|
11584
|
+
return await _sendRequest(instance, "Start Broadcast", API_URL, "POST", undefined, BODY);
|
|
11585
|
+
}
|
|
11586
|
+
|
|
11587
|
+
|
|
11588
|
+
|
|
11589
|
+
|
|
11590
|
+
async function _startSegment(instance, ID)
|
|
11591
|
+
{
|
|
11592
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/startSegment`;
|
|
11593
|
+
|
|
11594
|
+
return await _sendRequest(instance, "Start Segment", API_URL, "POST", undefined, undefined);
|
|
11595
|
+
}
|
|
11596
|
+
|
|
11597
|
+
|
|
11598
|
+
|
|
11599
|
+
|
|
11600
|
+
|
|
11601
|
+
async function _stopBroadcast(instance, ID)
|
|
11602
|
+
{
|
|
11603
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/stop`;
|
|
11604
|
+
|
|
11605
|
+
return await _sendRequest(instance, "Stop Broadcast", API_URL, "POST", undefined, undefined);
|
|
11606
|
+
}
|
|
11607
|
+
|
|
11608
|
+
|
|
11609
|
+
|
|
11610
|
+
|
|
11611
|
+
|
|
11612
|
+
async function _waitForLiveOperatorStatus(instance, OPERATOR_ID, STATUS_TO_WAIT_FOR, TIMEOUT = 30,
|
|
11613
|
+
POLL_INTERVAL = 2)
|
|
11614
|
+
{
|
|
11615
|
+
// Set the starting time
|
|
11616
|
+
const STARTING_TIME = new Date().getTime();
|
|
11617
|
+
|
|
11618
|
+
// Elapsed time in seconds
|
|
11619
|
+
let elapsedTime = 0;
|
|
11620
|
+
|
|
11621
|
+
while (elapsedTime < TIMEOUT)
|
|
11622
|
+
{
|
|
11623
|
+
const OPERATOR = await _getLiveOperator(instance, OPERATOR_ID);
|
|
11624
|
+
// Get the Live Operator status
|
|
11625
|
+
const OPERATOR_STATUS = OPERATOR.liveChannelStatus.description;
|
|
11626
|
+
|
|
11627
|
+
// If Live Operator is in statusToWaitFor return
|
|
11628
|
+
if (OPERATOR_STATUS === STATUS_TO_WAIT_FOR)
|
|
11629
|
+
{
|
|
11630
|
+
// Give feedback to the console
|
|
11631
|
+
if (instance.debug)
|
|
11632
|
+
{
|
|
11633
|
+
console.log(`Live Operator ${OPERATOR_ID} transitioned to status ${STATUS_TO_WAIT_FOR}`);
|
|
11634
|
+
}
|
|
11635
|
+
return;
|
|
11636
|
+
}
|
|
11637
|
+
|
|
11638
|
+
// Give feedback to the console
|
|
11639
|
+
console.log(`Live Operator [${OPERATOR_ID}] is in status [${OPERATOR_STATUS}]`);
|
|
11640
|
+
|
|
11641
|
+
// Check for Error status
|
|
11642
|
+
if (OPERATOR_STATUS === "Error")
|
|
11643
|
+
{
|
|
11644
|
+
// Can't continue if Live Operator is in error status
|
|
11645
|
+
throw new Error(`Live Operator ${OPERATOR_ID} is broken`);
|
|
11646
|
+
}
|
|
11647
|
+
|
|
11648
|
+
// Calculate elapsed time in seconds
|
|
11649
|
+
elapsedTime = (new Date().getTime() - STARTING_TIME) / 1000;
|
|
11650
|
+
|
|
11651
|
+
// Give feedback to the console
|
|
11652
|
+
if (instance.debug)
|
|
11653
|
+
{
|
|
11654
|
+
console.log(`Waiting for Live Operator [${OPERATOR_ID}] to transition to status [${STATUS_TO_WAIT_FOR}]... [${Math.round(elapsedTime)}/${TIMEOUT}]`);
|
|
11655
|
+
}
|
|
11656
|
+
|
|
11657
|
+
// Check for timeout
|
|
11658
|
+
if (elapsedTime > TIMEOUT)
|
|
11659
|
+
{
|
|
11660
|
+
break;
|
|
11661
|
+
}
|
|
11662
|
+
|
|
11663
|
+
// Wait poll interval
|
|
11664
|
+
await _sleep(POLL_INTERVAL);
|
|
11665
|
+
}
|
|
11666
|
+
|
|
11667
|
+
throw new Error(`Waiting for Live Operator [${OPERATOR_ID}] to transition to status [${STATUS_TO_WAIT_FOR}] timed out`);
|
|
11668
|
+
}
|
|
11669
|
+
|
|
11670
|
+
|
|
11671
|
+
|
|
11672
|
+
|
|
11673
|
+
|
|
11674
|
+
async function _createLiveOutputProfileGroup(instance, NAME, IS_ENABLED, MANIFEST_TYPE, IS_DEFAULT_GROUP,
|
|
11675
|
+
LIVE_OUTPUT_TYPE, ARCHIVE_LIVE_OUTPUT_PROFILE, LIVE_OUTPUT_PROFILES)
|
|
11676
|
+
{
|
|
11677
|
+
|
|
11678
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/liveOutputProfileGroup`;
|
|
11679
|
+
|
|
11680
|
+
const BODY = {
|
|
11681
|
+
name: NAME,
|
|
11682
|
+
enabled: IS_ENABLED,
|
|
11549
11683
|
manifestType: MANIFEST_TYPE,
|
|
11550
11684
|
isDefaultGroup: IS_DEFAULT_GROUP,
|
|
11551
11685
|
outputType: LIVE_OUTPUT_TYPE,
|
|
@@ -11721,59 +11855,59 @@ async function _updateLiveOutputProfile(instance, ID, NAME, OUTPUT_TYPE, ENABLED
|
|
|
11721
11855
|
|
|
11722
11856
|
|
|
11723
11857
|
|
|
11724
|
-
|
|
11725
|
-
|
|
11726
|
-
|
|
11727
|
-
async function _addAssetScheduleEvent(instance, CHANNEL_ID, ASSET, IS_LOOP,
|
|
11728
|
-
DURATION_TIME_CODE, PREVIOUS_ID)
|
|
11729
|
-
{
|
|
11730
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
|
|
11731
|
-
|
|
11732
|
-
const BODY = {
|
|
11733
|
-
isLoop: IS_LOOP,
|
|
11734
|
-
channelId: CHANNEL_ID,
|
|
11735
|
-
durationTimeCode: DURATION_TIME_CODE,
|
|
11736
|
-
previousId: PREVIOUS_ID,
|
|
11737
|
-
type: {
|
|
11738
|
-
id: _eventType.videoAsset,
|
|
11739
|
-
description: "Video Asset"
|
|
11740
|
-
},
|
|
11741
|
-
asset: ASSET
|
|
11742
|
-
};
|
|
11743
|
-
|
|
11744
|
-
return await _sendRequest(instance, "Adding Asset Schedule Event", API_URL, "POST", undefined, BODY);
|
|
11745
|
-
}
|
|
11746
|
-
|
|
11747
|
-
|
|
11748
|
-
|
|
11749
|
-
|
|
11750
|
-
|
|
11751
|
-
|
|
11752
|
-
async function _addInputScheduleEvent(instance, CHANNEL_ID, INPUT, BACKUP_INPUT,
|
|
11753
|
-
FIXED_ON_AIR_TIME_UTC, PREVIOUS_ID)
|
|
11754
|
-
{
|
|
11755
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
|
|
11756
|
-
|
|
11757
|
-
const BODY = {
|
|
11758
|
-
channelId: CHANNEL_ID,
|
|
11759
|
-
fixedOnAirTimeUtc: FIXED_ON_AIR_TIME_UTC,
|
|
11760
|
-
type: {
|
|
11761
|
-
id: _eventType.liveInput,
|
|
11762
|
-
description: "Live Input"
|
|
11763
|
-
},
|
|
11764
|
-
liveInput: INPUT,
|
|
11765
|
-
previousId: PREVIOUS_ID
|
|
11766
|
-
};
|
|
11767
|
-
|
|
11768
|
-
if (BACKUP_INPUT)
|
|
11769
|
-
{
|
|
11770
|
-
BODY["liveInput2"] = BACKUP_INPUT;
|
|
11771
|
-
}
|
|
11772
|
-
|
|
11773
|
-
|
|
11774
|
-
return await _sendRequest(instance, "Adding Input Schedule Event", API_URL, "POST", undefined, BODY);
|
|
11775
|
-
}
|
|
11776
|
-
|
|
11858
|
+
|
|
11859
|
+
|
|
11860
|
+
|
|
11861
|
+
async function _addAssetScheduleEvent(instance, CHANNEL_ID, ASSET, IS_LOOP,
|
|
11862
|
+
DURATION_TIME_CODE, PREVIOUS_ID)
|
|
11863
|
+
{
|
|
11864
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
|
|
11865
|
+
|
|
11866
|
+
const BODY = {
|
|
11867
|
+
isLoop: IS_LOOP,
|
|
11868
|
+
channelId: CHANNEL_ID,
|
|
11869
|
+
durationTimeCode: DURATION_TIME_CODE,
|
|
11870
|
+
previousId: PREVIOUS_ID,
|
|
11871
|
+
type: {
|
|
11872
|
+
id: _eventType.videoAsset,
|
|
11873
|
+
description: "Video Asset"
|
|
11874
|
+
},
|
|
11875
|
+
asset: ASSET
|
|
11876
|
+
};
|
|
11877
|
+
|
|
11878
|
+
return await _sendRequest(instance, "Adding Asset Schedule Event", API_URL, "POST", undefined, BODY);
|
|
11879
|
+
}
|
|
11880
|
+
|
|
11881
|
+
|
|
11882
|
+
|
|
11883
|
+
|
|
11884
|
+
|
|
11885
|
+
|
|
11886
|
+
async function _addInputScheduleEvent(instance, CHANNEL_ID, INPUT, BACKUP_INPUT,
|
|
11887
|
+
FIXED_ON_AIR_TIME_UTC, PREVIOUS_ID)
|
|
11888
|
+
{
|
|
11889
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
|
|
11890
|
+
|
|
11891
|
+
const BODY = {
|
|
11892
|
+
channelId: CHANNEL_ID,
|
|
11893
|
+
fixedOnAirTimeUtc: FIXED_ON_AIR_TIME_UTC,
|
|
11894
|
+
type: {
|
|
11895
|
+
id: _eventType.liveInput,
|
|
11896
|
+
description: "Live Input"
|
|
11897
|
+
},
|
|
11898
|
+
liveInput: INPUT,
|
|
11899
|
+
previousId: PREVIOUS_ID
|
|
11900
|
+
};
|
|
11901
|
+
|
|
11902
|
+
if (BACKUP_INPUT)
|
|
11903
|
+
{
|
|
11904
|
+
BODY["liveInput2"] = BACKUP_INPUT;
|
|
11905
|
+
}
|
|
11906
|
+
|
|
11907
|
+
|
|
11908
|
+
return await _sendRequest(instance, "Adding Input Schedule Event", API_URL, "POST", undefined, BODY);
|
|
11909
|
+
}
|
|
11910
|
+
|
|
11777
11911
|
|
|
11778
11912
|
const _eventType = {
|
|
11779
11913
|
liveInput: "eef7ef23-56dc-4f48-8c0e-1f4d52990405",
|
|
@@ -11832,92 +11966,92 @@ async function _removeInputScheduleEvent(instance, CHANNEL_ID, INPUT_ID)
|
|
|
11832
11966
|
{
|
|
11833
11967
|
const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/liveScheduleEvent/${INPUT_ID}`
|
|
11834
11968
|
|
|
11835
|
-
return await _sendRequest(instance, "Remove Input Schedule Event", API_URL, "DELETE", undefined, undefined);
|
|
11969
|
+
return await _sendRequest(instance, "Remove Input Schedule Event", API_URL, "DELETE", undefined, undefined);
|
|
11970
|
+
}
|
|
11971
|
+
|
|
11972
|
+
|
|
11973
|
+
|
|
11974
|
+
|
|
11975
|
+
|
|
11976
|
+
|
|
11977
|
+
async function _updateAssetScheduleEvent(instance, ID, CHANNEL_ID, ASSET, IS_LOOP,
|
|
11978
|
+
DURATION_TIME_CODE)
|
|
11979
|
+
{
|
|
11980
|
+
const SCHEDULE_EVENT_INFO = await _getAssetScheduleEvent(instance, CHANNEL_ID, ID);
|
|
11981
|
+
|
|
11982
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
|
|
11983
|
+
|
|
11984
|
+
const BODY = {
|
|
11985
|
+
type: {
|
|
11986
|
+
id: _eventType.videoAsset,
|
|
11987
|
+
description: "Video Asset"
|
|
11988
|
+
}
|
|
11989
|
+
};
|
|
11990
|
+
|
|
11991
|
+
BODY.id = ID && ID !== SCHEDULE_EVENT_INFO.id ? ID : SCHEDULE_EVENT_INFO.id;
|
|
11992
|
+
BODY.isLoop = IS_LOOP && IS_LOOP !== SCHEDULE_EVENT_INFO.isLoop ? IS_LOOP : SCHEDULE_EVENT_INFO.isLoop;
|
|
11993
|
+
BODY.channelId = CHANNEL_ID && CHANNEL_ID !== SCHEDULE_EVENT_INFO.channelId ? CHANNEL_ID : SCHEDULE_EVENT_INFO.channelId;
|
|
11994
|
+
BODY.durationTimeCode = DURATION_TIME_CODE && DURATION_TIME_CODE !== SCHEDULE_EVENT_INFO.durationTimeCode ? DURATION_TIME_CODE : SCHEDULE_EVENT_INFO.durationTimeCode;
|
|
11995
|
+
BODY.asset = ASSET && ASSET !== SCHEDULE_EVENT_INFO.asset ? ASSET : SCHEDULE_EVENT_INFO.asset;
|
|
11996
|
+
|
|
11997
|
+
return await _sendRequest(instance, "Updating Asset Schedule Event", API_URL, "PUT", undefined, BODY);
|
|
11998
|
+
}
|
|
11999
|
+
|
|
12000
|
+
|
|
12001
|
+
|
|
12002
|
+
|
|
12003
|
+
|
|
12004
|
+
|
|
12005
|
+
|
|
12006
|
+
async function _updateInputScheduleEvent(instance, ID, CHANNEL_ID, INPUT, BACKUP_INPUT,
|
|
12007
|
+
FIXED_ON_AIR_TIME_UTC)
|
|
12008
|
+
{
|
|
12009
|
+
const SCHEDULE_EVENT_INFO = await _getInputScheduleEvent(instance, CHANNEL_ID, ID);
|
|
12010
|
+
|
|
12011
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
|
|
12012
|
+
|
|
12013
|
+
const BODY = {
|
|
12014
|
+
type: {
|
|
12015
|
+
id: _eventType.liveInput,
|
|
12016
|
+
description: "Live Input"
|
|
12017
|
+
},
|
|
12018
|
+
};
|
|
12019
|
+
|
|
12020
|
+
BODY.id = ID && ID !== SCHEDULE_EVENT_INFO.id ? ID : SCHEDULE_EVENT_INFO.id;
|
|
12021
|
+
BODY.channelId = CHANNEL_ID && CHANNEL_ID !== SCHEDULE_EVENT_INFO.channelId ? CHANNEL_ID : SCHEDULE_EVENT_INFO.channelId;
|
|
12022
|
+
BODY.fixedOnAirTimeUtc = FIXED_ON_AIR_TIME_UTC && FIXED_ON_AIR_TIME_UTC !== SCHEDULE_EVENT_INFO.fixedOnAirTimeUtc ? FIXED_ON_AIR_TIME_UTC : SCHEDULE_EVENT_INFO.fixedOnAirTimeUtc;
|
|
12023
|
+
|
|
12024
|
+
if (INPUT && INPUT !== SCHEDULE_EVENT_INFO.liveInput)
|
|
12025
|
+
{
|
|
12026
|
+
BODY.liveInput = {
|
|
12027
|
+
id: INPUT.id,
|
|
12028
|
+
description: INPUT.name
|
|
12029
|
+
};
|
|
12030
|
+
}
|
|
12031
|
+
else
|
|
12032
|
+
{
|
|
12033
|
+
BODY.liveInput = {
|
|
12034
|
+
id: SCHEDULE_EVENT_INFO.liveInput.id,
|
|
12035
|
+
description: SCHEDULE_EVENT_INFO.liveInput.name
|
|
12036
|
+
};
|
|
12037
|
+
}
|
|
12038
|
+
|
|
12039
|
+
if (BACKUP_INPUT && BACKUP_INPUT !== SCHEDULE_EVENT_INFO.liveInput2) {
|
|
12040
|
+
BODY.liveInput2 = {
|
|
12041
|
+
id: BACKUP_INPUT.id,
|
|
12042
|
+
description: BACKUP_INPUT.name
|
|
12043
|
+
};
|
|
12044
|
+
} else if (SCHEDULE_EVENT_INFO.liveInput2) {
|
|
12045
|
+
BODY.liveInput2 = {
|
|
12046
|
+
id: SCHEDULE_EVENT_INFO.liveInput2.id,
|
|
12047
|
+
description: SCHEDULE_EVENT_INFO.liveInput2.name
|
|
12048
|
+
};
|
|
12049
|
+
}
|
|
12050
|
+
|
|
12051
|
+
return await _sendRequest(instance, "Updating Input Schedule Event", API_URL, "PUT", undefined, BODY);
|
|
11836
12052
|
}
|
|
11837
12053
|
|
|
11838
12054
|
|
|
11839
|
-
|
|
11840
|
-
|
|
11841
|
-
|
|
11842
|
-
|
|
11843
|
-
async function _updateAssetScheduleEvent(instance, ID, CHANNEL_ID, ASSET, IS_LOOP,
|
|
11844
|
-
DURATION_TIME_CODE)
|
|
11845
|
-
{
|
|
11846
|
-
const SCHEDULE_EVENT_INFO = await _getAssetScheduleEvent(instance, CHANNEL_ID, ID);
|
|
11847
|
-
|
|
11848
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
|
|
11849
|
-
|
|
11850
|
-
const BODY = {
|
|
11851
|
-
type: {
|
|
11852
|
-
id: _eventType.videoAsset,
|
|
11853
|
-
description: "Video Asset"
|
|
11854
|
-
}
|
|
11855
|
-
};
|
|
11856
|
-
|
|
11857
|
-
BODY.id = ID && ID !== SCHEDULE_EVENT_INFO.id ? ID : SCHEDULE_EVENT_INFO.id;
|
|
11858
|
-
BODY.isLoop = IS_LOOP && IS_LOOP !== SCHEDULE_EVENT_INFO.isLoop ? IS_LOOP : SCHEDULE_EVENT_INFO.isLoop;
|
|
11859
|
-
BODY.channelId = CHANNEL_ID && CHANNEL_ID !== SCHEDULE_EVENT_INFO.channelId ? CHANNEL_ID : SCHEDULE_EVENT_INFO.channelId;
|
|
11860
|
-
BODY.durationTimeCode = DURATION_TIME_CODE && DURATION_TIME_CODE !== SCHEDULE_EVENT_INFO.durationTimeCode ? DURATION_TIME_CODE : SCHEDULE_EVENT_INFO.durationTimeCode;
|
|
11861
|
-
BODY.asset = ASSET && ASSET !== SCHEDULE_EVENT_INFO.asset ? ASSET : SCHEDULE_EVENT_INFO.asset;
|
|
11862
|
-
|
|
11863
|
-
return await _sendRequest(instance, "Updating Asset Schedule Event", API_URL, "PUT", undefined, BODY);
|
|
11864
|
-
}
|
|
11865
|
-
|
|
11866
|
-
|
|
11867
|
-
|
|
11868
|
-
|
|
11869
|
-
|
|
11870
|
-
|
|
11871
|
-
|
|
11872
|
-
async function _updateInputScheduleEvent(instance, ID, CHANNEL_ID, INPUT, BACKUP_INPUT,
|
|
11873
|
-
FIXED_ON_AIR_TIME_UTC)
|
|
11874
|
-
{
|
|
11875
|
-
const SCHEDULE_EVENT_INFO = await _getInputScheduleEvent(instance, CHANNEL_ID, ID);
|
|
11876
|
-
|
|
11877
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
|
|
11878
|
-
|
|
11879
|
-
const BODY = {
|
|
11880
|
-
type: {
|
|
11881
|
-
id: _eventType.liveInput,
|
|
11882
|
-
description: "Live Input"
|
|
11883
|
-
},
|
|
11884
|
-
};
|
|
11885
|
-
|
|
11886
|
-
BODY.id = ID && ID !== SCHEDULE_EVENT_INFO.id ? ID : SCHEDULE_EVENT_INFO.id;
|
|
11887
|
-
BODY.channelId = CHANNEL_ID && CHANNEL_ID !== SCHEDULE_EVENT_INFO.channelId ? CHANNEL_ID : SCHEDULE_EVENT_INFO.channelId;
|
|
11888
|
-
BODY.fixedOnAirTimeUtc = FIXED_ON_AIR_TIME_UTC && FIXED_ON_AIR_TIME_UTC !== SCHEDULE_EVENT_INFO.fixedOnAirTimeUtc ? FIXED_ON_AIR_TIME_UTC : SCHEDULE_EVENT_INFO.fixedOnAirTimeUtc;
|
|
11889
|
-
|
|
11890
|
-
if (INPUT && INPUT !== SCHEDULE_EVENT_INFO.liveInput)
|
|
11891
|
-
{
|
|
11892
|
-
BODY.liveInput = {
|
|
11893
|
-
id: INPUT.id,
|
|
11894
|
-
description: INPUT.name
|
|
11895
|
-
};
|
|
11896
|
-
}
|
|
11897
|
-
else
|
|
11898
|
-
{
|
|
11899
|
-
BODY.liveInput = {
|
|
11900
|
-
id: SCHEDULE_EVENT_INFO.liveInput.id,
|
|
11901
|
-
description: SCHEDULE_EVENT_INFO.liveInput.name
|
|
11902
|
-
};
|
|
11903
|
-
}
|
|
11904
|
-
|
|
11905
|
-
if (BACKUP_INPUT && BACKUP_INPUT !== SCHEDULE_EVENT_INFO.liveInput2) {
|
|
11906
|
-
BODY.liveInput2 = {
|
|
11907
|
-
id: BACKUP_INPUT.id,
|
|
11908
|
-
description: BACKUP_INPUT.name
|
|
11909
|
-
};
|
|
11910
|
-
} else if (SCHEDULE_EVENT_INFO.liveInput2) {
|
|
11911
|
-
BODY.liveInput2 = {
|
|
11912
|
-
id: SCHEDULE_EVENT_INFO.liveInput2.id,
|
|
11913
|
-
description: SCHEDULE_EVENT_INFO.liveInput2.name
|
|
11914
|
-
};
|
|
11915
|
-
}
|
|
11916
|
-
|
|
11917
|
-
return await _sendRequest(instance, "Updating Input Schedule Event", API_URL, "PUT", undefined, BODY);
|
|
11918
|
-
}
|
|
11919
|
-
|
|
11920
|
-
|
|
11921
12055
|
|
|
11922
12056
|
|
|
11923
12057
|
|
|
@@ -12660,53 +12794,53 @@ async function _deleteUser(instance, USER_ID)
|
|
|
12660
12794
|
}
|
|
12661
12795
|
|
|
12662
12796
|
|
|
12663
|
-
|
|
12664
|
-
|
|
12665
|
-
async function _register(instance, EMAIL, FIRST_NAME, LAST_NAME, PASSWORD)
|
|
12666
|
-
{
|
|
12667
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/account/register`
|
|
12668
|
-
|
|
12669
|
-
const BODY = {
|
|
12670
|
-
firstName: FIRST_NAME,
|
|
12671
|
-
lastName: LAST_NAME,
|
|
12672
|
-
email: EMAIL,
|
|
12673
|
-
password: PASSWORD
|
|
12674
|
-
};
|
|
12675
|
-
|
|
12676
|
-
return await _sendRequest(instance, "Register", API_URL, "POST", undefined, BODY);
|
|
12677
|
-
}
|
|
12678
|
-
|
|
12679
|
-
|
|
12680
|
-
|
|
12681
|
-
|
|
12682
|
-
|
|
12683
|
-
|
|
12684
|
-
async function _resendCode(instance, EMAIL)
|
|
12685
|
-
{
|
|
12686
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/account/resend-code`
|
|
12687
|
-
|
|
12688
|
-
const BODY = {
|
|
12689
|
-
userName: EMAIL
|
|
12690
|
-
};
|
|
12691
|
-
|
|
12692
|
-
return await _sendRequest(instance, "Resend Code", API_URL, "POST", undefined, BODY);
|
|
12693
|
-
}
|
|
12694
|
-
|
|
12695
|
-
|
|
12696
|
-
|
|
12697
|
-
|
|
12698
|
-
async function _verify(instance, EMAIL, CODE)
|
|
12699
|
-
{
|
|
12700
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/account/verify`
|
|
12701
|
-
|
|
12702
|
-
const BODY = {
|
|
12703
|
-
userName: EMAIL,
|
|
12704
|
-
token: CODE
|
|
12705
|
-
};
|
|
12706
|
-
|
|
12707
|
-
return await _sendRequest(instance, "Verify", API_URL, "POST", undefined, BODY);
|
|
12708
|
-
}
|
|
12709
|
-
|
|
12797
|
+
|
|
12798
|
+
|
|
12799
|
+
async function _register(instance, EMAIL, FIRST_NAME, LAST_NAME, PASSWORD)
|
|
12800
|
+
{
|
|
12801
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/account/register`
|
|
12802
|
+
|
|
12803
|
+
const BODY = {
|
|
12804
|
+
firstName: FIRST_NAME,
|
|
12805
|
+
lastName: LAST_NAME,
|
|
12806
|
+
email: EMAIL,
|
|
12807
|
+
password: PASSWORD
|
|
12808
|
+
};
|
|
12809
|
+
|
|
12810
|
+
return await _sendRequest(instance, "Register", API_URL, "POST", undefined, BODY);
|
|
12811
|
+
}
|
|
12812
|
+
|
|
12813
|
+
|
|
12814
|
+
|
|
12815
|
+
|
|
12816
|
+
|
|
12817
|
+
|
|
12818
|
+
async function _resendCode(instance, EMAIL)
|
|
12819
|
+
{
|
|
12820
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/account/resend-code`
|
|
12821
|
+
|
|
12822
|
+
const BODY = {
|
|
12823
|
+
userName: EMAIL
|
|
12824
|
+
};
|
|
12825
|
+
|
|
12826
|
+
return await _sendRequest(instance, "Resend Code", API_URL, "POST", undefined, BODY);
|
|
12827
|
+
}
|
|
12828
|
+
|
|
12829
|
+
|
|
12830
|
+
|
|
12831
|
+
|
|
12832
|
+
async function _verify(instance, EMAIL, CODE)
|
|
12833
|
+
{
|
|
12834
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/account/verify`
|
|
12835
|
+
|
|
12836
|
+
const BODY = {
|
|
12837
|
+
userName: EMAIL,
|
|
12838
|
+
token: CODE
|
|
12839
|
+
};
|
|
12840
|
+
|
|
12841
|
+
return await _sendRequest(instance, "Verify", API_URL, "POST", undefined, BODY);
|
|
12842
|
+
}
|
|
12843
|
+
|
|
12710
12844
|
|
|
12711
12845
|
|
|
12712
12846
|
|
|
@@ -13532,25 +13666,25 @@ async function _createTagOrCollection(instance, TYPE, TAG_NAME)
|
|
|
13532
13666
|
}
|
|
13533
13667
|
|
|
13534
13668
|
|
|
13535
|
-
|
|
13536
|
-
|
|
13537
|
-
async function _deleteRelatedContent(instance, CONTENT_ID, RELATED_CONTENT_ID, CONTENT_DEFINITION)
|
|
13538
|
-
{
|
|
13539
|
-
const API_URL = instance.config.apiType === "admin" ? `${instance.config.serviceApiUrl}/api/admin/related/delete` : `${instance.config.serviceApiUrl}/api/content/related/delete`;
|
|
13540
|
-
|
|
13541
|
-
const BODY = {
|
|
13542
|
-
items: [
|
|
13543
|
-
{
|
|
13544
|
-
contentDefinition: CONTENT_DEFINITION,
|
|
13545
|
-
contentId: CONTENT_ID,
|
|
13546
|
-
relatedContentId: RELATED_CONTENT_ID
|
|
13547
|
-
}
|
|
13548
|
-
]
|
|
13549
|
-
};
|
|
13550
|
-
|
|
13551
|
-
return await _sendRequest(instance, "Deleting Related Content", API_URL, "POST", undefined, BODY);
|
|
13552
|
-
}
|
|
13553
|
-
|
|
13669
|
+
|
|
13670
|
+
|
|
13671
|
+
async function _deleteRelatedContent(instance, CONTENT_ID, RELATED_CONTENT_ID, CONTENT_DEFINITION)
|
|
13672
|
+
{
|
|
13673
|
+
const API_URL = instance.config.apiType === "admin" ? `${instance.config.serviceApiUrl}/api/admin/related/delete` : `${instance.config.serviceApiUrl}/api/content/related/delete`;
|
|
13674
|
+
|
|
13675
|
+
const BODY = {
|
|
13676
|
+
items: [
|
|
13677
|
+
{
|
|
13678
|
+
contentDefinition: CONTENT_DEFINITION,
|
|
13679
|
+
contentId: CONTENT_ID,
|
|
13680
|
+
relatedContentId: RELATED_CONTENT_ID
|
|
13681
|
+
}
|
|
13682
|
+
]
|
|
13683
|
+
};
|
|
13684
|
+
|
|
13685
|
+
return await _sendRequest(instance, "Deleting Related Content", API_URL, "POST", undefined, BODY);
|
|
13686
|
+
}
|
|
13687
|
+
|
|
13554
13688
|
|
|
13555
13689
|
|
|
13556
13690
|
|
|
@@ -13572,26 +13706,26 @@ async function _getTagOrCollection(instance, TYPE, ID)
|
|
|
13572
13706
|
}
|
|
13573
13707
|
|
|
13574
13708
|
|
|
13575
|
-
|
|
13576
|
-
|
|
13577
|
-
async function _removeTagOrCollection(instance, TYPE, CONTENT_ID, CONTENT_DEFINITION_ID, TAG_ID)
|
|
13578
|
-
{
|
|
13579
|
-
const API_URL = instance.config.apiType === "admin" ? `${instance.config.serviceApiUrl}/api/admin/${TYPE}/content/delete` : `${instance.config.serviceApiUrl}/api/content/${TYPE}/delete`;
|
|
13580
|
-
|
|
13581
|
-
const BODY = {
|
|
13582
|
-
items: [
|
|
13583
|
-
{
|
|
13584
|
-
contentDefinition: CONTENT_DEFINITION_ID,
|
|
13585
|
-
contentId: CONTENT_ID
|
|
13586
|
-
}
|
|
13587
|
-
]
|
|
13588
|
-
};
|
|
13589
|
-
|
|
13590
|
-
BODY.items[0][`${TYPE}Id`] = TAG_ID;
|
|
13591
|
-
|
|
13592
|
-
return await _sendRequest(instance, "Removing Tag or Collection", API_URL, "POST", undefined, BODY);
|
|
13593
|
-
}
|
|
13594
|
-
|
|
13709
|
+
|
|
13710
|
+
|
|
13711
|
+
async function _removeTagOrCollection(instance, TYPE, CONTENT_ID, CONTENT_DEFINITION_ID, TAG_ID)
|
|
13712
|
+
{
|
|
13713
|
+
const API_URL = instance.config.apiType === "admin" ? `${instance.config.serviceApiUrl}/api/admin/${TYPE}/content/delete` : `${instance.config.serviceApiUrl}/api/content/${TYPE}/delete`;
|
|
13714
|
+
|
|
13715
|
+
const BODY = {
|
|
13716
|
+
items: [
|
|
13717
|
+
{
|
|
13718
|
+
contentDefinition: CONTENT_DEFINITION_ID,
|
|
13719
|
+
contentId: CONTENT_ID
|
|
13720
|
+
}
|
|
13721
|
+
]
|
|
13722
|
+
};
|
|
13723
|
+
|
|
13724
|
+
BODY.items[0][`${TYPE}Id`] = TAG_ID;
|
|
13725
|
+
|
|
13726
|
+
return await _sendRequest(instance, "Removing Tag or Collection", API_URL, "POST", undefined, BODY);
|
|
13727
|
+
}
|
|
13728
|
+
|
|
13595
13729
|
|
|
13596
13730
|
|
|
13597
13731
|
|
|
@@ -13660,62 +13794,62 @@ async function _search(instance, QUERY, OFFSET, SIZE, FILTERS, SORT_FIELDS, SEAR
|
|
|
13660
13794
|
}
|
|
13661
13795
|
|
|
13662
13796
|
|
|
13663
|
-
function _apiExceptionHandler(error, message)
|
|
13664
|
-
{
|
|
13665
|
-
// Check if we have a response object and error message
|
|
13666
|
-
if (!error)
|
|
13667
|
-
{
|
|
13668
|
-
console.error(message);
|
|
13669
|
-
}
|
|
13670
|
-
|
|
13671
|
-
// Check if error is a string
|
|
13672
|
-
if (typeof error === "string")
|
|
13673
|
-
{
|
|
13674
|
-
console.error(`${message}: ${error}`);
|
|
13675
|
-
}
|
|
13676
|
-
else if (error.errors)
|
|
13677
|
-
{
|
|
13678
|
-
if (Array.isArray(error.errors))
|
|
13679
|
-
{
|
|
13680
|
-
let errorString = "";
|
|
13681
|
-
for (let errorIdx = 0; errorIdx < error.errors.length; errorIdx++)
|
|
13682
|
-
{
|
|
13683
|
-
errorString += `${error.errors[errorIdx].code}: ${error.errors[errorIdx].field}: ${error.errors[errorIdx].message}\n`;
|
|
13684
|
-
}
|
|
13685
|
-
console.error(`${message}: ${errorString}`);
|
|
13686
|
-
}
|
|
13687
|
-
else if (typeof error.errors === "object")
|
|
13688
|
-
{
|
|
13689
|
-
let errorString = "";
|
|
13690
|
-
for (let key in error.errors)
|
|
13691
|
-
{
|
|
13692
|
-
if (Object.prototype.hasOwnProperty.call(error.errors, key))
|
|
13693
|
-
{
|
|
13694
|
-
errorString += `${key}: ${error.errors[key]}\n`;
|
|
13695
|
-
}
|
|
13696
|
-
}
|
|
13697
|
-
console.error(`${message}: ${errorString}`);
|
|
13698
|
-
}
|
|
13699
|
-
}
|
|
13700
|
-
else
|
|
13701
|
-
{
|
|
13702
|
-
console.error(`${message}: ${error.message}`);
|
|
13703
|
-
}
|
|
13704
|
-
|
|
13705
|
-
return null;
|
|
13706
|
-
}
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
import { getRandomValues } from 'crypto';
|
|
13710
|
-
|
|
13711
|
-
function _newGuid()
|
|
13712
|
-
{
|
|
13713
|
-
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
|
|
13714
|
-
(c ^ (getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
|
13715
|
-
);
|
|
13716
|
-
}
|
|
13717
|
-
|
|
13718
|
-
|
|
13797
|
+
function _apiExceptionHandler(error, message)
|
|
13798
|
+
{
|
|
13799
|
+
// Check if we have a response object and error message
|
|
13800
|
+
if (!error)
|
|
13801
|
+
{
|
|
13802
|
+
console.error(message);
|
|
13803
|
+
}
|
|
13804
|
+
|
|
13805
|
+
// Check if error is a string
|
|
13806
|
+
if (typeof error === "string")
|
|
13807
|
+
{
|
|
13808
|
+
console.error(`${message}: ${error}`);
|
|
13809
|
+
}
|
|
13810
|
+
else if (error.errors)
|
|
13811
|
+
{
|
|
13812
|
+
if (Array.isArray(error.errors))
|
|
13813
|
+
{
|
|
13814
|
+
let errorString = "";
|
|
13815
|
+
for (let errorIdx = 0; errorIdx < error.errors.length; errorIdx++)
|
|
13816
|
+
{
|
|
13817
|
+
errorString += `${error.errors[errorIdx].code}: ${error.errors[errorIdx].field}: ${error.errors[errorIdx].message}\n`;
|
|
13818
|
+
}
|
|
13819
|
+
console.error(`${message}: ${errorString}`);
|
|
13820
|
+
}
|
|
13821
|
+
else if (typeof error.errors === "object")
|
|
13822
|
+
{
|
|
13823
|
+
let errorString = "";
|
|
13824
|
+
for (let key in error.errors)
|
|
13825
|
+
{
|
|
13826
|
+
if (Object.prototype.hasOwnProperty.call(error.errors, key))
|
|
13827
|
+
{
|
|
13828
|
+
errorString += `${key}: ${error.errors[key]}\n`;
|
|
13829
|
+
}
|
|
13830
|
+
}
|
|
13831
|
+
console.error(`${message}: ${errorString}`);
|
|
13832
|
+
}
|
|
13833
|
+
}
|
|
13834
|
+
else
|
|
13835
|
+
{
|
|
13836
|
+
console.error(`${message}: ${error.message}`);
|
|
13837
|
+
}
|
|
13838
|
+
|
|
13839
|
+
return null;
|
|
13840
|
+
}
|
|
13841
|
+
|
|
13842
|
+
|
|
13843
|
+
import { getRandomValues } from 'crypto';
|
|
13844
|
+
|
|
13845
|
+
function _newGuid()
|
|
13846
|
+
{
|
|
13847
|
+
return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
|
|
13848
|
+
(c ^ (getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
|
|
13849
|
+
);
|
|
13850
|
+
}
|
|
13851
|
+
|
|
13852
|
+
|
|
13719
13853
|
|
|
13720
13854
|
function _printDatetime(msg)
|
|
13721
13855
|
{
|
|
@@ -13726,7 +13860,7 @@ function _printDatetime(msg)
|
|
|
13726
13860
|
|
|
13727
13861
|
|
|
13728
13862
|
import { promises as fs } from 'fs';
|
|
13729
|
-
|
|
13863
|
+
import path from 'path';
|
|
13730
13864
|
|
|
13731
13865
|
async function _processFile(FILE)
|
|
13732
13866
|
{
|
|
@@ -13738,7 +13872,7 @@ async function _processFile(FILE)
|
|
|
13738
13872
|
{
|
|
13739
13873
|
FILE_PATH = FILE;
|
|
13740
13874
|
FILE = await fs.stat(FILE);
|
|
13741
|
-
FILE.
|
|
13875
|
+
FILE.originalName = path.basename(FILE_PATH);
|
|
13742
13876
|
if (!FILE.buffer)
|
|
13743
13877
|
{
|
|
13744
13878
|
FILE.buffer = await fs.readFile(FILE_PATH);
|
|
@@ -13751,7 +13885,7 @@ async function _processFile(FILE)
|
|
|
13751
13885
|
}
|
|
13752
13886
|
else
|
|
13753
13887
|
{
|
|
13754
|
-
FILE.
|
|
13888
|
+
FILE.originalName = FILE.name;
|
|
13755
13889
|
// if running in browser
|
|
13756
13890
|
if (!FILE.buffer)
|
|
13757
13891
|
{
|
|
@@ -13759,7 +13893,7 @@ async function _processFile(FILE)
|
|
|
13759
13893
|
}
|
|
13760
13894
|
}
|
|
13761
13895
|
|
|
13762
|
-
return
|
|
13896
|
+
return FILE;
|
|
13763
13897
|
}
|
|
13764
13898
|
|
|
13765
13899
|
async function _readFileAsArrayBuffer(file)
|
|
@@ -13849,70 +13983,70 @@ async function _sendRequest(instance, FUNCTION_NAME, URL, METHOD_TYPE, PARAMS, B
|
|
|
13849
13983
|
}
|
|
13850
13984
|
|
|
13851
13985
|
|
|
13852
|
-
async function _sleep(duration)
|
|
13853
|
-
{
|
|
13854
|
-
// Check for valid duration
|
|
13855
|
-
if (!duration || duration === 0)
|
|
13856
|
-
{
|
|
13857
|
-
// Ignore
|
|
13858
|
-
return;
|
|
13859
|
-
}
|
|
13860
|
-
|
|
13861
|
-
// Sleep
|
|
13862
|
-
return new Promise((resolve) => {
|
|
13863
|
-
setTimeout(() => {
|
|
13864
|
-
resolve();
|
|
13865
|
-
}, duration * 1000);
|
|
13866
|
-
});
|
|
13867
|
-
}
|
|
13868
|
-
|
|
13869
|
-
|
|
13870
|
-
|
|
13871
|
-
function _slugify(text)
|
|
13872
|
-
{
|
|
13873
|
-
if (!text || text.trim().length === 0) return "";
|
|
13874
|
-
return text
|
|
13875
|
-
.toString()
|
|
13876
|
-
.normalize("NFD")
|
|
13877
|
-
.replace(/[\u0300-\u036f]/g, "")
|
|
13878
|
-
.toLowerCase()
|
|
13879
|
-
.trim()
|
|
13880
|
-
.replace(/\s+/g, "-")
|
|
13881
|
-
.replace(/[^\w-]+/g, "")
|
|
13882
|
-
.replace(/--+/g, "-");
|
|
13883
|
-
}
|
|
13884
|
-
|
|
13885
|
-
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
async function _changeEmail(instance, EMAIL)
|
|
13890
|
-
{
|
|
13891
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/account/change-email`;
|
|
13892
|
-
|
|
13893
|
-
const BODY = {
|
|
13894
|
-
password: instance.config.password,
|
|
13895
|
-
newEmail: EMAIL
|
|
13896
|
-
};
|
|
13897
|
-
|
|
13898
|
-
return await _sendRequest(instance, "Change email", API_URL, "POST", undefined, BODY);
|
|
13899
|
-
}
|
|
13900
|
-
|
|
13901
|
-
|
|
13902
|
-
|
|
13903
|
-
|
|
13904
|
-
async function _changePassword(instance, NEW_PASSWORD)
|
|
13905
|
-
{
|
|
13906
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/account/change-password`;
|
|
13907
|
-
|
|
13908
|
-
const BODY = {
|
|
13909
|
-
password: instance.config.password,
|
|
13910
|
-
newPassword: NEW_PASSWORD
|
|
13911
|
-
};
|
|
13912
|
-
|
|
13913
|
-
return await _sendRequest(instance, "Change password", API_URL, "POST", undefined, BODY);
|
|
13914
|
-
}
|
|
13915
|
-
|
|
13986
|
+
async function _sleep(duration)
|
|
13987
|
+
{
|
|
13988
|
+
// Check for valid duration
|
|
13989
|
+
if (!duration || duration === 0)
|
|
13990
|
+
{
|
|
13991
|
+
// Ignore
|
|
13992
|
+
return;
|
|
13993
|
+
}
|
|
13994
|
+
|
|
13995
|
+
// Sleep
|
|
13996
|
+
return new Promise((resolve) => {
|
|
13997
|
+
setTimeout(() => {
|
|
13998
|
+
resolve();
|
|
13999
|
+
}, duration * 1000);
|
|
14000
|
+
});
|
|
14001
|
+
}
|
|
14002
|
+
|
|
14003
|
+
|
|
14004
|
+
|
|
14005
|
+
function _slugify(text)
|
|
14006
|
+
{
|
|
14007
|
+
if (!text || text.trim().length === 0) return "";
|
|
14008
|
+
return text
|
|
14009
|
+
.toString()
|
|
14010
|
+
.normalize("NFD")
|
|
14011
|
+
.replace(/[\u0300-\u036f]/g, "")
|
|
14012
|
+
.toLowerCase()
|
|
14013
|
+
.trim()
|
|
14014
|
+
.replace(/\s+/g, "-")
|
|
14015
|
+
.replace(/[^\w-]+/g, "")
|
|
14016
|
+
.replace(/--+/g, "-");
|
|
14017
|
+
}
|
|
14018
|
+
|
|
14019
|
+
|
|
14020
|
+
|
|
14021
|
+
|
|
14022
|
+
|
|
14023
|
+
async function _changeEmail(instance, EMAIL)
|
|
14024
|
+
{
|
|
14025
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/account/change-email`;
|
|
14026
|
+
|
|
14027
|
+
const BODY = {
|
|
14028
|
+
password: instance.config.password,
|
|
14029
|
+
newEmail: EMAIL
|
|
14030
|
+
};
|
|
14031
|
+
|
|
14032
|
+
return await _sendRequest(instance, "Change email", API_URL, "POST", undefined, BODY);
|
|
14033
|
+
}
|
|
14034
|
+
|
|
14035
|
+
|
|
14036
|
+
|
|
14037
|
+
|
|
14038
|
+
async function _changePassword(instance, NEW_PASSWORD)
|
|
14039
|
+
{
|
|
14040
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/account/change-password`;
|
|
14041
|
+
|
|
14042
|
+
const BODY = {
|
|
14043
|
+
password: instance.config.password,
|
|
14044
|
+
newPassword: NEW_PASSWORD
|
|
14045
|
+
};
|
|
14046
|
+
|
|
14047
|
+
return await _sendRequest(instance, "Change password", API_URL, "POST", undefined, BODY);
|
|
14048
|
+
}
|
|
14049
|
+
|
|
13916
14050
|
|
|
13917
14051
|
|
|
13918
14052
|
|
|
@@ -13935,74 +14069,74 @@ async function _getUser(instance)
|
|
|
13935
14069
|
}
|
|
13936
14070
|
|
|
13937
14071
|
|
|
13938
|
-
|
|
13939
|
-
|
|
13940
|
-
|
|
13941
|
-
|
|
13942
|
-
|
|
13943
|
-
async function _updateUser(instance, ADDRESS, ADDRESS2, CITY, COUNTRY,
|
|
13944
|
-
FIRST_NAME, LAST_NAME, ORGANIZATION, PHONE_NUMBER, PHONE_EXT, POSTAL_CODE, STATE)
|
|
13945
|
-
{
|
|
13946
|
-
const USER_INFO = await _getUser(instance);
|
|
13947
|
-
|
|
13948
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/account/user`;
|
|
13949
|
-
|
|
13950
|
-
const BODY = {};
|
|
13951
|
-
|
|
13952
|
-
const LOOKUPS = await _getLookups(instance);
|
|
13953
|
-
|
|
13954
|
-
const COUNTRIES_INFO = LOOKUPS.find(lookup => lookup["label"] === "Countries");
|
|
13955
|
-
const COUNTRY_SELECTED = COUNTRIES_INFO.children.find(country => country["label"] === COUNTRY);
|
|
13956
|
-
|
|
13957
|
-
const STATES_INFO = LOOKUPS.find(lookup => lookup["label"] === "States");
|
|
13958
|
-
const STATE_SELECTED = STATES_INFO.children.find(state => state["label"] === STATE);
|
|
13959
|
-
|
|
13960
|
-
const keyValues = {
|
|
13961
|
-
address: ADDRESS,
|
|
13962
|
-
address2: ADDRESS2,
|
|
13963
|
-
city: CITY,
|
|
13964
|
-
state: STATE_SELECTED,
|
|
13965
|
-
country: COUNTRY_SELECTED,
|
|
13966
|
-
firstName: FIRST_NAME,
|
|
13967
|
-
lastName: LAST_NAME,
|
|
13968
|
-
phone: PHONE_NUMBER,
|
|
13969
|
-
phoneExt: PHONE_EXT,
|
|
13970
|
-
postalCode: POSTAL_CODE,
|
|
13971
|
-
organization: ORGANIZATION,
|
|
13972
|
-
};
|
|
13973
|
-
|
|
13974
|
-
Object.entries(keyValues).forEach(([key, value]) => {
|
|
13975
|
-
BODY[key] = value !== null ? value: USER_INFO[key] ?? BODY[key];
|
|
13976
|
-
});
|
|
13977
|
-
|
|
13978
|
-
return await _sendRequest(instance, "Update user", API_URL, "PUT", undefined, BODY);
|
|
13979
|
-
}
|
|
13980
|
-
|
|
13981
|
-
|
|
13982
|
-
|
|
13983
|
-
|
|
13984
|
-
async function _addContentsToContentGroup(instance, CONTENT_GROUP_ID, CONTENTS)
|
|
13985
|
-
{
|
|
13986
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/add/${CONTENT_GROUP_ID}`;
|
|
13987
|
-
|
|
13988
|
-
const BODY = CONTENTS;
|
|
13989
|
-
|
|
13990
|
-
return await _sendRequest(instance, "Adding Contents to Content Group", API_URL, "POST", undefined, BODY);
|
|
13991
|
-
}
|
|
13992
|
-
|
|
13993
|
-
|
|
13994
|
-
|
|
13995
|
-
|
|
13996
|
-
async function _createContentGroup(instance, NAME)
|
|
13997
|
-
{
|
|
13998
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/contentGroup`;
|
|
13999
|
-
|
|
14000
|
-
const BODY = {};
|
|
14001
|
-
if (NAME) BODY.name = NAME;
|
|
14002
|
-
|
|
14003
|
-
return await _sendRequest(instance, "Creating Content Group", API_URL, "POST", undefined, BODY);
|
|
14004
|
-
}
|
|
14005
|
-
|
|
14072
|
+
|
|
14073
|
+
|
|
14074
|
+
|
|
14075
|
+
|
|
14076
|
+
|
|
14077
|
+
async function _updateUser(instance, ADDRESS, ADDRESS2, CITY, COUNTRY,
|
|
14078
|
+
FIRST_NAME, LAST_NAME, ORGANIZATION, PHONE_NUMBER, PHONE_EXT, POSTAL_CODE, STATE)
|
|
14079
|
+
{
|
|
14080
|
+
const USER_INFO = await _getUser(instance);
|
|
14081
|
+
|
|
14082
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/account/user`;
|
|
14083
|
+
|
|
14084
|
+
const BODY = {};
|
|
14085
|
+
|
|
14086
|
+
const LOOKUPS = await _getLookups(instance);
|
|
14087
|
+
|
|
14088
|
+
const COUNTRIES_INFO = LOOKUPS.find(lookup => lookup["label"] === "Countries");
|
|
14089
|
+
const COUNTRY_SELECTED = COUNTRIES_INFO.children.find(country => country["label"] === COUNTRY);
|
|
14090
|
+
|
|
14091
|
+
const STATES_INFO = LOOKUPS.find(lookup => lookup["label"] === "States");
|
|
14092
|
+
const STATE_SELECTED = STATES_INFO.children.find(state => state["label"] === STATE);
|
|
14093
|
+
|
|
14094
|
+
const keyValues = {
|
|
14095
|
+
address: ADDRESS,
|
|
14096
|
+
address2: ADDRESS2,
|
|
14097
|
+
city: CITY,
|
|
14098
|
+
state: STATE_SELECTED,
|
|
14099
|
+
country: COUNTRY_SELECTED,
|
|
14100
|
+
firstName: FIRST_NAME,
|
|
14101
|
+
lastName: LAST_NAME,
|
|
14102
|
+
phone: PHONE_NUMBER,
|
|
14103
|
+
phoneExt: PHONE_EXT,
|
|
14104
|
+
postalCode: POSTAL_CODE,
|
|
14105
|
+
organization: ORGANIZATION,
|
|
14106
|
+
};
|
|
14107
|
+
|
|
14108
|
+
Object.entries(keyValues).forEach(([key, value]) => {
|
|
14109
|
+
BODY[key] = value !== null ? value: USER_INFO[key] ?? BODY[key];
|
|
14110
|
+
});
|
|
14111
|
+
|
|
14112
|
+
return await _sendRequest(instance, "Update user", API_URL, "PUT", undefined, BODY);
|
|
14113
|
+
}
|
|
14114
|
+
|
|
14115
|
+
|
|
14116
|
+
|
|
14117
|
+
|
|
14118
|
+
async function _addContentsToContentGroup(instance, CONTENT_GROUP_ID, CONTENTS)
|
|
14119
|
+
{
|
|
14120
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/add/${CONTENT_GROUP_ID}`;
|
|
14121
|
+
|
|
14122
|
+
const BODY = CONTENTS;
|
|
14123
|
+
|
|
14124
|
+
return await _sendRequest(instance, "Adding Contents to Content Group", API_URL, "POST", undefined, BODY);
|
|
14125
|
+
}
|
|
14126
|
+
|
|
14127
|
+
|
|
14128
|
+
|
|
14129
|
+
|
|
14130
|
+
async function _createContentGroup(instance, NAME)
|
|
14131
|
+
{
|
|
14132
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/contentGroup`;
|
|
14133
|
+
|
|
14134
|
+
const BODY = {};
|
|
14135
|
+
if (NAME) BODY.name = NAME;
|
|
14136
|
+
|
|
14137
|
+
return await _sendRequest(instance, "Creating Content Group", API_URL, "POST", undefined, BODY);
|
|
14138
|
+
}
|
|
14139
|
+
|
|
14006
14140
|
|
|
14007
14141
|
|
|
14008
14142
|
|
|
@@ -14034,57 +14168,57 @@ async function _getContentGroups(instance)
|
|
|
14034
14168
|
}
|
|
14035
14169
|
|
|
14036
14170
|
|
|
14037
|
-
|
|
14038
|
-
|
|
14039
|
-
async function _getPortalGroups(instance, PORTAL_GROUPS)
|
|
14040
|
-
{
|
|
14041
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/portal/groups`;
|
|
14042
|
-
|
|
14043
|
-
const BODY = {
|
|
14044
|
-
"returnedGroupNames": PORTAL_GROUPS
|
|
14045
|
-
}
|
|
14046
|
-
|
|
14047
|
-
return await _sendRequest(instance, "Getting Portal Groups", API_URL, "POST", undefined, BODY);
|
|
14048
|
-
}
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
async function _removeContentsFromContentGroup(instance, CONTENT_GROUP_ID, CONTENTS)
|
|
14054
|
-
{
|
|
14055
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/remove/${CONTENT_GROUP_ID}`;
|
|
14056
|
-
|
|
14057
|
-
const BODY = CONTENTS;
|
|
14058
|
-
|
|
14059
|
-
return await _sendRequest(instance, "Removing Content From Content Group", API_URL, "POST", undefined, BODY);
|
|
14060
|
-
}
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
async function _renameContentGroup(instance, CONTENT_GROUP_ID, NAME)
|
|
14066
|
-
{
|
|
14067
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/${CONTENT_GROUP_ID}`;
|
|
14068
|
-
|
|
14069
|
-
const BODY = {
|
|
14070
|
-
Name: NAME
|
|
14071
|
-
};
|
|
14072
|
-
|
|
14073
|
-
return await _sendRequest(instance, "Renaming Content Group", API_URL, "PATCH", undefined, BODY);
|
|
14074
|
-
}
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
async function _shareContentGroupWithUsers(instance, CONTENT_GROUP_ID, USER_IDS)
|
|
14080
|
-
{
|
|
14081
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/share/${CONTENT_GROUP_ID}`;
|
|
14082
|
-
|
|
14083
|
-
const BODY = USER_IDS;
|
|
14084
|
-
|
|
14085
|
-
return await _sendRequest(instance, "Sharing Content Group With Users", API_URL, "POST", undefined, BODY);
|
|
14086
|
-
}
|
|
14087
|
-
|
|
14171
|
+
|
|
14172
|
+
|
|
14173
|
+
async function _getPortalGroups(instance, PORTAL_GROUPS)
|
|
14174
|
+
{
|
|
14175
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/portal/groups`;
|
|
14176
|
+
|
|
14177
|
+
const BODY = {
|
|
14178
|
+
"returnedGroupNames": PORTAL_GROUPS
|
|
14179
|
+
}
|
|
14180
|
+
|
|
14181
|
+
return await _sendRequest(instance, "Getting Portal Groups", API_URL, "POST", undefined, BODY);
|
|
14182
|
+
}
|
|
14183
|
+
|
|
14184
|
+
|
|
14185
|
+
|
|
14186
|
+
|
|
14187
|
+
async function _removeContentsFromContentGroup(instance, CONTENT_GROUP_ID, CONTENTS)
|
|
14188
|
+
{
|
|
14189
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/remove/${CONTENT_GROUP_ID}`;
|
|
14190
|
+
|
|
14191
|
+
const BODY = CONTENTS;
|
|
14192
|
+
|
|
14193
|
+
return await _sendRequest(instance, "Removing Content From Content Group", API_URL, "POST", undefined, BODY);
|
|
14194
|
+
}
|
|
14195
|
+
|
|
14196
|
+
|
|
14197
|
+
|
|
14198
|
+
|
|
14199
|
+
async function _renameContentGroup(instance, CONTENT_GROUP_ID, NAME)
|
|
14200
|
+
{
|
|
14201
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/${CONTENT_GROUP_ID}`;
|
|
14202
|
+
|
|
14203
|
+
const BODY = {
|
|
14204
|
+
Name: NAME
|
|
14205
|
+
};
|
|
14206
|
+
|
|
14207
|
+
return await _sendRequest(instance, "Renaming Content Group", API_URL, "PATCH", undefined, BODY);
|
|
14208
|
+
}
|
|
14209
|
+
|
|
14210
|
+
|
|
14211
|
+
|
|
14212
|
+
|
|
14213
|
+
async function _shareContentGroupWithUsers(instance, CONTENT_GROUP_ID, USER_IDS)
|
|
14214
|
+
{
|
|
14215
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/share/${CONTENT_GROUP_ID}`;
|
|
14216
|
+
|
|
14217
|
+
const BODY = USER_IDS;
|
|
14218
|
+
|
|
14219
|
+
return await _sendRequest(instance, "Sharing Content Group With Users", API_URL, "POST", undefined, BODY);
|
|
14220
|
+
}
|
|
14221
|
+
|
|
14088
14222
|
|
|
14089
14223
|
|
|
14090
14224
|
|
|
@@ -14098,60 +14232,60 @@ async function _stopSharingContentGroupWithUsers(instance, CONTENT_GROUP_ID, USE
|
|
|
14098
14232
|
}
|
|
14099
14233
|
|
|
14100
14234
|
|
|
14101
|
-
|
|
14102
|
-
|
|
14103
|
-
async function _guestInvite(instance, CONTENT_ID, CONTENT_DEFINITION_ID, USER_ID,
|
|
14104
|
-
EMAILS, CONTENT_SECURITY_ATTRIBUTE)
|
|
14105
|
-
{
|
|
14106
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/account/invite-user`;
|
|
14107
|
-
|
|
14108
|
-
const BODY = {
|
|
14109
|
-
contentId: CONTENT_ID,
|
|
14110
|
-
contentDefinitionId: CONTENT_DEFINITION_ID,
|
|
14111
|
-
userId: USER_ID,
|
|
14112
|
-
emails: EMAILS,
|
|
14113
|
-
contentSecurityAttribute: CONTENT_SECURITY_ATTRIBUTE
|
|
14114
|
-
};
|
|
14115
|
-
|
|
14116
|
-
return await _sendRequest(instance, "Guest Invite", API_URL, "POST", undefined, BODY);
|
|
14117
|
-
}
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
async function _registerGuest(instance, EMAIL, FIRST_NAME, LAST_NAME, PASSWORD)
|
|
14123
|
-
{
|
|
14124
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/account/register-guest`;
|
|
14125
|
-
|
|
14126
|
-
const BODY = {
|
|
14127
|
-
email: EMAIL,
|
|
14128
|
-
firstName: FIRST_NAME,
|
|
14129
|
-
lastName: LAST_NAME,
|
|
14130
|
-
password: PASSWORD
|
|
14131
|
-
};
|
|
14132
|
-
|
|
14133
|
-
return await _sendRequest(instance, "Register guest", API_URL, "POST", undefined, BODY);
|
|
14134
|
-
}
|
|
14135
|
-
|
|
14136
|
-
|
|
14137
|
-
|
|
14138
|
-
|
|
14139
|
-
async function _removeGuest(instance, CONTENT_ID, CONTENT_DEFINITION_ID, USER_ID,
|
|
14140
|
-
EMAILS, CONTENT_SECURITY_ATTRIBUTE)
|
|
14141
|
-
{
|
|
14142
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/account/remove-user`;
|
|
14143
|
-
|
|
14144
|
-
const BODY = {
|
|
14145
|
-
contentId: CONTENT_ID,
|
|
14146
|
-
contentDefinitionId: CONTENT_DEFINITION_ID,
|
|
14147
|
-
userId: USER_ID,
|
|
14148
|
-
emails: EMAILS,
|
|
14149
|
-
contentSecurityAttribute: CONTENT_SECURITY_ATTRIBUTE
|
|
14150
|
-
};
|
|
14151
|
-
|
|
14152
|
-
return await _sendRequest(instance, "Remove guest", API_URL, "POST", undefined, BODY);
|
|
14153
|
-
}
|
|
14154
|
-
|
|
14235
|
+
|
|
14236
|
+
|
|
14237
|
+
async function _guestInvite(instance, CONTENT_ID, CONTENT_DEFINITION_ID, USER_ID,
|
|
14238
|
+
EMAILS, CONTENT_SECURITY_ATTRIBUTE)
|
|
14239
|
+
{
|
|
14240
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/account/invite-user`;
|
|
14241
|
+
|
|
14242
|
+
const BODY = {
|
|
14243
|
+
contentId: CONTENT_ID,
|
|
14244
|
+
contentDefinitionId: CONTENT_DEFINITION_ID,
|
|
14245
|
+
userId: USER_ID,
|
|
14246
|
+
emails: EMAILS,
|
|
14247
|
+
contentSecurityAttribute: CONTENT_SECURITY_ATTRIBUTE
|
|
14248
|
+
};
|
|
14249
|
+
|
|
14250
|
+
return await _sendRequest(instance, "Guest Invite", API_URL, "POST", undefined, BODY);
|
|
14251
|
+
}
|
|
14252
|
+
|
|
14253
|
+
|
|
14254
|
+
|
|
14255
|
+
|
|
14256
|
+
async function _registerGuest(instance, EMAIL, FIRST_NAME, LAST_NAME, PASSWORD)
|
|
14257
|
+
{
|
|
14258
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/account/register-guest`;
|
|
14259
|
+
|
|
14260
|
+
const BODY = {
|
|
14261
|
+
email: EMAIL,
|
|
14262
|
+
firstName: FIRST_NAME,
|
|
14263
|
+
lastName: LAST_NAME,
|
|
14264
|
+
password: PASSWORD
|
|
14265
|
+
};
|
|
14266
|
+
|
|
14267
|
+
return await _sendRequest(instance, "Register guest", API_URL, "POST", undefined, BODY);
|
|
14268
|
+
}
|
|
14269
|
+
|
|
14270
|
+
|
|
14271
|
+
|
|
14272
|
+
|
|
14273
|
+
async function _removeGuest(instance, CONTENT_ID, CONTENT_DEFINITION_ID, USER_ID,
|
|
14274
|
+
EMAILS, CONTENT_SECURITY_ATTRIBUTE)
|
|
14275
|
+
{
|
|
14276
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/account/remove-user`;
|
|
14277
|
+
|
|
14278
|
+
const BODY = {
|
|
14279
|
+
contentId: CONTENT_ID,
|
|
14280
|
+
contentDefinitionId: CONTENT_DEFINITION_ID,
|
|
14281
|
+
userId: USER_ID,
|
|
14282
|
+
emails: EMAILS,
|
|
14283
|
+
contentSecurityAttribute: CONTENT_SECURITY_ATTRIBUTE
|
|
14284
|
+
};
|
|
14285
|
+
|
|
14286
|
+
return await _sendRequest(instance, "Remove guest", API_URL, "POST", undefined, BODY);
|
|
14287
|
+
}
|
|
14288
|
+
|
|
14155
14289
|
|
|
14156
14290
|
|
|
14157
14291
|
|
|
@@ -14366,17 +14500,17 @@ async function _clearWatchlist(instance, USER_ID)
|
|
|
14366
14500
|
}
|
|
14367
14501
|
|
|
14368
14502
|
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
async function _createForm(instance, CONTENT_DEFINITION_ID, FORM_INFO)
|
|
14372
|
-
{
|
|
14373
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/media/form/${CONTENT_DEFINITION_ID}`;
|
|
14374
|
-
|
|
14375
|
-
const BODY = FORM_INFO;
|
|
14376
|
-
|
|
14377
|
-
return await _sendRequest(instance, "Creating Form", API_URL, "POST", undefined, BODY);
|
|
14378
|
-
}
|
|
14379
|
-
|
|
14503
|
+
|
|
14504
|
+
|
|
14505
|
+
async function _createForm(instance, CONTENT_DEFINITION_ID, FORM_INFO)
|
|
14506
|
+
{
|
|
14507
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/media/form/${CONTENT_DEFINITION_ID}`;
|
|
14508
|
+
|
|
14509
|
+
const BODY = FORM_INFO;
|
|
14510
|
+
|
|
14511
|
+
return await _sendRequest(instance, "Creating Form", API_URL, "POST", undefined, BODY);
|
|
14512
|
+
}
|
|
14513
|
+
|
|
14380
14514
|
|
|
14381
14515
|
|
|
14382
14516
|
|
|
@@ -14468,25 +14602,25 @@ async function _getSiteConfig(instance, ID)
|
|
|
14468
14602
|
}
|
|
14469
14603
|
|
|
14470
14604
|
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
async function _mediaSearch(instance, SEARCH_QUERY, IDS, SORT_FIELDS,
|
|
14474
|
-
PAGE_OFFSET, PAGE_SIZE)
|
|
14475
|
-
{
|
|
14476
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/media/search`;
|
|
14477
|
-
|
|
14478
|
-
const BODY = {
|
|
14479
|
-
searchQuery: SEARCH_QUERY,
|
|
14480
|
-
ids: IDS,
|
|
14481
|
-
sortFields: SORT_FIELDS
|
|
14482
|
-
};
|
|
14483
|
-
|
|
14484
|
-
PAGE_OFFSET ? BODY["pageOffset"] = PAGE_OFFSET : BODY["pageOffset"] = 0;
|
|
14485
|
-
PAGE_SIZE ? BODY["pageSize"] = PAGE_SIZE : BODY["pageSize"] = 100;
|
|
14486
|
-
|
|
14487
|
-
return await _sendRequest(instance, "Media Search", API_URL, "POST", undefined, BODY);
|
|
14488
|
-
}
|
|
14489
|
-
|
|
14605
|
+
|
|
14606
|
+
|
|
14607
|
+
async function _mediaSearch(instance, SEARCH_QUERY, IDS, SORT_FIELDS,
|
|
14608
|
+
PAGE_OFFSET, PAGE_SIZE)
|
|
14609
|
+
{
|
|
14610
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/media/search`;
|
|
14611
|
+
|
|
14612
|
+
const BODY = {
|
|
14613
|
+
searchQuery: SEARCH_QUERY,
|
|
14614
|
+
ids: IDS,
|
|
14615
|
+
sortFields: SORT_FIELDS
|
|
14616
|
+
};
|
|
14617
|
+
|
|
14618
|
+
PAGE_OFFSET ? BODY["pageOffset"] = PAGE_OFFSET : BODY["pageOffset"] = 0;
|
|
14619
|
+
PAGE_SIZE ? BODY["pageSize"] = PAGE_SIZE : BODY["pageSize"] = 100;
|
|
14620
|
+
|
|
14621
|
+
return await _sendRequest(instance, "Media Search", API_URL, "POST", undefined, BODY);
|
|
14622
|
+
}
|
|
14623
|
+
|
|
14490
14624
|
|
|
14491
14625
|
|
|
14492
14626
|
|