@nomad-media/full 1.1.19-alpha.1 → 1.1.19-alpha.3

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