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