@amityco/ts-sdk 6.24.2-909a018.0 → 6.25.0
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/.env +26 -26
- package/dist/@types/core/events.d.ts +2 -0
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -2
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +2 -1
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/domains/stream.d.ts +19 -3
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/index.cjs.js +220 -148
- package/dist/index.esm.js +220 -148
- package/dist/index.umd.js +2 -2
- package/dist/reactionRepository/events/onReactorAdded.d.ts.map +1 -1
- package/dist/reactionRepository/events/onReactorRemoved.d.ts.map +1 -1
- package/dist/streamRepository/api/createStream.d.ts +4 -4
- package/dist/streamRepository/api/createStream.d.ts.map +1 -1
- package/dist/streamRepository/api/deleteStream.d.ts +4 -4
- package/dist/streamRepository/api/deleteStream.d.ts.map +1 -1
- package/dist/streamRepository/api/disposeStream.d.ts +4 -4
- package/dist/streamRepository/api/disposeStream.d.ts.map +1 -1
- package/dist/streamRepository/api/queryStreams.d.ts +4 -4
- package/dist/streamRepository/api/queryStreams.d.ts.map +1 -1
- package/dist/streamRepository/api/updateStream.d.ts.map +1 -1
- package/dist/streamRepository/events/index.d.ts +2 -0
- package/dist/streamRepository/events/index.d.ts.map +1 -1
- package/dist/streamRepository/events/onStreamFlagged.d.ts +17 -0
- package/dist/streamRepository/events/onStreamFlagged.d.ts.map +1 -0
- package/dist/streamRepository/events/onStreamRecorded.d.ts +2 -2
- package/dist/streamRepository/events/onStreamRecorded.d.ts.map +1 -1
- package/dist/streamRepository/events/onStreamStarted.d.ts +2 -2
- package/dist/streamRepository/events/onStreamStarted.d.ts.map +1 -1
- package/dist/streamRepository/events/onStreamStopped.d.ts +2 -2
- package/dist/streamRepository/events/onStreamStopped.d.ts.map +1 -1
- package/dist/streamRepository/events/onStreamTerminated.d.ts +17 -0
- package/dist/streamRepository/events/onStreamTerminated.d.ts.map +1 -0
- package/dist/streamRepository/internalApi/queryStreams.d.ts +3 -3
- package/dist/streamRepository/internalApi/queryStreams.d.ts.map +1 -1
- package/dist/streamRepository/observers/getStreamById.d.ts +1 -0
- package/dist/streamRepository/observers/getStreamById.d.ts.map +1 -1
- package/dist/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.d.ts +14 -0
- package/dist/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.d.ts.map +1 -0
- package/dist/streamRepository/observers/getStreams/GetStreamsPageController.d.ts +14 -0
- package/dist/streamRepository/observers/getStreams/GetStreamsPageController.d.ts.map +1 -0
- package/dist/streamRepository/observers/getStreams/GetStreamsQueryStreamController.d.ts +15 -0
- package/dist/streamRepository/observers/getStreams/GetStreamsQueryStreamController.d.ts.map +1 -0
- package/dist/streamRepository/observers/getStreams/getStreams.d.ts +2 -0
- package/dist/streamRepository/observers/getStreams/getStreams.d.ts.map +1 -0
- package/dist/streamRepository/observers/getStreams/index.d.ts +2 -0
- package/dist/streamRepository/observers/getStreams/index.d.ts.map +1 -0
- package/dist/utils/linkedObject/index.d.ts +1 -0
- package/dist/utils/linkedObject/index.d.ts.map +1 -1
- package/dist/utils/linkedObject/streamLinkedObject.d.ts +2 -0
- package/dist/utils/linkedObject/streamLinkedObject.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/@types/core/events.ts +4 -0
- package/src/@types/core/model.ts +4 -2
- package/src/@types/core/payload.ts +2 -1
- package/src/@types/domains/stream.ts +23 -3
- package/src/core/model/idResolvers.ts +1 -0
- package/src/core/model/index.ts +1 -0
- package/src/reactionRepository/events/onReactorAdded.ts +6 -1
- package/src/reactionRepository/events/onReactorRemoved.ts +6 -1
- package/src/streamRepository/api/createStream.ts +8 -5
- package/src/streamRepository/api/deleteStream.ts +6 -4
- package/src/streamRepository/api/disposeStream.ts +5 -5
- package/src/streamRepository/api/queryStreams.ts +4 -4
- package/src/streamRepository/api/updateStream.ts +2 -1
- package/src/streamRepository/events/index.ts +2 -0
- package/src/streamRepository/events/onStreamFlagged.ts +37 -0
- package/src/streamRepository/events/onStreamRecorded.ts +4 -2
- package/src/streamRepository/events/onStreamStarted.ts +4 -2
- package/src/streamRepository/events/onStreamStopped.ts +4 -2
- package/src/streamRepository/events/onStreamTerminated.ts +37 -0
- package/src/streamRepository/internalApi/queryStreams.ts +3 -3
- package/src/streamRepository/observers/getStreamById.ts +18 -5
- package/src/streamRepository/observers/getStreams/GetStreamsLiveCollectionController.ts +114 -0
- package/src/streamRepository/observers/getStreams/GetStreamsPageController.ts +23 -0
- package/src/streamRepository/observers/getStreams/GetStreamsQueryStreamController.ts +83 -0
- package/src/streamRepository/observers/getStreams/getStreams.ts +32 -0
- package/src/streamRepository/observers/getStreams/index.ts +1 -0
- package/src/streamRepository/observers/tests/getStreamById.test.ts +1 -1
- package/src/utils/linkedObject/index.ts +2 -0
- package/src/utils/linkedObject/streamLinkedObject.ts +11 -0
- package/dist/streamRepository/api/getStreams.d.ts +0 -39
- package/dist/streamRepository/api/getStreams.d.ts.map +0 -1
- package/dist/streamRepository/observers/getStreams.d.ts +0 -17
- package/dist/streamRepository/observers/getStreams.d.ts.map +0 -1
- package/src/streamRepository/api/getStreams.ts +0 -81
- package/src/streamRepository/observers/getStreams.ts +0 -152
package/dist/index.cjs.js
CHANGED
|
@@ -97,8 +97,8 @@ const PostContentType = Object.freeze({
|
|
|
97
97
|
|
|
98
98
|
function getVersion() {
|
|
99
99
|
try {
|
|
100
|
-
// the string ''v6.
|
|
101
|
-
return 'v6.
|
|
100
|
+
// the string ''v6.25.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
101
|
+
return 'v6.25.0-cjs';
|
|
102
102
|
}
|
|
103
103
|
catch (error) {
|
|
104
104
|
return '__dev__';
|
|
@@ -526,6 +526,7 @@ const idResolvers = {
|
|
|
526
526
|
reaction: ({ referenceType, referenceId }) => `${referenceType}#${referenceId}`,
|
|
527
527
|
reactor: ({ reactionId }) => reactionId,
|
|
528
528
|
stream: ({ streamId }) => streamId,
|
|
529
|
+
streamModeration: ({ streamId }) => streamId,
|
|
529
530
|
follow: ({ from, to }) => `${from}#${to}`,
|
|
530
531
|
followInfo: ({ userId }) => userId,
|
|
531
532
|
followCount: ({ userId }) => userId,
|
|
@@ -575,6 +576,7 @@ const PAYLOAD2MODEL = {
|
|
|
575
576
|
reactors: 'reactor',
|
|
576
577
|
reactions: 'reaction',
|
|
577
578
|
videoStreamings: 'stream',
|
|
579
|
+
videoStreamModerations: 'streamModeration',
|
|
578
580
|
follows: 'follow',
|
|
579
581
|
followCounts: 'followCount',
|
|
580
582
|
feeds: 'feed',
|
|
@@ -5241,6 +5243,13 @@ const storyLinkedObject = (story) => {
|
|
|
5241
5243
|
} });
|
|
5242
5244
|
};
|
|
5243
5245
|
|
|
5246
|
+
const streamLinkedObject = (stream) => {
|
|
5247
|
+
return Object.assign(Object.assign({}, stream), { get moderation() {
|
|
5248
|
+
var _a;
|
|
5249
|
+
return (_a = pullFromCache(['streamModeration', 'get', stream.streamId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
5250
|
+
} });
|
|
5251
|
+
};
|
|
5252
|
+
|
|
5244
5253
|
const categoryLinkedObject = (category) => {
|
|
5245
5254
|
return Object.assign(Object.assign({}, category), { get avatar() {
|
|
5246
5255
|
var _a;
|
|
@@ -5709,6 +5718,7 @@ const LinkedObject = {
|
|
|
5709
5718
|
post: postLinkedObject,
|
|
5710
5719
|
user: userLinkedObject,
|
|
5711
5720
|
category: categoryLinkedObject,
|
|
5721
|
+
stream: streamLinkedObject,
|
|
5712
5722
|
story: storyLinkedObject,
|
|
5713
5723
|
storyTarget: storyTargetLinkedObject,
|
|
5714
5724
|
message: messageLinkedObject,
|
|
@@ -13279,7 +13289,7 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
|
|
|
13279
13289
|
ingestInCache(payload);
|
|
13280
13290
|
callbackWrapper('message', payload.messages[0].messageId, payload.reactions[0]);
|
|
13281
13291
|
};
|
|
13282
|
-
return createEventSubscriber(client, 'reaction/onReactorAdded', 'message.
|
|
13292
|
+
return createEventSubscriber(client, 'reaction/onReactorAdded', 'message.reactionAdded', filter);
|
|
13283
13293
|
}
|
|
13284
13294
|
if (referenceType === 'post') {
|
|
13285
13295
|
const filter = (payload) => {
|
|
@@ -13342,7 +13352,7 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
|
|
|
13342
13352
|
ingestInCache(payload);
|
|
13343
13353
|
callbackWrapper('message', payload.messages[0].messageId, payload.reactions[0]);
|
|
13344
13354
|
};
|
|
13345
|
-
return createEventSubscriber(client, 'reaction/onReactorRemoved', 'message.
|
|
13355
|
+
return createEventSubscriber(client, 'reaction/onReactorRemoved', 'message.reactionRemoved', filter);
|
|
13346
13356
|
}
|
|
13347
13357
|
if (referenceType === 'post') {
|
|
13348
13358
|
const filter = (payload) => {
|
|
@@ -22013,10 +22023,10 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
22013
22023
|
* const created = await createStream({ title: 'my stream', 'thumbnailFileId': fileId })
|
|
22014
22024
|
* ```
|
|
22015
22025
|
*
|
|
22016
|
-
* Creates an {@link Amity.
|
|
22026
|
+
* Creates an {@link Amity.InternalStream}
|
|
22017
22027
|
*
|
|
22018
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
22019
|
-
* @returns The newly created {@link Amity.
|
|
22028
|
+
* @param bundle The data necessary to create a new {@link Amity.InternalStream}
|
|
22029
|
+
* @returns The newly created {@link Amity.InternalStream}
|
|
22020
22030
|
*
|
|
22021
22031
|
* @category Stream API
|
|
22022
22032
|
* @async
|
|
@@ -22030,7 +22040,7 @@ const createStream = async (bundle) => {
|
|
|
22030
22040
|
ingestInCache(data, { cachedAt });
|
|
22031
22041
|
const { videoStreamings } = data;
|
|
22032
22042
|
return {
|
|
22033
|
-
data: videoStreamings[0],
|
|
22043
|
+
data: LinkedObject.stream(videoStreamings[0]),
|
|
22034
22044
|
cachedAt,
|
|
22035
22045
|
};
|
|
22036
22046
|
};
|
|
@@ -22063,7 +22073,7 @@ const updateStream = async (streamId, patch) => {
|
|
|
22063
22073
|
ingestInCache(data, { cachedAt });
|
|
22064
22074
|
const { videoStreamings } = data;
|
|
22065
22075
|
return {
|
|
22066
|
-
data: videoStreamings.find(stream => stream.streamId === streamId),
|
|
22076
|
+
data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)),
|
|
22067
22077
|
cachedAt,
|
|
22068
22078
|
};
|
|
22069
22079
|
};
|
|
@@ -22137,10 +22147,10 @@ getStream.locally = (streamId) => {
|
|
|
22137
22147
|
* const success = await deleteStream(streamId)
|
|
22138
22148
|
* ```
|
|
22139
22149
|
*
|
|
22140
|
-
* Deletes a {@link Amity.
|
|
22150
|
+
* Deletes a {@link Amity.InternalStream}
|
|
22141
22151
|
*
|
|
22142
|
-
* @param streamId The {@link Amity.
|
|
22143
|
-
* @return A success boolean if the {@link Amity.
|
|
22152
|
+
* @param streamId The {@link Amity.InternalStream} ID to delete
|
|
22153
|
+
* @return A success boolean if the {@link Amity.InternalStream} was deleted
|
|
22144
22154
|
*
|
|
22145
22155
|
* @category Stream API
|
|
22146
22156
|
* @async
|
|
@@ -22165,11 +22175,11 @@ const deleteStream = async (streamId) => {
|
|
|
22165
22175
|
* const stream = await disposeStream(streamId)
|
|
22166
22176
|
* ```
|
|
22167
22177
|
*
|
|
22168
|
-
* Dispose a {@link Amity.
|
|
22178
|
+
* Dispose a {@link Amity.InternalStream}.
|
|
22169
22179
|
* Streaming status will be updated to "ended" and streaming url will be invalidated
|
|
22170
22180
|
*
|
|
22171
|
-
* @param streamId The {@link Amity.
|
|
22172
|
-
* @returns the associated {@link Amity.
|
|
22181
|
+
* @param streamId The {@link Amity.InternalStream} ID to dispose
|
|
22182
|
+
* @returns the associated {@link Amity.InternalStream} object
|
|
22173
22183
|
*
|
|
22174
22184
|
* @category Stream API
|
|
22175
22185
|
* @async
|
|
@@ -22200,15 +22210,15 @@ const disposeStream = async (streamId) => {
|
|
|
22200
22210
|
* const streams = await getStreams()
|
|
22201
22211
|
* ```
|
|
22202
22212
|
*
|
|
22203
|
-
* Queries a paginable list of {@link Amity.
|
|
22213
|
+
* Queries a paginable list of {@link Amity.InternalStream} objects
|
|
22204
22214
|
*
|
|
22205
22215
|
* @param query The query parameters
|
|
22206
|
-
* @returns A page of {@link Amity.
|
|
22216
|
+
* @returns A page of {@link Amity.InternalStream} objects
|
|
22207
22217
|
*
|
|
22208
22218
|
* @category Stream API
|
|
22209
22219
|
* @async
|
|
22210
22220
|
*/
|
|
22211
|
-
const queryStreams
|
|
22221
|
+
const queryStreams = async (query) => {
|
|
22212
22222
|
const client = getActiveClient();
|
|
22213
22223
|
client.log('stream/queryStreams', query);
|
|
22214
22224
|
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
@@ -22238,7 +22248,7 @@ const queryStreams$1 = async (query) => {
|
|
|
22238
22248
|
* })
|
|
22239
22249
|
* ```
|
|
22240
22250
|
*
|
|
22241
|
-
* Fired when a {@link Amity.
|
|
22251
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
22242
22252
|
*
|
|
22243
22253
|
* @param callback The function to call when the event was fired
|
|
22244
22254
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -22262,7 +22272,7 @@ const onStreamStarted = (callback) => {
|
|
|
22262
22272
|
* })
|
|
22263
22273
|
* ```
|
|
22264
22274
|
*
|
|
22265
|
-
* Fired when a {@link Amity.
|
|
22275
|
+
* Fired when a {@link Amity.InternalStream} has stopped airing
|
|
22266
22276
|
*
|
|
22267
22277
|
* @param callback The function to call when the event was fired
|
|
22268
22278
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -22286,7 +22296,7 @@ const onStreamStopped = (callback) => {
|
|
|
22286
22296
|
* })
|
|
22287
22297
|
* ```
|
|
22288
22298
|
*
|
|
22289
|
-
* Fired when the recordings of a {@link Amity.
|
|
22299
|
+
* Fired when the recordings of a {@link Amity.InternalStream} are available
|
|
22290
22300
|
*
|
|
22291
22301
|
* @param callback The function to call when the event was fired
|
|
22292
22302
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -22302,6 +22312,54 @@ const onStreamRecorded = (callback) => {
|
|
|
22302
22312
|
return createEventSubscriber(client, 'stream/onStreamRecorded', 'v3.video-streaming.didRecord', filter);
|
|
22303
22313
|
};
|
|
22304
22314
|
|
|
22315
|
+
/**
|
|
22316
|
+
* ```js
|
|
22317
|
+
* import { onStreamFlagged } from '@amityco/ts-sdk'
|
|
22318
|
+
* const dispose = onStreamFlagged(stream => {
|
|
22319
|
+
* // ...
|
|
22320
|
+
* })
|
|
22321
|
+
* ```
|
|
22322
|
+
*
|
|
22323
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
22324
|
+
*
|
|
22325
|
+
* @param callback The function to call when the event was fired
|
|
22326
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22327
|
+
*
|
|
22328
|
+
* @category Stream Events
|
|
22329
|
+
*/
|
|
22330
|
+
const onStreamFlagged = (callback) => {
|
|
22331
|
+
const client = getActiveClient();
|
|
22332
|
+
const filter = (payload) => {
|
|
22333
|
+
ingestInCache(payload);
|
|
22334
|
+
callback(payload.videoStreamings[0]);
|
|
22335
|
+
};
|
|
22336
|
+
return createEventSubscriber(client, 'stream/onStreamFlagged', 'v3.video-streaming.didFlag', filter);
|
|
22337
|
+
};
|
|
22338
|
+
|
|
22339
|
+
/**
|
|
22340
|
+
* ```js
|
|
22341
|
+
* import { onStreamTerminated } from '@amityco/ts-sdk'
|
|
22342
|
+
* const dispose = onStreamTerminated(stream => {
|
|
22343
|
+
* // ...
|
|
22344
|
+
* })
|
|
22345
|
+
* ```
|
|
22346
|
+
*
|
|
22347
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
22348
|
+
*
|
|
22349
|
+
* @param callback The function to call when the event was fired
|
|
22350
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22351
|
+
*
|
|
22352
|
+
* @category Stream Events
|
|
22353
|
+
*/
|
|
22354
|
+
const onStreamTerminated = (callback) => {
|
|
22355
|
+
const client = getActiveClient();
|
|
22356
|
+
const filter = (payload) => {
|
|
22357
|
+
ingestInCache(payload);
|
|
22358
|
+
callback(payload.videoStreamings[0]);
|
|
22359
|
+
};
|
|
22360
|
+
return createEventSubscriber(client, 'stream/onStreamTerminated', 'v3.video-streaming.didTerminate', filter);
|
|
22361
|
+
};
|
|
22362
|
+
|
|
22305
22363
|
/* eslint-disable no-use-before-define */
|
|
22306
22364
|
/* begin_public_function
|
|
22307
22365
|
id: stream.get
|
|
@@ -22316,15 +22374,22 @@ const onStreamRecorded = (callback) => {
|
|
|
22316
22374
|
* Fetches a {@link Amity.Stream} object
|
|
22317
22375
|
*
|
|
22318
22376
|
* @param streamId the ID of the {@link Amity.Stream} to get
|
|
22377
|
+
* @param callback
|
|
22319
22378
|
* @returns the associated {@link Amity.Stream} object
|
|
22320
22379
|
*
|
|
22321
22380
|
* @category Stream Live Object
|
|
22322
22381
|
*/
|
|
22323
22382
|
const getStreamById = (streamId, callback) => {
|
|
22324
|
-
|
|
22383
|
+
const reactor = (snapshot) => {
|
|
22384
|
+
const { data } = snapshot;
|
|
22385
|
+
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.stream(snapshot.data) : data }));
|
|
22386
|
+
};
|
|
22387
|
+
return liveObject(streamId, reactor, 'streamId', getStream, [
|
|
22325
22388
|
onStreamRecorded,
|
|
22326
22389
|
onStreamStarted,
|
|
22327
22390
|
onStreamStopped,
|
|
22391
|
+
onStreamFlagged,
|
|
22392
|
+
onStreamTerminated,
|
|
22328
22393
|
]);
|
|
22329
22394
|
};
|
|
22330
22395
|
/* end_public_function */
|
|
@@ -22350,145 +22415,150 @@ getStreamById.locally = (streamId) => {
|
|
|
22350
22415
|
if (!cached)
|
|
22351
22416
|
return;
|
|
22352
22417
|
return {
|
|
22353
|
-
data: cached.data,
|
|
22418
|
+
data: LinkedObject.stream(cached.data),
|
|
22354
22419
|
cachedAt: cached.cachedAt,
|
|
22355
22420
|
};
|
|
22356
22421
|
};
|
|
22357
22422
|
|
|
22358
|
-
|
|
22359
|
-
|
|
22360
|
-
|
|
22361
|
-
|
|
22362
|
-
|
|
22363
|
-
|
|
22364
|
-
|
|
22365
|
-
|
|
22366
|
-
|
|
22367
|
-
|
|
22368
|
-
*
|
|
22369
|
-
* @param query The query parameters
|
|
22370
|
-
* @returns A page of {@link Amity.Stream} objects
|
|
22371
|
-
*
|
|
22372
|
-
* @category Stream API
|
|
22373
|
-
* @async
|
|
22374
|
-
*/
|
|
22375
|
-
const queryStreams = async (query) => {
|
|
22376
|
-
const client = getActiveClient();
|
|
22377
|
-
client.log('stream/queryStreams', query);
|
|
22378
|
-
const _a = query !== null && query !== void 0 ? query : {}, { page, limit } = _a, params = __rest(_a, ["page", "limit"]);
|
|
22379
|
-
const options = (() => {
|
|
22380
|
-
if (page)
|
|
22381
|
-
return { token: page };
|
|
22382
|
-
if (limit)
|
|
22383
|
-
return { limit };
|
|
22384
|
-
return undefined;
|
|
22385
|
-
})();
|
|
22386
|
-
const { data } = await client.http.get(`/api/v3/video-streaming`, {
|
|
22387
|
-
params: Object.assign(Object.assign({}, params), { options }),
|
|
22388
|
-
});
|
|
22389
|
-
// API-FIX: backend to response Amity.Response: const { paging, videoStreamings } = unwrapPayload(data)
|
|
22390
|
-
// API-FIX: seems returned data has a results identifier on top of data, like no other apis, and this is beautiful
|
|
22391
|
-
const { paging, results: payload } = data;
|
|
22392
|
-
const { videoStreamings } = payload;
|
|
22393
|
-
const cachedAt = client.cache && Date.now();
|
|
22394
|
-
if (client.cache)
|
|
22395
|
-
ingestInCache(payload, { cachedAt });
|
|
22396
|
-
return { data: videoStreamings, cachedAt, paging };
|
|
22397
|
-
};
|
|
22398
|
-
/* end_public_function */
|
|
22423
|
+
class GetStreamsPageController extends PaginationController {
|
|
22424
|
+
async getRequest(queryParams, token) {
|
|
22425
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
22426
|
+
const options = token ? { token } : { limit };
|
|
22427
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/video-streaming`, {
|
|
22428
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
22429
|
+
});
|
|
22430
|
+
return Object.assign(Object.assign({}, queryResponse.results), { paging: queryResponse.paging });
|
|
22431
|
+
}
|
|
22432
|
+
}
|
|
22399
22433
|
|
|
22400
|
-
|
|
22401
|
-
|
|
22402
|
-
|
|
22403
|
-
|
|
22404
|
-
|
|
22405
|
-
* import { StreamRepository } from '@amityco/ts-sdk'
|
|
22406
|
-
* const streams = await StreamRepository.getStreams()
|
|
22407
|
-
* ```
|
|
22408
|
-
*
|
|
22409
|
-
* Observe all mutations on a list of {@link Amity.Stream}s
|
|
22410
|
-
*
|
|
22411
|
-
* @param params for querying streams
|
|
22412
|
-
* @param callback the function to call when new data are available
|
|
22413
|
-
* @param config
|
|
22414
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the streams
|
|
22415
|
-
*
|
|
22416
|
-
* @category Stream Live Collection
|
|
22417
|
-
*/
|
|
22418
|
-
const getStreams = (params, callback, config) => {
|
|
22419
|
-
const { log, cache } = getActiveClient();
|
|
22420
|
-
if (!cache) {
|
|
22421
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
22434
|
+
class GetStreamsQueryStreamController extends QueryStreamController {
|
|
22435
|
+
constructor(query, cacheKey, notifyChange, paginationController) {
|
|
22436
|
+
super(query, cacheKey);
|
|
22437
|
+
this.notifyChange = notifyChange;
|
|
22438
|
+
this.paginationController = paginationController;
|
|
22422
22439
|
}
|
|
22423
|
-
|
|
22424
|
-
|
|
22425
|
-
|
|
22426
|
-
|
|
22427
|
-
|
|
22428
|
-
|
|
22429
|
-
|
|
22430
|
-
|
|
22431
|
-
|
|
22432
|
-
streams = streams.sort(params.sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
22433
|
-
return streams;
|
|
22434
|
-
};
|
|
22435
|
-
const responder = (data, isEventModel = false) => {
|
|
22440
|
+
// eslint-disable-next-line class-methods-use-this
|
|
22441
|
+
saveToMainDB(response) {
|
|
22442
|
+
const client = getActiveClient();
|
|
22443
|
+
const cachedAt = client.cache && Date.now();
|
|
22444
|
+
if (client.cache) {
|
|
22445
|
+
ingestInCache(response, { cachedAt });
|
|
22446
|
+
}
|
|
22447
|
+
}
|
|
22448
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
22436
22449
|
var _a, _b;
|
|
22437
|
-
|
|
22438
|
-
.
|
|
22439
|
-
|
|
22440
|
-
|
|
22441
|
-
|
|
22442
|
-
|
|
22443
|
-
|
|
22444
|
-
|
|
22445
|
-
|
|
22446
|
-
|
|
22447
|
-
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
|
|
22451
|
-
|
|
22452
|
-
|
|
22453
|
-
|
|
22454
|
-
|
|
22450
|
+
if (refresh) {
|
|
22451
|
+
pushToCache(this.cacheKey, {
|
|
22452
|
+
data: response.videoStreamings.map(getResolver('stream')),
|
|
22453
|
+
query: this.query,
|
|
22454
|
+
});
|
|
22455
|
+
}
|
|
22456
|
+
else {
|
|
22457
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22458
|
+
const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
22459
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === 'next'
|
|
22460
|
+
? [...new Set([...messages, ...response.videoStreamings.map(getResolver('stream'))])]
|
|
22461
|
+
: [...new Set([...response.videoStreamings.map(getResolver('stream')), ...messages])] }));
|
|
22462
|
+
}
|
|
22463
|
+
}
|
|
22464
|
+
reactor(action) {
|
|
22465
|
+
return (payload) => {
|
|
22466
|
+
var _a;
|
|
22467
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22468
|
+
if (!collection)
|
|
22469
|
+
return;
|
|
22470
|
+
collection.data = [...new Set([payload.streamId, ...collection.data])];
|
|
22471
|
+
pushToCache(this.cacheKey, collection);
|
|
22472
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
22473
|
+
};
|
|
22474
|
+
}
|
|
22475
|
+
subscribeRTE(createSubscriber) {
|
|
22476
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
22477
|
+
}
|
|
22478
|
+
}
|
|
22479
|
+
|
|
22480
|
+
class GetStreamsLiveCollectionController extends LiveCollectionController {
|
|
22481
|
+
constructor(query, callback) {
|
|
22482
|
+
const queryStreamId = hash__default["default"](query);
|
|
22483
|
+
const cacheKey = ['streams', 'collection', queryStreamId];
|
|
22484
|
+
const paginationController = new GetStreamsPageController(query);
|
|
22485
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
22486
|
+
this.applyFilter = (data) => {
|
|
22487
|
+
let streams = filterByPropEquality(data, 'isDeleted', this.query.isDeleted);
|
|
22488
|
+
streams = streams.sort(this.query.sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
22489
|
+
return streams;
|
|
22490
|
+
};
|
|
22491
|
+
this.query = query;
|
|
22492
|
+
this.queryStreamController = new GetStreamsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), paginationController);
|
|
22493
|
+
this.paginationController = paginationController;
|
|
22494
|
+
this.callback = callback.bind(this);
|
|
22495
|
+
this.loadPage({ initial: true });
|
|
22496
|
+
}
|
|
22497
|
+
notifyChange({ origin, loading, error }) {
|
|
22455
22498
|
var _a;
|
|
22456
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22499
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22457
22500
|
if (!collection)
|
|
22458
22501
|
return;
|
|
22459
|
-
|
|
22460
|
-
|
|
22461
|
-
|
|
22462
|
-
|
|
22463
|
-
|
|
22464
|
-
var _a, _b;
|
|
22465
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22466
|
-
const streams = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
22467
|
-
if (!initial && streams.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
22502
|
+
let data = collection.data
|
|
22503
|
+
.map(streamId => pullFromCache(['stream', 'get', streamId]))
|
|
22504
|
+
.filter(Boolean)
|
|
22505
|
+
.map(stream => LinkedObject.stream(stream.data));
|
|
22506
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
22468
22507
|
return;
|
|
22469
|
-
|
|
22470
|
-
|
|
22471
|
-
|
|
22472
|
-
|
|
22473
|
-
|
|
22474
|
-
|
|
22475
|
-
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22481
|
-
|
|
22482
|
-
|
|
22483
|
-
|
|
22484
|
-
|
|
22485
|
-
|
|
22508
|
+
data = this.applyFilter(data);
|
|
22509
|
+
this.callback({
|
|
22510
|
+
onNextPage: () => this.loadPage({ initial: false, direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
22511
|
+
data,
|
|
22512
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
22513
|
+
loading,
|
|
22514
|
+
error,
|
|
22515
|
+
});
|
|
22516
|
+
}
|
|
22517
|
+
startSubscription() {
|
|
22518
|
+
return this.queryStreamController.subscribeRTE([
|
|
22519
|
+
{ fn: onStreamRecorded, action: 'onStreamRecorded' },
|
|
22520
|
+
{ fn: onStreamStarted, action: 'onStreamStarted' },
|
|
22521
|
+
{ fn: onStreamStopped, action: 'onStreamStopped' },
|
|
22522
|
+
{ fn: onStreamFlagged, action: 'onStreamFlagged' },
|
|
22523
|
+
{ fn: onStreamTerminated, action: 'onStreamTerminated' },
|
|
22524
|
+
]);
|
|
22525
|
+
}
|
|
22526
|
+
setup() {
|
|
22527
|
+
var _a;
|
|
22528
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22529
|
+
if (!collection) {
|
|
22530
|
+
pushToCache(this.cacheKey, {
|
|
22531
|
+
data: [],
|
|
22532
|
+
params: {},
|
|
22533
|
+
});
|
|
22534
|
+
}
|
|
22535
|
+
}
|
|
22536
|
+
persistModel(response) {
|
|
22537
|
+
this.queryStreamController.saveToMainDB(response);
|
|
22538
|
+
}
|
|
22539
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
22540
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
22541
|
+
}
|
|
22542
|
+
}
|
|
22543
|
+
|
|
22544
|
+
const getStreams = (params, callback, config) => {
|
|
22545
|
+
const { log, cache, userId } = getActiveClient();
|
|
22546
|
+
if (!cache) {
|
|
22547
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
22548
|
+
}
|
|
22549
|
+
const timestamp = Date.now();
|
|
22550
|
+
log(`getStreams(tmpid: ${timestamp}) > listen`);
|
|
22551
|
+
const liveCollection = new GetStreamsLiveCollectionController(params, callback);
|
|
22552
|
+
const disposers = liveCollection.startSubscription();
|
|
22553
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
22554
|
+
disposers.push(() => {
|
|
22555
|
+
dropFromCache(cacheKey);
|
|
22556
|
+
});
|
|
22486
22557
|
return () => {
|
|
22487
22558
|
log(`getStreams(tmpid: ${timestamp}) > dispose`);
|
|
22488
22559
|
disposers.forEach(fn => fn());
|
|
22489
22560
|
};
|
|
22490
|
-
};
|
|
22491
|
-
/* end_public_function */
|
|
22561
|
+
};
|
|
22492
22562
|
|
|
22493
22563
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
22494
22564
|
__proto__: null,
|
|
@@ -22496,11 +22566,13 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
22496
22566
|
updateStream: updateStream,
|
|
22497
22567
|
deleteStream: deleteStream,
|
|
22498
22568
|
disposeStream: disposeStream,
|
|
22499
|
-
queryStreams: queryStreams
|
|
22569
|
+
queryStreams: queryStreams,
|
|
22500
22570
|
getStream: getStream,
|
|
22501
22571
|
onStreamStarted: onStreamStarted,
|
|
22502
22572
|
onStreamStopped: onStreamStopped,
|
|
22503
22573
|
onStreamRecorded: onStreamRecorded,
|
|
22574
|
+
onStreamFlagged: onStreamFlagged,
|
|
22575
|
+
onStreamTerminated: onStreamTerminated,
|
|
22504
22576
|
getStreamById: getStreamById,
|
|
22505
22577
|
getStreams: getStreams
|
|
22506
22578
|
});
|
|
@@ -22833,7 +22905,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
22833
22905
|
getPoll: getPoll
|
|
22834
22906
|
});
|
|
22835
22907
|
|
|
22836
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
22908
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4ysp5ourY6Vj+DLwpdRiI9YDjqYAQDIUmhNxJP7XPhOMoZI6st+xZQBM34ic/bv\nAMSJm9OZphSp3+qXVkFZztr2mxD2EZSJJLYxi8BCdgM2qhazalbcJ6zDKHCZWVWm\n8RRxDGldyMb/237JxETzP40tAlzOZDmBAbUgEnurDJ93RVDIE3rbZUshwgeQd18a\nem096mWgvB1AIKYgsTAR3pw+V19YWAjq/glP6fz8wQKBgQD/oQq+ukKF0PRgBeM5\ngeTjSwsdGppQLmf5ndujvoiz/TpdjDEPu6R8kigQr1rG2t4K/yfdZoI8RdmJD1al\n3Q7N9hofooSy4rj6E3txzWZCHJjHad2cnCp/O26HiReGAl7wTcfTmNdiFHhZQzm5\nJBkvWAiwuvQMNfEbnXxw6/vIDwKBgQDH7fX8gsc77JLvAWgp1MaQN/sbqVb6JeT1\nFQfR8E/WFCSmzQBtNzd5KgYuCeelwr/8DyYytvN2BzCYZXp73gI1jF3YlW5jVn74\nOY6TwQ095digwo6Z0yuxopdIOApKgAkL9PRKgNrqAf3NAyMua6lOGifzjDojC3KU\nfylQmxMn4wKBgHp2B9O/H0dEBw5JQ8W0+JX6yWQz7mEjGiR2/1W+XXb8hQ1zr709\nw1r6Gb+EghRpnZ3fBpYGGbYOMFx8wKHM+N6qW3F0ReX8v2juFGE8aRSa5oYBrWzt\nU16Idjbv8hj84cZ1PJmdyvDtpYn9rpWHOZl4rxEbPvbqkIsOMyNVqdT5AoGAOSge\nmwIIU2le2FVeohbibXiToWTYKMuMmURZ5/r72AgKMmWJKbAPe+Q3wBG01/7FRBpQ\noU8Ma0HC8s6QJbliiEyIx9JwrJWd1vkdecBHONrtA4ibm/5zD2WcOllLF+FitLhi\n3qnX6+6F0IaFGFBPJrTzlv0P4dTz/OAdv52V7GECgYEA2TttOKBAqWllgOaZOkql\nLVMJVmgR7s6tLi1+cEP8ZcapV9aRbRzTAKXm4f8AEhtlG9F9kCOvHYCYGi6JaiWJ\nZkHjeex3T+eE6Di6y5Bm/Ift5jtVhJ4jCVwHOKTMej79NPUFTJfv8hCo29haBDv6\nRXFrv+T21KCcw8k3sJeJWWQ=\n-----END PRIVATE KEY-----";
|
|
22837
22909
|
/*
|
|
22838
22910
|
* The crypto algorithm used for importing key and signing string
|
|
22839
22911
|
*/
|