@nomad-media/full 1.1.20-alpha.0 → 1.1.23
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +43 -12
- package/dist/nomad-media-sdk-debug.js +100 -82
- package/dist/nomad-media-sdk.min.js +4 -4
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -1,17 +1,26 @@
|
|
|
1
|
-
|
|
2
|
-
This package contains the full version of the Nomad Media SDK. It includes all the methods of the SDK.
|
|
1
|
+
## Prerequisites
|
|
3
2
|
|
|
4
|
-
|
|
5
|
-
- Node.js 12.0.0
|
|
3
|
+
- Node package manager (npm).
|
|
6
4
|
|
|
7
|
-
|
|
8
|
-
|
|
5
|
+
> 📘 Note
|
|
6
|
+
>
|
|
7
|
+
> You can download npm [here](https://nodejs.org/en/download).
|
|
9
8
|
|
|
9
|
+
## Setup
|
|
10
|
+
|
|
11
|
+
To use the Nomad SDK, download the @nomad-media npm. There are two versions, the full version which includes all of the Nomad-Media endpoints, and the public version which only includes the media endpoints.
|
|
12
|
+
|
|
13
|
+
To install the full version, use the following command:
|
|
10
14
|
```shell
|
|
11
15
|
npm install @nomad-media/full
|
|
12
16
|
```
|
|
13
17
|
|
|
14
|
-
|
|
18
|
+
To install the public version, use the following command:
|
|
19
|
+
```shell
|
|
20
|
+
npm install @nomad-media/public
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Then to import it, you can either use the default version, or the debug version. The difference is that the debug version isn't compressed and has more documentation and named parameters. Both full and public have a debug version. Currently the debug version's tooltips don't show up. This is an issue with npm.
|
|
15
24
|
|
|
16
25
|
To use the default version use:
|
|
17
26
|
|
|
@@ -31,6 +40,10 @@ To initialize the sdk, call the NomadMediaSDK class as shown below:
|
|
|
31
40
|
const SDK = NomadMediaSDK(config);
|
|
32
41
|
```
|
|
33
42
|
|
|
43
|
+
## Logging in
|
|
44
|
+
|
|
45
|
+
To log in to the sdk, in the config, enter the username/email of your user. Then enter your api key if you are using an api key, or your password.
|
|
46
|
+
|
|
34
47
|
## Configure Environmental Variables
|
|
35
48
|
|
|
36
49
|
Follow this format for the config:
|
|
@@ -39,24 +52,42 @@ Follow this format for the config:
|
|
|
39
52
|
const config = {
|
|
40
53
|
"username": "username",
|
|
41
54
|
"password": "password",
|
|
55
|
+
"apiKey": "apiKey",
|
|
42
56
|
"serviceApiUrl": "serverApiUrl",
|
|
43
57
|
"apiType": "admin",
|
|
44
|
-
"debugMode": true
|
|
58
|
+
"debugMode": true,
|
|
59
|
+
"singleton": false
|
|
45
60
|
};
|
|
46
61
|
```
|
|
47
|
-
serviceApiUrl: Specifies the url of the server you are trying to connect to.
|
|
48
62
|
|
|
49
63
|
apiType: Specifies whether the function you are trying to run is **admin** or **portal**.
|
|
50
64
|
|
|
51
65
|
debugMode: Specifies when running functions, whether of not to print api call information.
|
|
52
66
|
|
|
67
|
+
singleton: Whether or not to only create one class instance.
|
|
68
|
+
|
|
69
|
+
Place the config in a file called config.js and import it into your project.
|
|
70
|
+
|
|
53
71
|
You are now ready to use the SDK in your project.
|
|
54
72
|
|
|
55
73
|
> 📘 Contact: Make sure to contact Nomad Media support to get username, password, and url for your enviromnent.
|
|
56
74
|
|
|
57
75
|
> 🚧 Make sure to keep your configuration options secret and do not share them publicly.
|
|
58
76
|
|
|
59
|
-
##
|
|
77
|
+
## Upgrading NPM
|
|
78
|
+
|
|
79
|
+
To upgrade the npm, use the following command:
|
|
80
|
+
|
|
81
|
+
```shell
|
|
82
|
+
npm update @nomad-media/full
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
## Nomad SDK References
|
|
86
|
+
|
|
87
|
+
An overview of all of the Nomad SDK methods. Includes prameter details for the methods. Scroll down to the Nomad SDK section.
|
|
88
|
+
|
|
89
|
+
[Nomad SDK References](https://developer.nomad-cms.com/reference)
|
|
90
|
+
|
|
91
|
+
## Nomad SDK NPM Samples
|
|
60
92
|
|
|
61
|
-
|
|
62
|
-
- [Nomad SDK NPM Samples](https://github.com/Nomad-Media/samples-js)
|
|
93
|
+
[Nomad SDK NPM Samples](https://github.com/Nomad-Media/samples-js)
|
|
@@ -317,7 +317,10 @@ class NomadMediaSDK {
|
|
|
317
317
|
*/
|
|
318
318
|
async _init()
|
|
319
319
|
{
|
|
320
|
-
|
|
320
|
+
if (this.config.username && this.config.password)
|
|
321
|
+
{
|
|
322
|
+
await this.login();
|
|
323
|
+
}
|
|
321
324
|
}
|
|
322
325
|
|
|
323
326
|
// account functions
|
|
@@ -498,12 +501,14 @@ class NomadMediaSDK {
|
|
|
498
501
|
* This is ignored if the ExistingAssetId or if the RelatedContentId has a value.
|
|
499
502
|
* @param {string | null} LANGUAGE_ID - The language of the asset to upload.
|
|
500
503
|
* If this is left blank then the default system language is used.
|
|
504
|
+
* @param {Array<String> | null} UPLOAD_REPLACE_OPTIONS - Gets or sets if the asset already
|
|
505
|
+
* exists on the server, this decides how to handle the situation with related assets.
|
|
501
506
|
* @returns {Promise<string>} - A promise that resolves when the asset is uploaded.
|
|
502
507
|
* Returns the content ID of the uploaded asset.
|
|
503
508
|
* @throws {Error} - An error is thrown if the asset fails to upload.
|
|
504
509
|
*/
|
|
505
510
|
async uploadAsset(NAME, EXISTING_ASSET_ID, RELATED_CONTENT_ID,
|
|
506
|
-
UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID)
|
|
511
|
+
UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID, UPLOAD_REPLACE_OPTIONS)
|
|
507
512
|
{
|
|
508
513
|
if (this.token === null)
|
|
509
514
|
{
|
|
@@ -525,7 +530,7 @@ class NomadMediaSDK {
|
|
|
525
530
|
_printDatetime("Starting upload");
|
|
526
531
|
startUploadInfo = await _startUpload(this, NAME, EXISTING_ASSET_ID,
|
|
527
532
|
RELATED_CONTENT_ID, UPLOAD_OVERWRITE_OPTION, FILE_PROPS, PARENT_ID,
|
|
528
|
-
LANGUAGE_ID);
|
|
533
|
+
LANGUAGE_ID, UPLOAD_REPLACE_OPTIONS);
|
|
529
534
|
|
|
530
535
|
if (!startUploadInfo) throw new Error("Failed to start upload");
|
|
531
536
|
|
|
@@ -565,59 +570,41 @@ class NomadMediaSDK {
|
|
|
565
570
|
* The option you want to use when uploading the asset. The options are continue, replace,
|
|
566
571
|
* and cancel. Continue continues the upload from where it left off. Replace replaces an
|
|
567
572
|
* existing asset. Replace is the one you want to use if you are starting a new upload.
|
|
568
|
-
* @param {FILE | string
|
|
573
|
+
* @param {FILE | string} FILE - The FILE object or full or relative path of the file to upload.
|
|
569
574
|
* This is ignored if the ExistingAssetId or if the RelatedContentId has a value
|
|
570
575
|
* @param {string | null} LANGUAGE_ID - The language of the asset to upload.
|
|
571
576
|
* 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
577
|
* @returns {Promise<string>} - A promise that resolves when the related asset is uploaded.
|
|
575
578
|
* Returns the content ID of the uploaded related asset.
|
|
576
579
|
* @throws {Error} - An error is thrown if the related asset fails to upload.
|
|
577
580
|
*/
|
|
578
581
|
async uploadRelatedAsset(EXISTING_ASSET_ID, RELATED_ASSET_ID, NEW_RELATED_ASSET_METADATA_TYPE,
|
|
579
|
-
UPLOAD_OVERWRITE_OPTION, FILE, LANGUAGE_ID
|
|
582
|
+
UPLOAD_OVERWRITE_OPTION, FILE, LANGUAGE_ID)
|
|
580
583
|
{
|
|
581
584
|
if (this.token === null)
|
|
582
585
|
{
|
|
583
586
|
await this._init();
|
|
584
587
|
}
|
|
585
588
|
|
|
586
|
-
if (!FILE && !FILE_CONTENTS)
|
|
587
|
-
{
|
|
588
|
-
throw new Error("Either FILE or FILE_CONTENTS must be provided.");
|
|
589
|
-
}
|
|
590
|
-
|
|
591
589
|
_printDatetime(`Uploading related asset`);
|
|
592
590
|
|
|
593
591
|
let startUploadInfo = null;
|
|
594
592
|
try
|
|
595
593
|
{
|
|
596
|
-
|
|
597
|
-
if (!
|
|
598
|
-
{
|
|
599
|
-
const fileProps = await _processFile(FILE);
|
|
600
|
-
if (!fileProps)
|
|
601
|
-
{
|
|
602
|
-
_printDatetime("File not found");
|
|
603
|
-
return;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
else
|
|
594
|
+
const FILE_PROPS = await _processFile(FILE);
|
|
595
|
+
if (!FILE_PROPS)
|
|
607
596
|
{
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
size: FILE_CONTENTS.byteLength
|
|
611
|
-
};
|
|
597
|
+
_printDatetime("File not found");
|
|
598
|
+
return;
|
|
612
599
|
}
|
|
613
600
|
|
|
614
601
|
startUploadInfo = await _startRelatedAssetUpload(this, EXISTING_ASSET_ID,
|
|
615
602
|
RELATED_ASSET_ID, NEW_RELATED_ASSET_METADATA_TYPE, UPLOAD_OVERWRITE_OPTION,
|
|
616
|
-
|
|
603
|
+
FILE_PROPS, LANGUAGE_ID);
|
|
617
604
|
|
|
618
605
|
if (!startUploadInfo) throw new Error("Failed to start related asset upload");
|
|
619
606
|
|
|
620
|
-
const response = await _multiThreadUpload(this,
|
|
607
|
+
const response = await _multiThreadUpload(this, FILE_PROPS, startUploadInfo);
|
|
621
608
|
if (!response) throw new Error("Failed to upload");
|
|
622
609
|
|
|
623
610
|
await _completeUpload(this, startUploadInfo.id);
|
|
@@ -625,9 +612,7 @@ class NomadMediaSDK {
|
|
|
625
612
|
|
|
626
613
|
const DETAILS = await _getAssetDetails(this, EXISTING_ASSET_ID);
|
|
627
614
|
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
const ASSET_INFO = DETAILS.relatedAssets.find(asset => asset.url.includes(FILE_NAME));
|
|
615
|
+
const ASSET_INFO = DETAILS.relatedAssets.find(asset => asset.url.includes(FILE_PROPS.originalName));
|
|
631
616
|
if (!ASSET_INFO) throw new Error("Asset ID not found");
|
|
632
617
|
return ASSET_INFO.id;
|
|
633
618
|
}
|
|
@@ -1085,14 +1070,20 @@ class NomadMediaSDK {
|
|
|
1085
1070
|
* @param {string} CONTENT_ID - The ID of the content to add the custom properties to.
|
|
1086
1071
|
* @param {string | null} NAME - The name of the content to add the custom properties to.
|
|
1087
1072
|
* @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
|
|
1073
|
+
* @param {JSON | null} CUSTOM_PROPERTIES - A list of custom properties that should be saved for the
|
|
1089
1074
|
* asset. To remove a property value, set the value to null
|
|
1075
|
+
* @param {string} AVAILABLE_START_DATE - Gets or sets the availability starting date of the asset
|
|
1076
|
+
* for entitlement purposes MinValue is used to differentiate between null values and missing properties
|
|
1077
|
+
* We technically want null so we can clear the date.
|
|
1078
|
+
* @param {string} AVAILABLE_END_DATE - Gets or sets the availability ending date of the asset
|
|
1079
|
+
* for entitlement purposes MaxValue is used to differentiate between null values and missing properties
|
|
1080
|
+
* We technically want null so we can clear the date.
|
|
1090
1081
|
* @returns {Promise<JSON>} - A promise that resolves when the custom properties are added.
|
|
1091
1082
|
* Returns the information of the added custom properties.
|
|
1092
1083
|
* @throws {Error} - An error is thrown if the custom properties fail to add.
|
|
1093
1084
|
* @throws {Error} - An error is thrown if the API type is not admin.
|
|
1094
1085
|
*/
|
|
1095
|
-
async addCustomProperties(CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES)
|
|
1086
|
+
async addCustomProperties(CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES, AVAILABLE_START_DATE, AVAILABLE_END_DATE)
|
|
1096
1087
|
{
|
|
1097
1088
|
if (this.token === null)
|
|
1098
1089
|
{
|
|
@@ -1109,7 +1100,7 @@ class NomadMediaSDK {
|
|
|
1109
1100
|
try
|
|
1110
1101
|
{
|
|
1111
1102
|
const ADD_CUSTOM_PROPERTIES_INFO = await _addCustomProperties(this,
|
|
1112
|
-
CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES);
|
|
1103
|
+
CONTENT_ID, NAME, DATE, CUSTOM_PROPERTIES, AVAILABLE_START_DATE, AVAILABLE_END_DATE);
|
|
1113
1104
|
if (ADD_CUSTOM_PROPERTIES_INFO) _printDatetime(`Custom properties added to content: ${CONTENT_ID}`);
|
|
1114
1105
|
return ADD_CUSTOM_PROPERTIES_INFO;
|
|
1115
1106
|
}
|
|
@@ -1959,7 +1950,7 @@ class NomadMediaSDK {
|
|
|
1959
1950
|
|
|
1960
1951
|
try
|
|
1961
1952
|
{
|
|
1962
|
-
await
|
|
1953
|
+
await _createJobId(
|
|
1963
1954
|
this, ASSET_ID, JOB_RESULTS_URL, EXTERNAL_ID);
|
|
1964
1955
|
_printDatetime(`Job created: ${ASSET_ID}`);
|
|
1965
1956
|
} catch (error) {
|
|
@@ -6599,7 +6590,7 @@ class NomadMediaSDK {
|
|
|
6599
6590
|
* @async
|
|
6600
6591
|
* @description Gets the asset manifest with cookies for the specified asset ID.
|
|
6601
6592
|
* @param {string} ASSET_ID - The ID of the asset to get the manifest with cookies for.
|
|
6602
|
-
* @param {
|
|
6593
|
+
* @param {string} COOKIE_ID - The ID of the cookie.
|
|
6603
6594
|
* @returns {Promise<JSON>} - A promise that resolves when the asset manifest with cookies are retrieved.
|
|
6604
6595
|
* Returns the asset manifest with cookies.
|
|
6605
6596
|
* @throws {Error} - An error is thrown if the asset manifest with cookies fail to retrieve.
|
|
@@ -7493,13 +7484,12 @@ class NomadMediaSDK {
|
|
|
7493
7484
|
* @function ping
|
|
7494
7485
|
* @async
|
|
7495
7486
|
* @description Pings the user.
|
|
7496
|
-
* @param {
|
|
7497
|
-
* @param {string | nul} USER_SESSION_ID - The user session ID of the user.
|
|
7487
|
+
* @param {boolean | null} INCLUDE_HEADERS
|
|
7498
7488
|
* @returns {Promise<JSON>} - A promise that resolves when the user is pinged.
|
|
7499
7489
|
* Returns the ping status of the user.
|
|
7500
7490
|
* @throws {Error} - An error is thrown if the user fails to ping.
|
|
7501
7491
|
*/
|
|
7502
|
-
async ping(
|
|
7492
|
+
async ping(INCLUDE_HEADERS)
|
|
7503
7493
|
{
|
|
7504
7494
|
if (this.token === null)
|
|
7505
7495
|
{
|
|
@@ -7510,7 +7500,7 @@ class NomadMediaSDK {
|
|
|
7510
7500
|
|
|
7511
7501
|
try
|
|
7512
7502
|
{
|
|
7513
|
-
const PING = await _ping(this,
|
|
7503
|
+
const PING = await _ping(this, INCLUDE_HEADERS);
|
|
7514
7504
|
if (PING) _printDatetime(`User pinged`);
|
|
7515
7505
|
return PING;
|
|
7516
7506
|
}
|
|
@@ -7628,7 +7618,7 @@ class NomadMediaSDK {
|
|
|
7628
7618
|
DISTINCT_ON_FIELD_NAME, INCLUDE_VIDEO_CLIPS, USE_LLM_SEARCH,
|
|
7629
7619
|
INCLUDE_INTERNAL_FIELDS_IN_RESULTS);
|
|
7630
7620
|
if (SEARCH_INFO) _printDatetime(`Search complete`);
|
|
7631
|
-
return SEARCH_INFO
|
|
7621
|
+
return SEARCH_INFO?.hasItems ? SEARCH_INFO : false
|
|
7632
7622
|
}
|
|
7633
7623
|
catch (error)
|
|
7634
7624
|
{
|
|
@@ -8444,12 +8434,13 @@ class NomadMediaSDK {
|
|
|
8444
8434
|
* @async
|
|
8445
8435
|
* @description Gets media group.
|
|
8446
8436
|
* @param {string} MEDIA_GROUP_ID - The ID of the media group.
|
|
8437
|
+
* @param { Array<string> } FILTER_IDS - The IDs of the media group items to filter by.
|
|
8447
8438
|
* @returns {Promise<JSON>} - A promise that resolves when the media group is gotten.
|
|
8448
8439
|
* Returns the information of the gotten media group.
|
|
8449
8440
|
* @throws {Error} - An error is thrown if the media group fails to get.
|
|
8450
8441
|
* @throws {Error} - An error is thrown if the API type is not portal.
|
|
8451
8442
|
*/
|
|
8452
|
-
async getMediaGroup(MEDIA_GROUP_ID)
|
|
8443
|
+
async getMediaGroup(MEDIA_GROUP_ID, FILTER_IDS)
|
|
8453
8444
|
{
|
|
8454
8445
|
if (this.token === null)
|
|
8455
8446
|
{
|
|
@@ -8465,7 +8456,7 @@ class NomadMediaSDK {
|
|
|
8465
8456
|
|
|
8466
8457
|
try
|
|
8467
8458
|
{
|
|
8468
|
-
const GET_MEDIA_GROUP_INFO = await _getMediaGroup(this, MEDIA_GROUP_ID);
|
|
8459
|
+
const GET_MEDIA_GROUP_INFO = await _getMediaGroup(this, MEDIA_GROUP_ID, FILTER_IDS);
|
|
8469
8460
|
if (GET_MEDIA_GROUP_INFO) _printDatetime(`Media group gotten: ${MEDIA_GROUP_ID}`);
|
|
8470
8461
|
return GET_MEDIA_GROUP_INFO;
|
|
8471
8462
|
}
|
|
@@ -9801,22 +9792,26 @@ class NomadMediaSDK {
|
|
|
9801
9792
|
* JSON format: {"id": string, "description": string }
|
|
9802
9793
|
* @param {JSON | null} SHARED_DURATION - The shared Duration of the share.
|
|
9803
9794
|
* JSON format: {"id": string, "description": string }
|
|
9804
|
-
* @param {Array<JSON> | null}
|
|
9795
|
+
* @param {Array<JSON> | null} SHARED_PERMISSIONS - The sharedPermissions of the share.
|
|
9805
9796
|
* JSON format: {"id": string, "description": string }
|
|
9806
9797
|
* @param {JSON | null} SHARED_TYPE: - The sharedType of the share.
|
|
9807
9798
|
* JSON format: {"id": string, "description": string }
|
|
9808
|
-
* @param {
|
|
9799
|
+
* @param {JSON | null} SHARED_STATUS - The sharedStatus of the share.
|
|
9809
9800
|
* JSON format: {"id": string, "description": string }
|
|
9810
9801
|
* @param {integer | null} SHARED_DURATION_IN_HOURS - The sharedDurationInHours of the share.
|
|
9811
9802
|
* @param {string | null} SHARED_LINK - The sharedLink of the share.
|
|
9812
9803
|
* @param {string | null} OWNER_ID - The ownerId of the share.
|
|
9813
9804
|
* @param {string | null} EXPIRATION_DATE - The expirationDate of the share.
|
|
9805
|
+
* @param {string | null} ASSET_ID - The assetId of the share.
|
|
9806
|
+
* @param {Array<JSON> | null} SHARED_USERS - The sharedUsers of the share.
|
|
9807
|
+
* JSON format: {"id": string, "description": string }
|
|
9814
9808
|
* @returns {Promise<object>}
|
|
9815
9809
|
* @throws {Error} - An error is thrown if share fails.
|
|
9816
9810
|
* @throws {Error} - An error is the API type is not post.
|
|
9817
9811
|
*/
|
|
9818
9812
|
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
|
|
9813
|
+
SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE,
|
|
9814
|
+
ASSET_ID, SHARED_USERS)
|
|
9820
9815
|
{
|
|
9821
9816
|
if (this.token === null)
|
|
9822
9817
|
{
|
|
@@ -9834,7 +9829,8 @@ class NomadMediaSDK {
|
|
|
9834
9829
|
{
|
|
9835
9830
|
const RESPONSE = await _share(this, ID, NAME, SHARED_CONTENTS,
|
|
9836
9831
|
SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE, SHARED_STATUS,
|
|
9837
|
-
SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE
|
|
9832
|
+
SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE,
|
|
9833
|
+
ASSET_ID, SHARED_USERS);
|
|
9838
9834
|
|
|
9839
9835
|
_printDatetime(`Share called successfully.`);
|
|
9840
9836
|
|
|
@@ -9942,18 +9938,22 @@ class NomadMediaSDK {
|
|
|
9942
9938
|
* JSON format: {"id": string, "description": string }
|
|
9943
9939
|
* @param {JSON | null} SHARED_TYPE - The sharedType of the updateShare.
|
|
9944
9940
|
* JSON format: {"id": string, "description": string }
|
|
9945
|
-
* @param {
|
|
9941
|
+
* @param {JSON | null} SHARED_STATUS - The sharedStatus of the updateShare.
|
|
9946
9942
|
* JSON format: {"id": string, "description": string }
|
|
9947
9943
|
* @param {integer | null} SHARED_DURATION_IN_HOURS - The sharedDurationInHours of the updateShare.
|
|
9948
9944
|
* @param {string | null} SHARED_LINK - The sharedLink of the updateShare.
|
|
9949
9945
|
* @param {string | null} OWNER_ID - The ownerId of the updateShare.
|
|
9950
9946
|
* @param {string | null} EXPIRATION_DATE - The expirationDate of the updateShare.
|
|
9947
|
+
* @param {string | null} ASSET_ID - The assetId of the updateShare.
|
|
9948
|
+
* @param {Array<JSON> | null} SHARED_USERS - The sharedUsers of the updateShare.
|
|
9949
|
+
* JSON format: {"id": string, "description": string }
|
|
9951
9950
|
* @returns {Promise<object>}
|
|
9952
9951
|
* @throws {Error} - An error is thrown if updateShare fails.
|
|
9953
9952
|
* @throws {Error} - An error is the API type is not put.
|
|
9954
9953
|
*/
|
|
9955
9954
|
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
|
|
9955
|
+
SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE,
|
|
9956
|
+
ASSET_ID, SHARED_USERS)
|
|
9957
9957
|
{
|
|
9958
9958
|
if (this.token === null)
|
|
9959
9959
|
{
|
|
@@ -9972,7 +9972,7 @@ class NomadMediaSDK {
|
|
|
9972
9972
|
const RESPONSE = await _updateShare(this, SHARE_ID, ID, NAME,
|
|
9973
9973
|
SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE,
|
|
9974
9974
|
SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID,
|
|
9975
|
-
EXPIRATION_DATE);
|
|
9975
|
+
EXPIRATION_DATE, ASSET_ID, SHARED_USERS);
|
|
9976
9976
|
|
|
9977
9977
|
_printDatetime(`Update share called successfully.`);
|
|
9978
9978
|
|
|
@@ -10127,12 +10127,23 @@ async function _cancelUpload(instance, ID)
|
|
|
10127
10127
|
|
|
10128
10128
|
const MAX_CONCURRENT_PROMISES = 3;
|
|
10129
10129
|
|
|
10130
|
-
async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE
|
|
10130
|
+
async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE)
|
|
10131
10131
|
{
|
|
10132
10132
|
const PARTS = UPLOAD_RESPONSE.parts;
|
|
10133
10133
|
const LENGTH = PARTS.length;
|
|
10134
10134
|
const abortController = new AbortController();
|
|
10135
10135
|
|
|
10136
|
+
let buffer;
|
|
10137
|
+
try
|
|
10138
|
+
{
|
|
10139
|
+
buffer = Buffer.from(FILE.buffer, 'binary');
|
|
10140
|
+
}
|
|
10141
|
+
catch (error)
|
|
10142
|
+
{
|
|
10143
|
+
console.error("Error converting file buffer to Buffer:", error);
|
|
10144
|
+
return false;
|
|
10145
|
+
}
|
|
10146
|
+
|
|
10136
10147
|
try {
|
|
10137
10148
|
for (let INDEX = 0; INDEX < LENGTH; INDEX += MAX_CONCURRENT_PROMISES)
|
|
10138
10149
|
{
|
|
@@ -10142,7 +10153,7 @@ async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE, FILE_CONTENTS
|
|
|
10142
10153
|
|
|
10143
10154
|
try {
|
|
10144
10155
|
console.log(`Uploading part ${INDEX + 1} of ${LENGTH}...`);
|
|
10145
|
-
const ETAG = await _uploadPart(
|
|
10156
|
+
const ETAG = await _uploadPart(buffer, PART, instance.debug);
|
|
10146
10157
|
if (!ETAG) {
|
|
10147
10158
|
throw new Error("Connection error");
|
|
10148
10159
|
}
|
|
@@ -10175,7 +10186,7 @@ async function _multiThreadUpload(instance, FILE, UPLOAD_RESPONSE, FILE_CONTENTS
|
|
|
10175
10186
|
|
|
10176
10187
|
|
|
10177
10188
|
async function _startUpload(instance, NAME, EXISTING_ASSET_ID, RELATED_CONTENT_ID,
|
|
10178
|
-
UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID)
|
|
10189
|
+
UPLOAD_OVERWRITE_OPTION, FILE, PARENT_ID, LANGUAGE_ID, UPLOAD_REPLACE_OPTIONS)
|
|
10179
10190
|
{
|
|
10180
10191
|
const API_URL = `${instance.config.serviceApiUrl}/api/asset/upload/start`;
|
|
10181
10192
|
|
|
@@ -10190,7 +10201,8 @@ async function _startUpload(instance, NAME, EXISTING_ASSET_ID, RELATED_CONTENT_I
|
|
|
10190
10201
|
chunkSize: CHUNK_SIZE,
|
|
10191
10202
|
relatedContentId: RELATED_CONTENT_ID,
|
|
10192
10203
|
languageId: LANGUAGE_ID,
|
|
10193
|
-
existingAssetId: EXISTING_ASSET_ID
|
|
10204
|
+
existingAssetId: EXISTING_ASSET_ID,
|
|
10205
|
+
uploadReplaceOptions: UPLOAD_REPLACE_OPTIONS
|
|
10194
10206
|
};
|
|
10195
10207
|
|
|
10196
10208
|
return await _sendRequest(instance, "Start asset upload", API_URL, "POST", undefined, BODY);
|
|
@@ -10248,23 +10260,15 @@ async function _uploadPartComplete(instance, PART_ID, ETAG)
|
|
|
10248
10260
|
|
|
10249
10261
|
import { Buffer } from "buffer";
|
|
10250
10262
|
|
|
10251
|
-
async function _uploadPart(
|
|
10263
|
+
async function _uploadPart(BUFFER, PART, DEBUG_MODE, maxRetries = 3)
|
|
10252
10264
|
{
|
|
10253
|
-
for (let attempt = 0; attempt < maxRetries; ++
|
|
10254
|
-
|
|
10265
|
+
for (let attempt = 0; attempt < maxRetries; attempt++)
|
|
10266
|
+
{
|
|
10255
10267
|
try
|
|
10256
10268
|
{
|
|
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
|
-
}
|
|
10269
|
+
const BODY = BUFFER.slice(PART.startingPosition, PART.endingPosition + 1);
|
|
10267
10270
|
|
|
10271
|
+
// Create header for the request
|
|
10268
10272
|
const HEADERS = new Headers();
|
|
10269
10273
|
HEADERS.append("Accept", "application/json, text/plain, */*");
|
|
10270
10274
|
|
|
@@ -10273,7 +10277,7 @@ async function _uploadPart(FILE, PART, FILE_CONTENTS, DEBUG_MODE, maxRetries = 3
|
|
|
10273
10277
|
const RESPONSE = await fetch(PART.url, {
|
|
10274
10278
|
method: "PUT",
|
|
10275
10279
|
headers: HEADERS,
|
|
10276
|
-
body:
|
|
10280
|
+
body: BODY
|
|
10277
10281
|
});
|
|
10278
10282
|
|
|
10279
10283
|
if (!RESPONSE.ok)
|
|
@@ -10287,11 +10291,13 @@ async function _uploadPart(FILE, PART, FILE_CONTENTS, DEBUG_MODE, maxRetries = 3
|
|
|
10287
10291
|
catch (error)
|
|
10288
10292
|
{
|
|
10289
10293
|
if (attempt < maxRetries - 1)
|
|
10290
|
-
|
|
10294
|
+
{
|
|
10295
|
+
// Retry if there are more attempts left
|
|
10291
10296
|
console.error(`Upload attempt ${attempt + 1} failed. Retrying...`);
|
|
10292
10297
|
}
|
|
10293
10298
|
else
|
|
10294
10299
|
{
|
|
10300
|
+
// No more retries left, handle the error
|
|
10295
10301
|
_apiExceptionHandler(error, "Upload Part Failed");
|
|
10296
10302
|
break;
|
|
10297
10303
|
}
|
|
@@ -11459,6 +11465,8 @@ async function _updateLiveInput(instance, ID, NAME, SOURCE, TYPE, IS_STANDARD, V
|
|
|
11459
11465
|
|
|
11460
11466
|
const INFO = await _sendRequest(instance, "Updating Live Input", API_URL, "PUT", undefined, BODY);
|
|
11461
11467
|
await _waitForLiveInputStatus(instance, INFO.id, _LIVE_INPUT_STATUSES.Detached, 15, 1);
|
|
11468
|
+
|
|
11469
|
+
return INFO;
|
|
11462
11470
|
}
|
|
11463
11471
|
|
|
11464
11472
|
|
|
@@ -13605,15 +13613,18 @@ async function _updateAsset(instance, ASSET_ID, DISPLAY_NAME, DISPLAY_DATE, AVAI
|
|
|
13605
13613
|
|
|
13606
13614
|
|
|
13607
13615
|
|
|
13608
|
-
async function _addCustomProperties(instance, ID, NAME, DATE, CUSTOM_PROPERTIES
|
|
13616
|
+
async function _addCustomProperties(instance, ID, NAME, DATE, CUSTOM_PROPERTIES,
|
|
13617
|
+
AVAILABLE_START_DATE, AVAILABLE_END_DATE)
|
|
13609
13618
|
{
|
|
13610
13619
|
const API_URL = `${instance.config.serviceApiUrl}/api/admin/asset/${ID}`;
|
|
13611
13620
|
|
|
13612
13621
|
const BODY = {};
|
|
13613
13622
|
|
|
13614
|
-
if (NAME) BODY.name = NAME;
|
|
13615
|
-
if (DATE) BODY.date = DATE;
|
|
13616
|
-
if (CUSTOM_PROPERTIES) BODY.customProperties = CUSTOM_PROPERTIES;
|
|
13623
|
+
if (NAME !== undefined) BODY.name = NAME;
|
|
13624
|
+
if (DATE !== undefined) BODY.date = DATE;
|
|
13625
|
+
if (CUSTOM_PROPERTIES !== undefined) BODY.customProperties = CUSTOM_PROPERTIES;
|
|
13626
|
+
if (AVAILABLE_START_DATE !== undefined) BODY.availableStartDate = AVAILABLE_START_DATE;
|
|
13627
|
+
if (AVAILABLE_END_DATE !== undefined) BODY.availableEndDate = AVAILABLE_END_DATE;
|
|
13617
13628
|
|
|
13618
13629
|
return await _sendRequest(instance, "Adding Custom Properties", API_URL, "PATCH", undefined, BODY);
|
|
13619
13630
|
}
|
|
@@ -13970,6 +13981,7 @@ async function _sendRequest(instance, FUNCTION_NAME, URL, METHOD_TYPE, PARAMS, B
|
|
|
13970
13981
|
};
|
|
13971
13982
|
|
|
13972
13983
|
if (instance.token) HEADERS["Authorization"] = `Bearer ${instance.token}`;
|
|
13984
|
+
else if (instance.config.apiKey) HEADERS["Authorization"] = `ApiKey ${instance.config.apiKey}`;
|
|
13973
13985
|
|
|
13974
13986
|
if (instance.debug && FUNCTION_NAME !== "Login") console.log(`URL: ${URL}\nMETHOD: ${METHOD_TYPE}` + (PARAMS && PARAMS.size === 0 ? `\nPARAMS: ${JSON.stringify(PARAMS, null, 4)}` : "") + (BODY ? `\nBODY: ${JSON.stringify(BODY, null, 4)}` : ""));
|
|
13975
13987
|
|
|
@@ -13980,7 +13992,6 @@ async function _sendRequest(instance, FUNCTION_NAME, URL, METHOD_TYPE, PARAMS, B
|
|
|
13980
13992
|
{
|
|
13981
13993
|
try
|
|
13982
13994
|
{
|
|
13983
|
-
refreshedToken = true;
|
|
13984
13995
|
RESPONSE = await axios({
|
|
13985
13996
|
method: METHOD_TYPE,
|
|
13986
13997
|
url: URL,
|
|
@@ -14597,11 +14608,14 @@ async function _getDynamicContents(instance)
|
|
|
14597
14608
|
|
|
14598
14609
|
|
|
14599
14610
|
|
|
14600
|
-
async function _getMediaGroup(instance, ID)
|
|
14611
|
+
async function _getMediaGroup(instance, ID, FILTER_IDS)
|
|
14601
14612
|
{
|
|
14602
|
-
|
|
14613
|
+
let apiUrl = `${instance.config.serviceApiUrl}/api/media/group/${ID}`;
|
|
14614
|
+
if (FILTER_IDS && FILTER_IDS.length > 0) {
|
|
14615
|
+
apiUrl += '?' + FILTER_IDS.map(id => `filterIds=${id}`).join('&');
|
|
14616
|
+
}
|
|
14603
14617
|
|
|
14604
|
-
return await _sendRequest(instance, "Get Media Group",
|
|
14618
|
+
return await _sendRequest(instance, "Get Media Group", apiUrl, "GET", undefined, undefined);
|
|
14605
14619
|
}
|
|
14606
14620
|
|
|
14607
14621
|
|
|
@@ -14870,7 +14884,7 @@ async function _shareNotification(instance, SHARE_ID, NOMAD_USERS, EXTERNAL_USER
|
|
|
14870
14884
|
|
|
14871
14885
|
async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS,
|
|
14872
14886
|
SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID,
|
|
14873
|
-
EXPIRATION_DATE)
|
|
14887
|
+
EXPIRATION_DATE, ASSET_ID, NOMAD_USERS)
|
|
14874
14888
|
{
|
|
14875
14889
|
const API_URL = `${instance.config.serviceApiUrl}/api/share`;
|
|
14876
14890
|
|
|
@@ -14885,7 +14899,9 @@ async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHAR
|
|
|
14885
14899
|
sharedDurationInHours: SHARED_DURATION_IN_HOURS,
|
|
14886
14900
|
sharedLink: SHARED_LINK,
|
|
14887
14901
|
ownerId: OWNER_ID,
|
|
14888
|
-
expirationDate: EXPIRATION_DATE
|
|
14902
|
+
expirationDate: EXPIRATION_DATE,
|
|
14903
|
+
assetId: ASSET_ID,
|
|
14904
|
+
nomadUsers: NOMAD_USERS
|
|
14889
14905
|
};
|
|
14890
14906
|
|
|
14891
14907
|
return await _sendRequest(instance, "Share", API_URL, "POST", undefined, BODY);
|
|
@@ -14897,7 +14913,7 @@ async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHAR
|
|
|
14897
14913
|
|
|
14898
14914
|
async function _updateShare(instance, SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARED_DURATION,
|
|
14899
14915
|
SHARED_PERMISSIONS, SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK,
|
|
14900
|
-
OWNER_ID, EXPIRATION_DATE)
|
|
14916
|
+
OWNER_ID, EXPIRATION_DATE, ASSET_ID, NOMAD_USERS)
|
|
14901
14917
|
{
|
|
14902
14918
|
const API_URL = `${instance.config.serviceApiUrl}/api/share/${SHARE_ID}?`;
|
|
14903
14919
|
|
|
@@ -14920,7 +14936,9 @@ async function _updateShare(instance, SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARE
|
|
|
14920
14936
|
sharedDurationInHours: SHARED_DURATION_IN_HOURS || share_info.sharedDurationInHours,
|
|
14921
14937
|
sharedLink: SHARED_LINK || share_info.sharedLink,
|
|
14922
14938
|
ownerId: OWNER_ID || share_info.ownerId,
|
|
14923
|
-
expirationDate: EXPIRATION_DATE || share_info.expirationDate
|
|
14939
|
+
expirationDate: EXPIRATION_DATE || share_info.expirationDate,
|
|
14940
|
+
assetId: ASSET_ID || share_info.assetId,
|
|
14941
|
+
nomadUsers: NOMAD_USERS || share_info.nomadUsers
|
|
14924
14942
|
};
|
|
14925
14943
|
|
|
14926
14944
|
return await _sendRequest(instance, "Update Share", API_URL, "PUT", undefined, BODY);
|