@nomad-media/full 1.1.20-alpha.0 → 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.
|
@@ -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
|
{
|
|
@@ -525,7 +527,7 @@ class NomadMediaSDK {
|
|
|
525
527
|
_printDatetime("Starting upload");
|
|
526
528
|
startUploadInfo = await _startUpload(this, NAME, EXISTING_ASSET_ID,
|
|
527
529
|
RELATED_CONTENT_ID, UPLOAD_OVERWRITE_OPTION, FILE_PROPS, PARENT_ID,
|
|
528
|
-
LANGUAGE_ID);
|
|
530
|
+
LANGUAGE_ID, UPLOAD_REPLACE_OPTIONS);
|
|
529
531
|
|
|
530
532
|
if (!startUploadInfo) throw new Error("Failed to start upload");
|
|
531
533
|
|
|
@@ -565,59 +567,41 @@ class NomadMediaSDK {
|
|
|
565
567
|
* The option you want to use when uploading the asset. The options are continue, replace,
|
|
566
568
|
* and cancel. Continue continues the upload from where it left off. Replace replaces an
|
|
567
569
|
* existing asset. Replace is the one you want to use if you are starting a new upload.
|
|
568
|
-
* @param {FILE | string
|
|
570
|
+
* @param {FILE | string} FILE - The FILE object or full or relative path of the file to upload.
|
|
569
571
|
* This is ignored if the ExistingAssetId or if the RelatedContentId has a value
|
|
570
572
|
* @param {string | null} LANGUAGE_ID - The language of the asset to upload.
|
|
571
573
|
* If this is left blank then the default system language is used.
|
|
572
|
-
* @param {bytes | null} FILE_CONTENTS - The contents of the file to upload.
|
|
573
|
-
* This is used to upload the file in memory instead of from a file.
|
|
574
574
|
* @returns {Promise<string>} - A promise that resolves when the related asset is uploaded.
|
|
575
575
|
* Returns the content ID of the uploaded related asset.
|
|
576
576
|
* @throws {Error} - An error is thrown if the related asset fails to upload.
|
|
577
577
|
*/
|
|
578
578
|
async uploadRelatedAsset(EXISTING_ASSET_ID, RELATED_ASSET_ID, NEW_RELATED_ASSET_METADATA_TYPE,
|
|
579
|
-
UPLOAD_OVERWRITE_OPTION, FILE, LANGUAGE_ID
|
|
579
|
+
UPLOAD_OVERWRITE_OPTION, FILE, LANGUAGE_ID)
|
|
580
580
|
{
|
|
581
581
|
if (this.token === null)
|
|
582
582
|
{
|
|
583
583
|
await this._init();
|
|
584
584
|
}
|
|
585
585
|
|
|
586
|
-
if (!FILE && !FILE_CONTENTS)
|
|
587
|
-
{
|
|
588
|
-
throw new Error("Either FILE or FILE_CONTENTS must be provided.");
|
|
589
|
-
}
|
|
590
|
-
|
|
591
586
|
_printDatetime(`Uploading related asset`);
|
|
592
587
|
|
|
593
588
|
let startUploadInfo = null;
|
|
594
589
|
try
|
|
595
590
|
{
|
|
596
|
-
|
|
597
|
-
if (!
|
|
591
|
+
const FILE_PROPS = await _processFile(FILE);
|
|
592
|
+
if (!FILE_PROPS)
|
|
598
593
|
{
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
{
|
|
602
|
-
_printDatetime("File not found");
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
else
|
|
607
|
-
{
|
|
608
|
-
fileProps = {
|
|
609
|
-
originalname: FILE,
|
|
610
|
-
size: FILE_CONTENTS.byteLength
|
|
611
|
-
};
|
|
594
|
+
_printDatetime("File not found");
|
|
595
|
+
return;
|
|
612
596
|
}
|
|
613
597
|
|
|
614
598
|
startUploadInfo = await _startRelatedAssetUpload(this, EXISTING_ASSET_ID,
|
|
615
599
|
RELATED_ASSET_ID, NEW_RELATED_ASSET_METADATA_TYPE, UPLOAD_OVERWRITE_OPTION,
|
|
616
|
-
|
|
600
|
+
FILE_PROPS, LANGUAGE_ID);
|
|
617
601
|
|
|
618
602
|
if (!startUploadInfo) throw new Error("Failed to start related asset upload");
|
|
619
603
|
|
|
620
|
-
const response = await _multiThreadUpload(this,
|
|
604
|
+
const response = await _multiThreadUpload(this, FILE_PROPS, startUploadInfo);
|
|
621
605
|
if (!response) throw new Error("Failed to upload");
|
|
622
606
|
|
|
623
607
|
await _completeUpload(this, startUploadInfo.id);
|
|
@@ -625,9 +609,7 @@ class NomadMediaSDK {
|
|
|
625
609
|
|
|
626
610
|
const DETAILS = await _getAssetDetails(this, EXISTING_ASSET_ID);
|
|
627
611
|
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
const ASSET_INFO = DETAILS.relatedAssets.find(asset => asset.url.includes(FILE_NAME));
|
|
612
|
+
const ASSET_INFO = DETAILS.relatedAssets.find(asset => asset.url.includes(FILE_PROPS.originalName));
|
|
631
613
|
if (!ASSET_INFO) throw new Error("Asset ID not found");
|
|
632
614
|
return ASSET_INFO.id;
|
|
633
615
|
}
|
|
@@ -1085,14 +1067,20 @@ class NomadMediaSDK {
|
|
|
1085
1067
|
* @param {string} CONTENT_ID - The ID of the content to add the custom properties to.
|
|
1086
1068
|
* @param {string | null} NAME - The name of the content to add the custom properties to.
|
|
1087
1069
|
* @param {string | null} DATE - The display date of the content to add to the custom properties.
|
|
1088
|
-
* @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
|
|
1089
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.
|
|
1090
1078
|
* @returns {Promise<JSON>} - A promise that resolves when the custom properties are added.
|
|
1091
1079
|
* Returns the information of the added custom properties.
|
|
1092
1080
|
* @throws {Error} - An error is thrown if the custom properties fail to add.
|
|
1093
1081
|
* @throws {Error} - An error is thrown if the API type is not admin.
|
|
1094
1082
|
*/
|
|
1095
|
-
async addCustomProperties(CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES)
|
|
1083
|
+
async addCustomProperties(CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES, AVAILABLE_START_DATE, AVAILABLE_END_DATE)
|
|
1096
1084
|
{
|
|
1097
1085
|
if (this.token === null)
|
|
1098
1086
|
{
|
|
@@ -1109,7 +1097,7 @@ class NomadMediaSDK {
|
|
|
1109
1097
|
try
|
|
1110
1098
|
{
|
|
1111
1099
|
const ADD_CUSTOM_PROPERTIES_INFO = await _addCustomProperties(this,
|
|
1112
|
-
CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES);
|
|
1100
|
+
CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES, AVAILABLE_START_DATE, AVAILABLE_END_DATE);
|
|
1113
1101
|
if (ADD_CUSTOM_PROPERTIES_INFO) _printDatetime(`Custom properties added to content: ${CONTENT_ID}`);
|
|
1114
1102
|
return ADD_CUSTOM_PROPERTIES_INFO;
|
|
1115
1103
|
}
|
|
@@ -1959,7 +1947,7 @@ class NomadMediaSDK {
|
|
|
1959
1947
|
|
|
1960
1948
|
try
|
|
1961
1949
|
{
|
|
1962
|
-
await
|
|
1950
|
+
await _createJobId(
|
|
1963
1951
|
this, ASSET_ID, JOB_RESULTS_URL, EXTERNAL_ID);
|
|
1964
1952
|
_printDatetime(`Job created: ${ASSET_ID}`);
|
|
1965
1953
|
} catch (error) {
|
|
@@ -7493,13 +7481,12 @@ class NomadMediaSDK {
|
|
|
7493
7481
|
* @function ping
|
|
7494
7482
|
* @async
|
|
7495
7483
|
* @description Pings the user.
|
|
7496
|
-
* @param {
|
|
7497
|
-
* @param {string | nul} USER_SESSION_ID - The user session ID of the user.
|
|
7484
|
+
* @param {boolean | null} INCLUDE_HEADERS
|
|
7498
7485
|
* @returns {Promise<JSON>} - A promise that resolves when the user is pinged.
|
|
7499
7486
|
* Returns the ping status of the user.
|
|
7500
7487
|
* @throws {Error} - An error is thrown if the user fails to ping.
|
|
7501
7488
|
*/
|
|
7502
|
-
async ping(
|
|
7489
|
+
async ping(INCLUDE_HEADERS)
|
|
7503
7490
|
{
|
|
7504
7491
|
if (this.token === null)
|
|
7505
7492
|
{
|
|
@@ -7510,7 +7497,7 @@ class NomadMediaSDK {
|
|
|
7510
7497
|
|
|
7511
7498
|
try
|
|
7512
7499
|
{
|
|
7513
|
-
const PING = await _ping(this,
|
|
7500
|
+
const PING = await _ping(this, INCLUDE_HEADERS);
|
|
7514
7501
|
if (PING) _printDatetime(`User pinged`);
|
|
7515
7502
|
return PING;
|
|
7516
7503
|
}
|
|
@@ -7628,7 +7615,7 @@ class NomadMediaSDK {
|
|
|
7628
7615
|
DISTINCT_ON_FIELD_NAME, INCLUDE_VIDEO_CLIPS, USE_LLM_SEARCH,
|
|
7629
7616
|
INCLUDE_INTERNAL_FIELDS_IN_RESULTS);
|
|
7630
7617
|
if (SEARCH_INFO) _printDatetime(`Search complete`);
|
|
7631
|
-
return SEARCH_INFO
|
|
7618
|
+
return SEARCH_INFO?.hasItems ? SEARCH_INFO : false
|
|
7632
7619
|
}
|
|
7633
7620
|
catch (error)
|
|
7634
7621
|
{
|
|
@@ -8444,12 +8431,13 @@ class NomadMediaSDK {
|
|
|
8444
8431
|
* @async
|
|
8445
8432
|
* @description Gets media group.
|
|
8446
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.
|
|
8447
8435
|
* @returns {Promise<JSON>} - A promise that resolves when the media group is gotten.
|
|
8448
8436
|
* Returns the information of the gotten media group.
|
|
8449
8437
|
* @throws {Error} - An error is thrown if the media group fails to get.
|
|
8450
8438
|
* @throws {Error} - An error is thrown if the API type is not portal.
|
|
8451
8439
|
*/
|
|
8452
|
-
async getMediaGroup(MEDIA_GROUP_ID)
|
|
8440
|
+
async getMediaGroup(MEDIA_GROUP_ID, FILTER_IDS)
|
|
8453
8441
|
{
|
|
8454
8442
|
if (this.token === null)
|
|
8455
8443
|
{
|
|
@@ -8465,7 +8453,7 @@ class NomadMediaSDK {
|
|
|
8465
8453
|
|
|
8466
8454
|
try
|
|
8467
8455
|
{
|
|
8468
|
-
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);
|
|
8469
8457
|
if (GET_MEDIA_GROUP_INFO) _printDatetime(`Media group gotten: ${MEDIA_GROUP_ID}`);
|
|
8470
8458
|
return GET_MEDIA_GROUP_INFO;
|
|
8471
8459
|
}
|
|
@@ -9801,22 +9789,26 @@ class NomadMediaSDK {
|
|
|
9801
9789
|
* JSON format: {"id": string, "description": string }
|
|
9802
9790
|
* @param {JSON | null} SHARED_DURATION - The shared Duration of the share.
|
|
9803
9791
|
* JSON format: {"id": string, "description": string }
|
|
9804
|
-
* @param {Array<JSON> | null}
|
|
9792
|
+
* @param {Array<JSON> | null} SHARED_PERMISSIONS - The sharedPermissions of the share.
|
|
9805
9793
|
* JSON format: {"id": string, "description": string }
|
|
9806
9794
|
* @param {JSON | null} SHARED_TYPE: - The sharedType of the share.
|
|
9807
9795
|
* JSON format: {"id": string, "description": string }
|
|
9808
|
-
* @param {
|
|
9796
|
+
* @param {JSON | null} SHARED_STATUS - The sharedStatus of the share.
|
|
9809
9797
|
* JSON format: {"id": string, "description": string }
|
|
9810
9798
|
* @param {integer | null} SHARED_DURATION_IN_HOURS - The sharedDurationInHours of the share.
|
|
9811
9799
|
* @param {string | null} SHARED_LINK - The sharedLink of the share.
|
|
9812
9800
|
* @param {string | null} OWNER_ID - The ownerId of the share.
|
|
9813
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 }
|
|
9814
9805
|
* @returns {Promise<object>}
|
|
9815
9806
|
* @throws {Error} - An error is thrown if share fails.
|
|
9816
9807
|
* @throws {Error} - An error is the API type is not post.
|
|
9817
9808
|
*/
|
|
9818
9809
|
async share(ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE,
|
|
9819
|
-
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)
|
|
9820
9812
|
{
|
|
9821
9813
|
if (this.token === null)
|
|
9822
9814
|
{
|
|
@@ -9834,7 +9826,8 @@ class NomadMediaSDK {
|
|
|
9834
9826
|
{
|
|
9835
9827
|
const RESPONSE = await _share(this, ID, NAME, SHARED_CONTENTS,
|
|
9836
9828
|
SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE, SHARED_STATUS,
|
|
9837
|
-
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);
|
|
9838
9831
|
|
|
9839
9832
|
_printDatetime(`Share called successfully.`);
|
|
9840
9833
|
|
|
@@ -9942,18 +9935,22 @@ class NomadMediaSDK {
|
|
|
9942
9935
|
* JSON format: {"id": string, "description": string }
|
|
9943
9936
|
* @param {JSON | null} SHARED_TYPE - The sharedType of the updateShare.
|
|
9944
9937
|
* JSON format: {"id": string, "description": string }
|
|
9945
|
-
* @param {
|
|
9938
|
+
* @param {JSON | null} SHARED_STATUS - The sharedStatus of the updateShare.
|
|
9946
9939
|
* JSON format: {"id": string, "description": string }
|
|
9947
9940
|
* @param {integer | null} SHARED_DURATION_IN_HOURS - The sharedDurationInHours of the updateShare.
|
|
9948
9941
|
* @param {string | null} SHARED_LINK - The sharedLink of the updateShare.
|
|
9949
9942
|
* @param {string | null} OWNER_ID - The ownerId of the updateShare.
|
|
9950
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 }
|
|
9951
9947
|
* @returns {Promise<object>}
|
|
9952
9948
|
* @throws {Error} - An error is thrown if updateShare fails.
|
|
9953
9949
|
* @throws {Error} - An error is the API type is not put.
|
|
9954
9950
|
*/
|
|
9955
9951
|
async updateShare(SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS,
|
|
9956
|
-
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)
|
|
9957
9954
|
{
|
|
9958
9955
|
if (this.token === null)
|
|
9959
9956
|
{
|
|
@@ -9972,7 +9969,7 @@ class NomadMediaSDK {
|
|
|
9972
9969
|
const RESPONSE = await _updateShare(this, SHARE_ID, ID, NAME,
|
|
9973
9970
|
SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE,
|
|
9974
9971
|
SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID,
|
|
9975
|
-
EXPIRATION_DATE);
|
|
9972
|
+
EXPIRATION_DATE, ASSET_ID, SHARED_USERS);
|
|
9976
9973
|
|
|
9977
9974
|
_printDatetime(`Update share called successfully.`);
|
|
9978
9975
|
|
|
@@ -10127,12 +10124,23 @@ async function _cancelUpload(instance, ID)
|
|
|
10127
10124
|
|
|
10128
10125
|
const MAX_CONCURRENT_PROMISES = 3;
|
|
10129
10126
|
|
|
10130
|
-
async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE
|
|
10127
|
+
async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE)
|
|
10131
10128
|
{
|
|
10132
10129
|
const PARTS = UPLOAD_RESPONSE.parts;
|
|
10133
10130
|
const LENGTH = PARTS.length;
|
|
10134
10131
|
const abortController = new AbortController();
|
|
10135
10132
|
|
|
10133
|
+
let buffer;
|
|
10134
|
+
try
|
|
10135
|
+
{
|
|
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
|
+
|
|
10136
10144
|
try {
|
|
10137
10145
|
for (let INDEX = 0; INDEX < LENGTH; INDEX += MAX_CONCURRENT_PROMISES)
|
|
10138
10146
|
{
|
|
@@ -10142,7 +10150,7 @@ async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE, FILE_CONTENTS
|
|
|
10142
10150
|
|
|
10143
10151
|
try {
|
|
10144
10152
|
console.log(`Uploading part ${INDEX + 1} of ${LENGTH}...`);
|
|
10145
|
-
const ETAG = await _uploadPart(
|
|
10153
|
+
const ETAG = await _uploadPart(buffer, PART, instance.debug);
|
|
10146
10154
|
if (!ETAG) {
|
|
10147
10155
|
throw new Error("Connection error");
|
|
10148
10156
|
}
|
|
@@ -10175,7 +10183,7 @@ async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE, FILE_CONTENTS
|
|
|
10175
10183
|
|
|
10176
10184
|
|
|
10177
10185
|
async function _startUpload(instance, NAME, EXISTING_ASSET_ID, RELATED_CONTENT_ID,
|
|
10178
|
-
UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID)
|
|
10186
|
+
UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID, UPLOAD_REPLACE_OPTIONS)
|
|
10179
10187
|
{
|
|
10180
10188
|
const API_URL = `${instance.config.serviceApiUrl}/api/asset/upload/start`;
|
|
10181
10189
|
|
|
@@ -10190,7 +10198,8 @@ async function _startUpload(instance, NAME, EXISTING_ASSET_ID, RELATED_CONTENT_I
|
|
|
10190
10198
|
chunkSize: CHUNK_SIZE,
|
|
10191
10199
|
relatedContentId: RELATED_CONTENT_ID,
|
|
10192
10200
|
languageId: LANGUAGE_ID,
|
|
10193
|
-
existingAssetId: EXISTING_ASSET_ID
|
|
10201
|
+
existingAssetId: EXISTING_ASSET_ID,
|
|
10202
|
+
uploadReplaceOptions: UPLOAD_REPLACE_OPTIONS
|
|
10194
10203
|
};
|
|
10195
10204
|
|
|
10196
10205
|
return await _sendRequest(instance, "Start asset upload", API_URL, "POST", undefined, BODY);
|
|
@@ -10248,23 +10257,15 @@ async function _uploadPartComplete(instance, PART_ID, ETAG)
|
|
|
10248
10257
|
|
|
10249
10258
|
import { Buffer } from "buffer";
|
|
10250
10259
|
|
|
10251
|
-
async function _uploadPart(
|
|
10260
|
+
async function _uploadPart(BUFFER, PART, DEBUG_MODE, maxRetries = 3)
|
|
10252
10261
|
{
|
|
10253
|
-
for (let attempt = 0; attempt < maxRetries; ++
|
|
10254
|
-
|
|
10262
|
+
for (let attempt = 0; attempt < maxRetries; attempt++)
|
|
10263
|
+
{
|
|
10255
10264
|
try
|
|
10256
10265
|
{
|
|
10257
|
-
|
|
10258
|
-
if (FILE_CONTENTS)
|
|
10259
|
-
{
|
|
10260
|
-
body = FILE_CONTENTS.slice(PART.startingPosition, PART.endingPosition + 1);
|
|
10261
|
-
}
|
|
10262
|
-
else
|
|
10263
|
-
{
|
|
10264
|
-
const BUFFER = Buffer.from(FILE.buffer, 'binary');
|
|
10265
|
-
body = BUFFER.slice(PART.startingPosition, PART.endingPosition + 1);
|
|
10266
|
-
}
|
|
10266
|
+
const BODY = BUFFER.slice(PART.startingPosition, PART.endingPosition + 1);
|
|
10267
10267
|
|
|
10268
|
+
// Create header for the request
|
|
10268
10269
|
const HEADERS = new Headers();
|
|
10269
10270
|
HEADERS.append("Accept", "application/json, text/plain, */*");
|
|
10270
10271
|
|
|
@@ -10273,7 +10274,7 @@ async function _uploadPart(FILE, PART, FILE_CONTENTS, DEBUG_MODE, maxRetries = 3
|
|
|
10273
10274
|
const RESPONSE = await fetch(PART.url, {
|
|
10274
10275
|
method: "PUT",
|
|
10275
10276
|
headers: HEADERS,
|
|
10276
|
-
body:
|
|
10277
|
+
body: BODY
|
|
10277
10278
|
});
|
|
10278
10279
|
|
|
10279
10280
|
if (!RESPONSE.ok)
|
|
@@ -10287,11 +10288,13 @@ async function _uploadPart(FILE, PART, FILE_CONTENTS, DEBUG_MODE, maxRetries = 3
|
|
|
10287
10288
|
catch (error)
|
|
10288
10289
|
{
|
|
10289
10290
|
if (attempt < maxRetries - 1)
|
|
10290
|
-
|
|
10291
|
+
{
|
|
10292
|
+
// Retry if there are more attempts left
|
|
10291
10293
|
console.error(`Upload attempt ${attempt + 1} failed. Retrying...`);
|
|
10292
10294
|
}
|
|
10293
10295
|
else
|
|
10294
10296
|
{
|
|
10297
|
+
// No more retries left, handle the error
|
|
10295
10298
|
_apiExceptionHandler(error, "Upload Part Failed");
|
|
10296
10299
|
break;
|
|
10297
10300
|
}
|
|
@@ -11459,6 +11462,8 @@ async function _updateLiveInput(instance, ID, NAME, SOURCE, TYPE, IS_STANDARD, V
|
|
|
11459
11462
|
|
|
11460
11463
|
const INFO = await _sendRequest(instance, "Updating Live Input", API_URL, "PUT", undefined, BODY);
|
|
11461
11464
|
await _waitForLiveInputStatus(instance, INFO.id, _LIVE_INPUT_STATUSES.Detached, 15, 1);
|
|
11465
|
+
|
|
11466
|
+
return INFO;
|
|
11462
11467
|
}
|
|
11463
11468
|
|
|
11464
11469
|
|
|
@@ -13605,15 +13610,18 @@ async function _updateAsset(instance, ASSET_ID, DISPLAY_NAME, DISPLAY_DATE, AVAI
|
|
|
13605
13610
|
|
|
13606
13611
|
|
|
13607
13612
|
|
|
13608
|
-
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)
|
|
13609
13615
|
{
|
|
13610
13616
|
const API_URL = `${instance.config.serviceApiUrl}/api/admin/asset/${ID}`;
|
|
13611
13617
|
|
|
13612
13618
|
const BODY = {};
|
|
13613
13619
|
|
|
13614
|
-
if (NAME) BODY.name = NAME;
|
|
13615
|
-
if (DATE) BODY.date = DATE;
|
|
13616
|
-
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;
|
|
13617
13625
|
|
|
13618
13626
|
return await _sendRequest(instance, "Adding Custom Properties", API_URL, "PATCH", undefined, BODY);
|
|
13619
13627
|
}
|
|
@@ -13980,7 +13988,6 @@ async function _sendRequest(instance, FUNCTION_NAME, URL, METHOD_TYPE, PARAMS, B
|
|
|
13980
13988
|
{
|
|
13981
13989
|
try
|
|
13982
13990
|
{
|
|
13983
|
-
refreshedToken = true;
|
|
13984
13991
|
RESPONSE = await axios({
|
|
13985
13992
|
method: METHOD_TYPE,
|
|
13986
13993
|
url: URL,
|
|
@@ -14597,11 +14604,14 @@ async function _getDynamicContents(instance)
|
|
|
14597
14604
|
|
|
14598
14605
|
|
|
14599
14606
|
|
|
14600
|
-
async function _getMediaGroup(instance, ID)
|
|
14607
|
+
async function _getMediaGroup(instance, ID, FILTER_IDS)
|
|
14601
14608
|
{
|
|
14602
|
-
|
|
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
|
+
}
|
|
14603
14613
|
|
|
14604
|
-
return await _sendRequest(instance, "Get Media Group",
|
|
14614
|
+
return await _sendRequest(instance, "Get Media Group", apiUrl, "GET", undefined, undefined);
|
|
14605
14615
|
}
|
|
14606
14616
|
|
|
14607
14617
|
|
|
@@ -14870,7 +14880,7 @@ async function _shareNotification(instance, SHARE_ID, NOMAD_USERS, EXTERNAL_USER
|
|
|
14870
14880
|
|
|
14871
14881
|
async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS,
|
|
14872
14882
|
SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID,
|
|
14873
|
-
EXPIRATION_DATE)
|
|
14883
|
+
EXPIRATION_DATE, ASSET_ID, NOMAD_USERS)
|
|
14874
14884
|
{
|
|
14875
14885
|
const API_URL = `${instance.config.serviceApiUrl}/api/share`;
|
|
14876
14886
|
|
|
@@ -14885,7 +14895,9 @@ async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHAR
|
|
|
14885
14895
|
sharedDurationInHours: SHARED_DURATION_IN_HOURS,
|
|
14886
14896
|
sharedLink: SHARED_LINK,
|
|
14887
14897
|
ownerId: OWNER_ID,
|
|
14888
|
-
expirationDate: EXPIRATION_DATE
|
|
14898
|
+
expirationDate: EXPIRATION_DATE,
|
|
14899
|
+
assetId: ASSET_ID,
|
|
14900
|
+
nomadUsers: NOMAD_USERS
|
|
14889
14901
|
};
|
|
14890
14902
|
|
|
14891
14903
|
return await _sendRequest(instance, "Share", API_URL, "POST", undefined, BODY);
|
|
@@ -14897,7 +14909,7 @@ async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHAR
|
|
|
14897
14909
|
|
|
14898
14910
|
async function _updateShare(instance, SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARED_DURATION,
|
|
14899
14911
|
SHARED_PERMISSIONS, SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK,
|
|
14900
|
-
OWNER_ID, EXPIRATION_DATE)
|
|
14912
|
+
OWNER_ID, EXPIRATION_DATE, ASSET_ID, NOMAD_USERS)
|
|
14901
14913
|
{
|
|
14902
14914
|
const API_URL = `${instance.config.serviceApiUrl}/api/share/${SHARE_ID}?`;
|
|
14903
14915
|
|
|
@@ -14920,7 +14932,9 @@ async function _updateShare(instance, SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARE
|
|
|
14920
14932
|
sharedDurationInHours: SHARED_DURATION_IN_HOURS || share_info.sharedDurationInHours,
|
|
14921
14933
|
sharedLink: SHARED_LINK || share_info.sharedLink,
|
|
14922
14934
|
ownerId: OWNER_ID || share_info.ownerId,
|
|
14923
|
-
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
|
|
14924
14938
|
};
|
|
14925
14939
|
|
|
14926
14940
|
return await _sendRequest(instance, "Update Share", API_URL, "PUT", undefined, BODY);
|