@amityco/ts-sdk 7.11.1-fec87c5.0 → 7.12.1-501d118.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/dist/@types/core/events.d.ts +5 -4
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/linkPreviewMetadata.d.ts +12 -0
- package/dist/@types/core/linkPreviewMetadata.d.ts.map +1 -0
- package/dist/@types/domains/community.d.ts +2 -7
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +10 -0
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/room.d.ts +12 -2
- package/dist/@types/domains/room.d.ts.map +1 -1
- package/dist/client/api/fetchLinkPreview.d.ts +3 -0
- package/dist/client/api/fetchLinkPreview.d.ts.map +1 -1
- package/dist/client/api/getLinkPreviewMetadata.d.ts +14 -0
- package/dist/client/api/getLinkPreviewMetadata.d.ts.map +1 -0
- package/dist/client/api/index.d.ts +1 -0
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/core/events.d.ts +3 -3
- package/dist/core/events.d.ts.map +1 -1
- package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -1
- package/dist/index.cjs.js +631 -475
- package/dist/index.esm.js +487 -331
- package/dist/index.umd.js +3 -3
- package/dist/liveReactionRepository/api/createReaction.d.ts +7 -2
- package/dist/liveReactionRepository/api/createReaction.d.ts.map +1 -1
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts +3 -2
- package/dist/liveReactionRepository/internalApi/createLiveReaction.d.ts.map +1 -1
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts +2 -1
- package/dist/liveReactionRepository/service/ReactionSyncEngine.d.ts.map +1 -1
- package/dist/postRepository/api/createPost.d.ts +1 -0
- package/dist/postRepository/api/createPost.d.ts.map +1 -1
- package/dist/postRepository/api/editPost.d.ts +1 -0
- package/dist/postRepository/api/editPost.d.ts.map +1 -1
- package/dist/roomRepository/events/index.d.ts +2 -0
- package/dist/roomRepository/events/index.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts +1 -1
- package/dist/roomRepository/events/onRoomParticipantJoined.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts +1 -1
- package/dist/roomRepository/events/onRoomParticipantLeft.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomParticipantRemoved.d.ts +1 -1
- package/dist/roomRepository/events/onRoomParticipantRemoved.d.ts.map +1 -1
- package/dist/roomRepository/events/onRoomParticipantStageJoined.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantStageJoined.d.ts.map +1 -0
- package/dist/roomRepository/events/onRoomParticipantStageLeft.d.ts +17 -0
- package/dist/roomRepository/events/onRoomParticipantStageLeft.d.ts.map +1 -0
- package/dist/roomRepository/observers/getRoom.d.ts.map +1 -1
- package/dist/roomRepository/observers/getRooms/RoomLiveCollectionController.d.ts.map +1 -1
- package/dist/roomRepository/observers/utils.d.ts +1 -0
- package/dist/roomRepository/observers/utils.d.ts.map +1 -1
- package/dist/utils/linkedObject/roomLinkedObject.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -224,8 +224,8 @@ var AmityEventOrderOption;
|
|
|
224
224
|
|
|
225
225
|
function getVersion() {
|
|
226
226
|
try {
|
|
227
|
-
// the string ''v7.
|
|
228
|
-
return 'v7.
|
|
227
|
+
// the string ''v7.12.0-esm'' should be replaced by actual value by @rollup/plugin-replace
|
|
228
|
+
return 'v7.12.0-esm';
|
|
229
229
|
}
|
|
230
230
|
catch (error) {
|
|
231
231
|
return '__dev__';
|
|
@@ -24622,12 +24622,13 @@ var objectResolverEngineOnLoginHandler = () => {
|
|
|
24622
24622
|
* @category Live Reaction API
|
|
24623
24623
|
* @async
|
|
24624
24624
|
*/
|
|
24625
|
-
const createLiveReaction = async ({ reactions, liveStreamId, }) => {
|
|
24625
|
+
const createLiveReaction = async ({ reactions, liveStreamId, roomId, }) => {
|
|
24626
24626
|
const client = getActiveClient();
|
|
24627
24627
|
client.log('live_reaction/addReaction', reactions);
|
|
24628
24628
|
const { data } = await client.http.post(`/api/v1/reactions/live`, {
|
|
24629
24629
|
liveStreamId,
|
|
24630
24630
|
reactions,
|
|
24631
|
+
roomId,
|
|
24631
24632
|
});
|
|
24632
24633
|
return data;
|
|
24633
24634
|
};
|
|
@@ -24684,19 +24685,23 @@ class LiveReactionSyncEngine {
|
|
|
24684
24685
|
// Clear buffer
|
|
24685
24686
|
this.clearBuffer();
|
|
24686
24687
|
const payloads = reactions.reduce((prev, curr) => {
|
|
24687
|
-
const { roomId } = curr, rest = __rest(curr, ["roomId"]);
|
|
24688
|
-
|
|
24688
|
+
const { roomId, streamId } = curr, rest = __rest(curr, ["roomId", "streamId"]);
|
|
24689
|
+
const referenceType = streamId ? 'liveStream' : 'room';
|
|
24690
|
+
const referenceId = streamId !== null && streamId !== void 0 ? streamId : roomId;
|
|
24691
|
+
if (!prev[referenceId]) {
|
|
24689
24692
|
// eslint-disable-next-line no-param-reassign
|
|
24690
|
-
prev[
|
|
24693
|
+
prev[referenceId] = { referenceType, reactions: [] };
|
|
24694
|
+
prev[referenceId].reactions.push(rest);
|
|
24691
24695
|
}
|
|
24692
24696
|
else
|
|
24693
|
-
prev[
|
|
24697
|
+
prev[referenceId].reactions.push(rest);
|
|
24694
24698
|
return prev;
|
|
24695
24699
|
}, {});
|
|
24696
24700
|
// Call server api `POST /api/v1/reactions/live` to sync live reactions
|
|
24697
|
-
Object.entries(payloads).forEach(([
|
|
24701
|
+
Object.entries(payloads).forEach(([referenceId, reactionPayload]) => {
|
|
24702
|
+
const referenceIdName = reactionPayload.referenceType === 'room' ? 'roomId' : 'liveStreamId';
|
|
24698
24703
|
createLiveReaction({
|
|
24699
|
-
|
|
24704
|
+
[referenceIdName]: referenceId,
|
|
24700
24705
|
reactions,
|
|
24701
24706
|
});
|
|
24702
24707
|
});
|
|
@@ -26087,6 +26092,9 @@ function setUploadedFileAccessType(accessType) {
|
|
|
26087
26092
|
GlobalFileAccessType$1.getInstance().setFileAccessType(accessType);
|
|
26088
26093
|
}
|
|
26089
26094
|
|
|
26095
|
+
/**
|
|
26096
|
+
* @deprecated This function will to be deprecated and use the new getLinkPreviewMetadata
|
|
26097
|
+
*/
|
|
26090
26098
|
/**
|
|
26091
26099
|
* ```js
|
|
26092
26100
|
* import { fetchLinkPreview } from '@amityco/ts-sdk'
|
|
@@ -26109,6 +26117,24 @@ const fetchLinkPreview = async (url) => {
|
|
|
26109
26117
|
return data;
|
|
26110
26118
|
};
|
|
26111
26119
|
|
|
26120
|
+
/**
|
|
26121
|
+
* ```js
|
|
26122
|
+
* import { getLinkPreviewMetadata } from '@amityco/ts-sdk'
|
|
26123
|
+
* const { title, description, imageUrl } = getLinkPreviewMetadata('https://www.example.com/')
|
|
26124
|
+
* ```
|
|
26125
|
+
*
|
|
26126
|
+
*
|
|
26127
|
+
* @param url the url to fetch link preview
|
|
26128
|
+
* @returns A {@link Amity.LinkPreviewMetadata} instance
|
|
26129
|
+
*
|
|
26130
|
+
* @category Client API
|
|
26131
|
+
* */
|
|
26132
|
+
const getLinkPreviewMetadata = async (url) => {
|
|
26133
|
+
const client = getActiveClient();
|
|
26134
|
+
const { data } = await client.http.get(`/api/v1/link-preview?url=${url}`);
|
|
26135
|
+
return data;
|
|
26136
|
+
};
|
|
26137
|
+
|
|
26112
26138
|
/**
|
|
26113
26139
|
* ```js
|
|
26114
26140
|
* import Client from '@amityco/ts-sdk'
|
|
@@ -26638,6 +26664,7 @@ var index$r = /*#__PURE__*/Object.freeze({
|
|
|
26638
26664
|
enableUnreadCount: enableUnreadCount,
|
|
26639
26665
|
setUploadedFileAccessType: setUploadedFileAccessType,
|
|
26640
26666
|
fetchLinkPreview: fetchLinkPreview,
|
|
26667
|
+
getLinkPreviewMetadata: getLinkPreviewMetadata,
|
|
26641
26668
|
getSocialSettings: getSocialSettings,
|
|
26642
26669
|
getShareableLinkConfiguration: getShareableLinkConfiguration,
|
|
26643
26670
|
loginAsVisitor: loginAsVisitor,
|
|
@@ -28538,12 +28565,9 @@ const rejectInvitation = async (invitationId) => {
|
|
|
28538
28565
|
};
|
|
28539
28566
|
/* end_public_function */
|
|
28540
28567
|
|
|
28541
|
-
|
|
28542
|
-
(
|
|
28543
|
-
|
|
28544
|
-
InvitationActionsEnum["OnLocalInvitationUpdated"] = "onLocalInvitationUpdated";
|
|
28545
|
-
InvitationActionsEnum["OnLocalInvitationCanceled"] = "onLocalInvitationCanceled";
|
|
28546
|
-
})(InvitationActionsEnum || (InvitationActionsEnum = {}));
|
|
28568
|
+
const prepareMyInvitationsPayload = (rawPayload) => {
|
|
28569
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
|
|
28570
|
+
};
|
|
28547
28571
|
|
|
28548
28572
|
const invitationLinkedObject = (invitation) => {
|
|
28549
28573
|
return Object.assign(Object.assign({}, invitation), { get user() {
|
|
@@ -28577,274 +28601,6 @@ const invitationLinkedObject = (invitation) => {
|
|
|
28577
28601
|
} });
|
|
28578
28602
|
};
|
|
28579
28603
|
|
|
28580
|
-
class InvitationsPaginationController extends PaginationController {
|
|
28581
|
-
async getRequest(queryParams, token) {
|
|
28582
|
-
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
28583
|
-
const options = token ? { token } : { limit };
|
|
28584
|
-
const { data } = await this.http.get('/api/v1/invitations', { params: Object.assign(Object.assign({}, params), { options }) });
|
|
28585
|
-
return data;
|
|
28586
|
-
}
|
|
28587
|
-
}
|
|
28588
|
-
|
|
28589
|
-
class InvitationsQueryStreamController extends QueryStreamController {
|
|
28590
|
-
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
28591
|
-
super(query, cacheKey);
|
|
28592
|
-
this.notifyChange = notifyChange;
|
|
28593
|
-
this.preparePayload = preparePayload;
|
|
28594
|
-
}
|
|
28595
|
-
async saveToMainDB(response) {
|
|
28596
|
-
const processedPayload = await this.preparePayload(response);
|
|
28597
|
-
const client = getActiveClient();
|
|
28598
|
-
const cachedAt = client.cache && Date.now();
|
|
28599
|
-
if (client.cache) {
|
|
28600
|
-
ingestInCache(processedPayload, { cachedAt });
|
|
28601
|
-
}
|
|
28602
|
-
}
|
|
28603
|
-
appendToQueryStream(response, direction, refresh = false) {
|
|
28604
|
-
var _a, _b;
|
|
28605
|
-
if (refresh) {
|
|
28606
|
-
pushToCache(this.cacheKey, {
|
|
28607
|
-
data: response.invitations.map(getResolver('invitation')),
|
|
28608
|
-
});
|
|
28609
|
-
}
|
|
28610
|
-
else {
|
|
28611
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28612
|
-
const invitations = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
28613
|
-
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
28614
|
-
...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
|
|
28615
|
-
] }));
|
|
28616
|
-
}
|
|
28617
|
-
}
|
|
28618
|
-
reactor(action) {
|
|
28619
|
-
return (invitations) => {
|
|
28620
|
-
var _a;
|
|
28621
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28622
|
-
if (!collection)
|
|
28623
|
-
return;
|
|
28624
|
-
if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
|
|
28625
|
-
const isExist = collection.data.find(id => id === invitations[0].invitationId);
|
|
28626
|
-
if (!isExist)
|
|
28627
|
-
return;
|
|
28628
|
-
}
|
|
28629
|
-
if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
|
|
28630
|
-
collection.data = [
|
|
28631
|
-
...new Set([
|
|
28632
|
-
...invitations.map(invitation => invitation.invitationId),
|
|
28633
|
-
...collection.data,
|
|
28634
|
-
]),
|
|
28635
|
-
];
|
|
28636
|
-
}
|
|
28637
|
-
if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
|
|
28638
|
-
collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
|
|
28639
|
-
}
|
|
28640
|
-
pushToCache(this.cacheKey, collection);
|
|
28641
|
-
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
28642
|
-
};
|
|
28643
|
-
}
|
|
28644
|
-
subscribeRTE(createSubscriber) {
|
|
28645
|
-
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
28646
|
-
}
|
|
28647
|
-
}
|
|
28648
|
-
|
|
28649
|
-
/**
|
|
28650
|
-
* ```js
|
|
28651
|
-
* import { onLocalInvitationCreated } from '@amityco/ts-sdk'
|
|
28652
|
-
* const dispose = onLocalInvitationCreated(data => {
|
|
28653
|
-
* // ...
|
|
28654
|
-
* })
|
|
28655
|
-
* ```
|
|
28656
|
-
*
|
|
28657
|
-
* Fired when an {@link Amity.InvitationPayload} has been created
|
|
28658
|
-
*
|
|
28659
|
-
* @param callback The function to call when the event was fired
|
|
28660
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28661
|
-
*
|
|
28662
|
-
* @category Invitation Events
|
|
28663
|
-
*/
|
|
28664
|
-
const onLocalInvitationCreated = (callback) => {
|
|
28665
|
-
const client = getActiveClient();
|
|
28666
|
-
const disposers = [
|
|
28667
|
-
createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload => callback(payload)),
|
|
28668
|
-
];
|
|
28669
|
-
return () => {
|
|
28670
|
-
disposers.forEach(fn => fn());
|
|
28671
|
-
};
|
|
28672
|
-
};
|
|
28673
|
-
|
|
28674
|
-
/**
|
|
28675
|
-
* ```js
|
|
28676
|
-
* import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
|
|
28677
|
-
* const dispose = onLocalInvitationUpdated(data => {
|
|
28678
|
-
* // ...
|
|
28679
|
-
* })
|
|
28680
|
-
* ```
|
|
28681
|
-
*
|
|
28682
|
-
* Fired when an {@link Amity.InvitationPayload} has been updated
|
|
28683
|
-
*
|
|
28684
|
-
* @param callback The function to call when the event was fired
|
|
28685
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28686
|
-
*
|
|
28687
|
-
* @category Invitation Events
|
|
28688
|
-
*/
|
|
28689
|
-
const onLocalInvitationUpdated = (callback) => {
|
|
28690
|
-
const client = getActiveClient();
|
|
28691
|
-
const disposers = [
|
|
28692
|
-
createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload => callback(payload)),
|
|
28693
|
-
];
|
|
28694
|
-
return () => {
|
|
28695
|
-
disposers.forEach(fn => fn());
|
|
28696
|
-
};
|
|
28697
|
-
};
|
|
28698
|
-
|
|
28699
|
-
/**
|
|
28700
|
-
* ```js
|
|
28701
|
-
* import { onLocalInvitationCanceled } from '@amityco/ts-sdk'
|
|
28702
|
-
* const dispose = onLocalInvitationCanceled(data => {
|
|
28703
|
-
* // ...
|
|
28704
|
-
* })
|
|
28705
|
-
* ```
|
|
28706
|
-
*
|
|
28707
|
-
* Fired when an {@link Amity.InvitationPayload} has been deleted
|
|
28708
|
-
*
|
|
28709
|
-
* @param callback The function to call when the event was fired
|
|
28710
|
-
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
28711
|
-
*
|
|
28712
|
-
* @category Invitation Events
|
|
28713
|
-
*/
|
|
28714
|
-
const onLocalInvitationCanceled = (callback) => {
|
|
28715
|
-
const client = getActiveClient();
|
|
28716
|
-
const disposers = [
|
|
28717
|
-
createEventSubscriber(client, 'onLocalInvitationCanceled', 'local.invitation.canceled', payload => callback(payload)),
|
|
28718
|
-
];
|
|
28719
|
-
return () => {
|
|
28720
|
-
disposers.forEach(fn => fn());
|
|
28721
|
-
};
|
|
28722
|
-
};
|
|
28723
|
-
|
|
28724
|
-
class InvitationsLiveCollectionController extends LiveCollectionController {
|
|
28725
|
-
constructor(query, callback) {
|
|
28726
|
-
const queryStreamId = hash(query);
|
|
28727
|
-
const cacheKey = ['invitation', 'collection', queryStreamId];
|
|
28728
|
-
const paginationController = new InvitationsPaginationController(query);
|
|
28729
|
-
super(paginationController, queryStreamId, cacheKey, callback);
|
|
28730
|
-
this.query = query;
|
|
28731
|
-
this.queryStreamController = new InvitationsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareInvitationPayload);
|
|
28732
|
-
this.callback = callback.bind(this);
|
|
28733
|
-
this.loadPage({ initial: true });
|
|
28734
|
-
}
|
|
28735
|
-
setup() {
|
|
28736
|
-
var _a;
|
|
28737
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28738
|
-
if (!collection) {
|
|
28739
|
-
pushToCache(this.cacheKey, {
|
|
28740
|
-
data: [],
|
|
28741
|
-
params: this.query,
|
|
28742
|
-
});
|
|
28743
|
-
}
|
|
28744
|
-
}
|
|
28745
|
-
async persistModel(queryPayload) {
|
|
28746
|
-
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
28747
|
-
}
|
|
28748
|
-
persistQueryStream({ response, direction, refresh, }) {
|
|
28749
|
-
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
28750
|
-
}
|
|
28751
|
-
startSubscription() {
|
|
28752
|
-
return this.queryStreamController.subscribeRTE([
|
|
28753
|
-
{
|
|
28754
|
-
fn: onLocalInvitationCreated,
|
|
28755
|
-
action: InvitationActionsEnum.OnLocalInvitationCreated,
|
|
28756
|
-
},
|
|
28757
|
-
{
|
|
28758
|
-
fn: onLocalInvitationUpdated,
|
|
28759
|
-
action: InvitationActionsEnum.OnLocalInvitationUpdated,
|
|
28760
|
-
},
|
|
28761
|
-
{
|
|
28762
|
-
fn: onLocalInvitationCanceled,
|
|
28763
|
-
action: InvitationActionsEnum.OnLocalInvitationCanceled,
|
|
28764
|
-
},
|
|
28765
|
-
]);
|
|
28766
|
-
}
|
|
28767
|
-
notifyChange({ origin, loading, error }) {
|
|
28768
|
-
var _a, _b;
|
|
28769
|
-
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
28770
|
-
if (!collection)
|
|
28771
|
-
return;
|
|
28772
|
-
const data = this.applyFilter((_b = collection.data
|
|
28773
|
-
.map(id => pullFromCache(['invitation', 'get', id]))
|
|
28774
|
-
.filter(isNonNullable)
|
|
28775
|
-
.map(({ data }) => invitationLinkedObject(data))) !== null && _b !== void 0 ? _b : []);
|
|
28776
|
-
if (!this.shouldNotify(data) && origin === 'event')
|
|
28777
|
-
return;
|
|
28778
|
-
this.callback({
|
|
28779
|
-
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
28780
|
-
data,
|
|
28781
|
-
hasNextPage: !!this.paginationController.getNextToken(),
|
|
28782
|
-
loading,
|
|
28783
|
-
error,
|
|
28784
|
-
});
|
|
28785
|
-
}
|
|
28786
|
-
applyFilter(data) {
|
|
28787
|
-
let invitations = data;
|
|
28788
|
-
if (this.query.targetId) {
|
|
28789
|
-
invitations = invitations.filter(invitation => invitation.targetId === this.query.targetId);
|
|
28790
|
-
}
|
|
28791
|
-
if (this.query.statuses) {
|
|
28792
|
-
invitations = invitations.filter(invitation => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(invitation.status); });
|
|
28793
|
-
}
|
|
28794
|
-
if (this.query.targetType) {
|
|
28795
|
-
invitations = invitations.filter(invitation => invitation.targetType === this.query.targetType);
|
|
28796
|
-
}
|
|
28797
|
-
if (this.query.type) {
|
|
28798
|
-
invitations = invitations.filter(invitation => invitation.type === this.query.type);
|
|
28799
|
-
}
|
|
28800
|
-
const sortFn = (() => {
|
|
28801
|
-
switch (this.query.sortBy) {
|
|
28802
|
-
case 'firstCreated':
|
|
28803
|
-
return sortByFirstCreated;
|
|
28804
|
-
case 'lastCreated':
|
|
28805
|
-
return sortByLastCreated;
|
|
28806
|
-
default:
|
|
28807
|
-
return sortByLastCreated;
|
|
28808
|
-
}
|
|
28809
|
-
})();
|
|
28810
|
-
invitations = invitations.sort(sortFn);
|
|
28811
|
-
return invitations;
|
|
28812
|
-
}
|
|
28813
|
-
}
|
|
28814
|
-
|
|
28815
|
-
/**
|
|
28816
|
-
* Get invitations
|
|
28817
|
-
*
|
|
28818
|
-
* @param params the query parameters
|
|
28819
|
-
* @param callback the callback to be called when the invitations are updated
|
|
28820
|
-
* @returns invitations
|
|
28821
|
-
*
|
|
28822
|
-
* @category Invitation Live Collection
|
|
28823
|
-
*
|
|
28824
|
-
*/
|
|
28825
|
-
const getInvitations$1 = (params, callback, config) => {
|
|
28826
|
-
const { log, cache } = getActiveClient();
|
|
28827
|
-
if (!cache) {
|
|
28828
|
-
console.log(ENABLE_CACHE_MESSAGE);
|
|
28829
|
-
}
|
|
28830
|
-
const timestamp = Date.now();
|
|
28831
|
-
log(`getInvitations: (tmpid: ${timestamp}) > listen`);
|
|
28832
|
-
const invitationsLiveCollection = new InvitationsLiveCollectionController(params, callback);
|
|
28833
|
-
const disposers = invitationsLiveCollection.startSubscription();
|
|
28834
|
-
const cacheKey = invitationsLiveCollection.getCacheKey();
|
|
28835
|
-
disposers.push(() => {
|
|
28836
|
-
dropFromCache(cacheKey);
|
|
28837
|
-
});
|
|
28838
|
-
return () => {
|
|
28839
|
-
log(`getInvitations (tmpid: ${timestamp}) > dispose`);
|
|
28840
|
-
disposers.forEach(fn => fn());
|
|
28841
|
-
};
|
|
28842
|
-
};
|
|
28843
|
-
|
|
28844
|
-
const prepareMyInvitationsPayload = (rawPayload) => {
|
|
28845
|
-
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser), invitations: rawPayload.invitations.map(convertRawInvitationToInternalInvitation) });
|
|
28846
|
-
};
|
|
28847
|
-
|
|
28848
28604
|
/* begin_public_function
|
|
28849
28605
|
id: invitation.get
|
|
28850
28606
|
*/
|
|
@@ -28917,7 +28673,7 @@ const roomLinkedObject = (room) => {
|
|
|
28917
28673
|
targetType: 'room',
|
|
28918
28674
|
targetId: room.roomId,
|
|
28919
28675
|
userIds: [userId],
|
|
28920
|
-
}), getInvitations:
|
|
28676
|
+
}), getInvitations: async () => {
|
|
28921
28677
|
const { data } = await getInvitation({
|
|
28922
28678
|
targetId: room.roomId,
|
|
28923
28679
|
targetType: 'room',
|
|
@@ -29492,6 +29248,277 @@ const getJoinRequests = (params, callback, config) => {
|
|
|
29492
29248
|
};
|
|
29493
29249
|
};
|
|
29494
29250
|
|
|
29251
|
+
var InvitationActionsEnum;
|
|
29252
|
+
(function (InvitationActionsEnum) {
|
|
29253
|
+
InvitationActionsEnum["OnLocalInvitationCreated"] = "onLocalInvitationCreated";
|
|
29254
|
+
InvitationActionsEnum["OnLocalInvitationUpdated"] = "onLocalInvitationUpdated";
|
|
29255
|
+
InvitationActionsEnum["OnLocalInvitationCanceled"] = "onLocalInvitationCanceled";
|
|
29256
|
+
})(InvitationActionsEnum || (InvitationActionsEnum = {}));
|
|
29257
|
+
|
|
29258
|
+
class InvitationsPaginationController extends PaginationController {
|
|
29259
|
+
async getRequest(queryParams, token) {
|
|
29260
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
29261
|
+
const options = token ? { token } : { limit };
|
|
29262
|
+
const { data } = await this.http.get('/api/v1/invitations', { params: Object.assign(Object.assign({}, params), { options }) });
|
|
29263
|
+
return data;
|
|
29264
|
+
}
|
|
29265
|
+
}
|
|
29266
|
+
|
|
29267
|
+
class InvitationsQueryStreamController extends QueryStreamController {
|
|
29268
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
29269
|
+
super(query, cacheKey);
|
|
29270
|
+
this.notifyChange = notifyChange;
|
|
29271
|
+
this.preparePayload = preparePayload;
|
|
29272
|
+
}
|
|
29273
|
+
async saveToMainDB(response) {
|
|
29274
|
+
const processedPayload = await this.preparePayload(response);
|
|
29275
|
+
const client = getActiveClient();
|
|
29276
|
+
const cachedAt = client.cache && Date.now();
|
|
29277
|
+
if (client.cache) {
|
|
29278
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
29279
|
+
}
|
|
29280
|
+
}
|
|
29281
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
29282
|
+
var _a, _b;
|
|
29283
|
+
if (refresh) {
|
|
29284
|
+
pushToCache(this.cacheKey, {
|
|
29285
|
+
data: response.invitations.map(getResolver('invitation')),
|
|
29286
|
+
});
|
|
29287
|
+
}
|
|
29288
|
+
else {
|
|
29289
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29290
|
+
const invitations = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
29291
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [
|
|
29292
|
+
...new Set([...invitations, ...response.invitations.map(getResolver('invitation'))]),
|
|
29293
|
+
] }));
|
|
29294
|
+
}
|
|
29295
|
+
}
|
|
29296
|
+
reactor(action) {
|
|
29297
|
+
return (invitations) => {
|
|
29298
|
+
var _a;
|
|
29299
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29300
|
+
if (!collection)
|
|
29301
|
+
return;
|
|
29302
|
+
if (action === InvitationActionsEnum.OnLocalInvitationUpdated) {
|
|
29303
|
+
const isExist = collection.data.find(id => id === invitations[0].invitationId);
|
|
29304
|
+
if (!isExist)
|
|
29305
|
+
return;
|
|
29306
|
+
}
|
|
29307
|
+
if (action === InvitationActionsEnum.OnLocalInvitationCreated) {
|
|
29308
|
+
collection.data = [
|
|
29309
|
+
...new Set([
|
|
29310
|
+
...invitations.map(invitation => invitation.invitationId),
|
|
29311
|
+
...collection.data,
|
|
29312
|
+
]),
|
|
29313
|
+
];
|
|
29314
|
+
}
|
|
29315
|
+
if (action === InvitationActionsEnum.OnLocalInvitationDeleted) {
|
|
29316
|
+
collection.data = collection.data.filter(id => id !== invitations[0].invitationId);
|
|
29317
|
+
}
|
|
29318
|
+
pushToCache(this.cacheKey, collection);
|
|
29319
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
29320
|
+
};
|
|
29321
|
+
}
|
|
29322
|
+
subscribeRTE(createSubscriber) {
|
|
29323
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
29324
|
+
}
|
|
29325
|
+
}
|
|
29326
|
+
|
|
29327
|
+
/**
|
|
29328
|
+
* ```js
|
|
29329
|
+
* import { onLocalInvitationCreated } from '@amityco/ts-sdk'
|
|
29330
|
+
* const dispose = onLocalInvitationCreated(data => {
|
|
29331
|
+
* // ...
|
|
29332
|
+
* })
|
|
29333
|
+
* ```
|
|
29334
|
+
*
|
|
29335
|
+
* Fired when an {@link Amity.InvitationPayload} has been created
|
|
29336
|
+
*
|
|
29337
|
+
* @param callback The function to call when the event was fired
|
|
29338
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
29339
|
+
*
|
|
29340
|
+
* @category Invitation Events
|
|
29341
|
+
*/
|
|
29342
|
+
const onLocalInvitationCreated = (callback) => {
|
|
29343
|
+
const client = getActiveClient();
|
|
29344
|
+
const disposers = [
|
|
29345
|
+
createEventSubscriber(client, 'onLocalInvitationCreated', 'local.invitation.created', payload => callback(payload)),
|
|
29346
|
+
];
|
|
29347
|
+
return () => {
|
|
29348
|
+
disposers.forEach(fn => fn());
|
|
29349
|
+
};
|
|
29350
|
+
};
|
|
29351
|
+
|
|
29352
|
+
/**
|
|
29353
|
+
* ```js
|
|
29354
|
+
* import { onLocalInvitationUpdated } from '@amityco/ts-sdk'
|
|
29355
|
+
* const dispose = onLocalInvitationUpdated(data => {
|
|
29356
|
+
* // ...
|
|
29357
|
+
* })
|
|
29358
|
+
* ```
|
|
29359
|
+
*
|
|
29360
|
+
* Fired when an {@link Amity.InvitationPayload} has been updated
|
|
29361
|
+
*
|
|
29362
|
+
* @param callback The function to call when the event was fired
|
|
29363
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
29364
|
+
*
|
|
29365
|
+
* @category Invitation Events
|
|
29366
|
+
*/
|
|
29367
|
+
const onLocalInvitationUpdated = (callback) => {
|
|
29368
|
+
const client = getActiveClient();
|
|
29369
|
+
const disposers = [
|
|
29370
|
+
createEventSubscriber(client, 'onLocalInvitationUpdated', 'local.invitation.updated', payload => callback(payload)),
|
|
29371
|
+
];
|
|
29372
|
+
return () => {
|
|
29373
|
+
disposers.forEach(fn => fn());
|
|
29374
|
+
};
|
|
29375
|
+
};
|
|
29376
|
+
|
|
29377
|
+
/**
|
|
29378
|
+
* ```js
|
|
29379
|
+
* import { onLocalInvitationCanceled } from '@amityco/ts-sdk'
|
|
29380
|
+
* const dispose = onLocalInvitationCanceled(data => {
|
|
29381
|
+
* // ...
|
|
29382
|
+
* })
|
|
29383
|
+
* ```
|
|
29384
|
+
*
|
|
29385
|
+
* Fired when an {@link Amity.InvitationPayload} has been deleted
|
|
29386
|
+
*
|
|
29387
|
+
* @param callback The function to call when the event was fired
|
|
29388
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
29389
|
+
*
|
|
29390
|
+
* @category Invitation Events
|
|
29391
|
+
*/
|
|
29392
|
+
const onLocalInvitationCanceled = (callback) => {
|
|
29393
|
+
const client = getActiveClient();
|
|
29394
|
+
const disposers = [
|
|
29395
|
+
createEventSubscriber(client, 'onLocalInvitationCanceled', 'local.invitation.canceled', payload => callback(payload)),
|
|
29396
|
+
];
|
|
29397
|
+
return () => {
|
|
29398
|
+
disposers.forEach(fn => fn());
|
|
29399
|
+
};
|
|
29400
|
+
};
|
|
29401
|
+
|
|
29402
|
+
class InvitationsLiveCollectionController extends LiveCollectionController {
|
|
29403
|
+
constructor(query, callback) {
|
|
29404
|
+
const queryStreamId = hash(query);
|
|
29405
|
+
const cacheKey = ['invitation', 'collection', queryStreamId];
|
|
29406
|
+
const paginationController = new InvitationsPaginationController(query);
|
|
29407
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
29408
|
+
this.query = query;
|
|
29409
|
+
this.queryStreamController = new InvitationsQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareInvitationPayload);
|
|
29410
|
+
this.callback = callback.bind(this);
|
|
29411
|
+
this.loadPage({ initial: true });
|
|
29412
|
+
}
|
|
29413
|
+
setup() {
|
|
29414
|
+
var _a;
|
|
29415
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29416
|
+
if (!collection) {
|
|
29417
|
+
pushToCache(this.cacheKey, {
|
|
29418
|
+
data: [],
|
|
29419
|
+
params: this.query,
|
|
29420
|
+
});
|
|
29421
|
+
}
|
|
29422
|
+
}
|
|
29423
|
+
async persistModel(queryPayload) {
|
|
29424
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
29425
|
+
}
|
|
29426
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
29427
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
29428
|
+
}
|
|
29429
|
+
startSubscription() {
|
|
29430
|
+
return this.queryStreamController.subscribeRTE([
|
|
29431
|
+
{
|
|
29432
|
+
fn: onLocalInvitationCreated,
|
|
29433
|
+
action: InvitationActionsEnum.OnLocalInvitationCreated,
|
|
29434
|
+
},
|
|
29435
|
+
{
|
|
29436
|
+
fn: onLocalInvitationUpdated,
|
|
29437
|
+
action: InvitationActionsEnum.OnLocalInvitationUpdated,
|
|
29438
|
+
},
|
|
29439
|
+
{
|
|
29440
|
+
fn: onLocalInvitationCanceled,
|
|
29441
|
+
action: InvitationActionsEnum.OnLocalInvitationCanceled,
|
|
29442
|
+
},
|
|
29443
|
+
]);
|
|
29444
|
+
}
|
|
29445
|
+
notifyChange({ origin, loading, error }) {
|
|
29446
|
+
var _a, _b;
|
|
29447
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
29448
|
+
if (!collection)
|
|
29449
|
+
return;
|
|
29450
|
+
const data = this.applyFilter((_b = collection.data
|
|
29451
|
+
.map(id => pullFromCache(['invitation', 'get', id]))
|
|
29452
|
+
.filter(isNonNullable)
|
|
29453
|
+
.map(({ data }) => invitationLinkedObject(data))) !== null && _b !== void 0 ? _b : []);
|
|
29454
|
+
if (!this.shouldNotify(data) && origin === 'event')
|
|
29455
|
+
return;
|
|
29456
|
+
this.callback({
|
|
29457
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
29458
|
+
data,
|
|
29459
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
29460
|
+
loading,
|
|
29461
|
+
error,
|
|
29462
|
+
});
|
|
29463
|
+
}
|
|
29464
|
+
applyFilter(data) {
|
|
29465
|
+
let invitations = data;
|
|
29466
|
+
if (this.query.targetId) {
|
|
29467
|
+
invitations = invitations.filter(invitation => invitation.targetId === this.query.targetId);
|
|
29468
|
+
}
|
|
29469
|
+
if (this.query.statuses) {
|
|
29470
|
+
invitations = invitations.filter(invitation => { var _a; return (_a = this.query.statuses) === null || _a === void 0 ? void 0 : _a.includes(invitation.status); });
|
|
29471
|
+
}
|
|
29472
|
+
if (this.query.targetType) {
|
|
29473
|
+
invitations = invitations.filter(invitation => invitation.targetType === this.query.targetType);
|
|
29474
|
+
}
|
|
29475
|
+
if (this.query.type) {
|
|
29476
|
+
invitations = invitations.filter(invitation => invitation.type === this.query.type);
|
|
29477
|
+
}
|
|
29478
|
+
const sortFn = (() => {
|
|
29479
|
+
switch (this.query.sortBy) {
|
|
29480
|
+
case 'firstCreated':
|
|
29481
|
+
return sortByFirstCreated;
|
|
29482
|
+
case 'lastCreated':
|
|
29483
|
+
return sortByLastCreated;
|
|
29484
|
+
default:
|
|
29485
|
+
return sortByLastCreated;
|
|
29486
|
+
}
|
|
29487
|
+
})();
|
|
29488
|
+
invitations = invitations.sort(sortFn);
|
|
29489
|
+
return invitations;
|
|
29490
|
+
}
|
|
29491
|
+
}
|
|
29492
|
+
|
|
29493
|
+
/**
|
|
29494
|
+
* Get invitations
|
|
29495
|
+
*
|
|
29496
|
+
* @param params the query parameters
|
|
29497
|
+
* @param callback the callback to be called when the invitations are updated
|
|
29498
|
+
* @returns invitations
|
|
29499
|
+
*
|
|
29500
|
+
* @category Invitation Live Collection
|
|
29501
|
+
*
|
|
29502
|
+
*/
|
|
29503
|
+
const getInvitations$1 = (params, callback, config) => {
|
|
29504
|
+
const { log, cache } = getActiveClient();
|
|
29505
|
+
if (!cache) {
|
|
29506
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
29507
|
+
}
|
|
29508
|
+
const timestamp = Date.now();
|
|
29509
|
+
log(`getInvitations: (tmpid: ${timestamp}) > listen`);
|
|
29510
|
+
const invitationsLiveCollection = new InvitationsLiveCollectionController(params, callback);
|
|
29511
|
+
const disposers = invitationsLiveCollection.startSubscription();
|
|
29512
|
+
const cacheKey = invitationsLiveCollection.getCacheKey();
|
|
29513
|
+
disposers.push(() => {
|
|
29514
|
+
dropFromCache(cacheKey);
|
|
29515
|
+
});
|
|
29516
|
+
return () => {
|
|
29517
|
+
log(`getInvitations (tmpid: ${timestamp}) > dispose`);
|
|
29518
|
+
disposers.forEach(fn => fn());
|
|
29519
|
+
};
|
|
29520
|
+
};
|
|
29521
|
+
|
|
29495
29522
|
const communityLinkedObject = (community) => {
|
|
29496
29523
|
return Object.assign(Object.assign({}, community), { get categories() {
|
|
29497
29524
|
var _a;
|
|
@@ -44463,8 +44490,12 @@ const onRoomCoHostInviteCanceled = (callback) => {
|
|
|
44463
44490
|
const onRoomParticipantJoined = (callback) => {
|
|
44464
44491
|
const client = getActiveClient();
|
|
44465
44492
|
const filter = (payload) => {
|
|
44466
|
-
|
|
44467
|
-
|
|
44493
|
+
const { rooms, users } = payload;
|
|
44494
|
+
ingestInCache({ rooms, users });
|
|
44495
|
+
callback({
|
|
44496
|
+
room: roomLinkedObject(rooms[0]),
|
|
44497
|
+
actorInternalId: payload.eventActor.userInternalId,
|
|
44498
|
+
});
|
|
44468
44499
|
};
|
|
44469
44500
|
return createEventSubscriber(client, 'room/onRoomParticipantJoined', 'room.participantJoined', filter);
|
|
44470
44501
|
};
|
|
@@ -44487,12 +44518,72 @@ const onRoomParticipantJoined = (callback) => {
|
|
|
44487
44518
|
const onRoomParticipantLeft = (callback) => {
|
|
44488
44519
|
const client = getActiveClient();
|
|
44489
44520
|
const filter = (payload) => {
|
|
44490
|
-
|
|
44491
|
-
|
|
44521
|
+
const { rooms, users } = payload;
|
|
44522
|
+
ingestInCache({ rooms, users });
|
|
44523
|
+
callback({
|
|
44524
|
+
room: roomLinkedObject(rooms[0]),
|
|
44525
|
+
actorInternalId: payload.eventActor.userInternalId,
|
|
44526
|
+
});
|
|
44492
44527
|
};
|
|
44493
44528
|
return createEventSubscriber(client, 'room/onRoomParticipantLeft', 'room.participantLeft', filter);
|
|
44494
44529
|
};
|
|
44495
44530
|
|
|
44531
|
+
/**
|
|
44532
|
+
* ```js
|
|
44533
|
+
* import { onRoomParticipantStageLeft } from '@amityco/ts-sdk'
|
|
44534
|
+
* const dispose = onRoomParticipantStageLeft(room => {
|
|
44535
|
+
* // ...
|
|
44536
|
+
* })
|
|
44537
|
+
* ```
|
|
44538
|
+
*
|
|
44539
|
+
* Fired when a participant has left the stage of a {@link Amity.Room}
|
|
44540
|
+
*
|
|
44541
|
+
* @param callback The function to call when the event was fired
|
|
44542
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44543
|
+
*
|
|
44544
|
+
* @category Room Events
|
|
44545
|
+
*/
|
|
44546
|
+
const onRoomParticipantStageLeft = (callback) => {
|
|
44547
|
+
const client = getActiveClient();
|
|
44548
|
+
const filter = (payload) => {
|
|
44549
|
+
const { rooms, users } = payload;
|
|
44550
|
+
ingestInCache({ rooms, users });
|
|
44551
|
+
callback({
|
|
44552
|
+
room: roomLinkedObject(rooms[0]),
|
|
44553
|
+
actorInternalId: payload.eventActor.userInternalId,
|
|
44554
|
+
});
|
|
44555
|
+
};
|
|
44556
|
+
return createEventSubscriber(client, 'room/onRoomParticipantStageLeft', 'room.participantStageLeft', filter);
|
|
44557
|
+
};
|
|
44558
|
+
|
|
44559
|
+
/**
|
|
44560
|
+
* ```js
|
|
44561
|
+
* import { onRoomParticipantStageJoined } from '@amityco/ts-sdk'
|
|
44562
|
+
* const dispose = onRoomParticipantStageJoined(room => {
|
|
44563
|
+
* // ...
|
|
44564
|
+
* })
|
|
44565
|
+
* ```
|
|
44566
|
+
*
|
|
44567
|
+
* Fired when a participant has joined the stage of a {@link Amity.Room}
|
|
44568
|
+
*
|
|
44569
|
+
* @param callback The function to call when the event was fired
|
|
44570
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
44571
|
+
*
|
|
44572
|
+
* @category Room Events
|
|
44573
|
+
*/
|
|
44574
|
+
const onRoomParticipantStageJoined = (callback) => {
|
|
44575
|
+
const client = getActiveClient();
|
|
44576
|
+
const filter = (payload) => {
|
|
44577
|
+
const { rooms, users } = payload;
|
|
44578
|
+
ingestInCache({ rooms, users });
|
|
44579
|
+
callback({
|
|
44580
|
+
room: roomLinkedObject(rooms[0]),
|
|
44581
|
+
actorInternalId: payload.eventActor.userInternalId,
|
|
44582
|
+
});
|
|
44583
|
+
};
|
|
44584
|
+
return createEventSubscriber(client, 'room/onRoomParticipantStageJoined', 'room.participantStageJoined', filter);
|
|
44585
|
+
};
|
|
44586
|
+
|
|
44496
44587
|
/**
|
|
44497
44588
|
* ```js
|
|
44498
44589
|
* import { onRoomTerminated } from '@amityco/ts-sdk'
|
|
@@ -44631,8 +44722,12 @@ const onRoomStopped = (callback) => {
|
|
|
44631
44722
|
const onRoomParticipantRemoved = (callback) => {
|
|
44632
44723
|
const client = getActiveClient();
|
|
44633
44724
|
const filter = (payload) => {
|
|
44634
|
-
|
|
44635
|
-
|
|
44725
|
+
const { rooms, users } = payload;
|
|
44726
|
+
ingestInCache({ rooms, users });
|
|
44727
|
+
callback({
|
|
44728
|
+
room: roomLinkedObject(rooms[0]),
|
|
44729
|
+
actorInternalId: payload.eventActor.userInternalId,
|
|
44730
|
+
});
|
|
44636
44731
|
};
|
|
44637
44732
|
return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'room.participantRemoved', filter);
|
|
44638
44733
|
};
|
|
@@ -44685,6 +44780,68 @@ const onRoomParticipantRemovedLocal = (callback) => {
|
|
|
44685
44780
|
return createEventSubscriber(client, 'room/onRoomParticipantRemoved', 'local.room.participantRemoved', filter);
|
|
44686
44781
|
};
|
|
44687
44782
|
|
|
44783
|
+
var EnumRoomActions;
|
|
44784
|
+
(function (EnumRoomActions) {
|
|
44785
|
+
EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
|
|
44786
|
+
EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
|
|
44787
|
+
EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
|
|
44788
|
+
EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
|
|
44789
|
+
EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
|
|
44790
|
+
EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
|
|
44791
|
+
EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
|
|
44792
|
+
})(EnumRoomActions || (EnumRoomActions = {}));
|
|
44793
|
+
|
|
44794
|
+
const convertToRoomEventPayload = (eventHandler) => (callback) => eventHandler((payload) => {
|
|
44795
|
+
callback(payload.room);
|
|
44796
|
+
});
|
|
44797
|
+
// TODO: confirm related events
|
|
44798
|
+
const getRoomSubscription = () => [
|
|
44799
|
+
{
|
|
44800
|
+
fn: onRoomStartBroadcasting,
|
|
44801
|
+
action: EnumRoomActions.OnRoomStartBroadcasting,
|
|
44802
|
+
},
|
|
44803
|
+
{
|
|
44804
|
+
fn: onRoomEndBroadcasting,
|
|
44805
|
+
action: EnumRoomActions.OnRoomEndBroadcasting,
|
|
44806
|
+
},
|
|
44807
|
+
{
|
|
44808
|
+
fn: onRoomRecordedAvailable,
|
|
44809
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44810
|
+
},
|
|
44811
|
+
{
|
|
44812
|
+
fn: onRoomWaitingReconnect,
|
|
44813
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44814
|
+
},
|
|
44815
|
+
{
|
|
44816
|
+
fn: onRoomTerminated,
|
|
44817
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44818
|
+
},
|
|
44819
|
+
{
|
|
44820
|
+
fn: convertToRoomEventPayload(onRoomParticipantJoined),
|
|
44821
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44822
|
+
},
|
|
44823
|
+
{
|
|
44824
|
+
fn: convertToRoomEventPayload(onRoomParticipantLeft),
|
|
44825
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44826
|
+
},
|
|
44827
|
+
{
|
|
44828
|
+
fn: convertToRoomEventPayload(onRoomParticipantRemoved),
|
|
44829
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44830
|
+
},
|
|
44831
|
+
{
|
|
44832
|
+
fn: onRoomParticipantRemovedLocal,
|
|
44833
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44834
|
+
},
|
|
44835
|
+
{
|
|
44836
|
+
fn: convertToRoomEventPayload(onRoomParticipantStageJoined),
|
|
44837
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44838
|
+
},
|
|
44839
|
+
{
|
|
44840
|
+
fn: convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
|
|
44841
|
+
action: EnumRoomActions.OnRoomUpdated,
|
|
44842
|
+
},
|
|
44843
|
+
];
|
|
44844
|
+
|
|
44688
44845
|
const getRoom = (roomId, callback) => {
|
|
44689
44846
|
// TODO: add callbackDataSelector if there are linked object fields
|
|
44690
44847
|
return liveObject(roomId, callback, '_id', getRoomById, [
|
|
@@ -44693,10 +44850,11 @@ const getRoom = (roomId, callback) => {
|
|
|
44693
44850
|
onRoomWaitingReconnect,
|
|
44694
44851
|
onRoomTerminated,
|
|
44695
44852
|
onRoomRecordedAvailable,
|
|
44696
|
-
onRoomParticipantJoined,
|
|
44697
|
-
onRoomParticipantLeft,
|
|
44698
|
-
onRoomParticipantRemoved,
|
|
44853
|
+
convertToRoomEventPayload(onRoomParticipantJoined),
|
|
44854
|
+
convertToRoomEventPayload(onRoomParticipantLeft),
|
|
44855
|
+
convertToRoomEventPayload(onRoomParticipantRemoved),
|
|
44699
44856
|
onRoomParticipantRemovedLocal,
|
|
44857
|
+
convertToRoomEventPayload(onRoomParticipantStageJoined),
|
|
44700
44858
|
convertEventPayload(onRoomCoHostInviteAccepted, 'targetId', 'room'),
|
|
44701
44859
|
], {
|
|
44702
44860
|
callbackDataSelector: (data) => {
|
|
@@ -44721,17 +44879,6 @@ class RoomPaginationController extends PaginationController {
|
|
|
44721
44879
|
}
|
|
44722
44880
|
}
|
|
44723
44881
|
|
|
44724
|
-
var EnumRoomActions;
|
|
44725
|
-
(function (EnumRoomActions) {
|
|
44726
|
-
EnumRoomActions["OnRoomCreated"] = "OnRoomCreated";
|
|
44727
|
-
EnumRoomActions["OnRoomUpdated"] = "OnRoomUpdated";
|
|
44728
|
-
EnumRoomActions["OnRoomDeleted"] = "OnRoomDeleted";
|
|
44729
|
-
EnumRoomActions["OnRoomStartBroadcasting"] = "OnRoomStartBroadcasting";
|
|
44730
|
-
EnumRoomActions["OnRoomEndBroadcasting"] = "OnRoomEndBroadcasting";
|
|
44731
|
-
EnumRoomActions["OnRoomParticipantJoined"] = "OnRoomParticipantJoined";
|
|
44732
|
-
EnumRoomActions["OnRoomParticipantLeft"] = "OnRoomParticipantLeft";
|
|
44733
|
-
})(EnumRoomActions || (EnumRoomActions = {}));
|
|
44734
|
-
|
|
44735
44882
|
class RoomQueryStreamController extends QueryStreamController {
|
|
44736
44883
|
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
44737
44884
|
super(query, cacheKey);
|
|
@@ -44780,22 +44927,6 @@ class RoomQueryStreamController extends QueryStreamController {
|
|
|
44780
44927
|
}
|
|
44781
44928
|
}
|
|
44782
44929
|
|
|
44783
|
-
// TODO: confirm related events
|
|
44784
|
-
const getRoomSubscription = () => [
|
|
44785
|
-
{
|
|
44786
|
-
fn: onRoomStartBroadcasting,
|
|
44787
|
-
action: EnumRoomActions.OnRoomStartBroadcasting,
|
|
44788
|
-
},
|
|
44789
|
-
{
|
|
44790
|
-
fn: onRoomEndBroadcasting,
|
|
44791
|
-
action: EnumRoomActions.OnRoomEndBroadcasting,
|
|
44792
|
-
},
|
|
44793
|
-
{
|
|
44794
|
-
fn: onRoomRecordedAvailable,
|
|
44795
|
-
action: EnumRoomActions.OnRoomUpdated,
|
|
44796
|
-
},
|
|
44797
|
-
];
|
|
44798
|
-
|
|
44799
44930
|
class RoomLiveCollectionController extends LiveCollectionController {
|
|
44800
44931
|
constructor(query, callback) {
|
|
44801
44932
|
const queryStreamId = hash(query);
|
|
@@ -44834,7 +44965,7 @@ class RoomLiveCollectionController extends LiveCollectionController {
|
|
|
44834
44965
|
const data = this.applyFilter((_b = collection.data
|
|
44835
44966
|
.map(id => pullFromCache(['room', 'get', id]))
|
|
44836
44967
|
.filter(isNonNullable)
|
|
44837
|
-
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(
|
|
44968
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(roomLinkedObject);
|
|
44838
44969
|
if (!this.shouldNotify(data) && origin === 'event')
|
|
44839
44970
|
return;
|
|
44840
44971
|
this.callback({
|
|
@@ -44937,6 +45068,8 @@ var index$b = /*#__PURE__*/Object.freeze({
|
|
|
44937
45068
|
onRoomCoHostInviteCanceled: onRoomCoHostInviteCanceled,
|
|
44938
45069
|
onRoomParticipantJoined: onRoomParticipantJoined,
|
|
44939
45070
|
onRoomParticipantLeft: onRoomParticipantLeft,
|
|
45071
|
+
onRoomParticipantStageLeft: onRoomParticipantStageLeft,
|
|
45072
|
+
onRoomParticipantStageJoined: onRoomParticipantStageJoined,
|
|
44940
45073
|
onRoomTerminated: onRoomTerminated,
|
|
44941
45074
|
onRoomCreated: onRoomCreated,
|
|
44942
45075
|
onRoomUpdated: onRoomUpdated,
|
|
@@ -48740,24 +48873,30 @@ var index$2 = /*#__PURE__*/Object.freeze({
|
|
|
48740
48873
|
* @param referenceType should be 'post'
|
|
48741
48874
|
* @param reactionName that is the reaction name
|
|
48742
48875
|
* @param streamId stream id
|
|
48876
|
+
* @param roomId room id
|
|
48743
48877
|
* @returns a success boolean if the reaction was added
|
|
48744
48878
|
*
|
|
48745
48879
|
* @category Live Reaction API
|
|
48746
48880
|
* @async
|
|
48747
48881
|
*/
|
|
48748
|
-
const createReaction = async ({ referenceId, referenceType, reactionName, roomId, }) => {
|
|
48882
|
+
const createReaction = async ({ referenceId, referenceType, reactionName, streamId, roomId, }) => {
|
|
48749
48883
|
const client = getActiveClient();
|
|
48750
48884
|
client.log('live_reaction/createReaction', {
|
|
48751
48885
|
referenceId,
|
|
48752
48886
|
referenceType,
|
|
48753
48887
|
reactionName,
|
|
48888
|
+
streamId,
|
|
48889
|
+
roomId,
|
|
48754
48890
|
});
|
|
48891
|
+
if (!streamId && !roomId)
|
|
48892
|
+
throw new ASCError('You have to specify either streamId or roomId', 800110 /* Amity.ClientError.INVALID_PARAMETERS */, "error" /* Amity.ErrorLevel.ERROR */);
|
|
48755
48893
|
const reactionSynceEngine = ReactionSyncEngine.getInstance();
|
|
48756
48894
|
const reaction = {
|
|
48757
48895
|
reactionName,
|
|
48758
48896
|
referencePublicId: referenceId,
|
|
48759
48897
|
referenceType,
|
|
48760
48898
|
roomId,
|
|
48899
|
+
streamId,
|
|
48761
48900
|
occurredAt: new Date().toISOString(),
|
|
48762
48901
|
};
|
|
48763
48902
|
reactionSynceEngine.createLiveReaction(reaction);
|
|
@@ -48947,15 +49086,32 @@ const updateEvent = async (eventId, bundle) => {
|
|
|
48947
49086
|
const getEvent$1 = async (eventId) => {
|
|
48948
49087
|
const client = getActiveClient();
|
|
48949
49088
|
client.log('event/getEvent', eventId);
|
|
48950
|
-
|
|
48951
|
-
|
|
48952
|
-
|
|
48953
|
-
|
|
48954
|
-
|
|
48955
|
-
|
|
48956
|
-
|
|
48957
|
-
|
|
48958
|
-
|
|
49089
|
+
try {
|
|
49090
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
|
|
49091
|
+
const data = prepareEventPayload(payload);
|
|
49092
|
+
const cachedAt = client.cache && Date.now();
|
|
49093
|
+
if (client.cache)
|
|
49094
|
+
ingestInCache(data, { cachedAt });
|
|
49095
|
+
return {
|
|
49096
|
+
data: data.events.find(event => event.eventId === eventId),
|
|
49097
|
+
cachedAt,
|
|
49098
|
+
};
|
|
49099
|
+
}
|
|
49100
|
+
catch (error) {
|
|
49101
|
+
if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
|
|
49102
|
+
const event = getEvent$1.locally(eventId);
|
|
49103
|
+
if (!event)
|
|
49104
|
+
throw error;
|
|
49105
|
+
const deletedEvent = Object.assign(Object.assign({}, event === null || event === void 0 ? void 0 : event.data), { isDeleted: true });
|
|
49106
|
+
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
49107
|
+
const cachedAt = client.cache && Date.now();
|
|
49108
|
+
return {
|
|
49109
|
+
data: deletedEvent,
|
|
49110
|
+
cachedAt,
|
|
49111
|
+
};
|
|
49112
|
+
}
|
|
49113
|
+
throw error;
|
|
49114
|
+
}
|
|
48959
49115
|
};
|
|
48960
49116
|
/* end_public_function */
|
|
48961
49117
|
/**
|