@nomad-media/full 1.1.19-alpha.1 → 1.1.19-alpha.2
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/dist/nomad-media-sdk-debug.js +527 -53
- package/dist/nomad-media-sdk.min.js +3 -3
- package/package.json +2 -2
|
@@ -134,6 +134,7 @@
|
|
|
134
134
|
|
|
135
135
|
|
|
136
136
|
|
|
137
|
+
|
|
137
138
|
|
|
138
139
|
|
|
139
140
|
// common
|
|
@@ -251,6 +252,13 @@
|
|
|
251
252
|
|
|
252
253
|
|
|
253
254
|
|
|
255
|
+
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
|
|
254
262
|
|
|
255
263
|
|
|
256
264
|
|
|
@@ -264,7 +272,7 @@
|
|
|
264
272
|
|
|
265
273
|
|
|
266
274
|
|
|
267
|
-
|
|
275
|
+
|
|
268
276
|
import path from 'path';
|
|
269
277
|
|
|
270
278
|
/**
|
|
@@ -328,6 +336,8 @@ class NomadMediaSDK {
|
|
|
328
336
|
try
|
|
329
337
|
{
|
|
330
338
|
const LOGIN_INFO = await _login(this);
|
|
339
|
+
if (!LOGIN_INFO) throw new Error("Login failed");
|
|
340
|
+
|
|
331
341
|
this.token = LOGIN_INFO["token"];
|
|
332
342
|
this.refreshTokenVal = LOGIN_INFO["refreshToken"];
|
|
333
343
|
this.expirationSeconds = LOGIN_INFO["expirationSeconds"];
|
|
@@ -504,27 +514,16 @@ class NomadMediaSDK {
|
|
|
504
514
|
let startUploadInfo = null
|
|
505
515
|
try
|
|
506
516
|
{
|
|
507
|
-
|
|
508
|
-
if (typeof FILE === "string")
|
|
509
|
-
{
|
|
510
|
-
FILE_PATH = FILE;
|
|
511
|
-
FILE = await fs.stat(FILE);
|
|
512
|
-
FILE.originalname = path.basename(FILE_PATH);
|
|
513
|
-
}
|
|
517
|
+
const FILE_PROPS = (await _processFile(FILE))[0];
|
|
514
518
|
|
|
515
519
|
_printDatetime("Starting upload");
|
|
516
520
|
startUploadInfo = await _startUpload(this, NAME, EXISTING_ASSET_ID,
|
|
517
|
-
RELATED_CONTENT_ID, UPLOAD_OVERWRITE_OPTION,
|
|
521
|
+
RELATED_CONTENT_ID, UPLOAD_OVERWRITE_OPTION, FILE_PROPS, PARENT_ID,
|
|
518
522
|
LANGUAGE_ID);
|
|
519
523
|
|
|
520
524
|
if (!startUploadInfo) throw new Error("Failed to start upload");
|
|
521
525
|
|
|
522
|
-
|
|
523
|
-
{
|
|
524
|
-
FILE.buffer = await fs.readFile(FILE_PATH);
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
await _multiThreadUpload(this, FILE, startUploadInfo);
|
|
526
|
+
await _multiThreadUpload(this, FILE_PROPS, startUploadInfo);
|
|
528
527
|
await _completeUpload(this, startUploadInfo["id"]);
|
|
529
528
|
|
|
530
529
|
const CONTENT_ID = startUploadInfo.assetId;
|
|
@@ -579,26 +578,15 @@ class NomadMediaSDK {
|
|
|
579
578
|
let startUploadInfo = null;
|
|
580
579
|
try
|
|
581
580
|
{
|
|
582
|
-
|
|
583
|
-
if (typeof FILE === "string")
|
|
584
|
-
{
|
|
585
|
-
FILE_PATH = FILE;
|
|
586
|
-
FILE = await fs.stat(FILE);
|
|
587
|
-
FILE.originalname = path.basename(FILE_PATH);
|
|
588
|
-
}
|
|
581
|
+
const [FILE_PROPS, FILE_PATH] = await _processFile(FILE);
|
|
589
582
|
|
|
590
583
|
startUploadInfo = await _startRelatedAssetUpload(this, EXISTING_ASSET_ID,
|
|
591
584
|
RELATED_ASSET_ID, NEW_RELATED_ASSET_METADATA_TYPE, UPLOAD_OVERWRITE_OPTION,
|
|
592
|
-
|
|
585
|
+
FILE_PROPS, LANGUAGE_ID);
|
|
593
586
|
|
|
594
587
|
if (!startUploadInfo) throw new Error("Failed to start related asset upload");
|
|
595
588
|
|
|
596
|
-
|
|
597
|
-
{
|
|
598
|
-
FILE.buffer = await fs.readFile(FILE_PATH);
|
|
599
|
-
}
|
|
600
|
-
|
|
601
|
-
await _multiThreadUpload(this, FILE, startUploadInfo);
|
|
589
|
+
await _multiThreadUpload(this, FILE_PROPS, startUploadInfo);
|
|
602
590
|
|
|
603
591
|
await _completeUpload(this, startUploadInfo.id);
|
|
604
592
|
_printDatetime("Related asset upload successful");
|
|
@@ -1671,13 +1659,22 @@ class NomadMediaSDK {
|
|
|
1671
1659
|
* @param {string} PRIMARY_LIVESTREAM_INPUT_URL - The primary live stream URL of the event.
|
|
1672
1660
|
* @param {string} BACKUP_LIVESTREAM_INPUT_URL - The backup live stream URL of the event.
|
|
1673
1661
|
* @param {Array<JSON> | null} EXTERNAL_OUTPUT_PROFILES - The external output profiles of the event.
|
|
1662
|
+
* @param {JSON | null} STATUS - Current status of the Live Channel Settings configuration.
|
|
1663
|
+
* JSON format: { id: string, description: string }
|
|
1664
|
+
* @param {string | null} STATUS_MESSAGE - The status message of the event.
|
|
1665
|
+
* @param {JSON | null} LIVE_CHANNEL - The live channel of the event.
|
|
1666
|
+
* JSON format: { id: string, description: string }
|
|
1667
|
+
* @param {bool | null} OVERRIDE_SETTINGS - Whether to override the settings of the event.
|
|
1668
|
+
* @param {JSON | null} OUTPUT_PROFILE_GROUP - The output profile group of the event.
|
|
1669
|
+
* JSON format: { id: string, description: string }
|
|
1674
1670
|
* @returns {Promise<null>} - A promise that resolves when the live event schedule is created.
|
|
1675
1671
|
* @throws {Error} - An error is thrown if the live event schedule fails to create.
|
|
1676
1672
|
* @throws {Error} - An error is thrown if the API type is not admin.
|
|
1677
1673
|
*/
|
|
1678
1674
|
async addLiveScheduleToEvent(EVENT_ID, SLATE_VIDEO, PREROLL_VIDEO, POSTROLL_VIDEO,
|
|
1679
1675
|
IS_SECURE_OUTPUT, ARCHIVE_FOLDER, PRIMARY_LIVE_INPUT, BACKUP_LIVE_INPUT,
|
|
1680
|
-
PRIMARY_LIVESTREAM_INPUT_URL, BACKUP_LIVESTREAM_INPUT_URL, EXTERNAL_OUTPUT_PROFILES
|
|
1676
|
+
PRIMARY_LIVESTREAM_INPUT_URL, BACKUP_LIVESTREAM_INPUT_URL, EXTERNAL_OUTPUT_PROFILES,
|
|
1677
|
+
STATUS, STATUS_MESSAGE, LIVE_CHANNEL, OVERRIDE_SETTINGS, OUTPUT_PROFILE_GROUP)
|
|
1681
1678
|
{
|
|
1682
1679
|
if (this.token === null)
|
|
1683
1680
|
{
|
|
@@ -1696,7 +1693,8 @@ class NomadMediaSDK {
|
|
|
1696
1693
|
await _addLiveScheduleToEvent(this, EVENT_ID, SLATE_VIDEO, PREROLL_VIDEO,
|
|
1697
1694
|
POSTROLL_VIDEO, IS_SECURE_OUTPUT, ARCHIVE_FOLDER, PRIMARY_LIVE_INPUT,
|
|
1698
1695
|
BACKUP_LIVE_INPUT, PRIMARY_LIVESTREAM_INPUT_URL, BACKUP_LIVESTREAM_INPUT_URL,
|
|
1699
|
-
EXTERNAL_OUTPUT_PROFILES
|
|
1696
|
+
EXTERNAL_OUTPUT_PROFILES, STATUS, STATUS_MESSAGE, LIVE_CHANNEL,
|
|
1697
|
+
OVERRIDE_SETTINGS, OUTPUT_PROFILE_GROUP);
|
|
1700
1698
|
_printDatetime(`Live Schedule added to Event: ${EVENT_ID}`);
|
|
1701
1699
|
}
|
|
1702
1700
|
catch (error)
|
|
@@ -5450,6 +5448,44 @@ class NomadMediaSDK {
|
|
|
5450
5448
|
}
|
|
5451
5449
|
}
|
|
5452
5450
|
|
|
5451
|
+
/**
|
|
5452
|
+
* @function deleteUserShareData
|
|
5453
|
+
* @async
|
|
5454
|
+
* @description Deletes a user share data.
|
|
5455
|
+
* @param {string | null} USER_ID - The user ID of the user's share data.
|
|
5456
|
+
* If set to null, the user ID of the current user is used.
|
|
5457
|
+
* @returns {Promise<void>} - A promise that resolves when the user share data is deleted.
|
|
5458
|
+
* @throws {Error} - An error is thrown if the user share data fails to delete.
|
|
5459
|
+
* @throws {Error} - An error is thrown if the API type is not admin.
|
|
5460
|
+
*/
|
|
5461
|
+
async deleteUserShareData(USER_ID)
|
|
5462
|
+
{
|
|
5463
|
+
if (this.token === null)
|
|
5464
|
+
{
|
|
5465
|
+
await this._init();
|
|
5466
|
+
}
|
|
5467
|
+
|
|
5468
|
+
if (this.config.apiType !== "admin")
|
|
5469
|
+
{
|
|
5470
|
+
throw new Error("This function is only available for admin API type.");
|
|
5471
|
+
}
|
|
5472
|
+
|
|
5473
|
+
_printDatetime(`Deleting user share data`);
|
|
5474
|
+
|
|
5475
|
+
try
|
|
5476
|
+
{
|
|
5477
|
+
if (!USER_ID) USER_ID = this.id;
|
|
5478
|
+
|
|
5479
|
+
await _deleteUserShareData(this, USER_ID);
|
|
5480
|
+
_printDatetime(`User share data deleted`);
|
|
5481
|
+
}
|
|
5482
|
+
catch (error)
|
|
5483
|
+
{
|
|
5484
|
+
_printDatetime(`User share data failed to delete`);
|
|
5485
|
+
throw error;
|
|
5486
|
+
}
|
|
5487
|
+
}
|
|
5488
|
+
|
|
5453
5489
|
/**
|
|
5454
5490
|
* @function deleteUserVideoTrackingData
|
|
5455
5491
|
* @async
|
|
@@ -7028,21 +7064,18 @@ class NomadMediaSDK {
|
|
|
7028
7064
|
* @function shareAsset
|
|
7029
7065
|
* @async
|
|
7030
7066
|
* @description Shares an asset.
|
|
7031
|
-
* @param {
|
|
7067
|
+
* @param {string} ASSET_ID - The ID of the asset to share.
|
|
7032
7068
|
* @param {Array<JSON> | null} NOMAD_USERS - The nomad users of the share.
|
|
7033
7069
|
* JSON format: { id: string }
|
|
7034
7070
|
* @param {Array<JSON> | null} EXTERNAL_USERS - The external users of the share.
|
|
7035
7071
|
* JSON format: { id: string }
|
|
7036
|
-
* @param {number | null} SHARED_DURATION_IN_HOURS - The
|
|
7037
|
-
* @param {JSON | null} SHARED_DURATION - The share duration of the share.
|
|
7038
|
-
* JSON format: { id: string }
|
|
7039
|
-
* @param {boolean | null} ALLOW_DOWNLOADS - The allow downloads of the share.
|
|
7072
|
+
* @param {number | null} SHARED_DURATION_IN_HOURS - The shared duration in hours of the share.
|
|
7040
7073
|
* @returns {Promise<JSON>} - A promise that resolves when the asset is shared.
|
|
7041
7074
|
* Returns the information of the shared asset.
|
|
7042
7075
|
* @throws {Error} - An error is thrown if the asset fails to share.
|
|
7043
7076
|
* @throws {Error} - An error is thrown if the API type is not portal.
|
|
7044
7077
|
*/
|
|
7045
|
-
async shareAsset(
|
|
7078
|
+
async shareAsset(ASSET_ID, NOMAD_USERS, EXTERNAL_USERS, SHARED_DURATION_IN_HOURS)
|
|
7046
7079
|
{
|
|
7047
7080
|
if (this.token === null)
|
|
7048
7081
|
{
|
|
@@ -7054,18 +7087,18 @@ class NomadMediaSDK {
|
|
|
7054
7087
|
throw new Error("This function is only available for portal API type.");
|
|
7055
7088
|
}
|
|
7056
7089
|
|
|
7057
|
-
_printDatetime(`Sharing asset`);
|
|
7090
|
+
_printDatetime(`Sharing asset: ${ASSET_ID}`);
|
|
7058
7091
|
|
|
7059
7092
|
try
|
|
7060
7093
|
{
|
|
7061
|
-
const SHARE_INFO = await _shareAsset(this,
|
|
7062
|
-
SHARED_DURATION_IN_HOURS
|
|
7063
|
-
if (SHARE_INFO) _printDatetime(`Asset shared`);
|
|
7094
|
+
const SHARE_INFO = await _shareAsset(this, ASSET_ID, NOMAD_USERS, EXTERNAL_USERS,
|
|
7095
|
+
SHARED_DURATION_IN_HOURS);
|
|
7096
|
+
if (SHARE_INFO) _printDatetime(`Asset shared: ${ASSET_ID}`);
|
|
7064
7097
|
return SHARE_INFO;
|
|
7065
7098
|
}
|
|
7066
7099
|
catch (error)
|
|
7067
7100
|
{
|
|
7068
|
-
_printDatetime(`Asset failed to share`);
|
|
7101
|
+
_printDatetime(`Asset failed to share: ${ASSET_ID}`);
|
|
7069
7102
|
throw error;
|
|
7070
7103
|
}
|
|
7071
7104
|
}
|
|
@@ -9499,8 +9532,7 @@ class NomadMediaSDK {
|
|
|
9499
9532
|
* @param {number | null} OFFSET - The offset of the search.
|
|
9500
9533
|
* @param {number | null} SIZE - The size of the search.
|
|
9501
9534
|
* @param {Array<JSON> | null} FILTERS - The filters of the search.
|
|
9502
|
-
* Array format: [{"fieldName": "string", "operator": "string", "values" :
|
|
9503
|
-
* "array<string>" | "string"} ...]
|
|
9535
|
+
* Array format: [{"fieldName": "string", "operator": "string", "values" : "array<string>" | "string"} ...]
|
|
9504
9536
|
* @param {Array<JSON> | null} SORT_FIELDS - The sort fields of the search.
|
|
9505
9537
|
* Array format: [{"fieldName": "string", "sortType": ("Ascending" | "Descending")} ...]
|
|
9506
9538
|
* @param {Array<JSON> | null} SEARCH_RESULT_FIELDS - The property fields you want to show
|
|
@@ -9550,6 +9582,278 @@ class NomadMediaSDK {
|
|
|
9550
9582
|
}
|
|
9551
9583
|
}
|
|
9552
9584
|
|
|
9585
|
+
// share functions
|
|
9586
|
+
/**
|
|
9587
|
+
* @function deleteShare
|
|
9588
|
+
* @async
|
|
9589
|
+
* @description Deletes an asset
|
|
9590
|
+
* @param {string} SHARE_ID - The shareId of the deleteShare.
|
|
9591
|
+
* @returns {Promise<object>}
|
|
9592
|
+
* @throws {Error} - An error is thrown if deleteShare fails.
|
|
9593
|
+
* @throws {Error} - An error is the API type is not delete.
|
|
9594
|
+
*/
|
|
9595
|
+
async deleteShare(SHARE_ID)
|
|
9596
|
+
{
|
|
9597
|
+
if (this.token === null)
|
|
9598
|
+
{
|
|
9599
|
+
await this._init();
|
|
9600
|
+
}
|
|
9601
|
+
|
|
9602
|
+
if (this.config.apiType !== "portal")
|
|
9603
|
+
{
|
|
9604
|
+
throw new Error("This function is only available for delete type.");
|
|
9605
|
+
}
|
|
9606
|
+
|
|
9607
|
+
_printDatetime(`Calling delete share...`);
|
|
9608
|
+
|
|
9609
|
+
try
|
|
9610
|
+
{
|
|
9611
|
+
const RESPONSE = await _deleteShare(this, SHARE_ID);
|
|
9612
|
+
|
|
9613
|
+
_printDatetime(`Deletes share called successfully.`);
|
|
9614
|
+
|
|
9615
|
+
return RESPONSE;
|
|
9616
|
+
}
|
|
9617
|
+
catch (error)
|
|
9618
|
+
{
|
|
9619
|
+
_printDatetime(`Delete share failed`);
|
|
9620
|
+
throw error;
|
|
9621
|
+
}
|
|
9622
|
+
}
|
|
9623
|
+
|
|
9624
|
+
/**
|
|
9625
|
+
* @function getShare
|
|
9626
|
+
* @async
|
|
9627
|
+
* @description Gets an asset
|
|
9628
|
+
* @param {string} SHARE_ID - The shareId of the getShare.
|
|
9629
|
+
* @returns {Promise<object>}
|
|
9630
|
+
* @throws {Error} - An error is thrown if getShare fails.
|
|
9631
|
+
* @throws {Error} - An error is the API type is not get.
|
|
9632
|
+
*/
|
|
9633
|
+
async getShare(SHARE_ID)
|
|
9634
|
+
{
|
|
9635
|
+
if (this.token === null)
|
|
9636
|
+
{
|
|
9637
|
+
await this._init();
|
|
9638
|
+
}
|
|
9639
|
+
|
|
9640
|
+
if (this.config.apiType !== "portal")
|
|
9641
|
+
{
|
|
9642
|
+
throw new Error("This function is only available for get type.");
|
|
9643
|
+
}
|
|
9644
|
+
|
|
9645
|
+
_printDatetime(`Calling getShare...`);
|
|
9646
|
+
|
|
9647
|
+
try
|
|
9648
|
+
{
|
|
9649
|
+
const RESPONSE = await _getShare(this, SHARE_ID);
|
|
9650
|
+
|
|
9651
|
+
_printDatetime(`Get share called successfully.`);
|
|
9652
|
+
|
|
9653
|
+
return RESPONSE;
|
|
9654
|
+
}
|
|
9655
|
+
catch (error)
|
|
9656
|
+
{
|
|
9657
|
+
_printDatetime(`Get share failed`);
|
|
9658
|
+
throw error;
|
|
9659
|
+
}
|
|
9660
|
+
}
|
|
9661
|
+
|
|
9662
|
+
/**
|
|
9663
|
+
* @function share
|
|
9664
|
+
* @async
|
|
9665
|
+
* @description Share an asset
|
|
9666
|
+
* @param {string | null} ID - The id of the share.
|
|
9667
|
+
* @param {string | null} NAME - The name of the share.
|
|
9668
|
+
* @param {Array<string> | null} SHARED_CONTENTS - The sharedContents of the share.
|
|
9669
|
+
* JSON format: {"id": string, "description": string }
|
|
9670
|
+
* @param {JSON | null} SHARED_DURATION - The shared Duration of the share.
|
|
9671
|
+
* JSON format: {"id": string, "description": string }
|
|
9672
|
+
* @param {Array<JSON> | null} SHARED_PERMISSION - The sharedPermissions of the share.
|
|
9673
|
+
* JSON format: {"id": string, "description": string }
|
|
9674
|
+
* @param {JSON | null} SHARED_TYPE: - The sharedType of the share.
|
|
9675
|
+
* JSON format: {"id": string, "description": string }
|
|
9676
|
+
* @param {Array<JSON> | null} SHARED_STATUS - The sharedStatus of the share.
|
|
9677
|
+
* JSON format: {"id": string, "description": string }
|
|
9678
|
+
* @param {integer | null} SHARED_DURATION_IN_HOURS - The sharedDurationInHours of the share.
|
|
9679
|
+
* @param {string | null} SHARED_LINK - The sharedLink of the share.
|
|
9680
|
+
* @param {string | null} OWNER_ID - The ownerId of the share.
|
|
9681
|
+
* @param {string | null} EXPIRATION_DATE - The expirationDate of the share.
|
|
9682
|
+
* @returns {Promise<object>}
|
|
9683
|
+
* @throws {Error} - An error is thrown if share fails.
|
|
9684
|
+
* @throws {Error} - An error is the API type is not post.
|
|
9685
|
+
*/
|
|
9686
|
+
async share(ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE,
|
|
9687
|
+
SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE)
|
|
9688
|
+
{
|
|
9689
|
+
if (this.token === null)
|
|
9690
|
+
{
|
|
9691
|
+
await this._init();
|
|
9692
|
+
}
|
|
9693
|
+
|
|
9694
|
+
if (this.config.apiType !== "portal")
|
|
9695
|
+
{
|
|
9696
|
+
throw new Error("This function is only available for post type.");
|
|
9697
|
+
}
|
|
9698
|
+
|
|
9699
|
+
_printDatetime(`Calling share...`);
|
|
9700
|
+
|
|
9701
|
+
try
|
|
9702
|
+
{
|
|
9703
|
+
const RESPONSE = await _share(this, ID, NAME, SHARED_CONTENTS,
|
|
9704
|
+
SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE, SHARED_STATUS,
|
|
9705
|
+
SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE);
|
|
9706
|
+
|
|
9707
|
+
_printDatetime(`Share called successfully.`);
|
|
9708
|
+
|
|
9709
|
+
return RESPONSE;
|
|
9710
|
+
}
|
|
9711
|
+
catch (error)
|
|
9712
|
+
{
|
|
9713
|
+
_printDatetime(`Share failed`);
|
|
9714
|
+
throw error;
|
|
9715
|
+
}
|
|
9716
|
+
}
|
|
9717
|
+
|
|
9718
|
+
/**
|
|
9719
|
+
* @function shareExpire
|
|
9720
|
+
* @async
|
|
9721
|
+
* @description Expire a share
|
|
9722
|
+
* @param {string} SHARE_ID - The shareId of the shareExpire.
|
|
9723
|
+
* @returns {Promise<void>}
|
|
9724
|
+
* @throws {Error} - An error is thrown if shareExpire fails.
|
|
9725
|
+
* @throws {Error} - An error is the API type is not post.
|
|
9726
|
+
*/
|
|
9727
|
+
async shareExpire(SHARE_ID)
|
|
9728
|
+
{
|
|
9729
|
+
if (this.token === null)
|
|
9730
|
+
{
|
|
9731
|
+
await this._init();
|
|
9732
|
+
}
|
|
9733
|
+
|
|
9734
|
+
if (this.config.apiType !== "portal")
|
|
9735
|
+
{
|
|
9736
|
+
throw new Error("This function is only available for post type.");
|
|
9737
|
+
}
|
|
9738
|
+
|
|
9739
|
+
_printDatetime(`Calling share expire...`);
|
|
9740
|
+
|
|
9741
|
+
try
|
|
9742
|
+
{
|
|
9743
|
+
const RESPONSE = await _shareExpire(this, SHARE_ID);
|
|
9744
|
+
|
|
9745
|
+
_printDatetime(`Share expire called successfully.`);
|
|
9746
|
+
|
|
9747
|
+
return RESPONSE;
|
|
9748
|
+
}
|
|
9749
|
+
catch (error)
|
|
9750
|
+
{
|
|
9751
|
+
_printDatetime(`Share expire failed`);
|
|
9752
|
+
throw error;
|
|
9753
|
+
}
|
|
9754
|
+
}
|
|
9755
|
+
|
|
9756
|
+
/**
|
|
9757
|
+
* @function shareNotification
|
|
9758
|
+
* @async
|
|
9759
|
+
* @description Get an notification when asset is shared
|
|
9760
|
+
* @param {string} SHARE_ID - The shareId of the shareNotification.
|
|
9761
|
+
* @param {Array<JSON> | null} NOMAD_USERS - The nomadUsers of the shareNotification.
|
|
9762
|
+
* JSON format: {"id": string, "description": string }
|
|
9763
|
+
* @param {Array<JSON> | null} EXTERNAL_USERS - The externalUsers of the shareNotification.
|
|
9764
|
+
* JSON format: {"id": string, "description": string }
|
|
9765
|
+
* @returns {Promise<void>}
|
|
9766
|
+
* @throws {Error} - An error is thrown if shareNotification fails.
|
|
9767
|
+
* @throws {Error} - An error is the API type is not post.
|
|
9768
|
+
*/
|
|
9769
|
+
async shareNotification(SHARE_ID, NOMAD_USERS, EXTERNAL_USERS)
|
|
9770
|
+
{
|
|
9771
|
+
if (this.token === null)
|
|
9772
|
+
{
|
|
9773
|
+
await this._init();
|
|
9774
|
+
}
|
|
9775
|
+
|
|
9776
|
+
if (this.config.apiType !== "portal")
|
|
9777
|
+
{
|
|
9778
|
+
throw new Error("This function is only available for post type.");
|
|
9779
|
+
}
|
|
9780
|
+
|
|
9781
|
+
_printDatetime(`Calling share notification...`);
|
|
9782
|
+
|
|
9783
|
+
try
|
|
9784
|
+
{
|
|
9785
|
+
const RESPONSE = await _shareNotification(this, SHARE_ID, NOMAD_USERS, EXTERNAL_USERS);
|
|
9786
|
+
|
|
9787
|
+
_printDatetime(`shareNotification called successfully.`);
|
|
9788
|
+
|
|
9789
|
+
return RESPONSE;
|
|
9790
|
+
}
|
|
9791
|
+
catch (error)
|
|
9792
|
+
{
|
|
9793
|
+
_printDatetime(`Share notification failed`);
|
|
9794
|
+
throw error;
|
|
9795
|
+
}
|
|
9796
|
+
}
|
|
9797
|
+
|
|
9798
|
+
/**
|
|
9799
|
+
* @function updateShare
|
|
9800
|
+
* @async
|
|
9801
|
+
* @description Updates an asset
|
|
9802
|
+
* @param {string} SHARE_ID - The shareId of the updateShare.
|
|
9803
|
+
* @param {string | null} ID - The id of the updateShare.
|
|
9804
|
+
* @param {string | null} NAME - The name of the updateShare.
|
|
9805
|
+
* @param {Array<JSON> | null} SHARED_CONTENTS - The sharedContents of the updateShare.
|
|
9806
|
+
* JSON format: {"id": string, "description": string }
|
|
9807
|
+
* @param {JSON | null} SHARED_DURATION - The sharedDuration of the updateShare.
|
|
9808
|
+
* JSON format: {"id": string, "description": string }
|
|
9809
|
+
* @param {Array<JSON> | null} SHARED_PERMISSIONS - The sharedPermissions of the updateShare.
|
|
9810
|
+
* JSON format: {"id": string, "description": string }
|
|
9811
|
+
* @param {JSON | null} SHARED_TYPE - The sharedType of the updateShare.
|
|
9812
|
+
* JSON format: {"id": string, "description": string }
|
|
9813
|
+
* @param {Array<JSON> | null} SHARED_STATUS - The sharedStatus of the updateShare.
|
|
9814
|
+
* JSON format: {"id": string, "description": string }
|
|
9815
|
+
* @param {integer | null} SHARED_DURATION_IN_HOURS - The sharedDurationInHours of the updateShare.
|
|
9816
|
+
* @param {string | null} SHARED_LINK - The sharedLink of the updateShare.
|
|
9817
|
+
* @param {string | null} OWNER_ID - The ownerId of the updateShare.
|
|
9818
|
+
* @param {string | null} EXPIRATION_DATE - The expirationDate of the updateShare.
|
|
9819
|
+
* @returns {Promise<object>}
|
|
9820
|
+
* @throws {Error} - An error is thrown if updateShare fails.
|
|
9821
|
+
* @throws {Error} - An error is the API type is not put.
|
|
9822
|
+
*/
|
|
9823
|
+
async updateShare(SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS,
|
|
9824
|
+
SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID, EXPIRATION_DATE)
|
|
9825
|
+
{
|
|
9826
|
+
if (this.token === null)
|
|
9827
|
+
{
|
|
9828
|
+
await this._init();
|
|
9829
|
+
}
|
|
9830
|
+
|
|
9831
|
+
if (this.config.apiType !== "portal")
|
|
9832
|
+
{
|
|
9833
|
+
throw new Error("This function is only available for put type.");
|
|
9834
|
+
}
|
|
9835
|
+
|
|
9836
|
+
_printDatetime(`Calling Update share...`);
|
|
9837
|
+
|
|
9838
|
+
try
|
|
9839
|
+
{
|
|
9840
|
+
const RESPONSE = await _updateShare(this, SHARE_ID, ID, NAME,
|
|
9841
|
+
SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS, SHARED_TYPE,
|
|
9842
|
+
SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID,
|
|
9843
|
+
EXPIRATION_DATE);
|
|
9844
|
+
|
|
9845
|
+
_printDatetime(`Update share called successfully.`);
|
|
9846
|
+
|
|
9847
|
+
return RESPONSE;
|
|
9848
|
+
}
|
|
9849
|
+
catch (error)
|
|
9850
|
+
{
|
|
9851
|
+
_printDatetime(`Update share failed`);
|
|
9852
|
+
|
|
9853
|
+
throw error;
|
|
9854
|
+
}
|
|
9855
|
+
}
|
|
9856
|
+
|
|
9553
9857
|
// video tracking functions
|
|
9554
9858
|
/**
|
|
9555
9859
|
* @function getVideoTracking
|
|
@@ -10194,7 +10498,8 @@ function _updateProperties(body, properties) {
|
|
|
10194
10498
|
async function _addLiveScheduleToEvent(instance, EVENT_ID, SLATE_VIDEO,
|
|
10195
10499
|
PREROLL_VIDEO, POSTROLL_VIDEO, IS_SECURE_OUTPUT, ARCHIVE_FOLDER_ASSET,
|
|
10196
10500
|
PRIMARY_LIVE_INPUT, BACKUP_LIVE_INPUT, PRIMARY_LIVESTREAM_INPUT_URL,
|
|
10197
|
-
BACKUP_LIVESTREAM_INPUT_URL, EXTERNAL_OUTPUT_PROFILES
|
|
10501
|
+
BACKUP_LIVESTREAM_INPUT_URL, EXTERNAL_OUTPUT_PROFILES, STATUS, STATUS_MESSAGE,
|
|
10502
|
+
LIVE_CHANNEL, OVERRIDE_SETTINGS, OUTPUT_PROFILE_GROUP)
|
|
10198
10503
|
{
|
|
10199
10504
|
const API_URL = `${instance.config.serviceApiUrl}/api/admin/liveSchedule`
|
|
10200
10505
|
|
|
@@ -10209,7 +10514,12 @@ async function _addLiveScheduleToEvent(instance, EVENT_ID, SLATE_VIDEO,
|
|
|
10209
10514
|
backupLiveInput: (BACKUP_LIVE_INPUT !== null) ? BACKUP_LIVE_INPUT : "",
|
|
10210
10515
|
primaryLivestreamInputUrl: (PRIMARY_LIVESTREAM_INPUT_URL !== null) ? PRIMARY_LIVESTREAM_INPUT_URL : "",
|
|
10211
10516
|
backupLivestreamInputUrl: (BACKUP_LIVESTREAM_INPUT_URL !== null) ? BACKUP_LIVESTREAM_INPUT_URL : "",
|
|
10212
|
-
externalOutputProfiles: (EXTERNAL_OUTPUT_PROFILES !== null) ? EXTERNAL_OUTPUT_PROFILES : ""
|
|
10517
|
+
externalOutputProfiles: (EXTERNAL_OUTPUT_PROFILES !== null) ? EXTERNAL_OUTPUT_PROFILES : "",
|
|
10518
|
+
status: (STATUS !== null) ? STATUS : "",
|
|
10519
|
+
statusMessage: (STATUS_MESSAGE !== null) ? STATUS_MESSAGE : "",
|
|
10520
|
+
liveChannel: (LIVE_CHANNEL !== null) ? LIVE_CHANNEL : "",
|
|
10521
|
+
overrideSettings: (OVERRIDE_SETTINGS !== null) ? OVERRIDE_SETTINGS : "",
|
|
10522
|
+
outputProfileGroup: (OUTPUT_PROFILE_GROUP !== null) ? OUTPUT_PROFILE_GROUP : ""
|
|
10213
10523
|
}
|
|
10214
10524
|
|
|
10215
10525
|
return await _sendRequest(instance, "Adding Live Schedule to Event", API_URL, "POST", undefined, BODY);
|
|
@@ -12298,6 +12608,16 @@ async function _deleteUserSessionData(instance, USER_ID)
|
|
|
12298
12608
|
|
|
12299
12609
|
|
|
12300
12610
|
|
|
12611
|
+
async function _deleteUserShareData(instance, USER_ID)
|
|
12612
|
+
{
|
|
12613
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/admin/user/shares/${USER_ID}`;
|
|
12614
|
+
|
|
12615
|
+
return await _sendRequest(instance, "Delete User Share Data", API_URL, "DELETE", undefined, undefined);
|
|
12616
|
+
}
|
|
12617
|
+
|
|
12618
|
+
|
|
12619
|
+
|
|
12620
|
+
|
|
12301
12621
|
async function _deleteUserVideoTrackingData(instance, ASSET_ID, CONTENT_ID,
|
|
12302
12622
|
VIDEO_TRACKING_ATTRIBUTE, USER_ID, ID, IS_FIRST_QUARTILE, IS_MIDPOINT, IS_THIRD_QUARTILE,
|
|
12303
12623
|
IS_COMPLETE, IS_HIDDEN, IS_LIVE_STREAM, MAX_SECOND, LAST_SECOND, TOTAL_SECONDS,
|
|
@@ -12984,18 +13304,15 @@ async function _restoreAsset(instance, ASSET_ID)
|
|
|
12984
13304
|
|
|
12985
13305
|
|
|
12986
13306
|
|
|
12987
|
-
async function _shareAsset(instance,
|
|
12988
|
-
SHARED_DURATION, ALLOW_DOWNLOADS)
|
|
13307
|
+
async function _shareAsset(instance, ASSET_ID, NOMAD_USERS, EXTERNAL_USERS, SHARED_DURATION_IN_HOURS)
|
|
12989
13308
|
{
|
|
12990
|
-
const API_URL = `${instance.config.serviceApiUrl}/api/share`;
|
|
13309
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/asset/${ASSET_ID}/share`;
|
|
12991
13310
|
|
|
12992
13311
|
const BODY = {
|
|
12993
|
-
|
|
13312
|
+
assetId: ASSET_ID,
|
|
12994
13313
|
nomadUsers: NOMAD_USERS,
|
|
12995
13314
|
externalUsers: EXTERNAL_USERS,
|
|
12996
|
-
sharedDurationInHours: SHARED_DURATION_IN_HOURS
|
|
12997
|
-
sharedDuration: SHARED_DURATION,
|
|
12998
|
-
sharedPermissions: ALLOW_DOWNLOADS ? [{ id: "ac5146ea-4c01-4278-8c7b-0135f70c0001" }] : []
|
|
13315
|
+
sharedDurationInHours: SHARED_DURATION_IN_HOURS
|
|
12999
13316
|
};
|
|
13000
13317
|
|
|
13001
13318
|
return await _sendRequest(instance, "Share Asset", API_URL, "POST", undefined, BODY);
|
|
@@ -13406,6 +13723,56 @@ function _printDatetime(msg)
|
|
|
13406
13723
|
}
|
|
13407
13724
|
|
|
13408
13725
|
|
|
13726
|
+
import { promises as fs } from 'fs';
|
|
13727
|
+
|
|
13728
|
+
|
|
13729
|
+
async function _processFile(FILE)
|
|
13730
|
+
{
|
|
13731
|
+
let FILE_PATH = null;
|
|
13732
|
+
if (typeof FILE === "string")
|
|
13733
|
+
{
|
|
13734
|
+
// if running in node
|
|
13735
|
+
if (typeof window === "undefined")
|
|
13736
|
+
{
|
|
13737
|
+
FILE_PATH = FILE;
|
|
13738
|
+
FILE = await fs.stat(FILE);
|
|
13739
|
+
FILE.originalname = path.basename(FILE_PATH);
|
|
13740
|
+
if (!FILE.buffer)
|
|
13741
|
+
{
|
|
13742
|
+
FILE.buffer = await fs.readFile(FILE_PATH);
|
|
13743
|
+
}
|
|
13744
|
+
}
|
|
13745
|
+
else
|
|
13746
|
+
{
|
|
13747
|
+
throw new Error("File path is not supported in browser");
|
|
13748
|
+
}
|
|
13749
|
+
}
|
|
13750
|
+
else
|
|
13751
|
+
{
|
|
13752
|
+
// if running in browser
|
|
13753
|
+
if (!FILE.buffer)
|
|
13754
|
+
{
|
|
13755
|
+
FILE.buffer = await _readFileAsArrayBuffer(FILE);
|
|
13756
|
+
}
|
|
13757
|
+
}
|
|
13758
|
+
|
|
13759
|
+
return [FILE, FILE_PATH];
|
|
13760
|
+
}
|
|
13761
|
+
|
|
13762
|
+
async function _readFileAsArrayBuffer(file)
|
|
13763
|
+
{
|
|
13764
|
+
return new Promise((resolve, reject) =>
|
|
13765
|
+
{
|
|
13766
|
+
/* eslint-disable no-undef */
|
|
13767
|
+
const reader = new FileReader();
|
|
13768
|
+
/* eslint-enable no-undef */
|
|
13769
|
+
reader.onload = () => resolve(reader.result);
|
|
13770
|
+
reader.onerror = reject;
|
|
13771
|
+
reader.readAsArrayBuffer(file);
|
|
13772
|
+
});
|
|
13773
|
+
}
|
|
13774
|
+
|
|
13775
|
+
|
|
13409
13776
|
|
|
13410
13777
|
|
|
13411
13778
|
|
|
@@ -14275,6 +14642,113 @@ async function _updateSavedSearch(instance, ID, NAME, FEATURED, BOOKMARKED, PUBL
|
|
|
14275
14642
|
|
|
14276
14643
|
|
|
14277
14644
|
|
|
14645
|
+
async function _deleteShare(instance, SHARE_ID)
|
|
14646
|
+
{
|
|
14647
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/share/${SHARE_ID}?`;
|
|
14648
|
+
|
|
14649
|
+
return await _sendRequest(instance, "Delete Share", API_URL, "DELETE", undefined, undefined);
|
|
14650
|
+
}
|
|
14651
|
+
|
|
14652
|
+
|
|
14653
|
+
|
|
14654
|
+
|
|
14655
|
+
async function _getShare(instance, SHARE_ID)
|
|
14656
|
+
{
|
|
14657
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/share/${SHARE_ID}?`;
|
|
14658
|
+
|
|
14659
|
+
return await _sendRequest(instance, "Get Share", API_URL, "GET", undefined, undefined);
|
|
14660
|
+
}
|
|
14661
|
+
|
|
14662
|
+
|
|
14663
|
+
|
|
14664
|
+
|
|
14665
|
+
async function _shareExpire(instance, SHARE_ID)
|
|
14666
|
+
{
|
|
14667
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/share/expire/${SHARE_ID}?`;
|
|
14668
|
+
|
|
14669
|
+
return await _sendRequest(instance, "Share Expire", API_URL, "POST", undefined, undefined);
|
|
14670
|
+
}
|
|
14671
|
+
|
|
14672
|
+
|
|
14673
|
+
|
|
14674
|
+
|
|
14675
|
+
async function _shareNotification(instance, SHARE_ID, NOMAD_USERS, EXTERNAL_USERS)
|
|
14676
|
+
{
|
|
14677
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/share/${SHARE_ID}/notification`;
|
|
14678
|
+
|
|
14679
|
+
const BODY = {
|
|
14680
|
+
shareId: SHARE_ID,
|
|
14681
|
+
nomadUsers: NOMAD_USERS,
|
|
14682
|
+
externalUsers: EXTERNAL_USERS
|
|
14683
|
+
};
|
|
14684
|
+
|
|
14685
|
+
return await _sendRequest(instance, "Share Notification", API_URL, "POST", undefined, BODY);
|
|
14686
|
+
}
|
|
14687
|
+
|
|
14688
|
+
|
|
14689
|
+
|
|
14690
|
+
|
|
14691
|
+
async function _share(instance, ID, NAME, SHARED_CONTENTS, SHARED_DURATION, SHARED_PERMISSIONS,
|
|
14692
|
+
SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK, OWNER_ID,
|
|
14693
|
+
EXPIRATION_DATE)
|
|
14694
|
+
{
|
|
14695
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/share`;
|
|
14696
|
+
|
|
14697
|
+
const BODY = {
|
|
14698
|
+
id: ID,
|
|
14699
|
+
name: NAME,
|
|
14700
|
+
sharedContents: SHARED_CONTENTS,
|
|
14701
|
+
sharedDuration: SHARED_DURATION,
|
|
14702
|
+
sharedPermissions: SHARED_PERMISSIONS,
|
|
14703
|
+
sharedType: SHARED_TYPE,
|
|
14704
|
+
sharedStatus: SHARED_STATUS,
|
|
14705
|
+
sharedDurationInHours: SHARED_DURATION_IN_HOURS,
|
|
14706
|
+
sharedLink: SHARED_LINK,
|
|
14707
|
+
ownerId: OWNER_ID,
|
|
14708
|
+
expirationDate: EXPIRATION_DATE
|
|
14709
|
+
};
|
|
14710
|
+
|
|
14711
|
+
return await _sendRequest(instance, "Share", API_URL, "POST", undefined, BODY);
|
|
14712
|
+
}
|
|
14713
|
+
|
|
14714
|
+
|
|
14715
|
+
|
|
14716
|
+
|
|
14717
|
+
|
|
14718
|
+
async function _updateShare(instance, SHARE_ID, ID, NAME, SHARED_CONTENTS, SHARED_DURATION,
|
|
14719
|
+
SHARED_PERMISSIONS, SHARED_TYPE, SHARED_STATUS, SHARED_DURATION_IN_HOURS, SHARED_LINK,
|
|
14720
|
+
OWNER_ID, EXPIRATION_DATE)
|
|
14721
|
+
{
|
|
14722
|
+
const API_URL = `${instance.config.serviceApiUrl}/api/share/${SHARE_ID}?`;
|
|
14723
|
+
|
|
14724
|
+
const share_info = await _getShare(instance, SHARE_ID);
|
|
14725
|
+
|
|
14726
|
+
if (!share_info)
|
|
14727
|
+
{
|
|
14728
|
+
console.error(`Share with ID ${SHARE_ID} not found`);
|
|
14729
|
+
return null;
|
|
14730
|
+
}
|
|
14731
|
+
|
|
14732
|
+
const BODY = {
|
|
14733
|
+
id: ID ,
|
|
14734
|
+
name: NAME || share_info.name,
|
|
14735
|
+
sharedContents: SHARED_CONTENTS || share_info.sharedContents,
|
|
14736
|
+
sharedDuration: SHARED_DURATION || share_info.sharedDuration,
|
|
14737
|
+
sharedPermissions: SHARED_PERMISSIONS || share_info.sharedPermissions,
|
|
14738
|
+
sharedType: SHARED_TYPE || share_info.sharedType,
|
|
14739
|
+
sharedStatus: SHARED_STATUS || share_info.sharedStatus,
|
|
14740
|
+
sharedDurationInHours: SHARED_DURATION_IN_HOURS || share_info.sharedDurationInHours,
|
|
14741
|
+
sharedLink: SHARED_LINK || share_info.sharedLink,
|
|
14742
|
+
ownerId: OWNER_ID || share_info.ownerId,
|
|
14743
|
+
expirationDate: EXPIRATION_DATE || share_info.expirationDate
|
|
14744
|
+
};
|
|
14745
|
+
|
|
14746
|
+
return await _sendRequest(instance, "Update Share", API_URL, "PUT", undefined, BODY);
|
|
14747
|
+
}
|
|
14748
|
+
|
|
14749
|
+
|
|
14750
|
+
|
|
14751
|
+
|
|
14278
14752
|
async function _getVideoTracking(instance, ASSET_ID, TRACKING_EVENT, SECOND)
|
|
14279
14753
|
{
|
|
14280
14754
|
const API_URL = `${instance.config.serviceApiUrl}/api/asset/tracking?assetId=${ASSET_ID}`
|