@nomad-media/full 1.1.19-alpha.2 → 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.
@@ -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 [FILE_PROPS, FILE_PATH] = await _processFile(FILE);
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,9 @@ class NomadMediaSDK {
593
594
 
594
595
  const DETAILS = await _getAssetDetails(this, EXISTING_ASSET_ID);
595
596
 
596
- return DETAILS.relatedAssets.find(asset => asset.url.includes(path.basename(FILE_PATH))).id;
597
+ const ASSET_INFO = DETAILS.relatedAssets.find(asset => asset.url.includes(FILE_PROPS.originalName));
598
+ if (!ASSET_INFO) throw new Error("Asset ID not found");
599
+ return ASSET_INFO.id;
597
600
  }
598
601
  catch (error)
599
602
  {
@@ -1760,6 +1763,11 @@ class NomadMediaSDK {
1760
1763
  await this._init();
1761
1764
  }
1762
1765
 
1766
+ if (this.config.apiType !== "admin")
1767
+ {
1768
+ throw new Error ("This function is only available for admin API type.");
1769
+ }
1770
+
1763
1771
  _printDatetime(`Getting Live Schedule of Event: ${EVENT_ID}`);
1764
1772
 
1765
1773
  try
@@ -1791,6 +1799,11 @@ class NomadMediaSDK {
1791
1799
  await this._init();
1792
1800
  }
1793
1801
 
1802
+ if (this.config.apiType !== "admin")
1803
+ {
1804
+ throw new Error ("This function is only available for admin API type.");
1805
+ }
1806
+
1794
1807
  _printDatetime(`Starting Live Schedule of Event: ${EVENT_ID}`);
1795
1808
 
1796
1809
  try
@@ -1820,6 +1833,11 @@ class NomadMediaSDK {
1820
1833
  {
1821
1834
  await this._init();
1822
1835
  }
1836
+
1837
+ if (this.config.apiType !== "admin")
1838
+ {
1839
+ throw new Error ("This function is only available for admin API type.");
1840
+ }
1823
1841
 
1824
1842
  _printDatetime(`Stopping Live Schedule of Event: ${EVENT_ID}`);
1825
1843
 
@@ -1835,6 +1853,87 @@ class NomadMediaSDK {
1835
1853
  }
1836
1854
  }
1837
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
+ }
1838
1937
 
1839
1938
  // live channel functions
1840
1939
  /**
@@ -10433,65 +10532,65 @@ async function _getContent(instance, CONTENT_ID, CONTENT_DEFINITION_ID, IS_REVIS
10433
10532
  }
10434
10533
 
10435
10534
 
10436
-
10437
-
10438
- import deepEqual from "deep-equal";
10439
-
10440
- async function _updateContent(instance, CONTENT_ID, CONTENT_DEFINITION_ID, PROPERTIES, LANGUAGE_ID)
10441
- {
10442
- const API_URL = `${instance.config.serviceApiUrl}/api/content/${CONTENT_ID}`;
10443
-
10444
- let body = null;
10445
- try
10446
- {
10447
- body = await _getContent(instance, CONTENT_ID, CONTENT_DEFINITION_ID, null);
10448
-
10449
- if (body.contentDefinitionId !== CONTENT_DEFINITION_ID) body.contentDefinitionId = CONTENT_DEFINITION_ID;
10450
- if (body.contentId !== CONTENT_ID) body.contentId = CONTENT_ID;
10451
- if (body.language !== LANGUAGE_ID) body.language = LANGUAGE_ID;
10452
-
10453
- _updateProperties(body, PROPERTIES);
10454
- }
10455
- catch (error)
10456
- {
10457
- body = {
10458
- contentDefinitionId: CONTENT_DEFINITION_ID,
10459
- contentId: CONTENT_ID,
10460
- language: LANGUAGE_ID,
10461
- properties: PROPERTIES
10462
- }
10463
- }
10464
-
10465
- return await _sendRequest(instance, "Update Content", API_URL, "PUT", undefined, body);
10466
- }
10467
-
10468
- function _updateProperties(body, properties) {
10469
- for (const property in properties) {
10470
- if (Array.isArray(properties[property]))
10471
- {
10472
- for (let i = 0; i < properties[property].length; ++i)
10473
- {
10474
- if (!deepEqual(body.properties[property][i], properties[property][i]))
10475
- {
10476
- body.properties[property][i] = properties[property][i];
10477
- }
10478
- }
10479
- }
10480
- else if (typeof properties[property] === 'object')
10481
- {
10482
- if (!deepEqual(body.properties[property], properties[property]))
10483
- {
10484
- body.properties[property] = properties[property];
10485
- }
10486
- }
10487
- else if (body.properties[property] !== properties[property])
10488
- {
10489
- body.properties[property] = properties[property];
10490
- }
10491
- }
10492
- }
10493
-
10494
-
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
+
10495
10594
 
10496
10595
 
10497
10596
 
@@ -10622,6 +10721,43 @@ async function _stopLiveSchedule(instance, EVENT_ID)
10622
10721
 
10623
10722
 
10624
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
+
10625
10761
  async function _clipLiveChannel(instance, CHANNEL_ID, START_TIME_CODE, END_TIME_CODE,
10626
10762
  TITLE, OUTPUT_FOLDER_ID, TAGS, COLLECTIONS, RELATED_CONTENTS, VIDEO_BITRATE,
10627
10763
  AUDIO_TRACKS)
@@ -10644,64 +10780,64 @@ async function _clipLiveChannel(instance, CHANNEL_ID, START_TIME_CODE, END_TIME_
10644
10780
  }
10645
10781
 
10646
10782
 
10647
-
10648
-
10649
-
10650
-
10651
-
10652
-
10653
- async function _createLiveChannel(instance, NAME, THUMBNAIL_IMAGE_ID, ARCHIVE_FOLDER_ASSET_ID,
10654
- ENABLE_HIGH_AVAILABILITY, ENABLE_LIVE_CLIPPING, IS_SECURE_OUTPUT, IS_OUTPUT_SCREENSHOTS,
10655
- TYPE, EXTERNAL_URL, EXTERNAL_OUTPUT_PROFILES, SECURITY_GROUPS)
10656
- {
10657
- const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel`;
10658
-
10659
- const BODY = {
10660
- name: NAME,
10661
- routeName: _slugify(NAME),
10662
- enableHighAvailability: ENABLE_HIGH_AVAILABILITY,
10663
- enableLiveClipping: ENABLE_LIVE_CLIPPING,
10664
- externalOutputProfiles: EXTERNAL_OUTPUT_PROFILES,
10665
- isSecureOutput: IS_SECURE_OUTPUT,
10666
- outputScreenshots: IS_OUTPUT_SCREENSHOTS,
10667
- type: {
10668
- id: _LIVE_CHANNEL_TYPES[TYPE],
10669
- descrption: TYPE
10670
- }
10671
- };
10672
-
10673
-
10674
- if (THUMBNAIL_IMAGE_ID)
10675
- {
10676
- BODY.thumbnailImage = { id: THUMBNAIL_IMAGE_ID };
10677
- }
10678
-
10679
- if (ARCHIVE_FOLDER_ASSET_ID)
10680
- {
10681
- BODY.archiveFolderAsset = { id: ARCHIVE_FOLDER_ASSET_ID };
10682
- }
10683
-
10684
- // Set the appropriate fields based on the channel type
10685
- if (TYPE === "External")
10686
- {
10687
- BODY.externalUrl = EXTERNAL_URL;
10688
- }
10689
-
10690
- if (SECURITY_GROUPS) {
10691
- const NOMAD_SECURITY_GROUPS = await _getSecurityGroups(instance);
10692
-
10693
- BODY.securityGroups = NOMAD_SECURITY_GROUPS.items
10694
- .filter(group => SECURITY_GROUPS.includes(group.description))
10695
- .map(group => ({
10696
- description: group.description,
10697
- id: group.id
10698
- }));
10699
- }
10700
-
10701
- return await _sendRequest(instance, "Create Live Channel", API_URL, "POST", undefined, BODY);
10702
- }
10703
-
10704
-
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
+
10705
10841
 
10706
10842
 
10707
10843
 
@@ -10744,38 +10880,38 @@ async function _deleteLiveChannel(instance, CHANNEL_ID, DELETE_INPUTS)
10744
10880
  }
10745
10881
 
10746
10882
 
10747
-
10748
-
10749
- async function _getLiveChannelInputsIds(instance, CHANNEL_ID)
10750
- {
10751
- // Declare empty array for the IDs
10752
- const INPUT_IDS = [];
10753
-
10754
- // Get all the schedule events for the channel
10755
- if (instance.debug) console.log(`Getting Live Channel Schedule Events...`);
10756
-
10757
- const CHANNEL_EVENTS = await _getLiveChannelScheduleEvents(instance, CHANNEL_ID);
10758
-
10759
- // If there are schedule events
10760
- if (CHANNEL_EVENTS && CHANNEL_EVENTS.length > 0) {
10761
- // Loop schedule events
10762
- CHANNEL_EVENTS.forEach((SCHEDULE_EVENT) =>
10763
- {
10764
- // Check if schedule event is input type
10765
- if (SCHEDULE_EVENT && SCHEDULE_EVENT.liveInput && SCHEDULE_EVENT.liveInput != null) {
10766
- // If it has a valid lookupId add it to the array
10767
- if (SCHEDULE_EVENT.liveInput.lookupId) {
10768
- INPUT_IDS.push(SCHEDULE_EVENT.liveInput.lookupId);
10769
- }
10770
- }
10771
- });
10772
- }
10773
-
10774
- // Return the array of inputs IDs
10775
- return INPUT_IDS;
10776
- }
10777
-
10778
-
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
+
10779
10915
 
10780
10916
 
10781
10917
 
@@ -10787,52 +10923,52 @@ async function _getLiveChannelScheduleEvents(instance, CHANNEL_ID)
10787
10923
  }
10788
10924
 
10789
10925
 
10790
-
10791
-
10792
- async function _getLiveChannelStatusMessage(instance, CHANNEL_ID) {
10793
- // Get the live channel
10794
- if (instance.debug)
10795
- {
10796
- console.log(`Getting Live Channel...`);
10797
- }
10798
- const CHANNEL = await _getLiveChannel(instance, CHANNEL_ID);
10799
-
10800
- // Check if channel was found
10801
- if (CHANNEL) {
10802
- // Check if there are status messages
10803
- if (CHANNEL.statusMessages && CHANNEL.statusMessages.length > 0) {
10804
- // Return the first status message
10805
- return CHANNEL.statusMessages[0];
10806
- }
10807
- }
10808
-
10809
- // There are no status messages
10810
- return false;
10811
- }
10812
-
10813
-
10814
-
10815
-
10816
-
10817
- async function _getLiveChannelStatus(instance, CHANNEL_ID) {
10818
- // Get the live channel
10819
- if (instance.debug)
10820
- {
10821
- console.log(`Getting Live Channel...`);
10822
- }
10823
- const CHANNEL = await _getLiveChannel(instance, CHANNEL_ID);
10824
-
10825
- // Check if live channel was found
10826
- if (CHANNEL) {
10827
- // Return the status of the live channel
10828
- return CHANNEL.status.description;
10829
- }
10830
-
10831
- // Live channel was not found
10832
- return "Deleted";
10833
- }
10834
-
10835
-
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
+
10836
10972
 
10837
10973
 
10838
10974
 
@@ -10883,33 +11019,33 @@ const _SECURITY_GROUPS = {
10883
11019
  }
10884
11020
 
10885
11021
 
10886
- const _LIVE_CHANNEL_STATUSES = {
10887
- CreateFailed: "Create Failed",
10888
- Creating: "Creating",
10889
- Deleted: "Deleted",
10890
- Deleting: "Deleting",
10891
- Error: "Error",
10892
- Idle: "Idle",
10893
- New: "New",
10894
- Pause: "Pause",
10895
- Recovering: "Recovering",
10896
- Running: "Running",
10897
- Starting: "Starting",
10898
- Stopping: "Stopping",
10899
- Unmanaged: "Unmanaged",
10900
- UpdateFailed: "Update Failed",
10901
- Updating: "Updating"
10902
- };
10903
-
10904
-
10905
-
10906
- const _LIVE_CHANNEL_TYPES = {
10907
- External: "2bf01dd4-0a9c-4168-a61b-27e135732103",
10908
- IVS: "2bf01dd4-0a9c-4168-a61b-27e135732102",
10909
- Normal: "2bf01dd4-0a9c-4168-a61b-27e135732100",
10910
- Realtime: "2bf01dd4-0a9c-4168-a61b-27e135732104"
10911
- };
10912
-
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
+
10913
11049
 
10914
11050
 
10915
11051
 
@@ -10921,317 +11057,47 @@ async function _nextEvent(instance, CHANNEL_ID)
10921
11057
  }
10922
11058
 
10923
11059
 
10924
-
10925
-
10926
-
10927
-
10928
- async function _startLiveChannel(instance, CHANNEL_ID, WAIT_FOR_START)
10929
- {
10930
- const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/start`
10931
-
10932
- await _sendRequest(instance, "Start Live Channel", API_URL, "POST", undefined, undefined);
10933
-
10934
- if (!WAIT_FOR_START) return;
10935
- await _waitForLiveChannelStatus(instance, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Running, 1200, 20);
10936
- }
10937
-
10938
11060
 
10939
11061
 
10940
11062
 
10941
- async function _startOutputTracking(instance, CHANNEL_ID)
11063
+
11064
+ async function _startLiveChannel(instance, CHANNEL_ID, WAIT_FOR_START)
10942
11065
  {
10943
- const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/startOutputTracking`;
11066
+ const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/start`
10944
11067
 
10945
- return await _sendRequest(instance, "Start Output Tracking", API_URL, "POST", undefined, undefined);
10946
- }
11068
+ await _sendRequest(instance, "Start Live Channel", API_URL, "POST", undefined, undefined);
10947
11069
 
11070
+ if (!WAIT_FOR_START) return;
11071
+ await _waitForLiveChannelStatus(instance, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Running, 1200, 20);
11072
+ }
10948
11073
 
10949
-
10950
-
10951
-
10952
-
10953
- async function _stopLiveChannel(instance, CHANNEL_ID, WAIT_FOR_STOP)
10954
- {
10955
- const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/stop`
10956
-
10957
- await _sendRequest(instance, "Stop Live Channel", API_URL, "POST", undefined, undefined);
10958
-
10959
- if (!WAIT_FOR_STOP) return;
10960
- await _waitForLiveChannelStatus(instance, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Idle, 1200, 20);
10961
- }
10962
-
10963
-
10964
-
10965
-
10966
-
10967
-
10968
-
10969
-
10970
-
10971
-
10972
-
10973
- async function _updateLiveChannel(instance, ID, NAME, THUMBNAIL_IMAGE_ID, ARCHIVE_FOLDER_ASSET_ID,
10974
- ENABLE_HIGH_AVAILABILITY, ENABLE_LIVE_CLIPPING, IS_SECURE_OUTPUT, OUTPUT_SCREENSHOTS, TYPE,
10975
- EXTERNAL_URL, EXTERNAL_OUTPUT_PROFILES, SECURITY_GROUPS)
10976
- {
10977
- const BODY = await _getLiveChannel(instance, ID);
10978
-
10979
- const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel`;
10980
-
10981
- if (NAME && NAME !== BODY.name)
10982
- {
10983
- BODY.name = NAME;
10984
- BODY.routeName = _slugify(NAME);
10985
- }
10986
- if (THUMBNAIL_IMAGE_ID && THUMBNAIL_IMAGE_ID !== BODY.thumbnailImage) BODY.thumbnailImage = { id: THUMBNAIL_IMAGE_ID };
10987
- if (ARCHIVE_FOLDER_ASSET_ID && ARCHIVE_FOLDER_ASSET_ID !== BODY.archiveFolderAsset.id) BODY.archiveFolderAsset = { id: ARCHIVE_FOLDER_ASSET_ID };
10988
- if (ENABLE_HIGH_AVAILABILITY && ENABLE_HIGH_AVAILABILITY !== BODY.enableHighAvailability) BODY.enableHighAvailability = ENABLE_HIGH_AVAILABILITY;
10989
- if (ENABLE_LIVE_CLIPPING && ENABLE_LIVE_CLIPPING !== BODY.enableLiveClipping) BODY.enableLiveClipping = ENABLE_LIVE_CLIPPING;
10990
- if (IS_SECURE_OUTPUT && IS_SECURE_OUTPUT !== BODY.isSecureOutput) BODY.isSecureOutput = IS_SECURE_OUTPUT;
10991
- if (OUTPUT_SCREENSHOTS && OUTPUT_SCREENSHOTS !== BODY.outputScreenshots) BODY.outputScreenshots = OUTPUT_SCREENSHOTS;
10992
- if (TYPE && _LIVE_CHANNEL_STATUSES[TYPE] !== BODY.type.id) BODY.type = { id: _LIVE_CHANNEL_TYPES[TYPE] };
10993
- if (EXTERNAL_OUTPUT_PROFILES && EXTERNAL_OUTPUT_PROFILES !== BODY.externalOutputProfiles) BODY.externalOutputProfiles = EXTERNAL_OUTPUT_PROFILES;
10994
-
10995
-
10996
- // Set the appropriate fields based on the channel type
10997
- if (TYPE === "External") {
10998
- if (EXTERNAL_URL && EXTERNAL_URL !== BODY.externalUrl) BODY.externalUrl = EXTERNAL_URL;
10999
- }
11000
- else
11001
- {
11002
- if (EXTERNAL_URL && BODY.externalUrl) delete BODY.externalUrl;
11003
- }
11004
-
11005
- if (SECURITY_GROUPS) {
11006
- const NOMAD_SECURITY_GROUPS = await _getSecurityGroups(instance);
11007
-
11008
- const FILTERED_SECURITY_GROUPS = NOMAD_SECURITY_GROUPS
11009
- .filter(group => SECURITY_GROUPS.includes(group.description))
11010
- .map(group => ({
11011
- description: group.description,
11012
- id: group.id
11013
- }));
11014
-
11015
- if (FILTERED_SECURITY_GROUPS !== BODY.securityGroups) BODY.securityGroups = FILTERED_SECURITY_GROUPS;
11016
- }
11017
-
11018
- const INFO = await _sendRequest(instance, "Update Live Channel", API_URL, "PUT", undefined, BODY);
11019
-
11020
- await _waitForLiveChannelStatus(instance, INFO.id, _LIVE_CHANNEL_STATUSES.Idle, 120, 2);
11021
-
11022
- return INFO;
11023
- }
11024
-
11025
-
11026
-
11027
-
11028
-
11029
-
11030
-
11031
-
11032
- async function _waitForLiveChannelStatus(instance, CHANNEL_ID, STATUS_TO_WAIT_FOR, TIMEOUT = 30,
11033
- POLL_INTERVAL = 2)
11034
- {
11035
- const startingTime = new Date().getTime();
11036
-
11037
- // Elapsed time in seconds
11038
- let elapsedTime = 0;
11039
-
11040
- while (elapsedTime < TIMEOUT)
11041
- {
11042
- // Get the Live Channel status
11043
- const CHANNEL_STATUS = await _getLiveChannelStatus(instance, CHANNEL_ID);
11044
-
11045
- // If channel is in statusToWaitFor return
11046
- if (CHANNEL_STATUS === STATUS_TO_WAIT_FOR)
11047
- {
11048
- // Give feedback to the console
11049
- if (instance.debug)
11050
- {
11051
- console.log(`Live Channel [${CHANNEL_ID}] transitioned to status [${STATUS_TO_WAIT_FOR}]`);
11052
- }
11053
- return;
11054
- }
11055
-
11056
- // Give feedback to the console
11057
- console.log(`Live Channel [${CHANNEL_ID}] current status is [${CHANNEL_STATUS}]`);
11058
-
11059
- // Check for Error status
11060
- if (CHANNEL_STATUS === "Error")
11061
- {
11062
- // Get the error message
11063
- const CHANNEL_STATUS_MESSAGE = await _getLiveChannelStatusMessage(instance,
11064
- CHANNEL_ID);
11065
-
11066
- // Can't continue if Live Channel is in error status
11067
- throw new Error(`Live Channel [${CHANNEL_ID}] is in [Error] status: ${CHANNEL_STATUS_MESSAGE}`);
11068
- }
11069
-
11070
- // Calculate elapsed time in seconds
11071
- elapsedTime = (new Date().getTime() - startingTime) / 1000;
11072
-
11073
- // Give feedback to the console
11074
- if (instance.debug)
11075
- {
11076
- console.log(`Waiting for Live Channel [${CHANNEL_ID}] to transition to status [${STATUS_TO_WAIT_FOR}]... [${Math.round(elapsedTime)}/${TIMEOUT}]`);
11077
- }
11078
-
11079
- // Check for timeout
11080
- if (elapsedTime > TIMEOUT)
11081
- {
11082
- break;
11083
- }
11084
-
11085
- // Wait poll interval
11086
- await _sleep(POLL_INTERVAL);
11087
- }
11088
-
11089
- throw new Error(`Waiting for Live Channel [${CHANNEL_ID}] to transition to status [${STATUS_TO_WAIT_FOR}] timed out`);
11090
- }
11091
-
11092
-
11093
-
11094
-
11095
-
11096
-
11097
-
11098
-
11099
- async function _createLiveInput(instance, NAME, SOURCE, TYPE, IS_STANDARD, VIDEO_ASSET_ID,
11100
- DESTINATIONS, SOURCES)
11101
- {
11102
- const API_URL = `${instance.config.serviceApiUrl}/api/liveInput`;
11103
-
11104
- const BODY = {
11105
- name: NAME,
11106
- internalName: _slugify(NAME),
11107
- type: {
11108
- id: _LIVE_INPUT_TYPES[TYPE],
11109
- description: TYPE
11110
- }
11111
- };
11112
-
11113
- // Set the appropriate fields based on the type
11114
- if (TYPE == "RTMP_PUSH")
11115
- {
11116
- if (SOURCE) BODY["sourceCidr"] = SOURCE
11117
- }
11118
- else if (TYPE === "RTMP_PULL" || TYPE === "RTP_PUSH" || TYPE === "URL_PULL")
11119
- {
11120
- if (SOURCE) BODY["sources"] = [{ "url": SOURCE }]
11121
- }
11122
-
11123
- if (IS_STANDARD) BODY["isStandard"] = IS_STANDARD;
11124
- if (VIDEO_ASSET_ID) BODY["videoAsset"] = { id: VIDEO_ASSET_ID };
11125
- if (DESTINATIONS) BODY["destinations"] = DESTINATIONS;
11126
- if (SOURCES) BODY["sources"] = SOURCES;
11127
-
11128
- return await _sendRequest(instance, "Creating Live Input", API_URL, "POST", undefined, BODY);
11129
- }
11130
-
11131
-
11132
11074
 
11133
11075
 
11134
11076
 
11135
- async function _deleteLiveInput(instance, INPUT_ID)
11077
+ async function _startOutputTracking(instance, CHANNEL_ID)
11136
11078
  {
11137
- const API_URL = `${instance.config.serviceApiUrl}/api/liveInput/${INPUT_ID}`;
11079
+ const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/startOutputTracking`;
11138
11080
 
11139
- return await _sendRequest(instance, "Delete Live Input", API_URL, "DELETE", undefined, undefined);
11081
+ return await _sendRequest(instance, "Start Output Tracking", API_URL, "POST", undefined, undefined);
11140
11082
  }
11141
11083
 
11142
11084
 
11143
11085
 
11144
-
11145
-
11146
-
11147
- async function _getLiveInputStatusMessage(instance, INPUT_ID)
11148
- {
11149
- // Get the live input
11150
- if (instance.debug) console.log(`Getting Live Input...`);
11151
- const INPUT = await _getLiveInput(instance, INPUT_ID);
11152
-
11153
- // Check if input was found
11154
- if (INPUT)
11155
- {
11156
- // Check if there is status message
11157
- if (INPUT.statusMessage && INPUT.statusMessage)
11158
- {
11159
- // Return input status message
11160
- return INPUT.statusMessage;
11161
- }
11162
- }
11163
-
11164
- // There is no status message
11165
- return "";
11166
- }
11167
-
11168
-
11169
-
11170
-
11171
-
11172
- async function _getLiveInputStatus(instance, INPUT_ID)
11173
- {
11174
- // Get the live input
11175
- if (instance.debug) console.log(`Getting Live Input...`);
11176
- const INPUT = await _getLiveInput(instance, INPUT_ID);
11177
-
11178
- // Check if input was found
11179
- if (INPUT)
11180
- {
11181
- // Return the status of the input
11182
- return INPUT.status.description;
11183
- }
11184
-
11185
- // Input was not found
11186
- return "Deleted";
11187
- }
11188
-
11189
11086
 
11190
11087
 
11191
11088
 
11192
- async function _getLiveInput(instance, INPUT_ID)
11089
+ async function _stopLiveChannel(instance, CHANNEL_ID, WAIT_FOR_STOP)
11193
11090
  {
11194
- const API_URL = `${instance.config.serviceApiUrl}/api/liveInput/${INPUT_ID}`;
11195
-
11196
- return await _sendRequest(instance, "Get Live Input", API_URL, "GET", undefined, undefined);
11197
- }
11198
-
11199
-
11200
-
11091
+ const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/stop`
11201
11092
 
11202
- async function _getLiveInputs(instance)
11203
- {
11204
- const API_URL = `${instance.config.serviceApiUrl}/api/liveInput`;
11093
+ await _sendRequest(instance, "Stop Live Channel", API_URL, "POST", undefined, undefined);
11205
11094
 
11206
- return await _sendRequest(instance, "Get Live Inputs", API_URL, "GET", undefined, undefined);
11095
+ if (!WAIT_FOR_STOP) return;
11096
+ await _waitForLiveChannelStatus(instance, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Idle, 1200, 20);
11207
11097
  }
11208
11098
 
11209
11099
 
11210
- const _LIVE_INPUT_STATUSES = {
11211
- Attached: "Attached",
11212
- Attaching: "Attaching",
11213
- CreateFailed: "Create Failed",
11214
- Creating: "Creating",
11215
- Deleted: "Deleted",
11216
- Deleting: "Deleting",
11217
- Detached: "Detached",
11218
- Detaching: "Detaching",
11219
- Error: "Error",
11220
- Paused: "Paused",
11221
- Updating: "Updating"
11222
- };
11223
-
11224
-
11225
11100
 
11226
- const _LIVE_INPUT_TYPES = {
11227
- RTMP_PULL: "78acb07d-ba87-48fa-ad8f-c00e318a1254",
11228
- RTMP_PUSH: "78acb07d-ba87-48fa-ad8f-c00e318a1253",
11229
- RTP_PUSH: "78acb07d-ba87-48fa-ad8f-c00e318a1252",
11230
- UDP_PUSH: "78acb07d-ba87-48fa-ad8f-c00e318a1251",
11231
- URL_PULL: "78acb07d-ba87-48fa-ad8f-c00e318a1255"
11232
- };
11233
-
11234
-
11235
11101
 
11236
11102
 
11237
11103
 
@@ -11240,282 +11106,110 @@ const _LIVE_INPUT_TYPES = {
11240
11106
 
11241
11107
 
11242
11108
 
11243
- async function _updateLiveInput(instance, ID, NAME, SOURCE, TYPE, IS_STANDARD, VIDEO_ASSET_ID,
11244
- DESTINATIONS, SOURCES)
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)
11245
11112
  {
11246
- const INPUT_INFO = await _getLiveInput(instance, ID);
11247
-
11248
- const API_URL = `${instance.config.serviceApiUrl}/api/liveInput`;
11113
+ const BODY = await _getLiveChannel(instance, ID);
11249
11114
 
11250
- const BODY = INPUT_INFO
11115
+ const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel`;
11251
11116
 
11252
11117
  if (NAME && NAME !== BODY.name)
11253
11118
  {
11254
11119
  BODY.name = NAME;
11255
- BODY.internalName = _slugify(NAME);
11120
+ BODY.routeName = _slugify(NAME);
11256
11121
  }
11257
- if (TYPE && _LIVE_INPUT_TYPES[TYPE] !== BODY.type.id) BODY.type = { id: _LIVE_INPUT_TYPES[TYPE] };
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;
11258
11130
 
11259
- // Set the appropriate fields based on the type
11260
- if (TYPE == "RTMP_PUSH")
11261
- {
11262
- if (SOURCE && SOURCE !== BODY.sourceCidr) BODY["sourceCidr"] = SOURCE
11263
- if (BODY.sources) delete BODY.sources;
11264
- }
11265
- else if (TYPE === "RTMP_PULL" || TYPE === "RTP_PUSH" || TYPE === "URL_PULL")
11266
- {
11267
- if (SOURCE && SOURCE !== BODY.sources) BODY["sources"] = [{ "url": SOURCE }]
11268
- 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;
11269
11135
  }
11270
- else
11136
+ else
11271
11137
  {
11272
- if (BODY.sourceCidr) delete BODY.sourceCidr;
11273
- if (BODY.sources) delete BODY.sources;
11138
+ if (EXTERNAL_URL && BODY.externalUrl) delete BODY.externalUrl;
11274
11139
  }
11275
11140
 
11276
- if (IS_STANDARD && IS_STANDARD !== BODY.isStandard) BODY.isStandard = IS_STANDARD;
11277
- if (VIDEO_ASSET_ID && VIDEO_ASSET_ID !== BODY.videoAsset.id) BODY.videoAsset = { id: VIDEO_ASSET_ID };
11278
- if (DESTINATIONS && DESTINATIONS !== BODY.destinations) BODY.destinations = DESTINATIONS;
11279
- if (SOURCES && SOURCES !== BODY.SOURCES) BODY.sources = SOURCES;
11280
-
11281
- const INFO = await _sendRequest(instance, "Updating Live Input", API_URL, "PUT", undefined, BODY);
11282
- await _waitForLiveInputStatus(instance, INFO.id, _LIVE_INPUT_STATUSES.Detached, 15, 1);
11283
- }
11284
-
11285
-
11286
-
11287
-
11288
-
11289
-
11290
-
11291
- async function _waitForLiveInputStatus(instance, INPUT_ID, STATUS_TO_WAIT_FOR, TIMEOUT = 30,
11292
- POLL_INTERVAL = 2)
11293
- {
11294
- // Set the starting time
11295
- const STARTING_TIME = new Date().getTime();
11296
-
11297
- // Elapsed time in seconds
11298
- let elapsedTime = 0;
11299
-
11300
- while (elapsedTime < TIMEOUT)
11301
- {
11302
- // Get the Live Input status
11303
- const INPUT_STATUS = await _getLiveInputStatus(instance, INPUT_ID);
11304
-
11305
- // If Live Input is in statusToWaitFor return
11306
- if (INPUT_STATUS === STATUS_TO_WAIT_FOR)
11307
- {
11308
- // Give feedback to the console
11309
- if (instance.debug)
11310
- {
11311
- console.log(`Live Input ${INPUT_ID} transitioned to status ${STATUS_TO_WAIT_FOR}`);
11312
- }
11313
- return;
11314
- }
11315
-
11316
- // Give feedback to the console
11317
- console.log(`Live Input [${INPUT_ID}] is in status [${INPUT_STATUS}]`);
11318
-
11319
- // Check for Error status
11320
- if (INPUT_STATUS === "Error")
11321
- {
11322
- // Get the error message
11323
- const INPUT_STATUS_MESSAGE = await _getLiveInputStatusMessage(instance, INPUT_ID);
11324
-
11325
- // Can't continue if Live Input is in error status
11326
- throw new Error(`Live Input ${INPUT_ID} is in Error status: ${INPUT_STATUS_MESSAGE}`);
11327
- }
11328
-
11329
- // Calculate elapsed time in seconds
11330
- elapsedTime = (new Date().getTime() - STARTING_TIME) / 1000;
11331
-
11332
- // Give feedback to the console
11333
- if (instance.debug)
11334
- {
11335
- console.log(`Waiting for Live Input [${INPUT_ID}] to transition to status [${STATUS_TO_WAIT_FOR}]... [${Math.round(elapsedTime)}/${TIMEOUT}]`);
11336
- }
11337
-
11338
- // Check for timeout
11339
- if (elapsedTime > TIMEOUT)
11340
- {
11341
- break;
11342
- }
11343
-
11344
- // Wait poll interval
11345
- await _sleep(POLL_INTERVAL);
11346
- }
11347
-
11348
- throw new Error(`Waiting for Live Input [${INPUT_ID}] to transition to status [${STATUS_TO_WAIT_FOR}] timed out`);
11349
- }
11350
-
11351
-
11352
-
11353
-
11354
-
11355
-
11356
- async function _cancelBroadcast(instance, ID)
11357
- {
11358
- const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/cancel`;
11359
-
11360
- return await _sendRequest(instance, "Cancel Broadcast", API_URL, "POST", undefined, undefined);
11361
- }
11362
-
11363
-
11364
-
11365
-
11366
- async function _cancelSegment(instance, ID)
11367
- {
11368
- const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/cancelSegment`;
11369
-
11370
- return await _sendRequest(instance, "Cancel Segment", API_URL, "POST", undefined, undefined);
11371
- }
11372
-
11373
-
11374
-
11375
-
11376
- async function _completeSegment(instance, ID, RELATED_CONTENT_IDS, TAG_IDS)
11377
- {
11378
- const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/completeSegment`;
11379
-
11380
- const BODY = {
11381
- liveOperatorId: ID
11382
- };
11383
-
11384
- if (RELATED_CONTENT_IDS && Array.isArray(RELATED_CONTENT_IDS) && RELATED_CONTENT_IDS.length > 0) {
11385
- BODY.relatedContent = RELATED_CONTENT_IDS.map(id => ({ id }));
11386
- }
11387
- if (TAG_IDS && Array.isArray(TAG_IDS) && TAG_IDS.length > 0) {
11388
- BODY.tags = TAG_IDS.map(id => ({ id }));
11389
- }
11390
-
11391
- return await _sendRequest(instance, "Complete Segment", API_URL, "POST", undefined, BODY);
11392
- }
11393
-
11394
-
11395
-
11396
-
11397
- async function _getCompletedSegments(instance, ID)
11398
- {
11399
- const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/segments`;
11400
-
11401
- return await _sendRequest(instance, "Get Completed Segments", API_URL, "GET", undefined, undefined);
11402
- }
11141
+ if (SECURITY_GROUPS) {
11142
+ const NOMAD_SECURITY_GROUPS = await _getSecurityGroups(instance);
11403
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
+ }));
11404
11150
 
11151
+ if (FILTERED_SECURITY_GROUPS !== BODY.securityGroups) BODY.securityGroups = FILTERED_SECURITY_GROUPS;
11152
+ }
11405
11153
 
11154
+ const INFO = await _sendRequest(instance, "Update Live Channel", API_URL, "PUT", undefined, BODY);
11406
11155
 
11407
- async function _getLiveOperator(instance, ID)
11408
- {
11409
- const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}`;
11156
+ await _waitForLiveChannelStatus(instance, INFO.id, _LIVE_CHANNEL_STATUSES.Idle, 120, 2);
11410
11157
 
11411
- return await _sendRequest(instance, "Get Live Operator", API_URL, "GET", undefined, undefined);
11158
+ return INFO;
11412
11159
  }
11413
11160
 
11414
11161
 
11415
11162
 
11416
11163
 
11417
- async function _getLiveOperators(instance)
11418
- {
11419
- const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator`;
11420
-
11421
- return await _sendRequest(instance, "Get Live Operators", API_URL, "GET", undefined, undefined);
11422
- }
11423
-
11424
-
11425
-
11426
-
11427
-
11428
- async function _startBroadcast(instance, ID, PREROLL_ASSET_ID, POSTROLL_ASSET_ID, LIVE_INPUT_ID,
11429
- RELATED_CONTENT_IDS, TAG_IDS)
11430
- {
11431
- const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/start`;
11432
-
11433
- const BODY = {
11434
- id: ID
11435
- };
11436
-
11437
- if (PREROLL_ASSET_ID) { BODY.prerollAsset = { id: PREROLL_ASSET_ID }; }
11438
- if (POSTROLL_ASSET_ID) { BODY.postrollAsset = { id: POSTROLL_ASSET_ID }; }
11439
- if (LIVE_INPUT_ID) { BODY.liveInput = { id: LIVE_INPUT_ID }; }
11440
-
11441
- if (RELATED_CONTENT_IDS && Array.isArray(RELATED_CONTENT_IDS) && RELATED_CONTENT_IDS.length > 0) {
11442
- BODY.relatedContent = RELATED_CONTENT_IDS.map(id => ({ id }));
11443
- }
11444
- if (TAG_IDS && Array.isArray(TAG_IDS) && TAG_IDS.length > 0) {
11445
- BODY.tags = TAG_IDS.map(id => ({ id }));
11446
- }
11447
-
11448
- return await _sendRequest(instance, "Start Broadcast", API_URL, "POST", undefined, BODY);
11449
- }
11450
-
11451
-
11452
-
11453
-
11454
- async function _startSegment(instance, ID)
11455
- {
11456
- const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/startSegment`;
11457
-
11458
- return await _sendRequest(instance, "Start Segment", API_URL, "POST", undefined, undefined);
11459
- }
11460
-
11461
-
11462
-
11463
-
11464
-
11465
- async function _stopBroadcast(instance, ID)
11466
- {
11467
- const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveOperator/${ID}/stop`;
11468
-
11469
- return await _sendRequest(instance, "Stop Broadcast", API_URL, "POST", undefined, undefined);
11470
- }
11471
-
11472
11164
 
11473
11165
 
11474
11166
 
11475
11167
 
11476
- async function _waitForLiveOperatorStatus(instance, OPERATOR_ID, STATUS_TO_WAIT_FOR, TIMEOUT = 30,
11168
+ async function _waitForLiveChannelStatus(instance, CHANNEL_ID, STATUS_TO_WAIT_FOR, TIMEOUT = 30,
11477
11169
  POLL_INTERVAL = 2)
11478
11170
  {
11479
- // Set the starting time
11480
- const STARTING_TIME = new Date().getTime();
11171
+ const startingTime = new Date().getTime();
11481
11172
 
11482
11173
  // Elapsed time in seconds
11483
11174
  let elapsedTime = 0;
11484
11175
 
11485
11176
  while (elapsedTime < TIMEOUT)
11486
11177
  {
11487
- const OPERATOR = await _getLiveOperator(instance, OPERATOR_ID);
11488
- // Get the Live Operator status
11489
- const OPERATOR_STATUS = OPERATOR.liveChannelStatus.description;
11178
+ // Get the Live Channel status
11179
+ const CHANNEL_STATUS = await _getLiveChannelStatus(instance, CHANNEL_ID);
11490
11180
 
11491
- // If Live Operator is in statusToWaitFor return
11492
- if (OPERATOR_STATUS === STATUS_TO_WAIT_FOR)
11181
+ // If channel is in statusToWaitFor return
11182
+ if (CHANNEL_STATUS === STATUS_TO_WAIT_FOR)
11493
11183
  {
11494
11184
  // Give feedback to the console
11495
11185
  if (instance.debug)
11496
11186
  {
11497
- console.log(`Live Operator ${OPERATOR_ID} transitioned to status ${STATUS_TO_WAIT_FOR}`);
11187
+ console.log(`Live Channel [${CHANNEL_ID}] transitioned to status [${STATUS_TO_WAIT_FOR}]`);
11498
11188
  }
11499
11189
  return;
11500
11190
  }
11501
11191
 
11502
11192
  // Give feedback to the console
11503
- console.log(`Live Operator [${OPERATOR_ID}] is in status [${OPERATOR_STATUS}]`);
11193
+ console.log(`Live Channel [${CHANNEL_ID}] current status is [${CHANNEL_STATUS}]`);
11504
11194
 
11505
11195
  // Check for Error status
11506
- if (OPERATOR_STATUS === "Error")
11196
+ if (CHANNEL_STATUS === "Error")
11507
11197
  {
11508
- // Can't continue if Live Operator is in error status
11509
- throw new Error(`Live Operator ${OPERATOR_ID} is broken`);
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}`);
11510
11204
  }
11511
11205
 
11512
11206
  // Calculate elapsed time in seconds
11513
- elapsedTime = (new Date().getTime() - STARTING_TIME) / 1000;
11207
+ elapsedTime = (new Date().getTime() - startingTime) / 1000;
11514
11208
 
11515
11209
  // Give feedback to the console
11516
11210
  if (instance.debug)
11517
11211
  {
11518
- console.log(`Waiting for Live Operator [${OPERATOR_ID}] to transition to status [${STATUS_TO_WAIT_FOR}]... [${Math.round(elapsedTime)}/${TIMEOUT}]`);
11212
+ console.log(`Waiting for Live Channel [${CHANNEL_ID}] to transition to status [${STATUS_TO_WAIT_FOR}]... [${Math.round(elapsedTime)}/${TIMEOUT}]`);
11519
11213
  }
11520
11214
 
11521
11215
  // Check for timeout
@@ -11528,22 +11222,464 @@ async function _waitForLiveOperatorStatus(instance, OPERATOR_ID, STATUS_TO_WAIT_
11528
11222
  await _sleep(POLL_INTERVAL);
11529
11223
  }
11530
11224
 
11531
- throw new Error(`Waiting for Live Operator [${OPERATOR_ID}] to transition to status [${STATUS_TO_WAIT_FOR}] timed out`);
11225
+ throw new Error(`Waiting for Live Channel [${CHANNEL_ID}] to transition to status [${STATUS_TO_WAIT_FOR}] timed out`);
11532
11226
  }
11533
11227
 
11534
11228
 
11535
11229
 
11536
11230
 
11537
11231
 
11538
- async function _createLiveOutputProfileGroup(instance, NAME, IS_ENABLED, MANIFEST_TYPE, IS_DEFAULT_GROUP,
11539
- LIVE_OUTPUT_TYPE, ARCHIVE_LIVE_OUTPUT_PROFILE, LIVE_OUTPUT_PROFILES)
11540
- {
11541
11232
 
11542
- const API_URL = `${instance.config.serviceApiUrl}/api/liveOutputProfileGroup`;
11543
11233
 
11544
- const BODY = {
11545
- name: NAME,
11546
- enabled: IS_ENABLED,
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,
11547
11683
  manifestType: MANIFEST_TYPE,
11548
11684
  isDefaultGroup: IS_DEFAULT_GROUP,
11549
11685
  outputType: LIVE_OUTPUT_TYPE,
@@ -11719,59 +11855,59 @@ async function _updateLiveOutputProfile(instance, ID, NAME, OUTPUT_TYPE, ENABLED
11719
11855
 
11720
11856
 
11721
11857
 
11722
-
11723
-
11724
-
11725
- async function _addAssetScheduleEvent(instance, CHANNEL_ID, ASSET, IS_LOOP,
11726
- DURATION_TIME_CODE, PREVIOUS_ID)
11727
- {
11728
- const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
11729
-
11730
- const BODY = {
11731
- isLoop: IS_LOOP,
11732
- channelId: CHANNEL_ID,
11733
- durationTimeCode: DURATION_TIME_CODE,
11734
- previousId: PREVIOUS_ID,
11735
- type: {
11736
- id: _eventType.videoAsset,
11737
- description: "Video Asset"
11738
- },
11739
- asset: ASSET
11740
- };
11741
-
11742
- return await _sendRequest(instance, "Adding Asset Schedule Event", API_URL, "POST", undefined, BODY);
11743
- }
11744
-
11745
-
11746
-
11747
-
11748
-
11749
-
11750
- async function _addInputScheduleEvent(instance, CHANNEL_ID, INPUT, BACKUP_INPUT,
11751
- FIXED_ON_AIR_TIME_UTC, PREVIOUS_ID)
11752
- {
11753
- const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
11754
-
11755
- const BODY = {
11756
- channelId: CHANNEL_ID,
11757
- fixedOnAirTimeUtc: FIXED_ON_AIR_TIME_UTC,
11758
- type: {
11759
- id: _eventType.liveInput,
11760
- description: "Live Input"
11761
- },
11762
- liveInput: INPUT,
11763
- previousId: PREVIOUS_ID
11764
- };
11765
-
11766
- if (BACKUP_INPUT)
11767
- {
11768
- BODY["liveInput2"] = BACKUP_INPUT;
11769
- }
11770
-
11771
-
11772
- return await _sendRequest(instance, "Adding Input Schedule Event", API_URL, "POST", undefined, BODY);
11773
- }
11774
-
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
+
11775
11911
 
11776
11912
  const _eventType = {
11777
11913
  liveInput: "eef7ef23-56dc-4f48-8c0e-1f4d52990405",
@@ -11830,92 +11966,92 @@ async function _removeInputScheduleEvent(instance, CHANNEL_ID, INPUT_ID)
11830
11966
  {
11831
11967
  const API_URL = `${instance.config.serviceApiUrl}/api/liveChannel/${CHANNEL_ID}/liveScheduleEvent/${INPUT_ID}`
11832
11968
 
11833
- 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);
11834
12052
  }
11835
12053
 
11836
12054
 
11837
-
11838
-
11839
-
11840
-
11841
- async function _updateAssetScheduleEvent(instance, ID, CHANNEL_ID, ASSET, IS_LOOP,
11842
- DURATION_TIME_CODE)
11843
- {
11844
- const SCHEDULE_EVENT_INFO = await _getAssetScheduleEvent(instance, CHANNEL_ID, ID);
11845
-
11846
- const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
11847
-
11848
- const BODY = {
11849
- type: {
11850
- id: _eventType.videoAsset,
11851
- description: "Video Asset"
11852
- }
11853
- };
11854
-
11855
- BODY.id = ID && ID !== SCHEDULE_EVENT_INFO.id ? ID : SCHEDULE_EVENT_INFO.id;
11856
- BODY.isLoop = IS_LOOP && IS_LOOP !== SCHEDULE_EVENT_INFO.isLoop ? IS_LOOP : SCHEDULE_EVENT_INFO.isLoop;
11857
- BODY.channelId = CHANNEL_ID && CHANNEL_ID !== SCHEDULE_EVENT_INFO.channelId ? CHANNEL_ID : SCHEDULE_EVENT_INFO.channelId;
11858
- BODY.durationTimeCode = DURATION_TIME_CODE && DURATION_TIME_CODE !== SCHEDULE_EVENT_INFO.durationTimeCode ? DURATION_TIME_CODE : SCHEDULE_EVENT_INFO.durationTimeCode;
11859
- BODY.asset = ASSET && ASSET !== SCHEDULE_EVENT_INFO.asset ? ASSET : SCHEDULE_EVENT_INFO.asset;
11860
-
11861
- return await _sendRequest(instance, "Updating Asset Schedule Event", API_URL, "PUT", undefined, BODY);
11862
- }
11863
-
11864
-
11865
-
11866
-
11867
-
11868
-
11869
-
11870
- async function _updateInputScheduleEvent(instance, ID, CHANNEL_ID, INPUT, BACKUP_INPUT,
11871
- FIXED_ON_AIR_TIME_UTC)
11872
- {
11873
- const SCHEDULE_EVENT_INFO = await _getInputScheduleEvent(instance, CHANNEL_ID, ID);
11874
-
11875
- const API_URL = `${instance.config.serviceApiUrl}/api/LiveChannel/${CHANNEL_ID}/liveScheduleEvent`;
11876
-
11877
- const BODY = {
11878
- type: {
11879
- id: _eventType.liveInput,
11880
- description: "Live Input"
11881
- },
11882
- };
11883
-
11884
- BODY.id = ID && ID !== SCHEDULE_EVENT_INFO.id ? ID : SCHEDULE_EVENT_INFO.id;
11885
- BODY.channelId = CHANNEL_ID && CHANNEL_ID !== SCHEDULE_EVENT_INFO.channelId ? CHANNEL_ID : SCHEDULE_EVENT_INFO.channelId;
11886
- 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;
11887
-
11888
- if (INPUT && INPUT !== SCHEDULE_EVENT_INFO.liveInput)
11889
- {
11890
- BODY.liveInput = {
11891
- id: INPUT.id,
11892
- description: INPUT.name
11893
- };
11894
- }
11895
- else
11896
- {
11897
- BODY.liveInput = {
11898
- id: SCHEDULE_EVENT_INFO.liveInput.id,
11899
- description: SCHEDULE_EVENT_INFO.liveInput.name
11900
- };
11901
- }
11902
-
11903
- if (BACKUP_INPUT && BACKUP_INPUT !== SCHEDULE_EVENT_INFO.liveInput2) {
11904
- BODY.liveInput2 = {
11905
- id: BACKUP_INPUT.id,
11906
- description: BACKUP_INPUT.name
11907
- };
11908
- } else if (SCHEDULE_EVENT_INFO.liveInput2) {
11909
- BODY.liveInput2 = {
11910
- id: SCHEDULE_EVENT_INFO.liveInput2.id,
11911
- description: SCHEDULE_EVENT_INFO.liveInput2.name
11912
- };
11913
- }
11914
-
11915
- return await _sendRequest(instance, "Updating Input Schedule Event", API_URL, "PUT", undefined, BODY);
11916
- }
11917
-
11918
-
11919
12055
 
11920
12056
 
11921
12057
 
@@ -12658,53 +12794,53 @@ async function _deleteUser(instance, USER_ID)
12658
12794
  }
12659
12795
 
12660
12796
 
12661
-
12662
-
12663
- async function _register(instance, EMAIL, FIRST_NAME, LAST_NAME, PASSWORD)
12664
- {
12665
- const API_URL = `${instance.config.serviceApiUrl}/api/account/register`
12666
-
12667
- const BODY = {
12668
- firstName: FIRST_NAME,
12669
- lastName: LAST_NAME,
12670
- email: EMAIL,
12671
- password: PASSWORD
12672
- };
12673
-
12674
- return await _sendRequest(instance, "Register", API_URL, "POST", undefined, BODY);
12675
- }
12676
-
12677
-
12678
-
12679
-
12680
-
12681
-
12682
- async function _resendCode(instance, EMAIL)
12683
- {
12684
- const API_URL = `${instance.config.serviceApiUrl}/api/account/resend-code`
12685
-
12686
- const BODY = {
12687
- userName: EMAIL
12688
- };
12689
-
12690
- return await _sendRequest(instance, "Resend Code", API_URL, "POST", undefined, BODY);
12691
- }
12692
-
12693
-
12694
-
12695
-
12696
- async function _verify(instance, EMAIL, CODE)
12697
- {
12698
- const API_URL = `${instance.config.serviceApiUrl}/api/account/verify`
12699
-
12700
- const BODY = {
12701
- userName: EMAIL,
12702
- token: CODE
12703
- };
12704
-
12705
- return await _sendRequest(instance, "Verify", API_URL, "POST", undefined, BODY);
12706
- }
12707
-
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
+
12708
12844
 
12709
12845
 
12710
12846
 
@@ -13530,25 +13666,25 @@ async function _createTagOrCollection(instance, TYPE, TAG_NAME)
13530
13666
  }
13531
13667
 
13532
13668
 
13533
-
13534
-
13535
- async function _deleteRelatedContent(instance, CONTENT_ID, RELATED_CONTENT_ID, CONTENT_DEFINITION)
13536
- {
13537
- const API_URL = instance.config.apiType === "admin" ? `${instance.config.serviceApiUrl}/api/admin/related/delete` : `${instance.config.serviceApiUrl}/api/content/related/delete`;
13538
-
13539
- const BODY = {
13540
- items: [
13541
- {
13542
- contentDefinition: CONTENT_DEFINITION,
13543
- contentId: CONTENT_ID,
13544
- relatedContentId: RELATED_CONTENT_ID
13545
- }
13546
- ]
13547
- };
13548
-
13549
- return await _sendRequest(instance, "Deleting Related Content", API_URL, "POST", undefined, BODY);
13550
- }
13551
-
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
+
13552
13688
 
13553
13689
 
13554
13690
 
@@ -13570,26 +13706,26 @@ async function _getTagOrCollection(instance, TYPE, ID)
13570
13706
  }
13571
13707
 
13572
13708
 
13573
-
13574
-
13575
- async function _removeTagOrCollection(instance, TYPE, CONTENT_ID, CONTENT_DEFINITION_ID, TAG_ID)
13576
- {
13577
- const API_URL = instance.config.apiType === "admin" ? `${instance.config.serviceApiUrl}/api/admin/${TYPE}/content/delete` : `${instance.config.serviceApiUrl}/api/content/${TYPE}/delete`;
13578
-
13579
- const BODY = {
13580
- items: [
13581
- {
13582
- contentDefinition: CONTENT_DEFINITION_ID,
13583
- contentId: CONTENT_ID
13584
- }
13585
- ]
13586
- };
13587
-
13588
- BODY.items[0][`${TYPE}Id`] = TAG_ID;
13589
-
13590
- return await _sendRequest(instance, "Removing Tag or Collection", API_URL, "POST", undefined, BODY);
13591
- }
13592
-
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
+
13593
13729
 
13594
13730
 
13595
13731
 
@@ -13658,62 +13794,62 @@ async function _search(instance, QUERY, OFFSET, SIZE, FILTERS, SORT_FIELDS, SEAR
13658
13794
  }
13659
13795
 
13660
13796
 
13661
- function _apiExceptionHandler(error, message)
13662
- {
13663
- // Check if we have a response object and error message
13664
- if (!error)
13665
- {
13666
- console.error(message);
13667
- }
13668
-
13669
- // Check if error is a string
13670
- if (typeof error === "string")
13671
- {
13672
- console.error(`${message}: ${error}`);
13673
- }
13674
- else if (error.errors)
13675
- {
13676
- if (Array.isArray(error.errors))
13677
- {
13678
- let errorString = "";
13679
- for (let errorIdx = 0; errorIdx < error.errors.length; errorIdx++)
13680
- {
13681
- errorString += `${error.errors[errorIdx].code}: ${error.errors[errorIdx].field}: ${error.errors[errorIdx].message}\n`;
13682
- }
13683
- console.error(`${message}: ${errorString}`);
13684
- }
13685
- else if (typeof error.errors === "object")
13686
- {
13687
- let errorString = "";
13688
- for (let key in error.errors)
13689
- {
13690
- if (Object.prototype.hasOwnProperty.call(error.errors, key))
13691
- {
13692
- errorString += `${key}: ${error.errors[key]}\n`;
13693
- }
13694
- }
13695
- console.error(`${message}: ${errorString}`);
13696
- }
13697
- }
13698
- else
13699
- {
13700
- console.error(`${message}: ${error.message}`);
13701
- }
13702
-
13703
- return null;
13704
- }
13705
-
13706
-
13707
- import { getRandomValues } from 'crypto';
13708
-
13709
- function _newGuid()
13710
- {
13711
- return ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, (c) =>
13712
- (c ^ (getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
13713
- );
13714
- }
13715
-
13716
-
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
+
13717
13853
 
13718
13854
  function _printDatetime(msg)
13719
13855
  {
@@ -13724,7 +13860,7 @@ function _printDatetime(msg)
13724
13860
 
13725
13861
 
13726
13862
  import { promises as fs } from 'fs';
13727
-
13863
+ import path from 'path';
13728
13864
 
13729
13865
  async function _processFile(FILE)
13730
13866
  {
@@ -13736,7 +13872,7 @@ async function _processFile(FILE)
13736
13872
  {
13737
13873
  FILE_PATH = FILE;
13738
13874
  FILE = await fs.stat(FILE);
13739
- FILE.originalname = path.basename(FILE_PATH);
13875
+ FILE.originalName = path.basename(FILE_PATH);
13740
13876
  if (!FILE.buffer)
13741
13877
  {
13742
13878
  FILE.buffer = await fs.readFile(FILE_PATH);
@@ -13749,6 +13885,7 @@ async function _processFile(FILE)
13749
13885
  }
13750
13886
  else
13751
13887
  {
13888
+ FILE.originalName = FILE.name;
13752
13889
  // if running in browser
13753
13890
  if (!FILE.buffer)
13754
13891
  {
@@ -13756,7 +13893,7 @@ async function _processFile(FILE)
13756
13893
  }
13757
13894
  }
13758
13895
 
13759
- return [FILE, FILE_PATH];
13896
+ return FILE;
13760
13897
  }
13761
13898
 
13762
13899
  async function _readFileAsArrayBuffer(file)
@@ -13846,70 +13983,70 @@ async function _sendRequest(instance, FUNCTION_NAME, URL, METHOD_TYPE, PARAMS, B
13846
13983
  }
13847
13984
 
13848
13985
 
13849
- async function _sleep(duration)
13850
- {
13851
- // Check for valid duration
13852
- if (!duration || duration === 0)
13853
- {
13854
- // Ignore
13855
- return;
13856
- }
13857
-
13858
- // Sleep
13859
- return new Promise((resolve) => {
13860
- setTimeout(() => {
13861
- resolve();
13862
- }, duration * 1000);
13863
- });
13864
- }
13865
-
13866
-
13867
-
13868
- function _slugify(text)
13869
- {
13870
- if (!text || text.trim().length === 0) return "";
13871
- return text
13872
- .toString()
13873
- .normalize("NFD")
13874
- .replace(/[\u0300-\u036f]/g, "")
13875
- .toLowerCase()
13876
- .trim()
13877
- .replace(/\s+/g, "-")
13878
- .replace(/[^\w-]+/g, "")
13879
- .replace(/--+/g, "-");
13880
- }
13881
-
13882
-
13883
-
13884
-
13885
-
13886
- async function _changeEmail(instance, EMAIL)
13887
- {
13888
- const API_URL = `${instance.config.serviceApiUrl}/api/account/change-email`;
13889
-
13890
- const BODY = {
13891
- password: instance.config.password,
13892
- newEmail: EMAIL
13893
- };
13894
-
13895
- return await _sendRequest(instance, "Change email", API_URL, "POST", undefined, BODY);
13896
- }
13897
-
13898
-
13899
-
13900
-
13901
- async function _changePassword(instance, NEW_PASSWORD)
13902
- {
13903
- const API_URL = `${instance.config.serviceApiUrl}/api/account/change-password`;
13904
-
13905
- const BODY = {
13906
- password: instance.config.password,
13907
- newPassword: NEW_PASSWORD
13908
- };
13909
-
13910
- return await _sendRequest(instance, "Change password", API_URL, "POST", undefined, BODY);
13911
- }
13912
-
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
+
13913
14050
 
13914
14051
 
13915
14052
 
@@ -13932,74 +14069,74 @@ async function _getUser(instance)
13932
14069
  }
13933
14070
 
13934
14071
 
13935
-
13936
-
13937
-
13938
-
13939
-
13940
- async function _updateUser(instance, ADDRESS, ADDRESS2, CITY, COUNTRY,
13941
- FIRST_NAME, LAST_NAME, ORGANIZATION, PHONE_NUMBER, PHONE_EXT, POSTAL_CODE, STATE)
13942
- {
13943
- const USER_INFO = await _getUser(instance);
13944
-
13945
- const API_URL = `${instance.config.serviceApiUrl}/api/account/user`;
13946
-
13947
- const BODY = {};
13948
-
13949
- const LOOKUPS = await _getLookups(instance);
13950
-
13951
- const COUNTRIES_INFO = LOOKUPS.find(lookup => lookup["label"] === "Countries");
13952
- const COUNTRY_SELECTED = COUNTRIES_INFO.children.find(country => country["label"] === COUNTRY);
13953
-
13954
- const STATES_INFO = LOOKUPS.find(lookup => lookup["label"] === "States");
13955
- const STATE_SELECTED = STATES_INFO.children.find(state => state["label"] === STATE);
13956
-
13957
- const keyValues = {
13958
- address: ADDRESS,
13959
- address2: ADDRESS2,
13960
- city: CITY,
13961
- state: STATE_SELECTED,
13962
- country: COUNTRY_SELECTED,
13963
- firstName: FIRST_NAME,
13964
- lastName: LAST_NAME,
13965
- phone: PHONE_NUMBER,
13966
- phoneExt: PHONE_EXT,
13967
- postalCode: POSTAL_CODE,
13968
- organization: ORGANIZATION,
13969
- };
13970
-
13971
- Object.entries(keyValues).forEach(([key, value]) => {
13972
- BODY[key] = value !== null ? value: USER_INFO[key] ?? BODY[key];
13973
- });
13974
-
13975
- return await _sendRequest(instance, "Update user", API_URL, "PUT", undefined, BODY);
13976
- }
13977
-
13978
-
13979
-
13980
-
13981
- async function _addContentsToContentGroup(instance, CONTENT_GROUP_ID, CONTENTS)
13982
- {
13983
- const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/add/${CONTENT_GROUP_ID}`;
13984
-
13985
- const BODY = CONTENTS;
13986
-
13987
- return await _sendRequest(instance, "Adding Contents to Content Group", API_URL, "POST", undefined, BODY);
13988
- }
13989
-
13990
-
13991
-
13992
-
13993
- async function _createContentGroup(instance, NAME)
13994
- {
13995
- const API_URL = `${instance.config.serviceApiUrl}/api/contentGroup`;
13996
-
13997
- const BODY = {};
13998
- if (NAME) BODY.name = NAME;
13999
-
14000
- return await _sendRequest(instance, "Creating Content Group", API_URL, "POST", undefined, BODY);
14001
- }
14002
-
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
+
14003
14140
 
14004
14141
 
14005
14142
 
@@ -14031,57 +14168,57 @@ async function _getContentGroups(instance)
14031
14168
  }
14032
14169
 
14033
14170
 
14034
-
14035
-
14036
- async function _getPortalGroups(instance, PORTAL_GROUPS)
14037
- {
14038
- const API_URL = `${instance.config.serviceApiUrl}/api/portal/groups`;
14039
-
14040
- const BODY = {
14041
- "returnedGroupNames": PORTAL_GROUPS
14042
- }
14043
-
14044
- return await _sendRequest(instance, "Getting Portal Groups", API_URL, "POST", undefined, BODY);
14045
- }
14046
-
14047
-
14048
-
14049
-
14050
- async function _removeContentsFromContentGroup(instance, CONTENT_GROUP_ID, CONTENTS)
14051
- {
14052
- const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/remove/${CONTENT_GROUP_ID}`;
14053
-
14054
- const BODY = CONTENTS;
14055
-
14056
- return await _sendRequest(instance, "Removing Content From Content Group", API_URL, "POST", undefined, BODY);
14057
- }
14058
-
14059
-
14060
-
14061
-
14062
- async function _renameContentGroup(instance, CONTENT_GROUP_ID, NAME)
14063
- {
14064
- const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/${CONTENT_GROUP_ID}`;
14065
-
14066
- const BODY = {
14067
- Name: NAME
14068
- };
14069
-
14070
- return await _sendRequest(instance, "Renaming Content Group", API_URL, "PATCH", undefined, BODY);
14071
- }
14072
-
14073
-
14074
-
14075
-
14076
- async function _shareContentGroupWithUsers(instance, CONTENT_GROUP_ID, USER_IDS)
14077
- {
14078
- const API_URL = `${instance.config.serviceApiUrl}/api/contentgroup/share/${CONTENT_GROUP_ID}`;
14079
-
14080
- const BODY = USER_IDS;
14081
-
14082
- return await _sendRequest(instance, "Sharing Content Group With Users", API_URL, "POST", undefined, BODY);
14083
- }
14084
-
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
+
14085
14222
 
14086
14223
 
14087
14224
 
@@ -14095,60 +14232,60 @@ async function _stopSharingContentGroupWithUsers(instance, CONTENT_GROUP_ID, USE
14095
14232
  }
14096
14233
 
14097
14234
 
14098
-
14099
-
14100
- async function _guestInvite(instance, CONTENT_ID, CONTENT_DEFINITION_ID, USER_ID,
14101
- EMAILS, CONTENT_SECURITY_ATTRIBUTE)
14102
- {
14103
- const API_URL = `${instance.config.serviceApiUrl}/api/account/invite-user`;
14104
-
14105
- const BODY = {
14106
- contentId: CONTENT_ID,
14107
- contentDefinitionId: CONTENT_DEFINITION_ID,
14108
- userId: USER_ID,
14109
- emails: EMAILS,
14110
- contentSecurityAttribute: CONTENT_SECURITY_ATTRIBUTE
14111
- };
14112
-
14113
- return await _sendRequest(instance, "Guest Invite", API_URL, "POST", undefined, BODY);
14114
- }
14115
-
14116
-
14117
-
14118
-
14119
- async function _registerGuest(instance, EMAIL, FIRST_NAME, LAST_NAME, PASSWORD)
14120
- {
14121
- const API_URL = `${instance.config.serviceApiUrl}/api/account/register-guest`;
14122
-
14123
- const BODY = {
14124
- email: EMAIL,
14125
- firstName: FIRST_NAME,
14126
- lastName: LAST_NAME,
14127
- password: PASSWORD
14128
- };
14129
-
14130
- return await _sendRequest(instance, "Register guest", API_URL, "POST", undefined, BODY);
14131
- }
14132
-
14133
-
14134
-
14135
-
14136
- async function _removeGuest(instance, CONTENT_ID, CONTENT_DEFINITION_ID, USER_ID,
14137
- EMAILS, CONTENT_SECURITY_ATTRIBUTE)
14138
- {
14139
- const API_URL = `${instance.config.serviceApiUrl}/api/account/remove-user`;
14140
-
14141
- const BODY = {
14142
- contentId: CONTENT_ID,
14143
- contentDefinitionId: CONTENT_DEFINITION_ID,
14144
- userId: USER_ID,
14145
- emails: EMAILS,
14146
- contentSecurityAttribute: CONTENT_SECURITY_ATTRIBUTE
14147
- };
14148
-
14149
- return await _sendRequest(instance, "Remove guest", API_URL, "POST", undefined, BODY);
14150
- }
14151
-
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
+
14152
14289
 
14153
14290
 
14154
14291
 
@@ -14363,17 +14500,17 @@ async function _clearWatchlist(instance, USER_ID)
14363
14500
  }
14364
14501
 
14365
14502
 
14366
-
14367
-
14368
- async function _createForm(instance, CONTENT_DEFINITION_ID, FORM_INFO)
14369
- {
14370
- const API_URL = `${instance.config.serviceApiUrl}/api/media/form/${CONTENT_DEFINITION_ID}`;
14371
-
14372
- const BODY = FORM_INFO;
14373
-
14374
- return await _sendRequest(instance, "Creating Form", API_URL, "POST", undefined, BODY);
14375
- }
14376
-
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
+
14377
14514
 
14378
14515
 
14379
14516
 
@@ -14465,25 +14602,25 @@ async function _getSiteConfig(instance, ID)
14465
14602
  }
14466
14603
 
14467
14604
 
14468
-
14469
-
14470
- async function _mediaSearch(instance, SEARCH_QUERY, IDS, SORT_FIELDS,
14471
- PAGE_OFFSET, PAGE_SIZE)
14472
- {
14473
- const API_URL = `${instance.config.serviceApiUrl}/api/media/search`;
14474
-
14475
- const BODY = {
14476
- searchQuery: SEARCH_QUERY,
14477
- ids: IDS,
14478
- sortFields: SORT_FIELDS
14479
- };
14480
-
14481
- PAGE_OFFSET ? BODY["pageOffset"] = PAGE_OFFSET : BODY["pageOffset"] = 0;
14482
- PAGE_SIZE ? BODY["pageSize"] = PAGE_SIZE : BODY["pageSize"] = 100;
14483
-
14484
- return await _sendRequest(instance, "Media Search", API_URL, "POST", undefined, BODY);
14485
- }
14486
-
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
+
14487
14624
 
14488
14625
 
14489
14626