@reactoo/watchtogether-sdk-js 2.6.2 → 2.6.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.6.2",
3
+ "version": "2.6.4",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "src/index.js",
6
6
  "unpkg": "dist/watchtogether-sdk.min.js",
@@ -4,6 +4,7 @@ import {generateUUID} from "../modules/wt-utils";
4
4
 
5
5
  let asset = function() {
6
6
  return {
7
+
7
8
  getAssetList: ({type = 'instanceType', instanceType, assetType, size = 20, startKey = null, roomId, ids}) => {
8
9
  let apiParams = {
9
10
  type,
@@ -17,6 +18,10 @@ let asset = function() {
17
18
  return this.__privates.auth.__client
18
19
  .then(client => client.apis.asset.getAssetList(apiParams))
19
20
  },
21
+ getAssetById: (id) => {
22
+ return this.__privates.auth.__client
23
+ .then(client => client.apis.user.getAssetById({id}))
24
+ },
20
25
  updateAsset: ({id, assetType, title, roomIds} = {}) => {
21
26
  return this.__privates.auth.__client
22
27
  .then(client => client.apis.asset.updateAsset({id}, {requestBody:{assetType, title, roomIds}}))
@@ -25,10 +30,9 @@ let asset = function() {
25
30
  return this.__privates.auth.__client
26
31
  .then(client => client.apis.asset.deleteAsset({id}))
27
32
  },
28
- uploadAsset: (file, roomIds) => {
29
- let id = generateUUID();
33
+ uploadAsset: (file, roomIds, id = null) => {
30
34
  return this.__privates.auth.__client
31
- .then(client => Promise.all([client, client.apis.asset.initiateAssetUpload({id})]))
35
+ .then(client => Promise.all([client, client.apis.asset.initiateAssetUpload({id: id || generateUUID()})]))
32
36
  .then(([client, response]) => Promise.all([client, client.http({url: response.data.signedUrl, method: response.data.httpMethod, headers: {"Content-Type":file.type}, body:file}), response.data.id]))
33
37
  .then(([client, response, idn]) => Promise.all([client.apis.asset.publishAsset({id:idn}, {requestBody: {title: file.name, ...(roomIds ? {roomIds} : {})}}), idn]))
34
38
  ;