@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.esm.js
CHANGED
|
@@ -511,6 +511,7 @@ const idResolvers = {
|
|
|
511
511
|
reaction: ({ referenceType, referenceId }) => `${referenceType}#${referenceId}`,
|
|
512
512
|
reactor: ({ reactionId }) => reactionId,
|
|
513
513
|
stream: ({ streamId }) => streamId,
|
|
514
|
+
streamModeration: ({ streamId }) => streamId,
|
|
514
515
|
follow: ({ from, to }) => `${from}#${to}`,
|
|
515
516
|
followInfo: ({ userId }) => userId,
|
|
516
517
|
followCount: ({ userId }) => userId,
|
|
@@ -560,6 +561,7 @@ const PAYLOAD2MODEL = {
|
|
|
560
561
|
reactors: 'reactor',
|
|
561
562
|
reactions: 'reaction',
|
|
562
563
|
videoStreamings: 'stream',
|
|
564
|
+
videoStreamModerations: 'streamModeration',
|
|
563
565
|
follows: 'follow',
|
|
564
566
|
followCounts: 'followCount',
|
|
565
567
|
feeds: 'feed',
|
|
@@ -21331,6 +21333,13 @@ const storyLinkedObject = (story) => {
|
|
|
21331
21333
|
} });
|
|
21332
21334
|
};
|
|
21333
21335
|
|
|
21336
|
+
const streamLinkedObject = (stream) => {
|
|
21337
|
+
return Object.assign(Object.assign({}, stream), { get moderation() {
|
|
21338
|
+
var _a;
|
|
21339
|
+
return (_a = pullFromCache(['streamModeration', 'get', stream.streamId])) === null || _a === void 0 ? void 0 : _a.data;
|
|
21340
|
+
} });
|
|
21341
|
+
};
|
|
21342
|
+
|
|
21334
21343
|
const categoryLinkedObject = (category) => {
|
|
21335
21344
|
return Object.assign(Object.assign({}, category), { get avatar() {
|
|
21336
21345
|
var _a;
|
|
@@ -21799,6 +21808,7 @@ const LinkedObject = {
|
|
|
21799
21808
|
post: postLinkedObject,
|
|
21800
21809
|
user: userLinkedObject,
|
|
21801
21810
|
category: categoryLinkedObject,
|
|
21811
|
+
stream: streamLinkedObject,
|
|
21802
21812
|
story: storyLinkedObject,
|
|
21803
21813
|
storyTarget: storyTargetLinkedObject,
|
|
21804
21814
|
message: messageLinkedObject,
|
|
@@ -29367,9 +29377,10 @@ const onReactorAdded = (referenceType, referenceId, callback) => {
|
|
|
29367
29377
|
if (!payload.reactions[0])
|
|
29368
29378
|
return;
|
|
29369
29379
|
ingestInCache(payload);
|
|
29380
|
+
ingestInCache({ reactors: payload.reactions });
|
|
29370
29381
|
callbackWrapper('message', payload.messages[0].messageId, payload.reactions[0]);
|
|
29371
29382
|
};
|
|
29372
|
-
return createEventSubscriber(client, 'reaction/onReactorAdded', 'message.
|
|
29383
|
+
return createEventSubscriber(client, 'reaction/onReactorAdded', 'message.reactionAdded', filter);
|
|
29373
29384
|
}
|
|
29374
29385
|
if (referenceType === 'post') {
|
|
29375
29386
|
const filter = (payload) => {
|
|
@@ -29432,7 +29443,7 @@ const onReactorRemoved = (referenceType, referenceId, callback) => {
|
|
|
29432
29443
|
ingestInCache(payload);
|
|
29433
29444
|
callbackWrapper('message', payload.messages[0].messageId, payload.reactions[0]);
|
|
29434
29445
|
};
|
|
29435
|
-
return createEventSubscriber(client, 'reaction/onReactorRemoved', 'message.
|
|
29446
|
+
return createEventSubscriber(client, 'reaction/onReactorRemoved', 'message.reactionRemoved', filter);
|
|
29436
29447
|
}
|
|
29437
29448
|
if (referenceType === 'post') {
|
|
29438
29449
|
const filter = (payload) => {
|
|
@@ -38103,10 +38114,10 @@ var index$4 = /*#__PURE__*/Object.freeze({
|
|
|
38103
38114
|
* const created = await createStream({ title: 'my stream', 'thumbnailFileId': fileId })
|
|
38104
38115
|
* ```
|
|
38105
38116
|
*
|
|
38106
|
-
* Creates an {@link Amity.
|
|
38117
|
+
* Creates an {@link Amity.InternalStream}
|
|
38107
38118
|
*
|
|
38108
|
-
* @param bundle The data necessary to create a new {@link Amity.
|
|
38109
|
-
* @returns The newly created {@link Amity.
|
|
38119
|
+
* @param bundle The data necessary to create a new {@link Amity.InternalStream}
|
|
38120
|
+
* @returns The newly created {@link Amity.InternalStream}
|
|
38110
38121
|
*
|
|
38111
38122
|
* @category Stream API
|
|
38112
38123
|
* @async
|
|
@@ -38120,7 +38131,7 @@ const createStream = async (bundle) => {
|
|
|
38120
38131
|
ingestInCache(data, { cachedAt });
|
|
38121
38132
|
const { videoStreamings } = data;
|
|
38122
38133
|
return {
|
|
38123
|
-
data: videoStreamings[0],
|
|
38134
|
+
data: LinkedObject.stream(videoStreamings[0]),
|
|
38124
38135
|
cachedAt,
|
|
38125
38136
|
};
|
|
38126
38137
|
};
|
|
@@ -38153,7 +38164,7 @@ const updateStream = async (streamId, patch) => {
|
|
|
38153
38164
|
ingestInCache(data, { cachedAt });
|
|
38154
38165
|
const { videoStreamings } = data;
|
|
38155
38166
|
return {
|
|
38156
|
-
data: videoStreamings.find(stream => stream.streamId === streamId),
|
|
38167
|
+
data: LinkedObject.stream(videoStreamings.find(stream => stream.streamId === streamId)),
|
|
38157
38168
|
cachedAt,
|
|
38158
38169
|
};
|
|
38159
38170
|
};
|
|
@@ -38227,10 +38238,10 @@ getStream.locally = (streamId) => {
|
|
|
38227
38238
|
* const success = await deleteStream(streamId)
|
|
38228
38239
|
* ```
|
|
38229
38240
|
*
|
|
38230
|
-
* Deletes a {@link Amity.
|
|
38241
|
+
* Deletes a {@link Amity.InternalStream}
|
|
38231
38242
|
*
|
|
38232
|
-
* @param streamId The {@link Amity.
|
|
38233
|
-
* @return A success boolean if the {@link Amity.
|
|
38243
|
+
* @param streamId The {@link Amity.InternalStream} ID to delete
|
|
38244
|
+
* @return A success boolean if the {@link Amity.InternalStream} was deleted
|
|
38234
38245
|
*
|
|
38235
38246
|
* @category Stream API
|
|
38236
38247
|
* @async
|
|
@@ -38255,11 +38266,11 @@ const deleteStream = async (streamId) => {
|
|
|
38255
38266
|
* const stream = await disposeStream(streamId)
|
|
38256
38267
|
* ```
|
|
38257
38268
|
*
|
|
38258
|
-
* Dispose a {@link Amity.
|
|
38269
|
+
* Dispose a {@link Amity.InternalStream}.
|
|
38259
38270
|
* Streaming status will be updated to "ended" and streaming url will be invalidated
|
|
38260
38271
|
*
|
|
38261
|
-
* @param streamId The {@link Amity.
|
|
38262
|
-
* @returns the associated {@link Amity.
|
|
38272
|
+
* @param streamId The {@link Amity.InternalStream} ID to dispose
|
|
38273
|
+
* @returns the associated {@link Amity.InternalStream} object
|
|
38263
38274
|
*
|
|
38264
38275
|
* @category Stream API
|
|
38265
38276
|
* @async
|
|
@@ -38290,15 +38301,15 @@ const disposeStream = async (streamId) => {
|
|
|
38290
38301
|
* const streams = await getStreams()
|
|
38291
38302
|
* ```
|
|
38292
38303
|
*
|
|
38293
|
-
* Queries a paginable list of {@link Amity.
|
|
38304
|
+
* Queries a paginable list of {@link Amity.InternalStream} objects
|
|
38294
38305
|
*
|
|
38295
38306
|
* @param query The query parameters
|
|
38296
|
-
* @returns A page of {@link Amity.
|
|
38307
|
+
* @returns A page of {@link Amity.InternalStream} objects
|
|
38297
38308
|
*
|
|
38298
38309
|
* @category Stream API
|
|
38299
38310
|
* @async
|
|
38300
38311
|
*/
|
|
38301
|
-
const queryStreams
|
|
38312
|
+
const queryStreams = async (query) => {
|
|
38302
38313
|
const client = getActiveClient();
|
|
38303
38314
|
client.log('stream/queryStreams', query);
|
|
38304
38315
|
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
@@ -38328,7 +38339,7 @@ const queryStreams$1 = async (query) => {
|
|
|
38328
38339
|
* })
|
|
38329
38340
|
* ```
|
|
38330
38341
|
*
|
|
38331
|
-
* Fired when a {@link Amity.
|
|
38342
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
38332
38343
|
*
|
|
38333
38344
|
* @param callback The function to call when the event was fired
|
|
38334
38345
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -38352,7 +38363,7 @@ const onStreamStarted = (callback) => {
|
|
|
38352
38363
|
* })
|
|
38353
38364
|
* ```
|
|
38354
38365
|
*
|
|
38355
|
-
* Fired when a {@link Amity.
|
|
38366
|
+
* Fired when a {@link Amity.InternalStream} has stopped airing
|
|
38356
38367
|
*
|
|
38357
38368
|
* @param callback The function to call when the event was fired
|
|
38358
38369
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -38376,7 +38387,7 @@ const onStreamStopped = (callback) => {
|
|
|
38376
38387
|
* })
|
|
38377
38388
|
* ```
|
|
38378
38389
|
*
|
|
38379
|
-
* Fired when the recordings of a {@link Amity.
|
|
38390
|
+
* Fired when the recordings of a {@link Amity.InternalStream} are available
|
|
38380
38391
|
*
|
|
38381
38392
|
* @param callback The function to call when the event was fired
|
|
38382
38393
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
@@ -38392,6 +38403,54 @@ const onStreamRecorded = (callback) => {
|
|
|
38392
38403
|
return createEventSubscriber(client, 'stream/onStreamRecorded', 'v3.video-streaming.didRecord', filter);
|
|
38393
38404
|
};
|
|
38394
38405
|
|
|
38406
|
+
/**
|
|
38407
|
+
* ```js
|
|
38408
|
+
* import { onStreamFlagged } from '@amityco/ts-sdk'
|
|
38409
|
+
* const dispose = onStreamFlagged(stream => {
|
|
38410
|
+
* // ...
|
|
38411
|
+
* })
|
|
38412
|
+
* ```
|
|
38413
|
+
*
|
|
38414
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
38415
|
+
*
|
|
38416
|
+
* @param callback The function to call when the event was fired
|
|
38417
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
38418
|
+
*
|
|
38419
|
+
* @category Stream Events
|
|
38420
|
+
*/
|
|
38421
|
+
const onStreamFlagged = (callback) => {
|
|
38422
|
+
const client = getActiveClient();
|
|
38423
|
+
const filter = (payload) => {
|
|
38424
|
+
ingestInCache(payload);
|
|
38425
|
+
callback(payload.videoStreamings[0]);
|
|
38426
|
+
};
|
|
38427
|
+
return createEventSubscriber(client, 'stream/onStreamFlagged', 'v3.video-streaming.didFlag', filter);
|
|
38428
|
+
};
|
|
38429
|
+
|
|
38430
|
+
/**
|
|
38431
|
+
* ```js
|
|
38432
|
+
* import { onStreamTerminated } from '@amityco/ts-sdk'
|
|
38433
|
+
* const dispose = onStreamTerminated(stream => {
|
|
38434
|
+
* // ...
|
|
38435
|
+
* })
|
|
38436
|
+
* ```
|
|
38437
|
+
*
|
|
38438
|
+
* Fired when a {@link Amity.InternalStream} has started airing
|
|
38439
|
+
*
|
|
38440
|
+
* @param callback The function to call when the event was fired
|
|
38441
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
38442
|
+
*
|
|
38443
|
+
* @category Stream Events
|
|
38444
|
+
*/
|
|
38445
|
+
const onStreamTerminated = (callback) => {
|
|
38446
|
+
const client = getActiveClient();
|
|
38447
|
+
const filter = (payload) => {
|
|
38448
|
+
ingestInCache(payload);
|
|
38449
|
+
callback(payload.videoStreamings[0]);
|
|
38450
|
+
};
|
|
38451
|
+
return createEventSubscriber(client, 'stream/onStreamTerminated', 'v3.video-streaming.didTerminate', filter);
|
|
38452
|
+
};
|
|
38453
|
+
|
|
38395
38454
|
/* eslint-disable no-use-before-define */
|
|
38396
38455
|
/* begin_public_function
|
|
38397
38456
|
id: stream.get
|
|
@@ -38406,15 +38465,22 @@ const onStreamRecorded = (callback) => {
|
|
|
38406
38465
|
* Fetches a {@link Amity.Stream} object
|
|
38407
38466
|
*
|
|
38408
38467
|
* @param streamId the ID of the {@link Amity.Stream} to get
|
|
38468
|
+
* @param callback
|
|
38409
38469
|
* @returns the associated {@link Amity.Stream} object
|
|
38410
38470
|
*
|
|
38411
38471
|
* @category Stream Live Object
|
|
38412
38472
|
*/
|
|
38413
38473
|
const getStreamById = (streamId, callback) => {
|
|
38414
|
-
|
|
38474
|
+
const reactor = (snapshot) => {
|
|
38475
|
+
const { data } = snapshot;
|
|
38476
|
+
callback(Object.assign(Object.assign({}, snapshot), { data: data ? LinkedObject.stream(snapshot.data) : data }));
|
|
38477
|
+
};
|
|
38478
|
+
return liveObject(streamId, reactor, 'streamId', getStream, [
|
|
38415
38479
|
onStreamRecorded,
|
|
38416
38480
|
onStreamStarted,
|
|
38417
38481
|
onStreamStopped,
|
|
38482
|
+
onStreamFlagged,
|
|
38483
|
+
onStreamTerminated,
|
|
38418
38484
|
]);
|
|
38419
38485
|
};
|
|
38420
38486
|
/* end_public_function */
|
|
@@ -38440,145 +38506,150 @@ getStreamById.locally = (streamId) => {
|
|
|
38440
38506
|
if (!cached)
|
|
38441
38507
|
return;
|
|
38442
38508
|
return {
|
|
38443
|
-
data: cached.data,
|
|
38509
|
+
data: LinkedObject.stream(cached.data),
|
|
38444
38510
|
cachedAt: cached.cachedAt,
|
|
38445
38511
|
};
|
|
38446
38512
|
};
|
|
38447
38513
|
|
|
38448
|
-
|
|
38449
|
-
|
|
38450
|
-
|
|
38451
|
-
|
|
38452
|
-
|
|
38453
|
-
|
|
38454
|
-
|
|
38455
|
-
|
|
38456
|
-
|
|
38457
|
-
|
|
38458
|
-
*
|
|
38459
|
-
* @param query The query parameters
|
|
38460
|
-
* @returns A page of {@link Amity.Stream} objects
|
|
38461
|
-
*
|
|
38462
|
-
* @category Stream API
|
|
38463
|
-
* @async
|
|
38464
|
-
*/
|
|
38465
|
-
const queryStreams = async (query) => {
|
|
38466
|
-
const client = getActiveClient();
|
|
38467
|
-
client.log('stream/queryStreams', query);
|
|
38468
|
-
const _a = query !== null && query !== void 0 ? query : {}, { page, limit } = _a, params = __rest(_a, ["page", "limit"]);
|
|
38469
|
-
const options = (() => {
|
|
38470
|
-
if (page)
|
|
38471
|
-
return { token: page };
|
|
38472
|
-
if (limit)
|
|
38473
|
-
return { limit };
|
|
38474
|
-
return undefined;
|
|
38475
|
-
})();
|
|
38476
|
-
const { data } = await client.http.get(`/api/v3/video-streaming`, {
|
|
38477
|
-
params: Object.assign(Object.assign({}, params), { options }),
|
|
38478
|
-
});
|
|
38479
|
-
// API-FIX: backend to response Amity.Response: const { paging, videoStreamings } = unwrapPayload(data)
|
|
38480
|
-
// API-FIX: seems returned data has a results identifier on top of data, like no other apis, and this is beautiful
|
|
38481
|
-
const { paging, results: payload } = data;
|
|
38482
|
-
const { videoStreamings } = payload;
|
|
38483
|
-
const cachedAt = client.cache && Date.now();
|
|
38484
|
-
if (client.cache)
|
|
38485
|
-
ingestInCache(payload, { cachedAt });
|
|
38486
|
-
return { data: videoStreamings, cachedAt, paging };
|
|
38487
|
-
};
|
|
38488
|
-
/* end_public_function */
|
|
38514
|
+
class GetStreamsPageController extends PaginationController {
|
|
38515
|
+
async getRequest(queryParams, token) {
|
|
38516
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
38517
|
+
const options = token ? { token } : { limit };
|
|
38518
|
+
const { data: queryResponse } = await this.http.get(`/api/v3/video-streaming`, {
|
|
38519
|
+
params: Object.assign(Object.assign({}, params), { options }),
|
|
38520
|
+
});
|
|
38521
|
+
return Object.assign(Object.assign({}, queryResponse.results), { paging: queryResponse.paging });
|
|
38522
|
+
}
|
|
38523
|
+
}
|
|
38489
38524
|
|
|
38490
|
-
|
|
38491
|
-
|
|
38492
|
-
|
|
38493
|
-
|
|
38494
|
-
|
|
38495
|
-
* import { StreamRepository } from '@amityco/ts-sdk'
|
|
38496
|
-
* const streams = await StreamRepository.getStreams()
|
|
38497
|
-
* ```
|
|
38498
|
-
*
|
|
38499
|
-
* Observe all mutations on a list of {@link Amity.Stream}s
|
|
38500
|
-
*
|
|
38501
|
-
* @param params for querying streams
|
|
38502
|
-
* @param callback the function to call when new data are available
|
|
38503
|
-
* @param config
|
|
38504
|
-
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the streams
|
|
38505
|
-
*
|
|
38506
|
-
* @category Stream Live Collection
|
|
38507
|
-
*/
|
|
38508
|
-
const getStreams = (params, callback, config) => {
|
|
38509
|
-
const { log, cache } = getActiveClient();
|
|
38510
|
-
if (!cache) {
|
|
38511
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
38525
|
+
class GetStreamsQueryStreamController extends QueryStreamController {
|
|
38526
|
+
constructor(query, cacheKey, notifyChange, paginationController) {
|
|
38527
|
+
super(query, cacheKey);
|
|
38528
|
+
this.notifyChange = notifyChange;
|
|
38529
|
+
this.paginationController = paginationController;
|
|
38512
38530
|
}
|
|
38513
|
-
|
|
38514
|
-
|
|
38515
|
-
|
|
38516
|
-
|
|
38517
|
-
|
|
38518
|
-
|
|
38519
|
-
|
|
38520
|
-
|
|
38521
|
-
|
|
38522
|
-
streams = streams.sort(params.sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
38523
|
-
return streams;
|
|
38524
|
-
};
|
|
38525
|
-
const responder = (data, isEventModel = false) => {
|
|
38531
|
+
// eslint-disable-next-line class-methods-use-this
|
|
38532
|
+
saveToMainDB(response) {
|
|
38533
|
+
const client = getActiveClient();
|
|
38534
|
+
const cachedAt = client.cache && Date.now();
|
|
38535
|
+
if (client.cache) {
|
|
38536
|
+
ingestInCache(response, { cachedAt });
|
|
38537
|
+
}
|
|
38538
|
+
}
|
|
38539
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
38526
38540
|
var _a, _b;
|
|
38527
|
-
|
|
38528
|
-
.
|
|
38529
|
-
|
|
38530
|
-
|
|
38531
|
-
|
|
38532
|
-
|
|
38533
|
-
|
|
38534
|
-
|
|
38535
|
-
|
|
38536
|
-
|
|
38537
|
-
|
|
38538
|
-
|
|
38539
|
-
|
|
38540
|
-
|
|
38541
|
-
|
|
38542
|
-
|
|
38543
|
-
|
|
38544
|
-
|
|
38541
|
+
if (refresh) {
|
|
38542
|
+
pushToCache(this.cacheKey, {
|
|
38543
|
+
data: response.videoStreamings.map(getResolver('stream')),
|
|
38544
|
+
query: this.query,
|
|
38545
|
+
});
|
|
38546
|
+
}
|
|
38547
|
+
else {
|
|
38548
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38549
|
+
const messages = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
38550
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: direction === 'next'
|
|
38551
|
+
? [...new Set([...messages, ...response.videoStreamings.map(getResolver('stream'))])]
|
|
38552
|
+
: [...new Set([...response.videoStreamings.map(getResolver('stream')), ...messages])] }));
|
|
38553
|
+
}
|
|
38554
|
+
}
|
|
38555
|
+
reactor(action) {
|
|
38556
|
+
return (payload) => {
|
|
38557
|
+
var _a;
|
|
38558
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38559
|
+
if (!collection)
|
|
38560
|
+
return;
|
|
38561
|
+
collection.data = [...new Set([payload.streamId, ...collection.data])];
|
|
38562
|
+
pushToCache(this.cacheKey, collection);
|
|
38563
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
38564
|
+
};
|
|
38565
|
+
}
|
|
38566
|
+
subscribeRTE(createSubscriber) {
|
|
38567
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
38568
|
+
}
|
|
38569
|
+
}
|
|
38570
|
+
|
|
38571
|
+
class GetStreamsLiveCollectionController extends LiveCollectionController {
|
|
38572
|
+
constructor(query, callback) {
|
|
38573
|
+
const queryStreamId = hash(query);
|
|
38574
|
+
const cacheKey = ['streams', 'collection', queryStreamId];
|
|
38575
|
+
const paginationController = new GetStreamsPageController(query);
|
|
38576
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
38577
|
+
this.applyFilter = (data) => {
|
|
38578
|
+
let streams = filterByPropEquality(data, 'isDeleted', this.query.isDeleted);
|
|
38579
|
+
streams = streams.sort(this.query.sortBy === 'lastCreated' ? sortByLastCreated : sortByFirstCreated);
|
|
38580
|
+
return streams;
|
|
38581
|
+
};
|
|
38582
|
+
this.query = query;
|
|
38583
|
+
this.queryStreamController = new GetStreamsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), paginationController);
|
|
38584
|
+
this.paginationController = paginationController;
|
|
38585
|
+
this.callback = callback.bind(this);
|
|
38586
|
+
this.loadPage({ initial: true });
|
|
38587
|
+
}
|
|
38588
|
+
notifyChange({ origin, loading, error }) {
|
|
38545
38589
|
var _a;
|
|
38546
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38590
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38547
38591
|
if (!collection)
|
|
38548
38592
|
return;
|
|
38549
|
-
|
|
38550
|
-
|
|
38551
|
-
|
|
38552
|
-
|
|
38553
|
-
|
|
38554
|
-
var _a, _b;
|
|
38555
|
-
const collection = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38556
|
-
const streams = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
38557
|
-
if (!initial && streams.length > 0 && !(collection === null || collection === void 0 ? void 0 : collection.params.page))
|
|
38593
|
+
let data = collection.data
|
|
38594
|
+
.map(streamId => pullFromCache(['stream', 'get', streamId]))
|
|
38595
|
+
.filter(Boolean)
|
|
38596
|
+
.map(stream => LinkedObject.stream(stream.data));
|
|
38597
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
38558
38598
|
return;
|
|
38559
|
-
|
|
38560
|
-
|
|
38561
|
-
|
|
38562
|
-
|
|
38563
|
-
|
|
38564
|
-
|
|
38565
|
-
|
|
38566
|
-
|
|
38567
|
-
|
|
38568
|
-
|
|
38569
|
-
|
|
38570
|
-
|
|
38571
|
-
|
|
38572
|
-
|
|
38573
|
-
|
|
38574
|
-
|
|
38575
|
-
|
|
38599
|
+
data = this.applyFilter(data);
|
|
38600
|
+
this.callback({
|
|
38601
|
+
onNextPage: () => this.loadPage({ initial: false, direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
38602
|
+
data,
|
|
38603
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
38604
|
+
loading,
|
|
38605
|
+
error,
|
|
38606
|
+
});
|
|
38607
|
+
}
|
|
38608
|
+
startSubscription() {
|
|
38609
|
+
return this.queryStreamController.subscribeRTE([
|
|
38610
|
+
{ fn: onStreamRecorded, action: 'onStreamRecorded' },
|
|
38611
|
+
{ fn: onStreamStarted, action: 'onStreamStarted' },
|
|
38612
|
+
{ fn: onStreamStopped, action: 'onStreamStopped' },
|
|
38613
|
+
{ fn: onStreamFlagged, action: 'onStreamFlagged' },
|
|
38614
|
+
{ fn: onStreamTerminated, action: 'onStreamTerminated' },
|
|
38615
|
+
]);
|
|
38616
|
+
}
|
|
38617
|
+
setup() {
|
|
38618
|
+
var _a;
|
|
38619
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
38620
|
+
if (!collection) {
|
|
38621
|
+
pushToCache(this.cacheKey, {
|
|
38622
|
+
data: [],
|
|
38623
|
+
params: {},
|
|
38624
|
+
});
|
|
38625
|
+
}
|
|
38626
|
+
}
|
|
38627
|
+
persistModel(response) {
|
|
38628
|
+
this.queryStreamController.saveToMainDB(response);
|
|
38629
|
+
}
|
|
38630
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
38631
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
38632
|
+
}
|
|
38633
|
+
}
|
|
38634
|
+
|
|
38635
|
+
const getStreams = (params, callback, config) => {
|
|
38636
|
+
const { log, cache, userId } = getActiveClient();
|
|
38637
|
+
if (!cache) {
|
|
38638
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
38639
|
+
}
|
|
38640
|
+
const timestamp = Date.now();
|
|
38641
|
+
log(`getStreams(tmpid: ${timestamp}) > listen`);
|
|
38642
|
+
const liveCollection = new GetStreamsLiveCollectionController(params, callback);
|
|
38643
|
+
const disposers = liveCollection.startSubscription();
|
|
38644
|
+
const cacheKey = liveCollection.getCacheKey();
|
|
38645
|
+
disposers.push(() => {
|
|
38646
|
+
dropFromCache(cacheKey);
|
|
38647
|
+
});
|
|
38576
38648
|
return () => {
|
|
38577
38649
|
log(`getStreams(tmpid: ${timestamp}) > dispose`);
|
|
38578
38650
|
disposers.forEach(fn => fn());
|
|
38579
38651
|
};
|
|
38580
|
-
};
|
|
38581
|
-
/* end_public_function */
|
|
38652
|
+
};
|
|
38582
38653
|
|
|
38583
38654
|
var index$3 = /*#__PURE__*/Object.freeze({
|
|
38584
38655
|
__proto__: null,
|
|
@@ -38586,11 +38657,13 @@ var index$3 = /*#__PURE__*/Object.freeze({
|
|
|
38586
38657
|
updateStream: updateStream,
|
|
38587
38658
|
deleteStream: deleteStream,
|
|
38588
38659
|
disposeStream: disposeStream,
|
|
38589
|
-
queryStreams: queryStreams
|
|
38660
|
+
queryStreams: queryStreams,
|
|
38590
38661
|
getStream: getStream,
|
|
38591
38662
|
onStreamStarted: onStreamStarted,
|
|
38592
38663
|
onStreamStopped: onStreamStopped,
|
|
38593
38664
|
onStreamRecorded: onStreamRecorded,
|
|
38665
|
+
onStreamFlagged: onStreamFlagged,
|
|
38666
|
+
onStreamTerminated: onStreamTerminated,
|
|
38594
38667
|
getStreamById: getStreamById,
|
|
38595
38668
|
getStreams: getStreams
|
|
38596
38669
|
});
|
|
@@ -38923,7 +38996,7 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
38923
38996
|
getPoll: getPoll
|
|
38924
38997
|
});
|
|
38925
38998
|
|
|
38926
|
-
const privateKey = "-----BEGIN PRIVATE KEY-----\
|
|
38999
|
+
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-----";
|
|
38927
39000
|
/*
|
|
38928
39001
|
* The crypto algorithm used for importing key and signing string
|
|
38929
39002
|
*/
|