@amityco/ts-sdk 6.24.1 → 6.24.2-5a60993.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 +219 -146
- package/dist/index.esm.js +219 -146
- package/dist/index.umd.js +2 -2
- package/dist/reactionRepository/events/onReactionAdded.d.ts.map +1 -1
- 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/onReactionAdded.ts +0 -1
- package/src/reactionRepository/events/onReactorAdded.ts +7 -2
- 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
|
@@ -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,
|
|
@@ -13277,9 +13287,10 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
|
|
|
13277
13287
|
if (!payload.reactions[0])
|
|
13278
13288
|
return;
|
|
13279
13289
|
ingestInCache(payload);
|
|
13290
|
+
ingestInCache({ reactors: payload.reactions });
|
|
13280
13291
|
callbackWrapper('message', payload.messages[0].messageId, payload.reactions[0]);
|
|
13281
13292
|
};
|
|
13282
|
-
return createEventSubscriber(client, 'reaction/onReactorAdded', 'message.
|
|
13293
|
+
return createEventSubscriber(client, 'reaction/onReactorAdded', 'message.reactionAdded', filter);
|
|
13283
13294
|
}
|
|
13284
13295
|
if (referenceType === 'post') {
|
|
13285
13296
|
const filter = (payload) => {
|
|
@@ -13342,7 +13353,7 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
|
|
|
13342
13353
|
ingestInCache(payload);
|
|
13343
13354
|
callbackWrapper('message', payload.messages[0].messageId, payload.reactions[0]);
|
|
13344
13355
|
};
|
|
13345
|
-
return createEventSubscriber(client, 'reaction/onReactorRemoved', 'message.
|
|
13356
|
+
return createEventSubscriber(client, 'reaction/onReactorRemoved', 'message.reactionRemoved', filter);
|
|
13346
13357
|
}
|
|
13347
13358
|
if (referenceType === 'post') {
|
|
13348
13359
|
const filter = (payload) => {
|
|
@@ -22013,10 +22024,10 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
22013
22024
|
* const created = await createStream({ title: 'my stream', 'thumbnailFileId': fileId })
|
|
22014
22025
|
* ```
|
|
22015
22026
|
*
|
|
22016
|
-
* Creates an {@link Amity.
|
|
22027
|
+
* Creates an {@link Amity.InternalStream}
|
|
22017
22028
|
*
|
|
22018
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
22019
|
-
* @returns The newly created {@link Amity.
|
|
22029
|
+
* @param bundle The data necessary to create a new {@link Amity.InternalStream}
|
|
22030
|
+
* @returns The newly created {@link Amity.InternalStream}
|
|
22020
22031
|
*
|
|
22021
22032
|
* @category Stream API
|
|
22022
22033
|
* @async
|
|
@@ -22030,7 +22041,7 @@ const createStream = async (bundle) => {
|
|
|
22030
22041
|
ingestInCache(data, { cachedAt });
|
|
22031
22042
|
const { videoStreamings } = data;
|
|
22032
22043
|
return {
|
|
22033
|
-
data: videoStreamings[0],
|
|
22044
|
+
data: LinkedObject.stream(videoStreamings[0]),
|
|
22034
22045
|
cachedAt,
|
|
22035
22046
|
};
|
|
22036
22047
|
};
|
|
@@ -22063,7 +22074,7 @@ const updateStream = async (streamId, patch) => {
|
|
|
22063
22074
|
ingestInCache(data, { cachedAt });
|
|
22064
22075
|
const { videoStreamings } = data;
|
|
22065
22076
|
return {
|
|
22066
|
-
data: videoStreamings.find(stream => stream.streamId === streamId),
|
|
22077
|
+
data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)),
|
|
22067
22078
|
cachedAt,
|
|
22068
22079
|
};
|
|
22069
22080
|
};
|
|
@@ -22137,10 +22148,10 @@ getStream.locally = (streamId) => {
|
|
|
22137
22148
|
* const success = await deleteStream(streamId)
|
|
22138
22149
|
* ```
|
|
22139
22150
|
*
|
|
22140
|
-
* Deletes a {@link Amity.
|
|
22151
|
+
* Deletes a {@link Amity.InternalStream}
|
|
22141
22152
|
*
|
|
22142
|
-
* @param streamId The {@link Amity.
|
|
22143
|
-
* @return A success boolean if the {@link Amity.
|
|
22153
|
+
* @param streamId The {@link Amity.InternalStream} ID to delete
|
|
22154
|
+
* @return A success boolean if the {@link Amity.InternalStream} was deleted
|
|
22144
22155
|
*
|
|
22145
22156
|
* @category Stream API
|
|
22146
22157
|
* @async
|
|
@@ -22165,11 +22176,11 @@ const deleteStream = async (streamId) => {
|
|
|
22165
22176
|
* const stream = await disposeStream(streamId)
|
|
22166
22177
|
* ```
|
|
22167
22178
|
*
|
|
22168
|
-
* Dispose a {@link Amity.
|
|
22179
|
+
* Dispose a {@link Amity.InternalStream}.
|
|
22169
22180
|
* Streaming status will be updated to "ended" and streaming url will be invalidated
|
|
22170
22181
|
*
|
|
22171
|
-
* @param streamId The {@link Amity.
|
|
22172
|
-
* @returns the associated {@link Amity.
|
|
22182
|
+
* @param streamId The {@link Amity.InternalStream} ID to dispose
|
|
22183
|
+
* @returns the associated {@link Amity.InternalStream} object
|
|
22173
22184
|
*
|
|
22174
22185
|
* @category Stream API
|
|
22175
22186
|
* @async
|
|
@@ -22200,15 +22211,15 @@ const disposeStream = async (streamId) => {
|
|
|
22200
22211
|
* const streams = await getStreams()
|
|
22201
22212
|
* ```
|
|
22202
22213
|
*
|
|
22203
|
-
* Queries a paginable list of {@link Amity.
|
|
22214
|
+
* Queries a paginable list of {@link Amity.InternalStream} objects
|
|
22204
22215
|
*
|
|
22205
22216
|
* @param query The query parameters
|
|
22206
|
-
* @returns A page of {@link Amity.
|
|
22217
|
+
* @returns A page of {@link Amity.InternalStream} objects
|
|
22207
22218
|
*
|
|
22208
22219
|
* @category Stream API
|
|
22209
22220
|
* @async
|
|
22210
22221
|
*/
|
|
22211
|
-
const queryStreams
|
|
22222
|
+
const queryStreams = async (query) => {
|
|
22212
22223
|
const client = getActiveClient();
|
|
22213
22224
|
client.log('stream/queryStreams', query);
|
|
22214
22225
|
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
@@ -22238,7 +22249,7 @@ const queryStreams$1 = async (query) => {
|
|
|
22238
22249
|
* })
|
|
22239
22250
|
* ```
|
|
22240
22251
|
*
|
|
22241
|
-
* Fired when a {@link Amity.
|
|
22252
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
22242
22253
|
*
|
|
22243
22254
|
* @param callback The function to call when the event was fired
|
|
22244
22255
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -22262,7 +22273,7 @@ const onStreamStarted = (callback) => {
|
|
|
22262
22273
|
* })
|
|
22263
22274
|
* ```
|
|
22264
22275
|
*
|
|
22265
|
-
* Fired when a {@link Amity.
|
|
22276
|
+
* Fired when a {@link Amity.InternalStream} has stopped airing
|
|
22266
22277
|
*
|
|
22267
22278
|
* @param callback The function to call when the event was fired
|
|
22268
22279
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -22286,7 +22297,7 @@ const onStreamStopped = (callback) => {
|
|
|
22286
22297
|
* })
|
|
22287
22298
|
* ```
|
|
22288
22299
|
*
|
|
22289
|
-
* Fired when the recordings of a {@link Amity.
|
|
22300
|
+
* Fired when the recordings of a {@link Amity.InternalStream} are available
|
|
22290
22301
|
*
|
|
22291
22302
|
* @param callback The function to call when the event was fired
|
|
22292
22303
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -22302,6 +22313,54 @@ const onStreamRecorded = (callback) => {
|
|
|
22302
22313
|
return createEventSubscriber(client, 'stream/onStreamRecorded', 'v3.video-streaming.didRecord', filter);
|
|
22303
22314
|
};
|
|
22304
22315
|
|
|
22316
|
+
/**
|
|
22317
|
+
* ```js
|
|
22318
|
+
* import { onStreamFlagged } from '@amityco/ts-sdk'
|
|
22319
|
+
* const dispose = onStreamFlagged(stream => {
|
|
22320
|
+
* // ...
|
|
22321
|
+
* })
|
|
22322
|
+
* ```
|
|
22323
|
+
*
|
|
22324
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
22325
|
+
*
|
|
22326
|
+
* @param callback The function to call when the event was fired
|
|
22327
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22328
|
+
*
|
|
22329
|
+
* @category Stream Events
|
|
22330
|
+
*/
|
|
22331
|
+
const onStreamFlagged = (callback) => {
|
|
22332
|
+
const client = getActiveClient();
|
|
22333
|
+
const filter = (payload) => {
|
|
22334
|
+
ingestInCache(payload);
|
|
22335
|
+
callback(payload.videoStreamings[0]);
|
|
22336
|
+
};
|
|
22337
|
+
return createEventSubscriber(client, 'stream/onStreamFlagged', 'v3.video-streaming.didFlag', filter);
|
|
22338
|
+
};
|
|
22339
|
+
|
|
22340
|
+
/**
|
|
22341
|
+
* ```js
|
|
22342
|
+
* import { onStreamTerminated } from '@amityco/ts-sdk'
|
|
22343
|
+
* const dispose = onStreamTerminated(stream => {
|
|
22344
|
+
* // ...
|
|
22345
|
+
* })
|
|
22346
|
+
* ```
|
|
22347
|
+
*
|
|
22348
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
22349
|
+
*
|
|
22350
|
+
* @param callback The function to call when the event was fired
|
|
22351
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
22352
|
+
*
|
|
22353
|
+
* @category Stream Events
|
|
22354
|
+
*/
|
|
22355
|
+
const onStreamTerminated = (callback) => {
|
|
22356
|
+
const client = getActiveClient();
|
|
22357
|
+
const filter = (payload) => {
|
|
22358
|
+
ingestInCache(payload);
|
|
22359
|
+
callback(payload.videoStreamings[0]);
|
|
22360
|
+
};
|
|
22361
|
+
return createEventSubscriber(client, 'stream/onStreamTerminated', 'v3.video-streaming.didTerminate', filter);
|
|
22362
|
+
};
|
|
22363
|
+
|
|
22305
22364
|
/* eslint-disable no-use-before-define */
|
|
22306
22365
|
/* begin_public_function
|
|
22307
22366
|
id: stream.get
|
|
@@ -22316,15 +22375,22 @@ const onStreamRecorded = (callback) => {
|
|
|
22316
22375
|
* Fetches a {@link Amity.Stream} object
|
|
22317
22376
|
*
|
|
22318
22377
|
* @param streamId the ID of the {@link Amity.Stream} to get
|
|
22378
|
+
* @param callback
|
|
22319
22379
|
* @returns the associated {@link Amity.Stream} object
|
|
22320
22380
|
*
|
|
22321
22381
|
* @category Stream Live Object
|
|
22322
22382
|
*/
|
|
22323
22383
|
const getStreamById = (streamId, callback) => {
|
|
22324
|
-
|
|
22384
|
+
const reactor = (snapshot) => {
|
|
22385
|
+
const { data } = snapshot;
|
|
22386
|
+
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.stream(snapshot.data) : data }));
|
|
22387
|
+
};
|
|
22388
|
+
return liveObject(streamId, reactor, 'streamId', getStream, [
|
|
22325
22389
|
onStreamRecorded,
|
|
22326
22390
|
onStreamStarted,
|
|
22327
22391
|
onStreamStopped,
|
|
22392
|
+
onStreamFlagged,
|
|
22393
|
+
onStreamTerminated,
|
|
22328
22394
|
]);
|
|
22329
22395
|
};
|
|
22330
22396
|
/* end_public_function */
|
|
@@ -22350,145 +22416,150 @@ getStreamById.locally = (streamId) => {
|
|
|
22350
22416
|
if (!cached)
|
|
22351
22417
|
return;
|
|
22352
22418
|
return {
|
|
22353
|
-
data: cached.data,
|
|
22419
|
+
data: LinkedObject.stream(cached.data),
|
|
22354
22420
|
cachedAt: cached.cachedAt,
|
|
22355
22421
|
};
|
|
22356
22422
|
};
|
|
22357
22423
|
|
|
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 */
|
|
22424
|
+
class GetStreamsPageController extends PaginationController {
|
|
22425
|
+
async getRequest(queryParams, token) {
|
|
22426
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
22427
|
+
const options = token ? { token } : { limit };
|
|
22428
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/video-streaming`, {
|
|
22429
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
22430
|
+
});
|
|
22431
|
+
return Object.assign(Object.assign({}, queryResponse.results), { paging: queryResponse.paging });
|
|
22432
|
+
}
|
|
22433
|
+
}
|
|
22399
22434
|
|
|
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);
|
|
22435
|
+
class GetStreamsQueryStreamController extends QueryStreamController {
|
|
22436
|
+
constructor(query, cacheKey, notifyChange, paginationController) {
|
|
22437
|
+
super(query, cacheKey);
|
|
22438
|
+
this.notifyChange = notifyChange;
|
|
22439
|
+
this.paginationController = paginationController;
|
|
22422
22440
|
}
|
|
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) => {
|
|
22441
|
+
// eslint-disable-next-line class-methods-use-this
|
|
22442
|
+
saveToMainDB(response) {
|
|
22443
|
+
const client = getActiveClient();
|
|
22444
|
+
const cachedAt = client.cache && Date.now();
|
|
22445
|
+
if (client.cache) {
|
|
22446
|
+
ingestInCache(response, { cachedAt });
|
|
22447
|
+
}
|
|
22448
|
+
}
|
|
22449
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
22436
22450
|
var _a, _b;
|
|
22437
|
-
|
|
22438
|
-
.
|
|
22439
|
-
|
|
22440
|
-
|
|
22441
|
-
|
|
22442
|
-
|
|
22443
|
-
|
|
22444
|
-
|
|
22445
|
-
|
|
22446
|
-
|
|
22447
|
-
|
|
22448
|
-
|
|
22449
|
-
|
|
22450
|
-
|
|
22451
|
-
|
|
22452
|
-
|
|
22453
|
-
|
|
22454
|
-
|
|
22451
|
+
if (refresh) {
|
|
22452
|
+
pushToCache(this.cacheKey, {
|
|
22453
|
+
data: response.videoStreamings.map(getResolver('stream')),
|
|
22454
|
+
query: this.query,
|
|
22455
|
+
});
|
|
22456
|
+
}
|
|
22457
|
+
else {
|
|
22458
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22459
|
+
const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
22460
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === 'next'
|
|
22461
|
+
? [...new Set([...messages, ...response.videoStreamings.map(getResolver('stream'))])]
|
|
22462
|
+
: [...new Set([...response.videoStreamings.map(getResolver('stream')), ...messages])] }));
|
|
22463
|
+
}
|
|
22464
|
+
}
|
|
22465
|
+
reactor(action) {
|
|
22466
|
+
return (payload) => {
|
|
22467
|
+
var _a;
|
|
22468
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22469
|
+
if (!collection)
|
|
22470
|
+
return;
|
|
22471
|
+
collection.data = [...new Set([payload.streamId, ...collection.data])];
|
|
22472
|
+
pushToCache(this.cacheKey, collection);
|
|
22473
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
22474
|
+
};
|
|
22475
|
+
}
|
|
22476
|
+
subscribeRTE(createSubscriber) {
|
|
22477
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
22478
|
+
}
|
|
22479
|
+
}
|
|
22480
|
+
|
|
22481
|
+
class GetStreamsLiveCollectionController extends LiveCollectionController {
|
|
22482
|
+
constructor(query, callback) {
|
|
22483
|
+
const queryStreamId = hash__default["default"](query);
|
|
22484
|
+
const cacheKey = ['streams', 'collection', queryStreamId];
|
|
22485
|
+
const paginationController = new GetStreamsPageController(query);
|
|
22486
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
22487
|
+
this.applyFilter = (data) => {
|
|
22488
|
+
let streams = filterByPropEquality(data, 'isDeleted', this.query.isDeleted);
|
|
22489
|
+
streams = streams.sort(this.query.sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
22490
|
+
return streams;
|
|
22491
|
+
};
|
|
22492
|
+
this.query = query;
|
|
22493
|
+
this.queryStreamController = new GetStreamsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), paginationController);
|
|
22494
|
+
this.paginationController = paginationController;
|
|
22495
|
+
this.callback = callback.bind(this);
|
|
22496
|
+
this.loadPage({ initial: true });
|
|
22497
|
+
}
|
|
22498
|
+
notifyChange({ origin, loading, error }) {
|
|
22455
22499
|
var _a;
|
|
22456
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22500
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22457
22501
|
if (!collection)
|
|
22458
22502
|
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))
|
|
22503
|
+
let data = collection.data
|
|
22504
|
+
.map(streamId => pullFromCache(['stream', 'get', streamId]))
|
|
22505
|
+
.filter(Boolean)
|
|
22506
|
+
.map(stream => LinkedObject.stream(stream.data));
|
|
22507
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
22468
22508
|
return;
|
|
22469
|
-
|
|
22470
|
-
|
|
22471
|
-
|
|
22472
|
-
|
|
22473
|
-
|
|
22474
|
-
|
|
22475
|
-
|
|
22476
|
-
|
|
22477
|
-
|
|
22478
|
-
|
|
22479
|
-
|
|
22480
|
-
|
|
22481
|
-
|
|
22482
|
-
|
|
22483
|
-
|
|
22484
|
-
|
|
22485
|
-
|
|
22509
|
+
data = this.applyFilter(data);
|
|
22510
|
+
this.callback({
|
|
22511
|
+
onNextPage: () => this.loadPage({ initial: false, direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
22512
|
+
data,
|
|
22513
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
22514
|
+
loading,
|
|
22515
|
+
error,
|
|
22516
|
+
});
|
|
22517
|
+
}
|
|
22518
|
+
startSubscription() {
|
|
22519
|
+
return this.queryStreamController.subscribeRTE([
|
|
22520
|
+
{ fn: onStreamRecorded, action: 'onStreamRecorded' },
|
|
22521
|
+
{ fn: onStreamStarted, action: 'onStreamStarted' },
|
|
22522
|
+
{ fn: onStreamStopped, action: 'onStreamStopped' },
|
|
22523
|
+
{ fn: onStreamFlagged, action: 'onStreamFlagged' },
|
|
22524
|
+
{ fn: onStreamTerminated, action: 'onStreamTerminated' },
|
|
22525
|
+
]);
|
|
22526
|
+
}
|
|
22527
|
+
setup() {
|
|
22528
|
+
var _a;
|
|
22529
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
22530
|
+
if (!collection) {
|
|
22531
|
+
pushToCache(this.cacheKey, {
|
|
22532
|
+
data: [],
|
|
22533
|
+
params: {},
|
|
22534
|
+
});
|
|
22535
|
+
}
|
|
22536
|
+
}
|
|
22537
|
+
persistModel(response) {
|
|
22538
|
+
this.queryStreamController.saveToMainDB(response);
|
|
22539
|
+
}
|
|
22540
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
22541
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
22542
|
+
}
|
|
22543
|
+
}
|
|
22544
|
+
|
|
22545
|
+
const getStreams = (params, callback, config) => {
|
|
22546
|
+
const { log, cache, userId } = getActiveClient();
|
|
22547
|
+
if (!cache) {
|
|
22548
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
22549
|
+
}
|
|
22550
|
+
const timestamp = Date.now();
|
|
22551
|
+
log(`getStreams(tmpid: ${timestamp}) > listen`);
|
|
22552
|
+
const liveCollection = new GetStreamsLiveCollectionController(params, callback);
|
|
22553
|
+
const disposers = liveCollection.startSubscription();
|
|
22554
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
22555
|
+
disposers.push(() => {
|
|
22556
|
+
dropFromCache(cacheKey);
|
|
22557
|
+
});
|
|
22486
22558
|
return () => {
|
|
22487
22559
|
log(`getStreams(tmpid: ${timestamp}) > dispose`);
|
|
22488
22560
|
disposers.forEach(fn => fn());
|
|
22489
22561
|
};
|
|
22490
|
-
};
|
|
22491
|
-
/* end_public_function */
|
|
22562
|
+
};
|
|
22492
22563
|
|
|
22493
22564
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
22494
22565
|
__proto__: null,
|
|
@@ -22496,11 +22567,13 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
22496
22567
|
updateStream: updateStream,
|
|
22497
22568
|
deleteStream: deleteStream,
|
|
22498
22569
|
disposeStream: disposeStream,
|
|
22499
|
-
queryStreams: queryStreams
|
|
22570
|
+
queryStreams: queryStreams,
|
|
22500
22571
|
getStream: getStream,
|
|
22501
22572
|
onStreamStarted: onStreamStarted,
|
|
22502
22573
|
onStreamStopped: onStreamStopped,
|
|
22503
22574
|
onStreamRecorded: onStreamRecorded,
|
|
22575
|
+
onStreamFlagged: onStreamFlagged,
|
|
22576
|
+
onStreamTerminated: onStreamTerminated,
|
|
22504
22577
|
getStreamById: getStreamById,
|
|
22505
22578
|
getStreams: getStreams
|
|
22506
22579
|
});
|
|
@@ -22833,7 +22906,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
22833
22906
|
getPoll: getPoll
|
|
22834
22907
|
});
|
|
22835
22908
|
|
|
22836
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
22909
|
+
const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvwIBADANBgkqhkiG9w0BAQEFAASCBKkwggSlAgEAAoIBAQDAARz+hmBgi8pJ\nQb8LeY41gtHhk+ACMwRfhsn7GqpqRQNG2qU0755mzZuVDUqjQMGSo8THJB7O+OJs\nflbZRkFXlFoFOVNw1UpNOgwEQZ6wB9oRwzepTJAfF1sVhm/o/ixvXh1zDFNDy6yZ\npXyiiJHUVxqyjllZhxnwdvjoVtDs6hW6awG09bB9nh/TTejlUKXoAgzqVwu/1QMu\nUVViET495elEe19aUarEy+oL2iKeXCEvqda/pWNBdbieFyJvvZ08HN8dPuT88wq2\njZLEAth1vrwQ2IAa4ktaLcBQdLJgIkrbDvAiVZ8lQAjS/bq5vXQikTGvoPlC5bbn\nvuOM/3eLAgMBAAECggEAVZ+peHAghq2QVj71nX5lxsNCKaCyYwixSJBpfouTt7Rz\nE6PpzMOXFi1W1o+I22jDakuSM2SOQKqI/u0QefB0r0O/KVk5NrZHXk0mkrdYtxOp\nUgaGyf8UvmjB+8VqHrNKyZdk9qtmbnNj01kTTcAtmE4H39zPR7eR/8Rul94vaZbs\nwCnKJS3mLT3JxyGug6lxanveKkjG+CKC1nJQYWaxCJxaFSzbwXQPvDhB+TvrIbee\npd5v4EAyEJohpr+T9oDGGJkb/KARBZCtwLyB976PKJwwBA8MRVL1i5QwawuMiMq5\nUtnOnbGKtCeFzaLbNU0Qi8bqyims84EQxC6DOu1fkQKBgQDdvsoBsEhsOXV7hlIJ\naEd0eSJZVkdqimxH8uGoMM2FeNaOrcB6yBXqTSP0R3OIyf8eaY6yjRvP30ZNXcll\n/gD3O1Mu6YmWQdt1W2WA6pKOsUuPXasf0pdOF7IiFZKlSabz5YHXFqwVuqm8loaj\nsXel3YWqPVdHiankE7tz+3ssnQKBgQDdqi4TNdD1MdEpihx19jr0QjUiXW3939FK\nqp30HESPEGDGQzXdmJgif9HhZb+cJSuWaHEbjgBrYahvgCF+y6LbEpOD+D/dmT+s\nDEAQaR84sah6dokwPjV8fjBSrcVFjCS+doxv0d3p/9OUEeyUhFrY03nxtIEYkLIE\n/Zvn37b4RwKBgQCLENVFe9XfsaVhQ5r9dV2iyTlmh7qgMZG5CbTFs12hQGhm8McO\n+Z7s41YSJCFr/yq1WwP4LJDtrBw99vyQr1zRsG35tNLp3gGRNzGQSQyC2uQFVHw2\np+7mNewsfhUK/gbrXNsyFnDz6635rPlhfbII3sWuP2wWXFqkxE9CbMwR7QKBgQC6\nawDMzxmo2/iYArrkyevSuEuPVxvFwpF1RgAI6C0QVCnPE38dmdN4UB7mfHekje4W\nVEercMURidPp0cxZolCYBQtilUjAyL0vqC3In1/Ogjq6oy3FEMxSop1pKxMY5j+Q\nnoqFD+6deLUrddeNH7J3X4LSr4dSbX4JjG+tlgt+yQKBgQCuwTL4hA6KqeInQ0Ta\n9VQX5Qr8hFlqJz1gpymi/k63tW/Ob8yedbg3WWNWyShwRMFYyY9S81ITFWM95uL6\nvF3x9rmRjwElJw9PMwVu6dmf/CO0Z1wzXSp2VVD12gbrUD/0/d7MUoJ9LgC8X8f/\nn0txLHYGHbx+nf95+JUg6lV3hg==\n-----END PRIVATE KEY-----";
|
|
22837
22910
|
/*
|
|
22838
22911
|
* The crypto algorithm used for importing key and signing string
|
|
22839
22912
|
*/
|