@nomad-media/full 1.1.14 → 1.1.16

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.
@@ -303,9 +303,6 @@ class NomadMediaSDK {
303
303
  async _init()
304
304
  {
305
305
  await this.login();
306
-
307
- // Schedule token refresh
308
- this.__scheduleTokenRefresh();
309
306
  }
310
307
 
311
308
  // account functions
@@ -328,7 +325,7 @@ class NomadMediaSDK {
328
325
  this.config.serviceApiUrl, this.debugMode);
329
326
  this.token = LOGIN_INFO["token"];
330
327
  this.refreshTokenVal = LOGIN_INFO["refreshToken"];
331
- this.expirationSeconds = Date.now() + LOGIN_INFO["expirationSeconds"] * 1000;
328
+ this.expirationSeconds = LOGIN_INFO["expirationSeconds"];
332
329
  this.userSessionId = LOGIN_INFO["userSessionId"];
333
330
  this.id = LOGIN_INFO["id"];
334
331
  _printDatetime(`Login successful`);
@@ -388,10 +385,9 @@ class NomadMediaSDK {
388
385
 
389
386
  try
390
387
  {
391
- const TOKEN_INFO = await _refreshToken(this, this.token, this.config.serviceApiUrl,
388
+ const REFRESHED = await _refreshToken(this, this.token, this.config.serviceApiUrl,
392
389
  this.refreshTokenVal, this.debugMode);
393
- this.token = TOKEN_INFO["token"];
394
- _printDatetime(`Token refresh successful`);
390
+ if (REFRESHED) _printDatetime(`Token refresh successful`);
395
391
  }
396
392
  catch (error)
397
393
  {
@@ -400,31 +396,6 @@ class NomadMediaSDK {
400
396
  }
401
397
  }
402
398
 
403
- /**
404
- * @function scheduleTokenRefresh
405
- * @private
406
- * @description Schedules a token refresh for the duration set by the value returned in the login.
407
- * @returns {Promise<void>} - A promise that resolves when the token is refreshed.
408
- * Updates the token class variable.
409
- * @throws {Error} - An error is thrown if the token refresh fails.
410
- */
411
- __scheduleTokenRefresh() {
412
- if (this.token && this.expirationSeconds) {
413
- const remainingTime = this.expirationSeconds - Date.now();
414
- if (remainingTime > 0) {
415
- // Clear existing timer (if any)
416
- if (this.refreshTimer) {
417
- clearTimeout(this.refreshTimer);
418
- }
419
- // Schedule a refresh slightly before token expiration
420
- this.refreshTimer = setTimeout(async () => {
421
- await this.refreshToken();
422
- this.__scheduleTokenRefresh();
423
- }, remainingTime - 5000); // Refresh 5 seconds before expiration
424
- }
425
- }
426
- }
427
-
428
399
  /**
429
400
  * @function forgotPassword
430
401
  * @async
@@ -3250,8 +3221,7 @@ class NomadMediaSDK {
3250
3221
  * @throws {Error} - An error is thrown if the input schedule event fails to add.
3251
3222
  * @throws {Error} - An error is thrown if the API type is not admin.
3252
3223
  */
3253
- async updateInputScheduleEvent(ID, CHANNEL_ID, INPUT, BACKUP_INPUT, FIXED_ON_AIR_TIME_UTC,
3254
- PREVIOUS_ID)
3224
+ async updateInputScheduleEvent(ID, CHANNEL_ID, INPUT, BACKUP_INPUT, FIXED_ON_AIR_TIME_UTC)
3255
3225
  {
3256
3226
  if (this.token === null)
3257
3227
  {
@@ -3269,7 +3239,7 @@ class NomadMediaSDK {
3269
3239
  {
3270
3240
  const ADD_INPUT_SCHEDULE_EVENT_INFO = await _updateInputScheduleEvent(this, this.token,
3271
3241
  this.config.serviceApiUrl, ID, CHANNEL_ID, INPUT, BACKUP_INPUT,
3272
- FIXED_ON_AIR_TIME_UTC, PREVIOUS_ID, this.debugMode);
3242
+ FIXED_ON_AIR_TIME_UTC, this.debugMode);
3273
3243
  _printDatetime(`Input schedule event updated`);
3274
3244
  return ADD_INPUT_SCHEDULE_EVENT_INFO;
3275
3245
  }
@@ -8801,7 +8771,7 @@ class NomadMediaSDK {
8801
8771
 
8802
8772
  try
8803
8773
  {
8804
- const CREATE_MEDIA_BUILDER_ITEM_INFO = await _createMediaBuilderItemsAddAnnotations(
8774
+ const CREATE_MEDIA_BUILDER_ITEM_INFO = await _createMediaBuilderItemsAddAnnotations(this,
8805
8775
  this.token, this.config.serviceApiUrl, MEDIA_BUILDER_ID, SOURCE_ASSET_ID,
8806
8776
  this.debugMode);
8807
8777
 
@@ -9222,7 +9192,7 @@ class NomadMediaSDK {
9222
9192
  * @throws {Error} - An error is thrown if the API type is not portal.
9223
9193
  */
9224
9194
  async updateMediaBuilder(MEDIA_BUILDER_ID, NAME, DESTINATION_FOLDER_ID, COLLECTIONS,
9225
- RELATED_CONTENTS, PROPERTIES)
9195
+ RELATED_CONTENTS, TAGS, PROPERTIES)
9226
9196
  {
9227
9197
  if (this.token === null)
9228
9198
  {
@@ -9240,7 +9210,7 @@ class NomadMediaSDK {
9240
9210
  {
9241
9211
  const UPDATE_MEDIA_BUILDER_INFO = await _updateMediaBuilder(this, this.token,
9242
9212
  this.config.serviceApiUrl, MEDIA_BUILDER_ID, NAME, DESTINATION_FOLDER_ID, COLLECTIONS,
9243
- RELATED_CONTENTS, PROPERTIES, this.debugMode);
9213
+ RELATED_CONTENTS, TAGS, PROPERTIES, this.debugMode);
9244
9214
  _printDatetime(`Media builder updated: ${MEDIA_BUILDER_ID}`);
9245
9215
  return UPDATE_MEDIA_BUILDER_INFO;
9246
9216
  }
@@ -9987,17 +9957,11 @@ async function _startRelatedAssetUpload(instance, AUTH_TOKEN, URL, EXISTING_ASSE
9987
9957
  {
9988
9958
  const API_URL = `${URL}/api/asset/upload/start-related-asset`;
9989
9959
 
9990
- const AWS_MIN_LIMIT = 5242880;
9991
- let chunkSize = FILE.size / 10000;
9992
-
9993
- if (chunkSize < (AWS_MIN_LIMIT * 4))
9994
- {
9995
- chunkSize = 20971520;
9996
- }
9960
+ const CHUNK_SIZE = 8388608;
9997
9961
 
9998
9962
  const BODY = {
9963
+ chunkSize: CHUNK_SIZE,
9999
9964
  contentLength: FILE.size,
10000
- chunkSize: chunkSize,
10001
9965
  existingAssetId: EXISTING_ASSET_ID,
10002
9966
  languageId: LANGUAGE_ID,
10003
9967
  newRelatedAssetMetadataType: NEW_RELATED_ASSET_METADATA_TYPE,
@@ -10006,7 +9970,7 @@ async function _startRelatedAssetUpload(instance, AUTH_TOKEN, URL, EXISTING_ASSE
10006
9970
  uploadOverwriteOption: UPLOAD_OVERWRITE_OPTION,
10007
9971
  };
10008
9972
 
10009
- await _sendRequest(instance, AUTH_TOKEN, "Start related asset upload", API_URL, "POST", null, BODY, DEBUG_MODE);
9973
+ return await _sendRequest(instance, AUTH_TOKEN, "Start related asset upload", API_URL, "POST", null, BODY, DEBUG_MODE);
10010
9974
 
10011
9975
  }
10012
9976
 
@@ -10568,7 +10532,6 @@ async function _clipLiveChannel(instance, AUTH_TOKEN, URL, CHANNEL_ID, START_TIM
10568
10532
 
10569
10533
 
10570
10534
 
10571
-
10572
10535
  async function _createLiveChannel(instance, AUTH_TOKEN, URL, NAME, THUMBNAIL_IMAGE_ID, ARCHIVE_FOLDER_ASSET_ID,
10573
10536
  ENABLE_HIGH_AVAILABILITY, ENABLE_LIVE_CLIPPING, IS_SECURE_OUTPUT, IS_OUTPUT_SCREENSHOTS,
10574
10537
  TYPE, EXTERNAL_URL, EXTERNAL_OUTPUT_PROFILES, SECURITY_GROUPS, DEBUG_MODE)
@@ -10609,7 +10572,7 @@ async function _createLiveChannel(instance, AUTH_TOKEN, URL, NAME, THUMBNAIL_IMA
10609
10572
  if (SECURITY_GROUPS) {
10610
10573
  const NOMAD_SECURITY_GROUPS = await _getSecurityGroups(instance, AUTH_TOKEN, URL, DEBUG_MODE);
10611
10574
 
10612
- BODY.securityGroups = NOMAD_SECURITY_GROUPS
10575
+ BODY.securityGroups = NOMAD_SECURITY_GROUPS.items
10613
10576
  .filter(group => SECURITY_GROUPS.includes(group.description))
10614
10577
  .map(group => ({
10615
10578
  description: group.description,
@@ -10638,7 +10601,7 @@ async function _deleteLiveChannel(instance, AUTH_TOKEN, URL, CHANNEL_ID, DELETE_
10638
10601
  {
10639
10602
  console.log(`Getting Live Channel Inputs IDs...`);
10640
10603
  }
10641
- INPUT_IDS = await _getLiveChannelInputsIds(AUTH_TOKEN, CHANNEL_ID);
10604
+ INPUT_IDS = await _getLiveChannelInputsIds(instance, AUTH_TOKEN, CHANNEL_ID);
10642
10605
  }
10643
10606
  else
10644
10607
  {
@@ -10655,7 +10618,7 @@ async function _deleteLiveChannel(instance, AUTH_TOKEN, URL, CHANNEL_ID, DELETE_
10655
10618
  for (let index = 0; index < INPUT_IDS.length; index++)
10656
10619
  {
10657
10620
  // Delete Live Input
10658
- await _deleteLiveInput(AUTH_TOKEN, INPUT_IDS[index]);
10621
+ await _deleteLiveInput(instance, AUTH_TOKEN, INPUT_IDS[index]);
10659
10622
  }
10660
10623
  }
10661
10624
 
@@ -10702,31 +10665,7 @@ async function _getLiveChannelScheduleEvents(instance, AUTH_TOKEN, URL, CHANNEL_
10702
10665
  {
10703
10666
  const API_URL = `${URL}/api/liveChannel/${CHANNEL_ID}/liveScheduleEvent`
10704
10667
 
10705
- // Create header for the request
10706
- const HEADERS = new Headers();
10707
- HEADERS.append("Content-Type", "application/json");
10708
- HEADERS.append("Authorization", `Bearer ${AUTH_TOKEN}`);
10709
-
10710
- if (DEBUG_MODE) console.log(`URL: ${API_URL}\nMETHOD: GET`);
10711
-
10712
- try
10713
- {
10714
- const RESPONSE = await fetch(API_URL, {
10715
- method: "GET",
10716
- headers: HEADERS
10717
- });
10718
-
10719
- // Check for success
10720
- if (!RESPONSE.ok) {
10721
- throw await RESPONSE.json()
10722
- }
10723
-
10724
- return await RESPONSE.json();
10725
- }
10726
- catch (error)
10727
- {
10728
- _apiExceptionHandler(error, "Get Live Channel Schedule Events Failed");
10729
- }
10668
+ return await _sendRequest(instance, AUTH_TOKEN, "Get Live Channel Schedule Events", API_URL, "GET", null, null, DEBUG_MODE);
10730
10669
  }
10731
10670
 
10732
10671
 
@@ -10872,10 +10811,10 @@ async function _startLiveChannel(instance, AUTH_TOKEN, URL, CHANNEL_ID, WAIT_FOR
10872
10811
  {
10873
10812
  const API_URL = `${URL}/api/liveChannel/${CHANNEL_ID}/start`
10874
10813
 
10875
- if (WAIT_FOR_START === false) return;
10876
- await _waitForLiveChannelStatus(instance, AUTH_TOKEN, URL, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Running, 1200, 20), DEBUG_MODE;
10814
+ await _sendRequest(instance, AUTH_TOKEN, "Start Live Channel", API_URL, "POST", null, null, DEBUG_MODE);
10877
10815
 
10878
- return await _sendRequest(instance, AUTH_TOKEN, "Start Live Channel", API_URL, "POST", null, null, DEBUG_MODE);
10816
+ if (!WAIT_FOR_START) return;
10817
+ await _waitForLiveChannelStatus(instance, AUTH_TOKEN, URL, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Running, 1200, 20, DEBUG_MODE);
10879
10818
  }
10880
10819
 
10881
10820
 
@@ -10885,28 +10824,7 @@ async function _startOutputTracking(instance, AUTH_TOKEN, URL, CHANNEL_ID, DEBUG
10885
10824
  {
10886
10825
  const API_URL = `${URL}/api/liveChannel/${CHANNEL_ID}/startOutputTracking`;
10887
10826
 
10888
- // Create header for the request
10889
- const HEADERS = new Headers();
10890
- HEADERS.append("Content-Type", "application/json");
10891
- HEADERS.append("Authorization", `Bearer ${AUTH_TOKEN}`);
10892
-
10893
- if (DEBUG_MODE) console.log(`URL: ${API_URL}\nMETHOD: POST`);
10894
-
10895
- try
10896
- {
10897
- const RESPONSE = await fetch(`${API_URL}`, {
10898
- method: "POST",
10899
- headers: HEADERS
10900
- });
10901
-
10902
- if (!RESPONSE.ok) {
10903
- throw await RESPONSE.json()
10904
- }
10905
- }
10906
- catch (error)
10907
- {
10908
- _apiExceptionHandler(error, "Start Output Tracking Failed");
10909
- }
10827
+ return await _sendRequest(instance, AUTH_TOKEN, "Start Output Tracking", API_URL, "POST", null, null, DEBUG_MODE);
10910
10828
  }
10911
10829
 
10912
10830
 
@@ -10918,30 +10836,10 @@ async function _stopLiveChannel(instance, AUTH_TOKEN, URL, CHANNEL_ID, WAIT_FOR_
10918
10836
  {
10919
10837
  const API_URL = `${URL}/api/liveChannel/${CHANNEL_ID}/stop`
10920
10838
 
10921
- // Create header for the request
10922
- const HEADERS = new Headers();
10923
- HEADERS.append("Authorization", `Bearer ${AUTH_TOKEN}`);
10924
-
10925
- if (DEBUG_MODE) console.log(`URL: ${API_URL}\nMETHOD: POST`);
10926
-
10927
- try
10928
- {
10929
- const RESPONSE = await fetch(API_URL, {
10930
- method: "POST",
10931
- headers: HEADERS
10932
- });
10933
-
10934
- if (!RESPONSE.ok) {
10935
- throw await RESPONSE.json()
10936
- }
10839
+ await _sendRequest(instance, AUTH_TOKEN, "Stop Live Channel", API_URL, "POST", null, null, DEBUG_MODE);
10937
10840
 
10938
- if (WAIT_FOR_STOP === false) return;
10939
- await _waitForLiveChannelStatus(instance, AUTH_TOKEN, URL, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Idle, 1200, 20, DEBUG_MODE);
10940
- }
10941
- catch (error)
10942
- {
10943
- _apiExceptionHandler(error, "Stop Live Channel Failed");
10944
- }
10841
+ if (!WAIT_FOR_STOP) return;
10842
+ await _waitForLiveChannelStatus(instance, AUTH_TOKEN, URL, CHANNEL_ID, _LIVE_CHANNEL_STATUSES.Idle, 1200, 20, DEBUG_MODE);
10945
10843
  }
10946
10844
 
10947
10845
 
@@ -11007,30 +10905,11 @@ async function _updateLiveChannel(instance, AUTH_TOKEN, URL, ID, NAME, THUMBNAIL
11007
10905
  if (FILTERED_SECURITY_GROUPS !== BODY.securityGroups) BODY.securityGroups = FILTERED_SECURITY_GROUPS;
11008
10906
  }
11009
10907
 
11010
- if (DEBUG_MODE) console.log(`URL: ${API_URL}\nMETHOD: POST\nBODY: ${JSON.stringify(BODY, null, 4 )}`);
11011
-
11012
- try
11013
- {
11014
- const RESPONSE = await fetch(API_URL, {
11015
- method: "PUT",
11016
- headers: HEADERS,
11017
- body: JSON.stringify(BODY)
11018
- });
11019
-
11020
- if (!RESPONSE.ok) {
11021
- throw await RESPONSE.json()
11022
- }
11023
-
11024
- const INFO = await RESPONSE.json();
10908
+ const INFO = await _sendRequest(instance, AUTH_TOKEN, "Update Live Channel", API_URL, "PUT", HEADERS, BODY, DEBUG_MODE);
11025
10909
 
11026
- await _waitForLiveChannelStatus(instance, AUTH_TOKEN, URL, INFO.id, _LIVE_CHANNEL_STATUSES.Idle, 120, 2, DEBUG_MODE);
10910
+ await _waitForLiveChannelStatus(instance, AUTH_TOKEN, URL, INFO.id, _LIVE_CHANNEL_STATUSES.Idle, 120, 2, DEBUG_MODE);
11027
10911
 
11028
- return INFO;
11029
- }
11030
- catch (error)
11031
- {
11032
- _apiExceptionHandler(error, "Updating Live Channel Failed");
11033
- }
10912
+ return INFO;
11034
10913
  }
11035
10914
 
11036
10915
 
@@ -11319,7 +11198,7 @@ async function _waitForLiveInputStatus(instance, AUTH_TOKEN, URL, INPUT_ID, STAT
11319
11198
  // Check for Error status
11320
11199
  if (INPUT_STATUS === "Error") {
11321
11200
  // Get the error message
11322
- const INPUT_STATUS_MESSAGE = await _getLiveInputStatusMessage(AUTH_TOKEN, INPUT_ID,
11201
+ const INPUT_STATUS_MESSAGE = await _getLiveInputStatusMessage(instance, AUTH_TOKEN, INPUT_ID,
11323
11202
  DEBUG_MODE);
11324
11203
 
11325
11204
  // Can't continue if Live Input is in error status
@@ -11606,29 +11485,7 @@ async function _updateLiveOutputProfileGroup(instance, AUTH_TOKEN, URL, LIVE_OUT
11606
11485
  outputProfiles: LIVE_OUTPUT_PROFILES || PROFILE_GROUP_INFO.outputProfiles
11607
11486
  };
11608
11487
 
11609
- if (DEBUG_MODE)
11610
- {
11611
- console.log(`API_URL: ${API_URL}\nMETHOD: PUT\nBODY: ${JSON.stringify(BODY, null, 4)}`);
11612
- }
11613
-
11614
- try
11615
- {
11616
- const RESPONSE = await fetch(API_URL, {
11617
- method: "PUT",
11618
- headers: HEADERS,
11619
- body: JSON.stringify(BODY)
11620
- });
11621
-
11622
- if (!RESPONSE.ok) {
11623
- throw new Error();
11624
- }
11625
-
11626
- return await RESPONSE.json();
11627
- }
11628
- catch (error)
11629
- {
11630
- _apiExceptionHandler(error, "Update Live Output Profile Group Failed");
11631
- }
11488
+ return await _sendRequest(instance, AUTH_TOKEN, "Update Live Output Profile Group", API_URL, "PUT", HEADERS, BODY, DEBUG_MODE);
11632
11489
  }
11633
11490
 
11634
11491
 
@@ -11669,28 +11526,7 @@ async function _deleteLiveOutputProfile(instance, AUTH_TOKEN, URL, OUTPUT_ID, DE
11669
11526
  {
11670
11527
  const API_URL = `${URL}/api/liveOutputProfile/${OUTPUT_ID}`;
11671
11528
 
11672
- // Create header for the request
11673
- const HEADERS = new Headers();
11674
- HEADERS.append("Content-Type", "application/json");
11675
- HEADERS.append("Authorization", `Bearer ${AUTH_TOKEN}`);
11676
-
11677
- if (DEBUG_MODE) console.log(`URL: ${API_URL}\nMETHOD: DELETE`);
11678
-
11679
- try
11680
- {
11681
- const RESPONSE = await fetch(API_URL, {
11682
- method: "DELETE",
11683
- headers: HEADERS
11684
- });
11685
-
11686
- if (!RESPONSE.ok) {
11687
- throw await RESPONSE.json()
11688
- }
11689
- }
11690
- catch (error)
11691
- {
11692
- _apiExceptionHandler(error, "Delete Live Output Profile Failed");
11693
- }
11529
+ return await _sendRequest(instance, AUTH_TOKEN, "Delete Live Output Profile", API_URL, "DELETE", null, null, DEBUG_MODE);
11694
11530
  }
11695
11531
 
11696
11532
 
@@ -11735,7 +11571,7 @@ async function _updateLiveOutputProfile(instance, AUTH_TOKEN, URL, ID, NAME, OUT
11735
11571
  {
11736
11572
  const API_URL = `${URL}/api/liveOutputProfile/${ID}`;
11737
11573
 
11738
- const PROFILE_INFO = await _getLiveOutputProfile(AUTH_TOKEN, URL, ID, DEBUG_MODE);
11574
+ const PROFILE_INFO = await _getLiveOutputProfile(instance, AUTH_TOKEN, URL, ID, DEBUG_MODE);
11739
11575
 
11740
11576
  const BODY = {
11741
11577
  name: NAME || PROFILE_INFO.name,
@@ -11924,8 +11760,33 @@ async function _updateInputScheduleEvent(instance, AUTH_TOKEN, URL, ID, CHANNEL_
11924
11760
  BODY.id = ID && ID !== SCHEDULE_EVENT_INFO.id ? ID : SCHEDULE_EVENT_INFO.id;
11925
11761
  BODY.channelId = CHANNEL_ID && CHANNEL_ID !== SCHEDULE_EVENT_INFO.channelId ? CHANNEL_ID : SCHEDULE_EVENT_INFO.channelId;
11926
11762
  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;
11927
- BODY.liveInput = INPUT && INPUT !== SCHEDULE_EVENT_INFO.liveInput ? INPUT : SCHEDULE_EVENT_INFO.liveInput;
11928
- BODY.liveInput2 = BACKUP_INPUT && BACKUP_INPUT !== SCHEDULE_EVENT_INFO.liveInput2 ? BACKUP_INPUT : SCHEDULE_EVENT_INFO.liveInput2;
11763
+
11764
+ if (INPUT && INPUT !== SCHEDULE_EVENT_INFO.liveInput)
11765
+ {
11766
+ BODY.liveInput = {
11767
+ id: INPUT.id,
11768
+ description: INPUT.name
11769
+ };
11770
+ }
11771
+ else
11772
+ {
11773
+ BODY.liveInput = {
11774
+ id: SCHEDULE_EVENT_INFO.liveInput.id,
11775
+ description: SCHEDULE_EVENT_INFO.liveInput.name
11776
+ };
11777
+ }
11778
+
11779
+ if (BACKUP_INPUT && BACKUP_INPUT !== SCHEDULE_EVENT_INFO.liveInput2) {
11780
+ BODY.liveInput2 = {
11781
+ id: BACKUP_INPUT.id,
11782
+ description: BACKUP_INPUT.name
11783
+ };
11784
+ } else if (SCHEDULE_EVENT_INFO.liveInput2) {
11785
+ BODY.liveInput2 = {
11786
+ id: SCHEDULE_EVENT_INFO.liveInput2.id,
11787
+ description: SCHEDULE_EVENT_INFO.liveInput2.name
11788
+ };
11789
+ }
11929
11790
 
11930
11791
  return await _sendRequest(instance, AUTH_TOKEN, "Updating Input Schedule Event", API_URL, "PUT", null, BODY, DEBUG_MODE);
11931
11792
  }
@@ -12345,7 +12206,7 @@ async function _updateIntelligentSchedule(instance, AUTH_TOKEN, URL, SCHEDULE_ID
12345
12206
  {
12346
12207
  const API_URL = `${URL}/api/admin/schedule/${SCHEDULE_ID}`;
12347
12208
 
12348
- const INTELLIGENT_SCHEDULE_INFO = await _getIntelligentSchedule(AUTH_TOKEN, URL, SCHEDULE_ID, DEBUG_MODE);
12209
+ const INTELLIGENT_SCHEDULE_INFO = await _getIntelligentSchedule(instance, AUTH_TOKEN, URL, SCHEDULE_ID, DEBUG_MODE);
12349
12210
 
12350
12211
  const BODY = {
12351
12212
  defaultVideoAsset: DEFAULT_VIDEO_ASSET || INTELLIGENT_SCHEDULE_INFO.defaultVideoAsset,
@@ -12382,7 +12243,7 @@ async function _updatePlaylist(instance, AUTH_TOKEN, URL, SCHEDULE_ID, DEFAULT_V
12382
12243
  {
12383
12244
  const API_URL = `${URL}/api/admin/schedule/${SCHEDULE_ID}`;
12384
12245
 
12385
- const PLAYLIST_INFO = await _getPlaylist(AUTH_TOKEN, URL, SCHEDULE_ID, DEBUG_MODE);
12246
+ const PLAYLIST_INFO = await _getPlaylist(instance, AUTH_TOKEN, URL, SCHEDULE_ID, DEBUG_MODE);
12386
12247
 
12387
12248
  const BODY = {
12388
12249
  defaultVideoAsset: DEFAULT_VIDEO_ASSET || PLAYLIST_INFO.defaultVideoAsset,
@@ -12405,7 +12266,7 @@ async function _updateScheduleItemAsset(instance, AUTH_TOKEN, URL, SCHEDULE_ID,
12405
12266
  {
12406
12267
  const API_URL = `${URL}/api/admin/schedule/${SCHEDULE_ID}/item/${ITEM_ID}`;
12407
12268
 
12408
- const ITEM_INFO = await _getScheduleItem(AUTH_TOKEN, URL, SCHEDULE_ID, ITEM_ID, DEBUG_MODE);
12269
+ const ITEM_INFO = await _getScheduleItem(instance, AUTH_TOKEN, URL, SCHEDULE_ID, ITEM_ID, DEBUG_MODE);
12409
12270
 
12410
12271
  const BODY = {
12411
12272
  asset: ASSET || ITEM_INFO.asset,
@@ -12430,7 +12291,7 @@ async function _updateScheduleItemLiveChannel(instance, AUTH_TOKEN, URL, SCHEDUL
12430
12291
  {
12431
12292
  const API_URL = `${URL}/api/admin/schedule/${SCHEDULE_ID}/item/${ITEM_ID}`;
12432
12293
 
12433
- const ITEM_INFO = await _getScheduleItem(AUTH_TOKEN, URL, SCHEDULE_ID, ITEM_ID, DEBUG_MODE);
12294
+ const ITEM_INFO = await _getScheduleItem(instance, AUTH_TOKEN, URL, SCHEDULE_ID, ITEM_ID, DEBUG_MODE);
12434
12295
 
12435
12296
  const BODY = {
12436
12297
  days: DAYS || ITEM_INFO.days,
@@ -12455,7 +12316,7 @@ async function _updateScheduleItemPlaylistSchedule(instance, AUTH_TOKEN, URL, SC
12455
12316
  {
12456
12317
  const API_URL = `${URL}/api/admin/schedule/${SCHEDULE_ID}/item/${ITEM_ID}`;
12457
12318
 
12458
- const ITEM_INFO = await _getScheduleItem(AUTH_TOKEN, URL, SCHEDULE_ID, ITEM_ID, DEBUG_MODE);
12319
+ const ITEM_INFO = await _getScheduleItem(instance, AUTH_TOKEN, URL, SCHEDULE_ID, ITEM_ID, DEBUG_MODE);
12459
12320
 
12460
12321
  const BODY = {
12461
12322
  days: DAYS || ITEM_INFO.days,
@@ -12482,7 +12343,7 @@ async function _updateScheduleItemSearchFilter(instance, AUTH_TOKEN, URL, SCHEDU
12482
12343
  {
12483
12344
  const API_URL = `${URL}/api/admin/schedule/${SCHEDULE_ID}/item/${ITEM_ID}`;
12484
12345
 
12485
- const ITEM_INFO = await _getScheduleItem(AUTH_TOKEN, URL, SCHEDULE_ID, ITEM_ID, DEBUG_MODE);
12346
+ const ITEM_INFO = await _getScheduleItem(instance, AUTH_TOKEN, URL, SCHEDULE_ID, ITEM_ID, DEBUG_MODE);
12486
12347
 
12487
12348
  const BODY = {
12488
12349
  collections: COLLECTIONS || ITEM_INFO.collections,
@@ -12784,6 +12645,7 @@ async function _logout(instance, AUTH_TOKEN, URL, DEBUG_MODE)
12784
12645
 
12785
12646
 
12786
12647
 
12648
+
12787
12649
  async function _refreshToken(instance, AUTH_TOKEN, URL, REFRESH_TOKEN, DEBUG_MODE)
12788
12650
  {
12789
12651
  const API_URL = `${URL}/api/account/refresh-token`;
@@ -12793,7 +12655,9 @@ async function _refreshToken(instance, AUTH_TOKEN, URL, REFRESH_TOKEN, DEBUG_MOD
12793
12655
  };
12794
12656
 
12795
12657
  const TOKEN_INFO = await _sendRequest(instance, AUTH_TOKEN, "Refreshing Token", API_URL, "POST", null, BODY, DEBUG_MODE);
12796
- return TOKEN_INFO;
12658
+ instance.token = TOKEN_INFO.token;
12659
+
12660
+ return true;
12797
12661
  }
12798
12662
 
12799
12663
 
@@ -13520,7 +13384,7 @@ async function _bulkUpdateMetadata(instance, AUTH_TOKEN, URL, CONTENT_IDS, COLLE
13520
13384
  {
13521
13385
  const API_URL = `${URL}/api/admin/content/bulk-metadata-update`;
13522
13386
 
13523
- const ASSET_DETAILS = await _getAssetDetails(AUTH_TOKEN, URL, CONTENT_IDS[0], "admin", DEBUG_MODE);
13387
+ const ASSET_DETAILS = await _getAssetDetails(this, AUTH_TOKEN, URL, CONTENT_IDS[0], "admin", DEBUG_MODE);
13524
13388
 
13525
13389
  const BODY = {
13526
13390
  collections: [
@@ -13584,7 +13448,7 @@ async function _deleteTagOrCollection(instance, AUTH_TOKEN, URL, TYPE, TAG_ID, D
13584
13448
  {
13585
13449
  const API_URL = `${URL}/api/admin/${TYPE}/${TAG_ID}`;
13586
13450
 
13587
- return await _sendRequest(instance, AUTH_TOKEN, "Delete Tag or Collection", API_URL, "POST", null, null, DEBUG_MODE);
13451
+ return await _sendRequest(instance, AUTH_TOKEN, "Delete Tag or Collection", API_URL, "DELETE", null, null, DEBUG_MODE);
13588
13452
  }
13589
13453
 
13590
13454
 
@@ -13757,7 +13621,7 @@ import axios from 'axios';
13757
13621
 
13758
13622
  const MAX_RETRIES = 5;
13759
13623
  const TIMEOUT = 30000;
13760
- const SLEEP_TIME = 60000;
13624
+ const SLEEP_TIME = .5;
13761
13625
 
13762
13626
  async function _sendRequest(instance, AUTH_TOKEN, FUNCTION_NAME, URL, METHOD_TYPE, PARAMS, BODY, DEBUG)
13763
13627
  {
@@ -13767,7 +13631,7 @@ async function _sendRequest(instance, AUTH_TOKEN, FUNCTION_NAME, URL, METHOD_TYP
13767
13631
 
13768
13632
  if (AUTH_TOKEN) HEADERS["Authorization"] = `Bearer ${AUTH_TOKEN}`;
13769
13633
 
13770
- if (DEBUG) console.log(`URL: ${URL}\nMETHOD: ${METHOD_TYPE}` + (PARAMS ? `\nPARAMS: ${JSON.stringify(PARAMS, null, 4)}` : "") + (BODY ? `\nBODY: ${JSON.stringify(BODY, null, 4)}` : ""));
13634
+ if (DEBUG) console.log(`URL: ${URL}\nMETHOD: ${METHOD_TYPE}` + (PARAMS && PARAMS.size === 0 ? `\nPARAMS: ${JSON.stringify(PARAMS, null, 4)}` : "") + (BODY ? `\nBODY: ${JSON.stringify(BODY, null, 4)}` : ""));
13771
13635
 
13772
13636
  let retries = 0;
13773
13637
  let RESPONSE = null;
@@ -13789,29 +13653,26 @@ async function _sendRequest(instance, AUTH_TOKEN, FUNCTION_NAME, URL, METHOD_TYP
13789
13653
  break;
13790
13654
  }
13791
13655
 
13792
- if (RESPONSE.status === 403 && FUNCTION_NAME !== "Refreshing Token")
13793
- {
13794
- await instance.refreshToken();
13795
- }
13796
- else
13797
- {
13798
- throw new Error();
13799
- }
13800
-
13656
+ throw new Error();
13801
13657
  }
13802
13658
  catch (error)
13803
13659
  {
13804
- if (error.code === 'ECONNABORTED' && retries < MAX_RETRIES)
13660
+ if (error?.response?.status === 403)
13805
13661
  {
13806
- retries++;
13807
- await _sleep(SLEEP_TIME * 2 ** retries);
13808
- }
13662
+ await instance.refreshToken();
13663
+ HEADERS["Authorization"] = `Bearer ${instance.token}`;
13664
+ }
13665
+ else if (error.code === 'ECONNABORTED')
13666
+ {
13667
+ await _sleep(SLEEP_TIME ** 2);
13668
+ }
13809
13669
  else
13810
13670
  {
13811
- _apiExceptionHandler(error.message, `${FUNCTION_NAME} failed`);
13671
+ _apiExceptionHandler(error.response?.data.message ? error.response.data.message : error.message, `${FUNCTION_NAME} failed`);
13812
13672
  }
13673
+ ++retries;
13813
13674
  }
13814
- } while (!RESPONSE || RESPONSE.status < 200 || RESPONSE.status >= 300);
13675
+ } while ((!RESPONSE || RESPONSE.status < 200 || RESPONSE.status >= 300) && retries < MAX_RETRIES);
13815
13676
  try { return RESPONSE.data; }
13816
13677
  catch (error) { return; }
13817
13678
  }
@@ -14316,7 +14177,7 @@ async function _updateMediaBuilder(instance, AUTH_TOKEN, URL, ID, NAME, DESTINAT
14316
14177
  {
14317
14178
  const API_URL = `${URL}/api/mediaBuilder/${ID}`;
14318
14179
 
14319
- const MEDIA_BUILDER_INFO = await _getMediaBuilder(AUTH_TOKEN, URL, ID, DEBUG_MODE);
14180
+ const MEDIA_BUILDER_INFO = await _getMediaBuilder(this, AUTH_TOKEN, URL, ID, DEBUG_MODE);
14320
14181
 
14321
14182
  const BODY = {
14322
14183
  name: NAME || MEDIA_BUILDER_INFO.name,
@@ -14560,7 +14421,20 @@ async function _getSearchSaved(instance, AUTH_TOKEN, URL, QUERY, OFFSET, SIZE ,
14560
14421
  {
14561
14422
  const API_URL = `${URL}/api/portal/search-saved`;
14562
14423
 
14563
- return await _sendRequest(instance, AUTH_TOKEN, "Get Search Saved", API_URL, "POST\nBODY: ${JSON.stringify(CRITERIA_BODY, null, 4 )}", null, null, DEBUG_MODE);
14424
+ const BODY = {
14425
+ "query": QUERY,
14426
+ "pageOffset": OFFSET,
14427
+ "pageSize": SIZE,
14428
+ "filters": FILTERS,
14429
+ "sortFields": SORT_FIELDS,
14430
+ "searchResultFields": SEARCH_RESULT_FIELDS,
14431
+ "similarAssetId": SIMILAR_ASSET_ID,
14432
+ "minScore": MIN_SCORE,
14433
+ "excludeTotalRecordCount": EXCLUDE_TOTAL_RECORD_COUNT,
14434
+ "filterBinder": FILTER_BINDER
14435
+ };
14436
+
14437
+ return await _sendRequest(instance, AUTH_TOKEN, "Get Search Saved", API_URL, "POST", null, BODY, DEBUG_MODE);
14564
14438
  }
14565
14439
 
14566
14440
 
@@ -14592,7 +14466,7 @@ async function _updateSavedSearch(instance, AUTH_TOKEN, URL, ID, NAME, FEATURED,
14592
14466
  {
14593
14467
  const API_URL = `${URL}/api/portal/savedsearch/${ID}`;
14594
14468
 
14595
- const SAVED_SEARCH_INFO = await _getSavedSearch(AUTH_TOKEN, URL, ID, DEBUG_MODE);
14469
+ const SAVED_SEARCH_INFO = await _getSavedSearch(instance, AUTH_TOKEN, URL, ID, DEBUG_MODE);
14596
14470
 
14597
14471
  const BODY= {
14598
14472
  "id": ID,