@reactoo/watchtogether-sdk-js 2.8.0 → 2.8.1-5.beta.1

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.
@@ -580,6 +580,9 @@
580
580
  Instance.room.getSessionByConstructId(constructId).restart()
581
581
  }
582
582
 
583
+ window.testData = function() {
584
+ Instance.room.getSessionByConstructId(constructId).sendMessageViaDataChannel(null, {cicina:true})
585
+ }
583
586
 
584
587
  </script>
585
588
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reactoo/watchtogether-sdk-js",
3
- "version": "2.8.0",
3
+ "version": "2.8.15.beta.1",
4
4
  "description": "Javascript SDK for Reactoo",
5
5
  "main": "dist/watchtogether-sdk.min.js",
6
6
  "module": "dist/watchtogether-sdk.min.js",
package/src/index.js CHANGED
@@ -10,6 +10,7 @@ import user from './models/user';
10
10
  import asset from "./models/asset";
11
11
  import system from "./models/system"
12
12
  import iot from './models/iot'
13
+ import liveBarn from './models/live-barn';
13
14
  import * as utils from './models/utils';
14
15
 
15
16
  function WatchTogether(modules = {}, instanceType, debug, playerFactory, providerAuth) {
@@ -38,6 +39,7 @@ function WatchTogether(modules = {}, instanceType, debug, playerFactory, provide
38
39
  this.asset = {...asset.call(this)};
39
40
  this.system = {...system.call(this)}
40
41
  this.iot = {...iot.call(this)};
42
+ this.liveBarn = {...liveBarn.call(this)};
41
43
  this.utils = utils;
42
44
  }
43
45
 
@@ -110,7 +110,23 @@ let asset = function() {
110
110
  createStreamAsset: (id, title, streamType, regionalPreference, ingestType, source, profile) => {
111
111
  return this.__privates.auth.__client
112
112
  .then(client => client.apis.asset.publishAsset({id}, {requestBody: {assetType: 'stream', title, stream: {streamType, regionalPreference, ingestType, source, profile}}}));
113
- }
113
+ },
114
+
115
+ createHighlightAsset: (id, title, roomIds, highlight = {}) => {
116
+ return this.__privates.auth.__client
117
+ .then(client => client.apis.asset.publishAsset({id}, {requestBody: {assetType: 'highlight',...(roomIds ? {roomIds} : {}), title, customAttributes: {highlight}}}));
118
+ },
119
+
120
+ createHighlightAssetWithThumbnail: (file, id, title, roomIds, highlight = {}, initiationData = null) => {
121
+
122
+ console.log(id, id || generateUUID(), title, roomIds, highlight, initiationData);
123
+
124
+ return this.__privates.auth.__client
125
+ .then(client => Promise.all([client, initiationData ? Promise.resolve(initiationData) : client.apis.asset.initiateAssetUpload({id: id || generateUUID()})]))
126
+ .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]))
127
+ .then(([client, response, idn]) => Promise.all([client.apis.asset.publishAsset({id:idn}, {requestBody: {assetType: 'highlight', title: title, ...(roomIds ? {roomIds} : {}), customAttributes: {highlight}}}), idn]))
128
+ ;
129
+ },
114
130
  }
115
131
  };
116
132
 
@@ -90,6 +90,13 @@ let auth = function () {
90
90
  .then(client => client.apis.auth.confirmForgotPassword({},{requestBody:{password, confirmationCode, username}}))
91
91
  },
92
92
 
93
+ changePassword: (oldPassword, password) => {
94
+ const accessToken = localStorage.getItem(this.__privates.auth.ACCESS_TOKEN);
95
+
96
+ return this.__privates.auth.__client
97
+ .then(client => client.apis.auth.changePassword({},{requestBody:{oldPassword, password, accessToken}}))
98
+ },
99
+
93
100
  socialAuth: (data = {}) => {
94
101
  return this.__privates.auth.__client
95
102
  .then(client => client.apis.auth.socialAuth(data))
@@ -0,0 +1,85 @@
1
+ 'use strict';
2
+
3
+ import {chunkArray} from "./utils";
4
+
5
+ let liveBarn = function() {
6
+ return {
7
+ getLiveBarnSurfaceList: ({fulltextPhrase, comingSoon, online, countries, sports, surfaceStatus, feedModes, cities, provinces, venues, ids, size, startKey, sort} = {}) => {
8
+ return chunkArray(ids, 50)
9
+ .reduce((promiseChain, idsChunk) => {
10
+ return promiseChain.then(chainResponse => {
11
+ const apiParams = {
12
+ ...(fulltextPhrase && {fulltextPhrase}),
13
+ ...(comingSoon && {comingSoon}),
14
+ ...(online && {online}),
15
+ ...(countries?.length && {countries: countries.join(',')}),
16
+ ...(sports?.length && {sports: sports.join(',')}),
17
+ ...(surfaceStatus?.length && {surfaceStatus: surfaceStatus.join(',')}),
18
+ ...(feedModes?.length && {feedModes: feedModes.join(',')}),
19
+ ...(cities?.length && {cities: cities.join(',')}),
20
+ ...(provinces?.length && {provinces: provinces.join(',')}),
21
+ ...(venues?.length && {venues: venues.join(',')}),
22
+ ...(idsChunk?.length && {ids: idsChunk.join(',')}),
23
+ ...(size && !ids?.length && {size}),
24
+ ...(startKey && {startKey}),
25
+ ...(sort && {sort}),
26
+ };
27
+ return this.__privates.auth.__client
28
+ .then(client => client.apis.livebarn.getLiveBarnSurfaceList(apiParams))
29
+ .then(response => ids?.length ? ({
30
+ data: {
31
+ items: [...chainResponse.data.items, ...response.data.items],
32
+ size: chainResponse.data.size + response.data.size,
33
+ startKey: null,
34
+ },
35
+ }) : response);
36
+ });
37
+ }, Promise.resolve({data: {items: [], size: 0, startKey: null}}));
38
+ },
39
+ getLiveBarnSurfaceById: (id) => {
40
+ return this.__privates.auth.__client
41
+ .then(client => client.apis.livebarn.getLiveBarnSurfaceById({id}));
42
+ },
43
+ getLiveBarnVenueList: ({fulltextPhrase, comingSoon, online, countries, sports, surfaceStatus, feedModes, cities, provinces, venueStatus, postalCode, uuid, surfaces, ids, size, startKey, sort} = {}) => {
44
+ return chunkArray(ids, 30)
45
+ .reduce((promiseChain, idsChunk) => {
46
+ return promiseChain.then(chainResponse => {
47
+ const apiParams = {
48
+ ...(fulltextPhrase && {fulltextPhrase}),
49
+ ...(comingSoon && {comingSoon}),
50
+ ...(online && {online}),
51
+ ...(countries?.length && {countries: countries.join(',')}),
52
+ ...(sports?.length && {sports: sports.join(',')}),
53
+ ...(surfaceStatus?.length && {surfaceStatus: surfaceStatus.join(',')}),
54
+ ...(feedModes?.length && {feedModes: feedModes.join(',')}),
55
+ ...(cities?.length && {cities: cities.join(',')}),
56
+ ...(provinces?.length && {provinces: provinces.join(',')}),
57
+ ...(venueStatus?.length && {venueStatus: venueStatus.join(',')}),
58
+ ...(postalCode?.length && {postalCode: postalCode.join(',')}),
59
+ ...(uuid?.length && {uuid: uuid.join(',')}),
60
+ ...(surfaces?.length && {surfaces: surfaces.join(',')}),
61
+ ...(idsChunk?.length && {ids: idsChunk.join(',')}),
62
+ ...(size && !ids?.length && {size}),
63
+ ...(startKey && {startKey}),
64
+ ...(sort && {sort}),
65
+ };
66
+ return this.__privates.auth.__client
67
+ .then(client => client.apis.livebarn.getLiveBarnVenueList(apiParams))
68
+ .then(response => ids?.length ? ({
69
+ data: {
70
+ items: [...chainResponse.data.items, ...response.data.items],
71
+ size: chainResponse.data.size + response.data.size,
72
+ startKey: null,
73
+ },
74
+ }) : response);
75
+ });
76
+ }, Promise.resolve({data: {items: [], size: 0, startKey: null}}));
77
+ },
78
+ getLiveBarnVenueById: (id) => {
79
+ return this.__privates.auth.__client
80
+ .then(client => client.apis.livebarn.getLiveBarnVenueById({id}));
81
+ },
82
+ };
83
+ };
84
+
85
+ export default liveBarn;
@@ -57,6 +57,9 @@ let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
57
57
  room.on('data', (data) => {
58
58
  ___.__parseDataEvents(data);
59
59
  });
60
+ room.on('dataMessage', (data) => {
61
+ ___.__parseDataMessageEvents(data);
62
+ })
60
63
 
61
64
  return (___ = {
62
65
 
@@ -189,8 +192,12 @@ let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
189
192
 
190
193
  },
191
194
 
195
+ __parseDataMessageEvents: function(msg = {}) {
196
+ emitter.emit('dataMessage', msg);
197
+ },
192
198
 
193
199
  __parseDataEvents: function (msg = {}) {
200
+
194
201
  if (msg.videoroom === 'message') {
195
202
  if (msg.action === 'pending_shutdown' || msg.action === 'shutting_down') {
196
203
  emitter.emit('scaling');
@@ -422,6 +429,10 @@ let roomSession = function ({roomId, pinHash, role, options = {}}, room, wt) {
422
429
  });
423
430
  },
424
431
 
432
+ sendMessageViaDataChannel: (label, data) => {
433
+ room.sendMessageViaDataChannel(label, data);
434
+ },
435
+
425
436
  __requestMuteStatus: function () {
426
437
  this.sendSystemMessage('remote_muted_request');
427
438
  },
@@ -12,7 +12,7 @@ let user = function () {
12
12
 
13
13
  updateUser: (data = {}) => {
14
14
  return this.__privates.auth.__client
15
- .then(client => client.apis.user.updateUser({id: data.id, lastRoomId: data.lastRoomId}, {requestBody: {displayname: data.displayname, bio: data.bio}}));
15
+ .then(client => client.apis.user.updateUser({id: data.id, lastRoomId: data.lastRoomId}, {requestBody: {displayname: data.displayname, bio: data.bio, permissions: data.permissions}}));
16
16
  },
17
17
 
18
18
  uploadAvatar: (file, lastRoomId) => {
@@ -141,16 +141,28 @@ let user = function () {
141
141
  });
142
142
  }, Promise.resolve({data: {items: [], size: 0, startKey: null}}));
143
143
  },
144
- getUsers: ({type, userId, roomId, size = 20, startKey = null} = {}) => {
145
- let apiParams = {
146
- type,
147
- size,
148
- ...(roomId && {roomId}),
149
- ...(userId && {userId}),
150
- ...(startKey && {startKey})
151
- };
152
- return this.__privates.auth.__client
153
- .then(client => client.apis.user.getUsers(apiParams))
144
+ getUserList: ({type = 'instanceType', roomId, ids, size = 20, startKey = null}) => {
145
+ return chunkArray(ids, 50)
146
+ .reduce((promiseChain, idsChunk) => {
147
+ return promiseChain.then(chainResponse => {
148
+ let apiParams = {
149
+ type,
150
+ ...(roomId && {roomId}),
151
+ ...(idsChunk?.length && {ids: idsChunk.join(',')}),
152
+ ...(size && !ids && {size}),
153
+ ...(startKey && {startKey})
154
+ };
155
+ return this.__privates.auth.__client
156
+ .then(client => client.apis.user.getUsers(apiParams))
157
+ .then(response => type === 'ids' ? ({
158
+ data: {
159
+ items: [...chainResponse.data.items, ...response.data.items],
160
+ size: chainResponse.data.size + response.data.size,
161
+ startKey: null,
162
+ },
163
+ }) : response);
164
+ });
165
+ }, Promise.resolve({data: {items: [], size: 0, startKey: null}}));
154
166
  },
155
167
 
156
168
  //TODO:deprecated
File without changes