@nomad-media/full 1.1.19 → 1.1.21

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.
@@ -326,7 +326,7 @@ class NomadMediaSDK {
326
326
  * @async
327
327
  * @description Logs in using the username and password from the config.
328
328
  * @returns {Promise<void>} - A promise that resolves when the login is successful.
329
- * Updates the token, refresh token, expiration seconds, and user session ID class varibles.
329
+ * Updates the token, refresh token, expiration seconds, and user session ID class variables.
330
330
  * @throws {Error} - An error is thrown if the login fails.
331
331
  */
332
332
  async login()
@@ -382,7 +382,7 @@ class NomadMediaSDK {
382
382
  }
383
383
  catch (error)
384
384
  {
385
- _printDatetime("Loggout failed");
385
+ _printDatetime("Logout failed");
386
386
  throw error;
387
387
  }
388
388
  }
@@ -490,7 +490,7 @@ class NomadMediaSDK {
490
490
  * and cancel. Continue continues the upload from where it left off. Replace replaces an
491
491
  * existing asset. Replace is the one you want to use if you are starting a new upload.
492
492
  * Cancel cancels an uploading asset.
493
- * @param {File | string} FILE - The FILE object or full or relateive path of the file to upload.
493
+ * @param {File | string} FILE - The FILE object or full or relative path of the file to upload.
494
494
  * This is ignored if the ExistingAssetId or if the RelatedContentId has a value.
495
495
  * @param {string | null} PARENT_ID - The Parent AssetId (folder) to add the upload to.
496
496
  * Note that if there is a full relativePath, then it is appended to this parent path.
@@ -498,12 +498,14 @@ class NomadMediaSDK {
498
498
  * This is ignored if the ExistingAssetId or if the RelatedContentId has a value.
499
499
  * @param {string | null} LANGUAGE_ID - The language of the asset to upload.
500
500
  * If this is left blank then the default system language is used.
501
+ * @param {Array<String> | null} UPLOAD_REPLACE_OPTIONS - Gets or sets if the asset already
502
+ * exists on the server, this decides how to handle the situation with related assets.
501
503
  * @returns {Promise<string>} - A promise that resolves when the asset is uploaded.
502
504
  * Returns the content ID of the uploaded asset.
503
505
  * @throws {Error} - An error is thrown if the asset fails to upload.
504
506
  */
505
507
  async uploadAsset(NAME, EXISTING_ASSET_ID, RELATED_CONTENT_ID,
506
- UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID)
508
+ UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID, UPLOAD_REPLACE_OPTIONS)
507
509
  {
508
510
  if (this.token === null)
509
511
  {
@@ -515,16 +517,23 @@ class NomadMediaSDK {
515
517
  let startUploadInfo = null
516
518
  try
517
519
  {
518
- const FILE_PROPS = (await _processFile(FILE))[0];
520
+ const FILE_PROPS = (await _processFile(FILE));
521
+ if (!FILE_PROPS)
522
+ {
523
+ _printDatetime("File not found");
524
+ return;
525
+ }
519
526
 
520
527
  _printDatetime("Starting upload");
521
528
  startUploadInfo = await _startUpload(this, NAME, EXISTING_ASSET_ID,
522
529
  RELATED_CONTENT_ID, UPLOAD_OVERWRITE_OPTION, FILE_PROPS, PARENT_ID,
523
- LANGUAGE_ID);
530
+ LANGUAGE_ID, UPLOAD_REPLACE_OPTIONS);
524
531
 
525
532
  if (!startUploadInfo) throw new Error("Failed to start upload");
526
533
 
527
- await _multiThreadUpload(this, FILE_PROPS, startUploadInfo);
534
+ const response = await _multiThreadUpload(this, FILE_PROPS, startUploadInfo);
535
+ if (!response) throw new Error("Failed to upload");
536
+
528
537
  await _completeUpload(this, startUploadInfo["id"]);
529
538
 
530
539
  const CONTENT_ID = startUploadInfo.assetId;
@@ -580,6 +589,11 @@ class NomadMediaSDK {
580
589
  try
581
590
  {
582
591
  const FILE_PROPS = await _processFile(FILE);
592
+ if (!FILE_PROPS)
593
+ {
594
+ _printDatetime("File not found");
595
+ return;
596
+ }
583
597
 
584
598
  startUploadInfo = await _startRelatedAssetUpload(this, EXISTING_ASSET_ID,
585
599
  RELATED_ASSET_ID, NEW_RELATED_ASSET_METADATA_TYPE, UPLOAD_OVERWRITE_OPTION,
@@ -587,7 +601,8 @@ class NomadMediaSDK {
587
601
 
588
602
  if (!startUploadInfo) throw new Error("Failed to start related asset upload");
589
603
 
590
- await _multiThreadUpload(this, FILE_PROPS, startUploadInfo);
604
+ const response = await _multiThreadUpload(this, FILE_PROPS, startUploadInfo);
605
+ if (!response) throw new Error("Failed to upload");
591
606
 
592
607
  await _completeUpload(this, startUploadInfo.id);
593
608
  _printDatetime("Related asset upload successful");
@@ -1052,14 +1067,20 @@ class NomadMediaSDK {
1052
1067
  * @param {string} CONTENT_ID - The ID of the content to add the custom properties to.
1053
1068
  * @param {string | null} NAME - The name of the content to add the custom properties to.
1054
1069
  * @param {string | null} DATE - The display date of the content to add to the custom properties.
1055
- * @param {JSON} CUSTOM_PROPERTIES - A list of custom properties that should be saved for the
1070
+ * @param {JSON | null} CUSTOM_PROPERTIES - A list of custom properties that should be saved for the
1056
1071
  * asset. To remove a property value, set the value to null
1072
+ * @param {string} AVAILABLE_START_DATE - Gets or sets the availability starting date of the asset
1073
+ * for entitlement purposes MinValue is used to differentiate between null values and missing properties
1074
+ * We technically want null so we can clear the date.
1075
+ * @param {string} AVAILABLE_END_DATE - Gets or sets the availability ending date of the asset
1076
+ * for entitlement purposes MaxValue is used to differentiate between null values and missing properties
1077
+ * We technically want null so we can clear the date.
1057
1078
  * @returns {Promise<JSON>} - A promise that resolves when the custom properties are added.
1058
1079
  * Returns the information of the added custom properties.
1059
1080
  * @throws {Error} - An error is thrown if the custom properties fail to add.
1060
1081
  * @throws {Error} - An error is thrown if the API type is not admin.
1061
1082
  */
1062
- async addCustomProperties(CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES)
1083
+ async addCustomProperties(CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES, AVAILABLE_START_DATE, AVAILABLE_END_DATE)
1063
1084
  {
1064
1085
  if (this.token === null)
1065
1086
  {
@@ -1076,7 +1097,7 @@ class NomadMediaSDK {
1076
1097
  try
1077
1098
  {
1078
1099
  const ADD_CUSTOM_PROPERTIES_INFO = await _addCustomProperties(this,
1079
- CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES);
1100
+ CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES, AVAILABLE_START_DATE, AVAILABLE_END_DATE);
1080
1101
  if (ADD_CUSTOM_PROPERTIES_INFO) _printDatetime(`Custom properties added to content: ${CONTENT_ID}`);
1081
1102
  return ADD_CUSTOM_PROPERTIES_INFO;
1082
1103
  }
@@ -1506,7 +1527,7 @@ class NomadMediaSDK {
1506
1527
  * @param {string | null} CONTENT_DEFINITION_GROUP - The content definition group of the content definition to update.
1507
1528
  * enum: Custom Definitions, Forms, Layout, Navigation, Page Content, System Definitions
1508
1529
  * @param {string | null} CONTENT_DEFINITION_TYPE - The content definition type of the content definition to update.
1509
- * enum: Asset List Content Type, Basic Content, Dynamic Module Content Type, Form Content Type, Navigetion Content Type
1530
+ * enum: Asset List Content Type, Basic Content, Dynamic Module Content Type, Form Content Type, navigation Content Type
1510
1531
  * @param {string | null} DISPLAY_FIELD - The display field of the content definition to update. Must be a field in the content definition or the content field
1511
1532
  * @param {string | null} ROUTE_ITEM_NAME_FIELD - The route item name field of the content definition to update. Must be a field in the content definition or the content field
1512
1533
  * @param {Array<string> | null} SECURITY_GROUPS - The security groups of the content definition to update.
@@ -1644,7 +1665,7 @@ class NomadMediaSDK {
1644
1665
  /**
1645
1666
  * @function addLiveScheduleToEvent
1646
1667
  * @async
1647
- * @description Adds a live schedule to an event and updated live schedule attatched to event.
1668
+ * @description Adds a live schedule to an event and updated live schedule attached to event.
1648
1669
  * @param {string} EVENT_ID - The ID of the event to add the live schedule to.
1649
1670
  * @param {JSON | null} SLATE_VIDEO - The slate video ID of the event.
1650
1671
  * JSON format: {"id": string, "description": string }
@@ -1861,7 +1882,7 @@ class NomadMediaSDK {
1861
1882
  * @param {string} BUCKET_NAME - The name of the bucket to create the job in.
1862
1883
  * @param {string} OBJECT_KEY - The object key of the job.
1863
1884
  * @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.
1885
+ * @param {string} EXTERNAL_ID - The external id of the job.
1865
1886
  * @param {boolean | null} REPLACE_EXISTING_JOB - Whether to replace an existing job.
1866
1887
  * @param {string | null} ASSET_URL - The asset url of the job.
1867
1888
  * @param {Array<string> | null} REQUESTED_TASKS - The tasks to request for the job.
@@ -1890,8 +1911,8 @@ class NomadMediaSDK {
1890
1911
  try
1891
1912
  {
1892
1913
  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);
1914
+ this, BUCKET_NAME, OBJECT_KEY, NOTIFICATION_CALLBACK_URL, EXTERNAL_ID,
1915
+ REPLACE_EXISTING_JOB, ASSET_URL, REQUESTED_TASKS, REQUESTED_TRANSCODE_PROFILES);
1895
1916
  if (CREATE_JOB_RESULT) _printDatetime(`Job created: ${BUCKET_NAME}`);
1896
1917
  return CREATE_JOB_RESULT;
1897
1918
  } catch (error) {
@@ -1926,7 +1947,7 @@ class NomadMediaSDK {
1926
1947
 
1927
1948
  try
1928
1949
  {
1929
- await _createJob(
1950
+ await _createJobId(
1930
1951
  this, ASSET_ID, JOB_RESULTS_URL, EXTERNAL_ID);
1931
1952
  _printDatetime(`Job created: ${ASSET_ID}`);
1932
1953
  } catch (error) {
@@ -5940,7 +5961,7 @@ class NomadMediaSDK {
5940
5961
  /**
5941
5962
  * @function copyAsset
5942
5963
  * @async
5943
- * @description Copys an asset.
5964
+ * @description Copies an asset.
5944
5965
  * @param {Array<string>} ASSET_IDS - The IDs of the asset to copy.
5945
5966
  * @param {string} DESTINATION_FOLDER_ID - The destination folder ID of the asset.
5946
5967
  * @param {JSON | null} BATCH_ACTION - The actions to be performed.
@@ -5949,14 +5970,14 @@ class NomadMediaSDK {
5949
5970
  * @param {string | null} SCHEMA_NAME - The schema name of the asset.
5950
5971
  * Note that we convert all incoming keys to lower first char to help with serialization for JSON later
5951
5972
  * JSON format: {"key": "string", "value": "string"}
5952
- * @param {boolean | null} RESOLVER_EXCEMPT - The resolver excempt of the asset.
5973
+ * @param {boolean | null} RESOLVER_EXEMPT - The resolver exempt of the asset.
5953
5974
  * @returns {Promise<JSON>} - A promise that resolves when the assets are performed.
5954
5975
  * Returns the information of the performed assets.
5955
5976
  * @throws {Error} - An error is thrown if the assets fail to perform.
5956
5977
  * @throws {Error} - An error is thrown if the API type is not admin.
5957
5978
  */
5958
5979
  async copyAsset(ASSET_IDS, DESTINATION_FOLDER_ID, BATCH_ACTION,
5959
- CONTENT_DEFINITION_ID, SCHEMA_NAME, RESOLVER_EXCEMPT)
5980
+ CONTENT_DEFINITION_ID, SCHEMA_NAME, RESOLVER_EXEMPT)
5960
5981
  {
5961
5982
  if (this.token === null)
5962
5983
  {
@@ -5973,7 +5994,7 @@ class NomadMediaSDK {
5973
5994
  try
5974
5995
  {
5975
5996
  const COPY_INFO = await _copyAsset(this, ASSET_IDS, DESTINATION_FOLDER_ID, BATCH_ACTION,
5976
- CONTENT_DEFINITION_ID, SCHEMA_NAME, RESOLVER_EXCEMPT);
5997
+ CONTENT_DEFINITION_ID, SCHEMA_NAME, RESOLVER_EXEMPT);
5977
5998
  if (COPY_INFO) _printDatetime(`Asset(s) copied: ${ASSET_IDS}`);
5978
5999
  return COPY_INFO;
5979
6000
  }
@@ -6947,14 +6968,14 @@ class NomadMediaSDK {
6947
6968
  * @param {JSON | null} BATCH_ACTION - The batch action of the move.
6948
6969
  * @param {string | null} CONTENT_DEFINITION_ID - The content definition ID of the move.
6949
6970
  * @param {string | null} SCHEMA_NAME - The schema name of the move.
6950
- * @param {boolean | null} RESOLVER_EXCEMPT - The resolver excempt of the move.
6971
+ * @param {boolean | null} RESOLVER_EXEMPT - The resolver exempt of the move.
6951
6972
  * @returns {Promise<JSON>} - A promise that resolves when the asset is moved.
6952
6973
  * Returns the information of the moved asset.
6953
6974
  * @throws {Error} - An error is thrown if the asset fails to move.
6954
6975
  * @throws {Error} - An error is thrown if the API type is not admin.
6955
6976
  */
6956
6977
  async moveAsset(ASSET_ID, DESTINATION_FOLDER_ID, NAME, BATCH_ACTION,
6957
- CONTENT_DEFINITION_ID, SCHEMA_NAME, RESOLVER_EXCEMPT)
6978
+ CONTENT_DEFINITION_ID, SCHEMA_NAME, RESOLVER_EXEMPT)
6958
6979
  {
6959
6980
  if (this.token === null)
6960
6981
  {
@@ -6971,7 +6992,7 @@ class NomadMediaSDK {
6971
6992
  try
6972
6993
  {
6973
6994
  const MOVE_INFO = await _moveAsset(this, ASSET_ID, DESTINATION_FOLDER_ID, NAME,
6974
- BATCH_ACTION, CONTENT_DEFINITION_ID, SCHEMA_NAME, RESOLVER_EXCEMPT);
6995
+ BATCH_ACTION, CONTENT_DEFINITION_ID, SCHEMA_NAME, RESOLVER_EXEMPT);
6975
6996
  if (MOVE_INFO) _printDatetime(`Asset moved: ${ASSET_ID}`);
6976
6997
  return MOVE_INFO;
6977
6998
  }
@@ -7044,7 +7065,7 @@ class NomadMediaSDK {
7044
7065
  * "Moving", "SlugReplaced", "Updating", "Error", "Assembling", "Clipping", "Placeholder", "Creating"
7045
7066
  * @param {string | null} STORAGE_CLASS - The storage class of the register.
7046
7067
  * enum: "Standard", "ReducedRedundancy", "Glacier", "StandardInfrequentAccess",
7047
- * "OneZoneInfrequentAccess", "IntelligentTiering", "DeepArchive", "GlacierInstanctRetrival",
7068
+ * "OneZoneInfrequentAccess", "IntelligentTiering", "DeepArchive", "GlacierInstantRetrieval",
7048
7069
  * "Outposts"
7049
7070
  * @param {string | null} ASSET_TYPE - The asset type of the register.
7050
7071
  * enum: "Folder", "File", "Bucket"
@@ -7460,13 +7481,12 @@ class NomadMediaSDK {
7460
7481
  * @function ping
7461
7482
  * @async
7462
7483
  * @description Pings the user.
7463
- * @param {string | null} APPLICATION_ID - The application ID of the user.
7464
- * @param {string | nul} USER_SESSION_ID - The user session ID of the user.
7484
+ * @param {boolean | null} INCLUDE_HEADERS
7465
7485
  * @returns {Promise<JSON>} - A promise that resolves when the user is pinged.
7466
7486
  * Returns the ping status of the user.
7467
7487
  * @throws {Error} - An error is thrown if the user fails to ping.
7468
7488
  */
7469
- async ping(APPLICATION_ID, USER_SESSION_ID)
7489
+ async ping(INCLUDE_HEADERS)
7470
7490
  {
7471
7491
  if (this.token === null)
7472
7492
  {
@@ -7477,7 +7497,7 @@ class NomadMediaSDK {
7477
7497
 
7478
7498
  try
7479
7499
  {
7480
- const PING = await _ping(this, APPLICATION_ID, USER_SESSION_ID);
7500
+ const PING = await _ping(this, INCLUDE_HEADERS);
7481
7501
  if (PING) _printDatetime(`User pinged`);
7482
7502
  return PING;
7483
7503
  }
@@ -7563,7 +7583,7 @@ class NomadMediaSDK {
7563
7583
  * @param {Array<string> | null} FULL_URL_FIELD_NAMES - Gets or sets the list of fields that should have
7564
7584
  * the FullURL calculated. The calculations are expensive and greatly slow down the query.
7565
7585
  * @param {string | null} DISTINCT_ON_FIELD_NAME - Gets or sets optional property that will be used to
7566
- * aggregate results records to distinct occurances of this field's values.
7586
+ * aggregate results records to distinct occurrences of this field's values.
7567
7587
  * @param {boolean | null} INCLUDE_VIDEO_CLIPS - Gets or sets a value indicating whether specify
7568
7588
  * if the video search results are grouped by include clips of the videos also.*
7569
7589
  * @param {bool | null} USE_LLM_SEARCH - Gets or sets a value indicating whether gets or
@@ -7595,7 +7615,7 @@ class NomadMediaSDK {
7595
7615
  DISTINCT_ON_FIELD_NAME, INCLUDE_VIDEO_CLIPS, USE_LLM_SEARCH,
7596
7616
  INCLUDE_INTERNAL_FIELDS_IN_RESULTS);
7597
7617
  if (SEARCH_INFO) _printDatetime(`Search complete`);
7598
- return SEARCH_INFO.hasItems ? SEARCH_INFO : false
7618
+ return SEARCH_INFO?.hasItems ? SEARCH_INFO : false
7599
7619
  }
7600
7620
  catch (error)
7601
7621
  {
@@ -8411,12 +8431,13 @@ class NomadMediaSDK {
8411
8431
  * @async
8412
8432
  * @description Gets media group.
8413
8433
  * @param {string} MEDIA_GROUP_ID - The ID of the media group.
8434
+ * @param { Array<string> } FILTER_IDS - The IDs of the media group items to filter by.
8414
8435
  * @returns {Promise<JSON>} - A promise that resolves when the media group is gotten.
8415
8436
  * Returns the information of the gotten media group.
8416
8437
  * @throws {Error} - An error is thrown if the media group fails to get.
8417
8438
  * @throws {Error} - An error is thrown if the API type is not portal.
8418
8439
  */
8419
- async getMediaGroup(MEDIA_GROUP_ID)
8440
+ async getMediaGroup(MEDIA_GROUP_ID, FILTER_IDS)
8420
8441
  {
8421
8442
  if (this.token === null)
8422
8443
  {
@@ -8432,7 +8453,7 @@ class NomadMediaSDK {
8432
8453
 
8433
8454
  try
8434
8455
  {
8435
- const GET_MEDIA_GROUP_INFO = await _getMediaGroup(this, MEDIA_GROUP_ID);
8456
+ const GET_MEDIA_GROUP_INFO = await _getMediaGroup(this, MEDIA_GROUP_ID, FILTER_IDS);
8436
8457
  if (GET_MEDIA_GROUP_INFO) _printDatetime(`Media group gotten: ${MEDIA_GROUP_ID}`);
8437
8458
  return GET_MEDIA_GROUP_INFO;
8438
8459
  }
@@ -9768,22 +9789,26 @@ class NomadMediaSDK {
9768
9789
  * JSON format: {"id": string, "description": string }
9769
9790
  * @param {JSON | null} SHARED_DURATION - The shared Duration of the share.
9770
9791
  * JSON format: {"id": string, "description": string }
9771
- * @param {Array<JSON> | null} SHARED_PERMISSION - The sharedPermissions of the share.
9792
+ * @param {Array<JSON> | null} SHARED_PERMISSIONS - The sharedPermissions of the share.
9772
9793
  * JSON format: {"id": string, "description": string }
9773
9794
  * @param {JSON | null} SHARED_TYPE: - The sharedType of the share.
9774
9795
  * JSON format: {"id": string, "description": string }
9775
- * @param {Array<JSON> | null} SHARED_STATUS - The sharedStatus of the share.
9796
+ * @param {JSON | null} SHARED_STATUS - The sharedStatus of the share.
9776
9797
  * JSON format: {"id": string, "description": string }
9777
9798
  * @param {integer | null} SHARED_DURATION_IN_HOURS - The sharedDurationInHours of the share.
9778
9799
  * @param {string | null} SHARED_LINK - The sharedLink of the share.
9779
9800
  * @param {string | null} OWNER_ID - The ownerId of the share.
9780
9801
  * @param {string | null} EXPIRATION_DATE - The expirationDate of the share.
9802
+ * @param {string | null} ASSET_ID - The assetId of the share.
9803
+ * @param {Array<JSON> | null} SHARED_USERS - The sharedUsers of the share.
9804
+ * JSON format: {"id": string, "description": string }
9781
9805
  * @returns {Promise<object>}
9782
9806
  * @throws {Error} - An error is thrown if share fails.
9783
9807
  * @throws {Error} - An error is the API type is not post.
9784
9808
  */
9785
9809
  async share(ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE,
9786
- SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE)
9810
+ SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE,
9811
+ ASSET_ID, SHARED_USERS)
9787
9812
  {
9788
9813
  if (this.token === null)
9789
9814
  {
@@ -9801,7 +9826,8 @@ class NomadMediaSDK {
9801
9826
  {
9802
9827
  const RESPONSE = await _share(this, ID, NAME, SHARED_CONTENTS,
9803
9828
  SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE, SHARED_STATUS,
9804
- SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE);
9829
+ SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE,
9830
+ ASSET_ID, SHARED_USERS);
9805
9831
 
9806
9832
  _printDatetime(`Share called successfully.`);
9807
9833
 
@@ -9909,18 +9935,22 @@ class NomadMediaSDK {
9909
9935
  * JSON format: {"id": string, "description": string }
9910
9936
  * @param {JSON | null} SHARED_TYPE - The sharedType of the updateShare.
9911
9937
  * JSON format: {"id": string, "description": string }
9912
- * @param {Array<JSON> | null} SHARED_STATUS - The sharedStatus of the updateShare.
9938
+ * @param {JSON | null} SHARED_STATUS - The sharedStatus of the updateShare.
9913
9939
  * JSON format: {"id": string, "description": string }
9914
9940
  * @param {integer | null} SHARED_DURATION_IN_HOURS - The sharedDurationInHours of the updateShare.
9915
9941
  * @param {string | null} SHARED_LINK - The sharedLink of the updateShare.
9916
9942
  * @param {string | null} OWNER_ID - The ownerId of the updateShare.
9917
9943
  * @param {string | null} EXPIRATION_DATE - The expirationDate of the updateShare.
9944
+ * @param {string | null} ASSET_ID - The assetId of the updateShare.
9945
+ * @param {Array<JSON> | null} SHARED_USERS - The sharedUsers of the updateShare.
9946
+ * JSON format: {"id": string, "description": string }
9918
9947
  * @returns {Promise<object>}
9919
9948
  * @throws {Error} - An error is thrown if updateShare fails.
9920
9949
  * @throws {Error} - An error is the API type is not put.
9921
9950
  */
9922
9951
  async updateShare(SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS,
9923
- SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE)
9952
+ SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE,
9953
+ ASSET_ID, SHARED_USERS)
9924
9954
  {
9925
9955
  if (this.token === null)
9926
9956
  {
@@ -9939,7 +9969,7 @@ class NomadMediaSDK {
9939
9969
  const RESPONSE = await _updateShare(this, SHARE_ID, ID, NAME,
9940
9970
  SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE,
9941
9971
  SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID,
9942
- EXPIRATION_DATE);
9972
+ EXPIRATION_DATE, ASSET_ID, SHARED_USERS);
9943
9973
 
9944
9974
  _printDatetime(`Update share called successfully.`);
9945
9975
 
@@ -9997,7 +10027,7 @@ class NomadMediaSDK {
9997
10027
 
9998
10028
  // misc functions
9999
10029
  /**
10000
- * @function miscFunctons
10030
+ * @function miscFunctions
10001
10031
  * @async
10002
10032
  * @description Calls any nomad function given URL method and body.
10003
10033
  * @param {string} URL_PATH - The URL path of the function.
@@ -10092,44 +10122,60 @@ async function _cancelUpload(instance, ID)
10092
10122
 
10093
10123
 
10094
10124
 
10095
- const MAX_CONCURRENT_PROMISES = 8;
10125
+ const MAX_CONCURRENT_PROMISES = 3;
10096
10126
 
10097
10127
  async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE)
10098
10128
  {
10099
10129
  const PARTS = UPLOAD_RESPONSE.parts;
10100
10130
  const LENGTH = PARTS.length;
10101
- const NUM_TRIES = 5;
10131
+ const abortController = new AbortController();
10102
10132
 
10103
- for (let INDEX = 0; INDEX < LENGTH; INDEX += MAX_CONCURRENT_PROMISES)
10133
+ let buffer;
10134
+ try
10104
10135
  {
10105
- const batch = PARTS.slice(INDEX, INDEX + MAX_CONCURRENT_PROMISES);
10106
- const batchPromises = batch.map(async (PART, INDEX) => {
10107
- for (let tryIdx = 0; tryIdx < NUM_TRIES; ++tryIdx)
10108
- {
10109
- try
10110
- {
10136
+ buffer = Buffer.from(FILE.buffer, 'binary');
10137
+ }
10138
+ catch (error)
10139
+ {
10140
+ console.error("Error converting file buffer to Buffer:", error);
10141
+ return false;
10142
+ }
10143
+
10144
+ try {
10145
+ for (let INDEX = 0; INDEX < LENGTH; INDEX += MAX_CONCURRENT_PROMISES)
10146
+ {
10147
+ const batch = PARTS.slice(INDEX, INDEX + MAX_CONCURRENT_PROMISES);
10148
+ const batchPromises = batch.map(async (PART, INDEX) => {
10149
+ if (abortController.signal.aborted) return false;
10150
+
10151
+ try {
10111
10152
  console.log(`Uploading part ${INDEX + 1} of ${LENGTH}...`);
10112
- const ETAG = await _uploadPart(FILE, PART, instance.debug);
10153
+ const ETAG = await _uploadPart(buffer, PART, instance.debug);
10154
+ if (!ETAG) {
10155
+ throw new Error("Connection error");
10156
+ }
10157
+
10113
10158
  await _uploadPartComplete(instance, PART.id, ETAG);
10114
10159
  console.log(`Uploaded part ${INDEX + 1} of ${LENGTH} successfully`);
10115
- break;
10116
- }
10117
- catch (error)
10118
- {
10119
- if (tryIdx === NUM_TRIES - 1)
10120
- {
10121
- throw error;
10122
- }
10123
- else
10124
- {
10125
- console.log(`Error uploading parts: ${error}. Retrying...`);
10126
- await new Promise((resolve) => setTimeout(resolve, 20000));
10127
- }
10160
+ } catch (error) {
10161
+ abortController.abort();
10162
+ console.error(`Upload failed at part ${INDEX + 1}: ${error}`);
10163
+ throw error;
10128
10164
  }
10165
+ });
10166
+
10167
+ await Promise.all(batchPromises).catch(error => {
10168
+ throw error;
10169
+ });
10170
+
10171
+ if (abortController.signal.aborted) {
10172
+ return false;
10129
10173
  }
10130
- });
10174
+ }
10131
10175
 
10132
- await Promise.all(batchPromises);
10176
+ return true;
10177
+ } catch (error) {
10178
+ return false;
10133
10179
  }
10134
10180
  }
10135
10181
 
@@ -10137,7 +10183,7 @@ async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE)
10137
10183
 
10138
10184
 
10139
10185
  async function _startUpload(instance, NAME, EXISTING_ASSET_ID, RELATED_CONTENT_ID,
10140
- UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID)
10186
+ UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID, UPLOAD_REPLACE_OPTIONS)
10141
10187
  {
10142
10188
  const API_URL = `${instance.config.serviceApiUrl}/api/asset/upload/start`;
10143
10189
 
@@ -10147,12 +10193,13 @@ async function _startUpload(instance, NAME, EXISTING_ASSET_ID, RELATED_CONTENT_I
10147
10193
  displayName: NAME || FILE.originalname,
10148
10194
  contentLength: FILE.size,
10149
10195
  uploadOverwriteOption: UPLOAD_OVERWRITE_OPTION,
10150
- relativePath: FILE.originalname,
10196
+ relativePath: FILE.originalName,
10151
10197
  parentId: PARENT_ID,
10152
10198
  chunkSize: CHUNK_SIZE,
10153
10199
  relatedContentId: RELATED_CONTENT_ID,
10154
10200
  languageId: LANGUAGE_ID,
10155
- existingAssetId: EXISTING_ASSET_ID
10201
+ existingAssetId: EXISTING_ASSET_ID,
10202
+ uploadReplaceOptions: UPLOAD_REPLACE_OPTIONS
10156
10203
  };
10157
10204
 
10158
10205
  return await _sendRequest(instance, "Start asset upload", API_URL, "POST", undefined, BODY);
@@ -10210,14 +10257,13 @@ async function _uploadPartComplete(instance, PART_ID, ETAG)
10210
10257
 
10211
10258
  import { Buffer } from "buffer";
10212
10259
 
10213
- async function _uploadPart(FILE, PART, DEBUG_MODE, maxRetries = 3)
10260
+ async function _uploadPart(BUFFER, PART, DEBUG_MODE, maxRetries = 3)
10214
10261
  {
10215
10262
  for (let attempt = 0; attempt < maxRetries; attempt++)
10216
10263
  {
10217
10264
  try
10218
10265
  {
10219
- const BUFFER = Buffer.from(FILE.buffer, 'binary');
10220
- const BODY = BUFFER.slice(PART.startingPostion, PART.endingPosition + 1);
10266
+ const BODY = BUFFER.slice(PART.startingPosition, PART.endingPosition + 1);
10221
10267
 
10222
10268
  // Create header for the request
10223
10269
  const HEADERS = new Headers();
@@ -11416,6 +11462,8 @@ async function _updateLiveInput(instance, ID, NAME, SOURCE, TYPE, IS_STANDARD, V
11416
11462
 
11417
11463
  const INFO = await _sendRequest(instance, "Updating Live Input", API_URL, "PUT", undefined, BODY);
11418
11464
  await _waitForLiveInputStatus(instance, INFO.id, _LIVE_INPUT_STATUSES.Detached, 15, 1);
11465
+
11466
+ return INFO;
11419
11467
  }
11420
11468
 
11421
11469
 
@@ -13562,15 +13610,18 @@ async function _updateAsset(instance, ASSET_ID, DISPLAY_NAME, DISPLAY_DATE, AVAI
13562
13610
 
13563
13611
 
13564
13612
 
13565
- async function _addCustomProperties(instance, ID, NAME, DATE, CUSTOM_PROPERTIES)
13613
+ async function _addCustomProperties(instance, ID, NAME, DATE, CUSTOM_PROPERTIES,
13614
+ AVAILABLE_START_DATE, AVAILABLE_END_DATE)
13566
13615
  {
13567
13616
  const API_URL = `${instance.config.serviceApiUrl}/api/admin/asset/${ID}`;
13568
13617
 
13569
13618
  const BODY = {};
13570
13619
 
13571
- if (NAME) BODY.name = NAME;
13572
- if (DATE) BODY.date = DATE;
13573
- if (CUSTOM_PROPERTIES) BODY.customProperties = CUSTOM_PROPERTIES;
13620
+ if (NAME !== undefined) BODY.name = NAME;
13621
+ if (DATE !== undefined) BODY.date = DATE;
13622
+ if (CUSTOM_PROPERTIES !== undefined) BODY.customProperties = CUSTOM_PROPERTIES;
13623
+ if (AVAILABLE_START_DATE !== undefined) BODY.availableStartDate = AVAILABLE_START_DATE;
13624
+ if (AVAILABLE_END_DATE !== undefined) BODY.availableEndDate = AVAILABLE_END_DATE;
13574
13625
 
13575
13626
  return await _sendRequest(instance, "Adding Custom Properties", API_URL, "PATCH", undefined, BODY);
13576
13627
  }
@@ -13916,9 +13967,9 @@ async function _readFileAsArrayBuffer(file)
13916
13967
 
13917
13968
  import axios from 'axios';
13918
13969
 
13919
- const MAX_RETRIES = 5;
13920
- const TIMEOUT = 30000;
13921
- const SLEEP_TIME = .5;
13970
+ const MAX_RETRIES = 3;
13971
+ const TIMEOUT = 10000;
13972
+ const SLEEP_TIME = 2;
13922
13973
 
13923
13974
  async function _sendRequest(instance, FUNCTION_NAME, URL, METHOD_TYPE, PARAMS, BODY)
13924
13975
  {
@@ -13937,7 +13988,6 @@ async function _sendRequest(instance, FUNCTION_NAME, URL, METHOD_TYPE, PARAMS, B
13937
13988
  {
13938
13989
  try
13939
13990
  {
13940
- refreshedToken = true;
13941
13991
  RESPONSE = await axios({
13942
13992
  method: METHOD_TYPE,
13943
13993
  url: URL,
@@ -14554,11 +14604,14 @@ async function _getDynamicContents(instance)
14554
14604
 
14555
14605
 
14556
14606
 
14557
- async function _getMediaGroup(instance, ID)
14607
+ async function _getMediaGroup(instance, ID, FILTER_IDS)
14558
14608
  {
14559
- const API_URL = `${instance.config.serviceApiUrl}/api/media/group/${ID}`;
14609
+ let apiUrl = `${instance.config.serviceApiUrl}/api/media/group/${ID}`;
14610
+ if (FILTER_IDS && FILTER_IDS.length > 0) {
14611
+ apiUrl += '?' + FILTER_IDS.map(id => `filterIds=${id}`).join('&');
14612
+ }
14560
14613
 
14561
- return await _sendRequest(instance, "Get Media Group", API_URL, "GET", undefined, undefined);
14614
+ return await _sendRequest(instance, "Get Media Group", apiUrl, "GET", undefined, undefined);
14562
14615
  }
14563
14616
 
14564
14617
 
@@ -14827,7 +14880,7 @@ async function _shareNotification(instance, SHARE_ID, NOMAD_USERS, EXTERNAL_USER
14827
14880
 
14828
14881
  async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS,
14829
14882
  SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID,
14830
- EXPIRATION_DATE)
14883
+ EXPIRATION_DATE, ASSET_ID, NOMAD_USERS)
14831
14884
  {
14832
14885
  const API_URL = `${instance.config.serviceApiUrl}/api/share`;
14833
14886
 
@@ -14842,7 +14895,9 @@ async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHAR
14842
14895
  sharedDurationInHours: SHARED_DURATION_IN_HOURS,
14843
14896
  sharedLink: SHARED_LINK,
14844
14897
  ownerId: OWNER_ID,
14845
- expirationDate: EXPIRATION_DATE
14898
+ expirationDate: EXPIRATION_DATE,
14899
+ assetId: ASSET_ID,
14900
+ nomadUsers: NOMAD_USERS
14846
14901
  };
14847
14902
 
14848
14903
  return await _sendRequest(instance, "Share", API_URL, "POST", undefined, BODY);
@@ -14854,7 +14909,7 @@ async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHAR
14854
14909
 
14855
14910
  async function _updateShare(instance, SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARED_DURATION,
14856
14911
  SHARED_PERMISSIONS, SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK,
14857
- OWNER_ID, EXPIRATION_DATE)
14912
+ OWNER_ID, EXPIRATION_DATE, ASSET_ID, NOMAD_USERS)
14858
14913
  {
14859
14914
  const API_URL = `${instance.config.serviceApiUrl}/api/share/${SHARE_ID}?`;
14860
14915
 
@@ -14877,7 +14932,9 @@ async function _updateShare(instance, SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARE
14877
14932
  sharedDurationInHours: SHARED_DURATION_IN_HOURS || share_info.sharedDurationInHours,
14878
14933
  sharedLink: SHARED_LINK || share_info.sharedLink,
14879
14934
  ownerId: OWNER_ID || share_info.ownerId,
14880
- expirationDate: EXPIRATION_DATE || share_info.expirationDate
14935
+ expirationDate: EXPIRATION_DATE || share_info.expirationDate,
14936
+ assetId: ASSET_ID || share_info.assetId,
14937
+ nomadUsers: NOMAD_USERS || share_info.nomadUsers
14881
14938
  };
14882
14939
 
14883
14940
  return await _sendRequest(instance, "Update Share", API_URL, "PUT", undefined, BODY);