@amityco/ts-sdk 7.11.1-31db2c1f.0 → 7.11.1-36144a41.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 +32 -2
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +4 -0
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +17 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/permissions.d.ts +5 -1
- package/dist/@types/core/permissions.d.ts.map +1 -1
- package/dist/@types/core/transport.d.ts +3 -0
- package/dist/@types/core/transport.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts +11 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/event.d.ts +81 -0
- package/dist/@types/domains/event.d.ts.map +1 -0
- package/dist/@types/domains/partials.d.ts +2 -2
- package/dist/@types/domains/partials.d.ts.map +1 -1
- package/dist/@types/index.d.ts +1 -0
- package/dist/@types/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/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/eventRepository/api/createEvent.d.ts +16 -0
- package/dist/eventRepository/api/createEvent.d.ts.map +1 -0
- package/dist/eventRepository/api/deleteEvent.d.ts +15 -0
- package/dist/eventRepository/api/deleteEvent.d.ts.map +1 -0
- package/dist/eventRepository/api/index.d.ts +4 -0
- package/dist/eventRepository/api/index.d.ts.map +1 -0
- package/dist/eventRepository/api/updateEvent.d.ts +17 -0
- package/dist/eventRepository/api/updateEvent.d.ts.map +1 -0
- package/dist/eventRepository/events/enums.d.ts +6 -0
- package/dist/eventRepository/events/enums.d.ts.map +1 -0
- package/dist/eventRepository/events/index.d.ts +7 -0
- package/dist/eventRepository/events/index.d.ts.map +1 -0
- package/dist/eventRepository/events/onEventCreated.d.ts +17 -0
- package/dist/eventRepository/events/onEventCreated.d.ts.map +1 -0
- package/dist/eventRepository/events/onEventDeleted.d.ts +17 -0
- package/dist/eventRepository/events/onEventDeleted.d.ts.map +1 -0
- package/dist/eventRepository/events/onEventUpdated.d.ts +17 -0
- package/dist/eventRepository/events/onEventUpdated.d.ts.map +1 -0
- package/dist/eventRepository/events/onLocalEventCreated.d.ts +17 -0
- package/dist/eventRepository/events/onLocalEventCreated.d.ts.map +1 -0
- package/dist/eventRepository/events/onLocalEventDeleted.d.ts +17 -0
- package/dist/eventRepository/events/onLocalEventDeleted.d.ts.map +1 -0
- package/dist/eventRepository/events/onLocalEventUpdated.d.ts +17 -0
- package/dist/eventRepository/events/onLocalEventUpdated.d.ts.map +1 -0
- package/dist/eventRepository/index.d.ts +4 -0
- package/dist/eventRepository/index.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/getEvent.d.ts +32 -0
- package/dist/eventRepository/internalApi/getEvent.d.ts.map +1 -0
- package/dist/eventRepository/internalApi/index.d.ts +2 -0
- package/dist/eventRepository/internalApi/index.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvent.d.ts +21 -0
- package/dist/eventRepository/observers/getEvent.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts +13 -0
- package/dist/eventRepository/observers/getEvents/LiveCollectionController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvents/PaginationController.d.ts +5 -0
- package/dist/eventRepository/observers/getEvents/PaginationController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts +15 -0
- package/dist/eventRepository/observers/getEvents/QueryStreamController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getEvents.d.ts +12 -0
- package/dist/eventRepository/observers/getEvents.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts +13 -0
- package/dist/eventRepository/observers/getMyEvents/LiveCollectionController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts +5 -0
- package/dist/eventRepository/observers/getMyEvents/PaginationController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts +15 -0
- package/dist/eventRepository/observers/getMyEvents/QueryStreamController.d.ts.map +1 -0
- package/dist/eventRepository/observers/getMyEvents.d.ts +12 -0
- package/dist/eventRepository/observers/getMyEvents.d.ts.map +1 -0
- package/dist/eventRepository/observers/index.d.ts +4 -0
- package/dist/eventRepository/observers/index.d.ts.map +1 -0
- package/dist/eventRepository/utils/createEventEventSubscriber.d.ts +2 -0
- package/dist/eventRepository/utils/createEventEventSubscriber.d.ts.map +1 -0
- package/dist/eventRepository/utils/index.d.ts +3 -0
- package/dist/eventRepository/utils/index.d.ts.map +1 -0
- package/dist/eventRepository/utils/prepareEventPayload.d.ts +2 -0
- package/dist/eventRepository/utils/prepareEventPayload.d.ts.map +1 -0
- package/dist/index.cjs.js +735 -52
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +714 -32
- package/dist/index.umd.js +3 -3
- package/dist/messagePreview/utils/getChannelMessagePreviewWithUser.d.ts +1 -1
- package/dist/utils/linkedObject/eventLinkObject.d.ts +2 -0
- package/dist/utils/linkedObject/eventLinkObject.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/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -199,6 +199,30 @@ exports.FeedSourceEnum = void 0;
|
|
|
199
199
|
FeedSourceEnum["User"] = "user";
|
|
200
200
|
})(exports.FeedSourceEnum || (exports.FeedSourceEnum = {}));
|
|
201
201
|
|
|
202
|
+
exports.AmityEventType = void 0;
|
|
203
|
+
(function (AmityEventType) {
|
|
204
|
+
AmityEventType["Virtual"] = "virtual";
|
|
205
|
+
AmityEventType["InPerson"] = "in_person";
|
|
206
|
+
})(exports.AmityEventType || (exports.AmityEventType = {}));
|
|
207
|
+
exports.AmityEventOriginType = void 0;
|
|
208
|
+
(function (AmityEventOriginType) {
|
|
209
|
+
AmityEventOriginType["Community"] = "community";
|
|
210
|
+
AmityEventOriginType["User"] = "user";
|
|
211
|
+
})(exports.AmityEventOriginType || (exports.AmityEventOriginType = {}));
|
|
212
|
+
exports.AmityEventStatus = void 0;
|
|
213
|
+
(function (AmityEventStatus) {
|
|
214
|
+
AmityEventStatus["Scheduled"] = "scheduled";
|
|
215
|
+
AmityEventStatus["Live"] = "live";
|
|
216
|
+
AmityEventStatus["Ended"] = "ended";
|
|
217
|
+
AmityEventStatus["Cancelled"] = "cancelled";
|
|
218
|
+
})(exports.AmityEventStatus || (exports.AmityEventStatus = {}));
|
|
219
|
+
exports.AmityEventResponseStatus = void 0;
|
|
220
|
+
(function (AmityEventResponseStatus) {
|
|
221
|
+
AmityEventResponseStatus["Going"] = "going";
|
|
222
|
+
AmityEventResponseStatus["Interested"] = "interested";
|
|
223
|
+
AmityEventResponseStatus["NotGoing"] = "not_going";
|
|
224
|
+
})(exports.AmityEventResponseStatus || (exports.AmityEventResponseStatus = {}));
|
|
225
|
+
|
|
202
226
|
function getVersion() {
|
|
203
227
|
try {
|
|
204
228
|
// the string ''v7.11.0-cjs'' should be replaced by actual value by @rollup/plugin-replace
|
|
@@ -648,6 +672,8 @@ const idResolvers = {
|
|
|
648
672
|
invitation: ({ _id }) => _id,
|
|
649
673
|
joinRequest: ({ joinRequestId }) => joinRequestId,
|
|
650
674
|
room: ({ roomId }) => roomId,
|
|
675
|
+
event: ({ eventId }) => eventId,
|
|
676
|
+
discussionCommunity: ({ communityId }) => communityId,
|
|
651
677
|
};
|
|
652
678
|
/**
|
|
653
679
|
* Retrieve the id resolver matching a domain name
|
|
@@ -704,6 +730,8 @@ const PAYLOAD2MODEL = {
|
|
|
704
730
|
invitations: 'invitation',
|
|
705
731
|
joinRequests: 'joinRequest',
|
|
706
732
|
rooms: 'room',
|
|
733
|
+
events: 'event',
|
|
734
|
+
discussionCommunities: 'discussionCommunity',
|
|
707
735
|
};
|
|
708
736
|
/** hidden */
|
|
709
737
|
const isOutdated = (prevData, nextData) => {
|
|
@@ -10479,7 +10507,7 @@ const getUserUnread = (callback) => {
|
|
|
10479
10507
|
};
|
|
10480
10508
|
};
|
|
10481
10509
|
|
|
10482
|
-
var index$
|
|
10510
|
+
var index$q = /*#__PURE__*/Object.freeze({
|
|
10483
10511
|
__proto__: null,
|
|
10484
10512
|
getActiveClient: getActiveClient,
|
|
10485
10513
|
getActiveUser: getActiveUser,
|
|
@@ -11698,7 +11726,7 @@ const getMyFollowInfo = (callback) => {
|
|
|
11698
11726
|
};
|
|
11699
11727
|
/* end_public_function */
|
|
11700
11728
|
|
|
11701
|
-
var index$
|
|
11729
|
+
var index$p = /*#__PURE__*/Object.freeze({
|
|
11702
11730
|
__proto__: null,
|
|
11703
11731
|
blockUser: blockUser,
|
|
11704
11732
|
unBlockUser: unBlockUser,
|
|
@@ -13788,6 +13816,51 @@ const communityLinkedObject = (community) => {
|
|
|
13788
13816
|
} });
|
|
13789
13817
|
};
|
|
13790
13818
|
|
|
13819
|
+
const eventLinkedObject = (event) => {
|
|
13820
|
+
return Object.assign(Object.assign({}, event), { get creator() {
|
|
13821
|
+
const cacheData = pullFromCache(['user', 'get', event.userId]);
|
|
13822
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13823
|
+
return;
|
|
13824
|
+
return userLinkedObject(cacheData.data);
|
|
13825
|
+
},
|
|
13826
|
+
get discussionCommunity() {
|
|
13827
|
+
if (!event.discussionCommunityId)
|
|
13828
|
+
return;
|
|
13829
|
+
const cacheData = pullFromCache([
|
|
13830
|
+
'discussionCommunity',
|
|
13831
|
+
'get',
|
|
13832
|
+
event.discussionCommunityId,
|
|
13833
|
+
]);
|
|
13834
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13835
|
+
return;
|
|
13836
|
+
return communityLinkedObject(cacheData.data);
|
|
13837
|
+
},
|
|
13838
|
+
get targetCommunity() {
|
|
13839
|
+
if (!event.originId)
|
|
13840
|
+
return;
|
|
13841
|
+
const cacheData = pullFromCache(['community', 'get', event.originId]);
|
|
13842
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13843
|
+
return;
|
|
13844
|
+
return communityLinkedObject(cacheData.data);
|
|
13845
|
+
},
|
|
13846
|
+
get coverImage() {
|
|
13847
|
+
if (!event.coverImageFileId)
|
|
13848
|
+
return;
|
|
13849
|
+
const cacheData = pullFromCache(['file', 'get', event.coverImageFileId]);
|
|
13850
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13851
|
+
return;
|
|
13852
|
+
return cacheData.data;
|
|
13853
|
+
},
|
|
13854
|
+
get liveStream() {
|
|
13855
|
+
if (!event.livestreamId)
|
|
13856
|
+
return;
|
|
13857
|
+
const cacheData = pullFromCache(['stream', 'get', event.livestreamId]);
|
|
13858
|
+
if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
|
|
13859
|
+
return;
|
|
13860
|
+
return cacheData.data;
|
|
13861
|
+
} });
|
|
13862
|
+
};
|
|
13863
|
+
|
|
13791
13864
|
const LinkedObject = {
|
|
13792
13865
|
ad: adLinkedObject,
|
|
13793
13866
|
comment: commentLinkedObject,
|
|
@@ -13807,6 +13880,7 @@ const LinkedObject = {
|
|
|
13807
13880
|
joinRequest: joinRequestLinkedObject,
|
|
13808
13881
|
channelMember: channelMemberLinkedObject,
|
|
13809
13882
|
room: roomLinkedObject,
|
|
13883
|
+
event: eventLinkedObject,
|
|
13810
13884
|
};
|
|
13811
13885
|
|
|
13812
13886
|
/* begin_public_function
|
|
@@ -14797,9 +14871,9 @@ var AmityUserSearchMatchType;
|
|
|
14797
14871
|
AmityUserSearchMatchType["PARTIAL"] = "partial";
|
|
14798
14872
|
})(AmityUserSearchMatchType || (AmityUserSearchMatchType = {}));
|
|
14799
14873
|
|
|
14800
|
-
var index$
|
|
14874
|
+
var index$o = /*#__PURE__*/Object.freeze({
|
|
14801
14875
|
__proto__: null,
|
|
14802
|
-
Relationship: index$
|
|
14876
|
+
Relationship: index$p,
|
|
14803
14877
|
getUserByIds: getUserByIds,
|
|
14804
14878
|
updateUser: updateUser,
|
|
14805
14879
|
flagUser: flagUser,
|
|
@@ -15202,7 +15276,7 @@ const uploadAudio = async (formData, onProgress) => {
|
|
|
15202
15276
|
};
|
|
15203
15277
|
/* end_public_function */
|
|
15204
15278
|
|
|
15205
|
-
var index$
|
|
15279
|
+
var index$n = /*#__PURE__*/Object.freeze({
|
|
15206
15280
|
__proto__: null,
|
|
15207
15281
|
getFile: getFile,
|
|
15208
15282
|
uploadFile: uploadFile,
|
|
@@ -17014,7 +17088,7 @@ const getReactions$1 = (params, callback, config) => {
|
|
|
17014
17088
|
};
|
|
17015
17089
|
/* end_public_function */
|
|
17016
17090
|
|
|
17017
|
-
var index$
|
|
17091
|
+
var index$m = /*#__PURE__*/Object.freeze({
|
|
17018
17092
|
__proto__: null,
|
|
17019
17093
|
addReaction: addReaction,
|
|
17020
17094
|
removeReaction: removeReaction,
|
|
@@ -18786,7 +18860,7 @@ const getMessages = (params, callback, config) => {
|
|
|
18786
18860
|
};
|
|
18787
18861
|
/* end_public_function */
|
|
18788
18862
|
|
|
18789
|
-
var index$
|
|
18863
|
+
var index$l = /*#__PURE__*/Object.freeze({
|
|
18790
18864
|
__proto__: null,
|
|
18791
18865
|
createMessage: createMessage,
|
|
18792
18866
|
updateMessage: updateMessage,
|
|
@@ -19312,7 +19386,7 @@ const stopMessageReceiptSync = (subChannelId) => {
|
|
|
19312
19386
|
};
|
|
19313
19387
|
/* end_public_function */
|
|
19314
19388
|
|
|
19315
|
-
var index$
|
|
19389
|
+
var index$k = /*#__PURE__*/Object.freeze({
|
|
19316
19390
|
__proto__: null,
|
|
19317
19391
|
getSubChannelByIds: getSubChannels$1,
|
|
19318
19392
|
createSubChannel: createSubChannel,
|
|
@@ -20639,7 +20713,7 @@ const searchMembers$1 = (params, callback, config) => {
|
|
|
20639
20713
|
};
|
|
20640
20714
|
/* end_public_function */
|
|
20641
20715
|
|
|
20642
|
-
var index$
|
|
20716
|
+
var index$j = /*#__PURE__*/Object.freeze({
|
|
20643
20717
|
__proto__: null,
|
|
20644
20718
|
addMembers: addMembers$1,
|
|
20645
20719
|
removeMembers: removeMembers$1,
|
|
@@ -20842,7 +20916,7 @@ const unmuteMembers = async (channelId, userIds) => {
|
|
|
20842
20916
|
};
|
|
20843
20917
|
/* end_public_function */
|
|
20844
20918
|
|
|
20845
|
-
var index$
|
|
20919
|
+
var index$i = /*#__PURE__*/Object.freeze({
|
|
20846
20920
|
__proto__: null,
|
|
20847
20921
|
addRole: addRole,
|
|
20848
20922
|
removeRole: removeRole,
|
|
@@ -20852,10 +20926,10 @@ var index$h = /*#__PURE__*/Object.freeze({
|
|
|
20852
20926
|
unmuteMembers: unmuteMembers
|
|
20853
20927
|
});
|
|
20854
20928
|
|
|
20855
|
-
var index$
|
|
20929
|
+
var index$h = /*#__PURE__*/Object.freeze({
|
|
20856
20930
|
__proto__: null,
|
|
20857
|
-
Membership: index$
|
|
20858
|
-
Moderation: index$
|
|
20931
|
+
Membership: index$j,
|
|
20932
|
+
Moderation: index$i,
|
|
20859
20933
|
getChannelByIds: getChannelByIds$1,
|
|
20860
20934
|
createChannel: createChannel,
|
|
20861
20935
|
updateChannel: updateChannel,
|
|
@@ -22258,7 +22332,7 @@ const searchMembers = (params, callback, config) => {
|
|
|
22258
22332
|
};
|
|
22259
22333
|
/* end_public_function */
|
|
22260
22334
|
|
|
22261
|
-
var index$
|
|
22335
|
+
var index$g = /*#__PURE__*/Object.freeze({
|
|
22262
22336
|
__proto__: null,
|
|
22263
22337
|
addMembers: addMembers,
|
|
22264
22338
|
removeMembers: removeMembers,
|
|
@@ -23509,7 +23583,7 @@ const unbanMembers = async (communityId, userIds) => {
|
|
|
23509
23583
|
};
|
|
23510
23584
|
/* end_public_function */
|
|
23511
23585
|
|
|
23512
|
-
var index$
|
|
23586
|
+
var index$f = /*#__PURE__*/Object.freeze({
|
|
23513
23587
|
__proto__: null,
|
|
23514
23588
|
addRoles: addRoles,
|
|
23515
23589
|
removeRoles: removeRoles,
|
|
@@ -23517,10 +23591,10 @@ var index$e = /*#__PURE__*/Object.freeze({
|
|
|
23517
23591
|
unbanMembers: unbanMembers
|
|
23518
23592
|
});
|
|
23519
23593
|
|
|
23520
|
-
var index$
|
|
23594
|
+
var index$e = /*#__PURE__*/Object.freeze({
|
|
23521
23595
|
__proto__: null,
|
|
23522
|
-
Moderation: index$
|
|
23523
|
-
Membership: index$
|
|
23596
|
+
Moderation: index$f,
|
|
23597
|
+
Membership: index$g,
|
|
23524
23598
|
getCommunityByIds: getCommunities$1,
|
|
23525
23599
|
createCommunity: createCommunity,
|
|
23526
23600
|
updateCommunity: updateCommunity,
|
|
@@ -23754,7 +23828,7 @@ const getCategories = (params, callback, config) => {
|
|
|
23754
23828
|
};
|
|
23755
23829
|
/* end_public_function */
|
|
23756
23830
|
|
|
23757
|
-
var index$
|
|
23831
|
+
var index$d = /*#__PURE__*/Object.freeze({
|
|
23758
23832
|
__proto__: null,
|
|
23759
23833
|
getCategory: getCategory,
|
|
23760
23834
|
getCategories: getCategories
|
|
@@ -24813,7 +24887,7 @@ const getComments = (params, callback, config) => {
|
|
|
24813
24887
|
};
|
|
24814
24888
|
/* end_public_function */
|
|
24815
24889
|
|
|
24816
|
-
var index$
|
|
24890
|
+
var index$c = /*#__PURE__*/Object.freeze({
|
|
24817
24891
|
__proto__: null,
|
|
24818
24892
|
getCommentByIds: getCommentByIds,
|
|
24819
24893
|
createComment: createComment,
|
|
@@ -25484,7 +25558,7 @@ const getUserFeed = (params, callback, config) => {
|
|
|
25484
25558
|
};
|
|
25485
25559
|
/* end_public_function */
|
|
25486
25560
|
|
|
25487
|
-
var index$
|
|
25561
|
+
var index$b = /*#__PURE__*/Object.freeze({
|
|
25488
25562
|
__proto__: null,
|
|
25489
25563
|
queryGlobalFeed: queryGlobalFeed,
|
|
25490
25564
|
getCustomRankingGlobalFeed: getCustomRankingGlobalFeed,
|
|
@@ -27165,7 +27239,7 @@ const searchPostsByHashtag = (params, callback, config) => {
|
|
|
27165
27239
|
};
|
|
27166
27240
|
/* end_public_function */
|
|
27167
27241
|
|
|
27168
|
-
var index$
|
|
27242
|
+
var index$a = /*#__PURE__*/Object.freeze({
|
|
27169
27243
|
__proto__: null,
|
|
27170
27244
|
getPostByIds: getPostByIds,
|
|
27171
27245
|
createPost: createPost,
|
|
@@ -27773,7 +27847,7 @@ const getStreams = (params, callback, config) => {
|
|
|
27773
27847
|
};
|
|
27774
27848
|
};
|
|
27775
27849
|
|
|
27776
|
-
var index$
|
|
27850
|
+
var index$9 = /*#__PURE__*/Object.freeze({
|
|
27777
27851
|
__proto__: null,
|
|
27778
27852
|
createStream: createStream,
|
|
27779
27853
|
updateStream: updateStream,
|
|
@@ -28629,7 +28703,7 @@ const getRooms = (params, callback, config) => {
|
|
|
28629
28703
|
};
|
|
28630
28704
|
/* end_public_function */
|
|
28631
28705
|
|
|
28632
|
-
var index$
|
|
28706
|
+
var index$8 = /*#__PURE__*/Object.freeze({
|
|
28633
28707
|
__proto__: null,
|
|
28634
28708
|
createRoom: createRoom,
|
|
28635
28709
|
updateRoom: updateRoom,
|
|
@@ -28957,7 +29031,7 @@ const getPoll = (pollId, callback) => {
|
|
|
28957
29031
|
};
|
|
28958
29032
|
/* end_public_function */
|
|
28959
29033
|
|
|
28960
|
-
var index$
|
|
29034
|
+
var index$7 = /*#__PURE__*/Object.freeze({
|
|
28961
29035
|
__proto__: null,
|
|
28962
29036
|
createPoll: createPoll,
|
|
28963
29037
|
closePoll: closePoll,
|
|
@@ -29340,7 +29414,7 @@ const getPlayer = async (parameters) => {
|
|
|
29340
29414
|
return video;
|
|
29341
29415
|
};
|
|
29342
29416
|
|
|
29343
|
-
var index$
|
|
29417
|
+
var index$6 = /*#__PURE__*/Object.freeze({
|
|
29344
29418
|
__proto__: null,
|
|
29345
29419
|
getPlayer: getPlayer
|
|
29346
29420
|
});
|
|
@@ -30513,7 +30587,7 @@ const getGlobalStoryTargets = (params, callback, config) => {
|
|
|
30513
30587
|
};
|
|
30514
30588
|
};
|
|
30515
30589
|
|
|
30516
|
-
var index$
|
|
30590
|
+
var index$5 = /*#__PURE__*/Object.freeze({
|
|
30517
30591
|
__proto__: null,
|
|
30518
30592
|
createImageStory: createImageStory,
|
|
30519
30593
|
createVideoStory: createVideoStory,
|
|
@@ -30550,7 +30624,7 @@ const getNetworkAds = async () => {
|
|
|
30550
30624
|
};
|
|
30551
30625
|
};
|
|
30552
30626
|
|
|
30553
|
-
var index$
|
|
30627
|
+
var index$4 = /*#__PURE__*/Object.freeze({
|
|
30554
30628
|
__proto__: null,
|
|
30555
30629
|
getNetworkAds: getNetworkAds
|
|
30556
30630
|
});
|
|
@@ -30941,7 +31015,7 @@ const markTraySeen = async (lastSeenAt) => {
|
|
|
30941
31015
|
};
|
|
30942
31016
|
/* end_public_function */
|
|
30943
31017
|
|
|
30944
|
-
var index$
|
|
31018
|
+
var index$3 = /*#__PURE__*/Object.freeze({
|
|
30945
31019
|
__proto__: null,
|
|
30946
31020
|
getNotificationTraySeen: getNotificationTraySeen,
|
|
30947
31021
|
getNotificationTrayItems: getNotificationTrayItems,
|
|
@@ -31258,7 +31332,7 @@ const observeInvitations = (params, callback) => {
|
|
|
31258
31332
|
};
|
|
31259
31333
|
};
|
|
31260
31334
|
|
|
31261
|
-
var index$
|
|
31335
|
+
var index$2 = /*#__PURE__*/Object.freeze({
|
|
31262
31336
|
__proto__: null,
|
|
31263
31337
|
cancelInvitation: cancelInvitation,
|
|
31264
31338
|
acceptInvitation: acceptInvitation,
|
|
@@ -31402,43 +31476,652 @@ const getReactions = (postId, callback) => {
|
|
|
31402
31476
|
};
|
|
31403
31477
|
};
|
|
31404
31478
|
|
|
31405
|
-
var index = /*#__PURE__*/Object.freeze({
|
|
31479
|
+
var index$1 = /*#__PURE__*/Object.freeze({
|
|
31406
31480
|
__proto__: null,
|
|
31407
31481
|
createReaction: createReaction,
|
|
31408
31482
|
onLiveReactionCreated: onLiveReactionCreated,
|
|
31409
31483
|
getReactions: getReactions
|
|
31410
31484
|
});
|
|
31411
31485
|
|
|
31486
|
+
const prepareEventPayload = (rawPayload) => {
|
|
31487
|
+
return Object.assign(Object.assign({}, rawPayload), { users: rawPayload.users.map(convertRawUserToInternalUser) });
|
|
31488
|
+
};
|
|
31489
|
+
|
|
31490
|
+
const createEventEventSubscriber = (event, callback) => {
|
|
31491
|
+
const client = getActiveClient();
|
|
31492
|
+
const filter = (payload) => {
|
|
31493
|
+
const unpackedPayload = prepareEventPayload(payload);
|
|
31494
|
+
if (!client.cache) {
|
|
31495
|
+
callback(unpackedPayload.events[0]);
|
|
31496
|
+
}
|
|
31497
|
+
else {
|
|
31498
|
+
ingestInCache(unpackedPayload);
|
|
31499
|
+
const event = pullFromCache([
|
|
31500
|
+
'event',
|
|
31501
|
+
'get',
|
|
31502
|
+
unpackedPayload.events[0].eventId,
|
|
31503
|
+
]);
|
|
31504
|
+
callback(event.data);
|
|
31505
|
+
}
|
|
31506
|
+
};
|
|
31507
|
+
return createEventSubscriber(client, event, event, filter);
|
|
31508
|
+
};
|
|
31509
|
+
|
|
31510
|
+
/* begin_public_function
|
|
31511
|
+
id: event.create
|
|
31512
|
+
*/
|
|
31513
|
+
/**
|
|
31514
|
+
* ```js
|
|
31515
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31516
|
+
* const response = await EventRepository.createEvent(bundle)
|
|
31517
|
+
* ```
|
|
31518
|
+
*
|
|
31519
|
+
* Creates an {@link Amity.Event}
|
|
31520
|
+
*
|
|
31521
|
+
* @param bundle The data necessary to create a new {@link Amity.Event}
|
|
31522
|
+
* @returns The newly created {@link Amity.Event}
|
|
31523
|
+
*
|
|
31524
|
+
* @category Event API
|
|
31525
|
+
* @async
|
|
31526
|
+
*/
|
|
31527
|
+
const createEvent = async (bundle) => {
|
|
31528
|
+
const client = getActiveClient();
|
|
31529
|
+
client.log('event/createEvent', bundle);
|
|
31530
|
+
const { data: payload } = await client.http.post('/api/v1/events', bundle);
|
|
31531
|
+
fireEvent('local.event.created', payload);
|
|
31532
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
31533
|
+
const cachedAt = client.cache && Date.now();
|
|
31534
|
+
if (client.cache)
|
|
31535
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
31536
|
+
return {
|
|
31537
|
+
data: eventLinkedObject(preparedPayload.events[0]),
|
|
31538
|
+
cachedAt,
|
|
31539
|
+
};
|
|
31540
|
+
};
|
|
31541
|
+
/* end_public_function */
|
|
31542
|
+
|
|
31543
|
+
/* begin_public_function
|
|
31544
|
+
id: event.update
|
|
31545
|
+
*/
|
|
31546
|
+
/**
|
|
31547
|
+
* ```js
|
|
31548
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31549
|
+
* const response = await EventRepository.updateEvent(eventId, bundle)
|
|
31550
|
+
* ```
|
|
31551
|
+
*
|
|
31552
|
+
* Updates an {@link Amity.Event}
|
|
31553
|
+
*
|
|
31554
|
+
* @param eventId The ID of the {@link Amity.Event} to edit
|
|
31555
|
+
* @param bundle The data necessary to update an existing {@link Amity.Event}
|
|
31556
|
+
* @returns the updated {@link Amity.Event}
|
|
31557
|
+
*
|
|
31558
|
+
* @category Event API
|
|
31559
|
+
* @async
|
|
31560
|
+
*/
|
|
31561
|
+
const updateEvent = async (eventId, bundle) => {
|
|
31562
|
+
const client = getActiveClient();
|
|
31563
|
+
client.log('event/updateEvent', eventId, bundle);
|
|
31564
|
+
const { data: payload } = await client.http.put(`/api/v1/events/${eventId}`, bundle);
|
|
31565
|
+
fireEvent('local.event.updated', payload);
|
|
31566
|
+
const preparedPayload = prepareEventPayload(payload);
|
|
31567
|
+
const cachedAt = client.cache && Date.now();
|
|
31568
|
+
if (client.cache)
|
|
31569
|
+
ingestInCache(preparedPayload, { cachedAt });
|
|
31570
|
+
return {
|
|
31571
|
+
data: eventLinkedObject(preparedPayload.events.find(event => event.eventId === eventId)),
|
|
31572
|
+
cachedAt,
|
|
31573
|
+
};
|
|
31574
|
+
};
|
|
31575
|
+
/* end_public_function */
|
|
31576
|
+
|
|
31577
|
+
/* begin_public_function
|
|
31578
|
+
id: event.get
|
|
31579
|
+
*/
|
|
31580
|
+
/**
|
|
31581
|
+
* ```js
|
|
31582
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31583
|
+
* const event = await EventRepository.getEvent(eventId)
|
|
31584
|
+
* ```
|
|
31585
|
+
*
|
|
31586
|
+
* Fetches a {@link Amity.Event} object
|
|
31587
|
+
*
|
|
31588
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
31589
|
+
* @returns the associated {@link Amity.Event} object
|
|
31590
|
+
*
|
|
31591
|
+
* @category Event API
|
|
31592
|
+
* @async
|
|
31593
|
+
*/
|
|
31594
|
+
const getEvent$1 = async (eventId) => {
|
|
31595
|
+
const client = getActiveClient();
|
|
31596
|
+
client.log('event/getEvent', eventId);
|
|
31597
|
+
const { data: payload } = await client.http.get(`/api/v1/events/${eventId}`);
|
|
31598
|
+
const data = prepareEventPayload(payload);
|
|
31599
|
+
const cachedAt = client.cache && Date.now();
|
|
31600
|
+
if (client.cache)
|
|
31601
|
+
ingestInCache(data, { cachedAt });
|
|
31602
|
+
return {
|
|
31603
|
+
data: data.events.find(event => event.eventId === eventId),
|
|
31604
|
+
cachedAt,
|
|
31605
|
+
};
|
|
31606
|
+
};
|
|
31607
|
+
/* end_public_function */
|
|
31608
|
+
/**
|
|
31609
|
+
* ```js
|
|
31610
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31611
|
+
* const event = EventRepository.getEvent.locally(eventId)
|
|
31612
|
+
* ```
|
|
31613
|
+
*
|
|
31614
|
+
* Fetches a {@link Amity.Event} object in cache
|
|
31615
|
+
*
|
|
31616
|
+
* @param eventId the ID of the {@link Amity.Event} to fetch
|
|
31617
|
+
* @returns the associated {@link Amity.Event} object
|
|
31618
|
+
*
|
|
31619
|
+
* @category Event API
|
|
31620
|
+
*/
|
|
31621
|
+
getEvent$1.locally = (eventId) => {
|
|
31622
|
+
const client = getActiveClient();
|
|
31623
|
+
client.log('event/getEvent.locally', eventId);
|
|
31624
|
+
if (!client.cache)
|
|
31625
|
+
return;
|
|
31626
|
+
const cache = pullFromCache(['event', 'get', eventId]);
|
|
31627
|
+
if (!cache)
|
|
31628
|
+
return;
|
|
31629
|
+
return {
|
|
31630
|
+
data: cache.data,
|
|
31631
|
+
cachedAt: cache.cachedAt,
|
|
31632
|
+
};
|
|
31633
|
+
};
|
|
31634
|
+
|
|
31635
|
+
/* begin_public_function
|
|
31636
|
+
id: event.delete
|
|
31637
|
+
*/
|
|
31638
|
+
/**
|
|
31639
|
+
* ```js
|
|
31640
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31641
|
+
* const { success } = await EventRepository.deleteEvent(eventId)
|
|
31642
|
+
* ```
|
|
31643
|
+
*
|
|
31644
|
+
* Deletes a {@link Amity.Event}
|
|
31645
|
+
*
|
|
31646
|
+
* @param eventId The {@link Amity.Event} ID to delete
|
|
31647
|
+
*
|
|
31648
|
+
* @category Event API
|
|
31649
|
+
* @async
|
|
31650
|
+
*/
|
|
31651
|
+
const deleteEvent = async (eventId) => {
|
|
31652
|
+
const client = getActiveClient();
|
|
31653
|
+
client.log('event/deleteEvent', eventId);
|
|
31654
|
+
const event = await getEvent$1(eventId);
|
|
31655
|
+
await client.http.delete(`/api/v1/events/${eventId}`);
|
|
31656
|
+
const deletedEvent = Object.assign(Object.assign({}, event.data), { isDeleted: true });
|
|
31657
|
+
upsertInCache(['event', 'get', eventId], deletedEvent);
|
|
31658
|
+
fireEvent('local.event.deleted', {
|
|
31659
|
+
users: [],
|
|
31660
|
+
files: [],
|
|
31661
|
+
communities: [],
|
|
31662
|
+
videoStreamings: [],
|
|
31663
|
+
events: [deletedEvent],
|
|
31664
|
+
discussionCommunities: [],
|
|
31665
|
+
});
|
|
31666
|
+
};
|
|
31667
|
+
/* end_public_function */
|
|
31668
|
+
|
|
31669
|
+
/**
|
|
31670
|
+
* ```js
|
|
31671
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31672
|
+
* const dispose = EventRepository.onEventCreated(event => {
|
|
31673
|
+
* // ...
|
|
31674
|
+
* })
|
|
31675
|
+
* ```
|
|
31676
|
+
*
|
|
31677
|
+
* Fired when a {@link Amity.Event} has been created
|
|
31678
|
+
*
|
|
31679
|
+
* @param callback The function to call when the event was fired
|
|
31680
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
31681
|
+
*
|
|
31682
|
+
* @category Event Events
|
|
31683
|
+
*/
|
|
31684
|
+
const onEventCreated = (callback) => createEventEventSubscriber('event.created', callback);
|
|
31685
|
+
|
|
31686
|
+
/**
|
|
31687
|
+
* ```js
|
|
31688
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31689
|
+
* const dispose = EventRepository.onEventUpdated(event => {
|
|
31690
|
+
* // ...
|
|
31691
|
+
* })
|
|
31692
|
+
* ```
|
|
31693
|
+
*
|
|
31694
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
31695
|
+
*
|
|
31696
|
+
* @param callback The function to call when the event was fired
|
|
31697
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
31698
|
+
*
|
|
31699
|
+
* @category Event Events
|
|
31700
|
+
*/
|
|
31701
|
+
const onEventUpdated = (callback) => createEventEventSubscriber('event.updated', callback);
|
|
31702
|
+
|
|
31703
|
+
/**
|
|
31704
|
+
* ```js
|
|
31705
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31706
|
+
* const dispose = EventRepository.onEventDeleted(event => {
|
|
31707
|
+
* // ...
|
|
31708
|
+
* })
|
|
31709
|
+
* ```
|
|
31710
|
+
*
|
|
31711
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
31712
|
+
*
|
|
31713
|
+
* @param callback The function to call when the event was fired
|
|
31714
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
31715
|
+
*
|
|
31716
|
+
* @category Event Events
|
|
31717
|
+
*/
|
|
31718
|
+
const onEventDeleted = (callback) => createEventEventSubscriber('event.deleted', callback);
|
|
31719
|
+
|
|
31720
|
+
/**
|
|
31721
|
+
* ```js
|
|
31722
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31723
|
+
* const dispose = EventRepository.onLocalEventCreated(event => {
|
|
31724
|
+
* // ...
|
|
31725
|
+
* })
|
|
31726
|
+
* ```
|
|
31727
|
+
*
|
|
31728
|
+
* Fired when a {@link Amity.Event} has been created
|
|
31729
|
+
*
|
|
31730
|
+
* @param callback The function to call when the event was fired
|
|
31731
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
31732
|
+
*
|
|
31733
|
+
* @category Event Events
|
|
31734
|
+
*/
|
|
31735
|
+
const onLocalEventCreated = (callback) => createEventEventSubscriber('local.event.created', callback);
|
|
31736
|
+
|
|
31737
|
+
/**
|
|
31738
|
+
* ```js
|
|
31739
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31740
|
+
* const dispose = EventRepository.onLocalEventUpdated(event => {
|
|
31741
|
+
* // ...
|
|
31742
|
+
* })
|
|
31743
|
+
* ```
|
|
31744
|
+
*
|
|
31745
|
+
* Fired when a {@link Amity.Event} has been updated
|
|
31746
|
+
*
|
|
31747
|
+
* @param callback The function to call when the event was fired
|
|
31748
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
31749
|
+
*
|
|
31750
|
+
* @category Event Events
|
|
31751
|
+
*/
|
|
31752
|
+
const onLocalEventUpdated = (callback) => createEventEventSubscriber('local.event.updated', callback);
|
|
31753
|
+
|
|
31754
|
+
/**
|
|
31755
|
+
* ```js
|
|
31756
|
+
* import { EventRepository } from '@amityco/ts-sdk'
|
|
31757
|
+
* const dispose = EventRepository.onLocalEventDeleted(event => {
|
|
31758
|
+
* // ...
|
|
31759
|
+
* })
|
|
31760
|
+
* ```
|
|
31761
|
+
*
|
|
31762
|
+
* Fired when a {@link Amity.Event} has been deleted
|
|
31763
|
+
*
|
|
31764
|
+
* @param callback The function to call when the event was fired
|
|
31765
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
31766
|
+
*
|
|
31767
|
+
* @category Event Events
|
|
31768
|
+
*/
|
|
31769
|
+
const onLocalEventDeleted = (callback) => createEventEventSubscriber('local.event.deleted', callback);
|
|
31770
|
+
|
|
31771
|
+
/* begin_public_function
|
|
31772
|
+
id: event.get
|
|
31773
|
+
*/
|
|
31774
|
+
/**
|
|
31775
|
+
* ```js
|
|
31776
|
+
* import { EventRepository } from '@amityco/ts-sdk';
|
|
31777
|
+
*
|
|
31778
|
+
* let event;
|
|
31779
|
+
*
|
|
31780
|
+
* const unsubscribe = EventRepository.getEvent(eventId, response => {
|
|
31781
|
+
* event = response.data;
|
|
31782
|
+
* });
|
|
31783
|
+
* ```
|
|
31784
|
+
*
|
|
31785
|
+
* Observe all mutation on a given {@link Amity.Event}
|
|
31786
|
+
*
|
|
31787
|
+
* @param eventId the ID of the event to observe
|
|
31788
|
+
* @param callback the function to call when new snapshot of event are available
|
|
31789
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the event
|
|
31790
|
+
*
|
|
31791
|
+
* @category Event Live Object
|
|
31792
|
+
*/
|
|
31793
|
+
const getEvent = (eventId, callback) => {
|
|
31794
|
+
return liveObject(eventId, callback, 'eventId', getEvent$1, [onEventUpdated, onEventDeleted, onLocalEventUpdated, onLocalEventDeleted], {
|
|
31795
|
+
callbackDataSelector: (data) => (data ? eventLinkedObject(data) : data),
|
|
31796
|
+
});
|
|
31797
|
+
};
|
|
31798
|
+
/* end_public_function */
|
|
31799
|
+
|
|
31800
|
+
var EventActionsEnum;
|
|
31801
|
+
(function (EventActionsEnum) {
|
|
31802
|
+
EventActionsEnum["OnEventCreated"] = "onEventCreated";
|
|
31803
|
+
EventActionsEnum["OnEventUpdated"] = "onEventUpdated";
|
|
31804
|
+
EventActionsEnum["OnEventDeleted"] = "onEventDeleted";
|
|
31805
|
+
})(EventActionsEnum || (EventActionsEnum = {}));
|
|
31806
|
+
|
|
31807
|
+
class EventPaginationController extends PaginationController {
|
|
31808
|
+
async getRequest(queryParams, token) {
|
|
31809
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
31810
|
+
const options = token ? { token } : { limit };
|
|
31811
|
+
const { data: response } = await this.http.get(`/api/v1/events`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
31812
|
+
return response;
|
|
31813
|
+
}
|
|
31814
|
+
}
|
|
31815
|
+
|
|
31816
|
+
class EventQueryStreamController extends QueryStreamController {
|
|
31817
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
31818
|
+
super(query, cacheKey);
|
|
31819
|
+
this.notifyChange = notifyChange;
|
|
31820
|
+
this.preparePayload = preparePayload;
|
|
31821
|
+
}
|
|
31822
|
+
async saveToMainDB(response) {
|
|
31823
|
+
const processedPayload = this.preparePayload(response);
|
|
31824
|
+
const client = getActiveClient();
|
|
31825
|
+
const cachedAt = client.cache && Date.now();
|
|
31826
|
+
if (client.cache)
|
|
31827
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
31828
|
+
}
|
|
31829
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
31830
|
+
var _a, _b;
|
|
31831
|
+
if (refresh) {
|
|
31832
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
31833
|
+
}
|
|
31834
|
+
else {
|
|
31835
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31836
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31837
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
31838
|
+
}
|
|
31839
|
+
}
|
|
31840
|
+
reactor(action) {
|
|
31841
|
+
return (event) => {
|
|
31842
|
+
var _a;
|
|
31843
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31844
|
+
if (!collection)
|
|
31845
|
+
return;
|
|
31846
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
31847
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
31848
|
+
}
|
|
31849
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
31850
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
31851
|
+
}
|
|
31852
|
+
pushToCache(this.cacheKey, collection);
|
|
31853
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
31854
|
+
};
|
|
31855
|
+
}
|
|
31856
|
+
subscribeRTE(createSubscriber) {
|
|
31857
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
31858
|
+
}
|
|
31859
|
+
}
|
|
31860
|
+
|
|
31861
|
+
class EventLiveCollectionController extends LiveCollectionController {
|
|
31862
|
+
constructor(query, callback) {
|
|
31863
|
+
const queryStreamId = hash__default["default"](query);
|
|
31864
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
31865
|
+
const paginationController = new EventPaginationController(query);
|
|
31866
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
31867
|
+
this.query = query;
|
|
31868
|
+
this.queryStreamController = new EventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
31869
|
+
this.callback = callback.bind(this);
|
|
31870
|
+
this.loadPage({ initial: true });
|
|
31871
|
+
}
|
|
31872
|
+
setup() {
|
|
31873
|
+
var _a;
|
|
31874
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31875
|
+
if (!collection)
|
|
31876
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
31877
|
+
}
|
|
31878
|
+
async persistModel(queryPayload) {
|
|
31879
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
31880
|
+
}
|
|
31881
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
31882
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
31883
|
+
}
|
|
31884
|
+
startSubscription() {
|
|
31885
|
+
return this.queryStreamController.subscribeRTE([
|
|
31886
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
31887
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
31888
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
31889
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
31890
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
31891
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
31892
|
+
]);
|
|
31893
|
+
}
|
|
31894
|
+
notifyChange({ origin, loading, error }) {
|
|
31895
|
+
var _a, _b;
|
|
31896
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31897
|
+
if (!collection)
|
|
31898
|
+
return;
|
|
31899
|
+
const data = ((_b = collection.data
|
|
31900
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
31901
|
+
.filter(isNonNullable)
|
|
31902
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
31903
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
31904
|
+
return;
|
|
31905
|
+
this.callback({
|
|
31906
|
+
data,
|
|
31907
|
+
error,
|
|
31908
|
+
loading,
|
|
31909
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
31910
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
31911
|
+
});
|
|
31912
|
+
}
|
|
31913
|
+
}
|
|
31914
|
+
|
|
31915
|
+
/**
|
|
31916
|
+
* Get events
|
|
31917
|
+
*
|
|
31918
|
+
* @param params the query parameters
|
|
31919
|
+
* @param callback the callback to be called when the events are updated
|
|
31920
|
+
* @returns events
|
|
31921
|
+
*
|
|
31922
|
+
* @category Event Live Collection
|
|
31923
|
+
*
|
|
31924
|
+
*/
|
|
31925
|
+
const getEvents = (params, callback, config) => {
|
|
31926
|
+
const { log, cache } = getActiveClient();
|
|
31927
|
+
if (!cache)
|
|
31928
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
31929
|
+
const timestamp = Date.now();
|
|
31930
|
+
log(`getEvents: (tmpid: ${timestamp}) > listen`);
|
|
31931
|
+
const eventLiveCollection = new EventLiveCollectionController(params, callback);
|
|
31932
|
+
const disposers = eventLiveCollection.startSubscription();
|
|
31933
|
+
const cacheKey = eventLiveCollection.getCacheKey();
|
|
31934
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
31935
|
+
return () => {
|
|
31936
|
+
log(`getEvents (tmpid: ${timestamp}) > dispose`);
|
|
31937
|
+
disposers.forEach(fn => fn());
|
|
31938
|
+
};
|
|
31939
|
+
};
|
|
31940
|
+
|
|
31941
|
+
class MyEventPaginationController extends PaginationController {
|
|
31942
|
+
async getRequest(queryParams, token) {
|
|
31943
|
+
const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT } = queryParams, params = __rest(queryParams, ["limit"]);
|
|
31944
|
+
const options = token ? { token } : { limit };
|
|
31945
|
+
const { data: response } = await this.http.get(`/api/v1/events/me/rsvps`, { params: Object.assign(Object.assign({}, params), { options }) });
|
|
31946
|
+
return response;
|
|
31947
|
+
}
|
|
31948
|
+
}
|
|
31949
|
+
|
|
31950
|
+
class MyEventQueryStreamController extends QueryStreamController {
|
|
31951
|
+
constructor(query, cacheKey, notifyChange, preparePayload) {
|
|
31952
|
+
super(query, cacheKey);
|
|
31953
|
+
this.notifyChange = notifyChange;
|
|
31954
|
+
this.preparePayload = preparePayload;
|
|
31955
|
+
}
|
|
31956
|
+
async saveToMainDB(response) {
|
|
31957
|
+
const processedPayload = this.preparePayload(response);
|
|
31958
|
+
const client = getActiveClient();
|
|
31959
|
+
const cachedAt = client.cache && Date.now();
|
|
31960
|
+
if (client.cache)
|
|
31961
|
+
ingestInCache(processedPayload, { cachedAt });
|
|
31962
|
+
}
|
|
31963
|
+
appendToQueryStream(response, direction, refresh = false) {
|
|
31964
|
+
var _a, _b;
|
|
31965
|
+
if (refresh) {
|
|
31966
|
+
pushToCache(this.cacheKey, { data: response.events.map(getResolver('event')) });
|
|
31967
|
+
}
|
|
31968
|
+
else {
|
|
31969
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31970
|
+
const events = (_b = collection === null || collection === void 0 ? void 0 : collection.data) !== null && _b !== void 0 ? _b : [];
|
|
31971
|
+
pushToCache(this.cacheKey, Object.assign(Object.assign({}, collection), { data: [...new Set([...events, ...response.events.map(getResolver('event'))])] }));
|
|
31972
|
+
}
|
|
31973
|
+
}
|
|
31974
|
+
reactor(action) {
|
|
31975
|
+
return (event) => {
|
|
31976
|
+
var _a;
|
|
31977
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
31978
|
+
if (!collection)
|
|
31979
|
+
return;
|
|
31980
|
+
if (action === EventActionsEnum.OnEventCreated) {
|
|
31981
|
+
const client = getActiveClient();
|
|
31982
|
+
if (client.userId !== event.userId)
|
|
31983
|
+
return;
|
|
31984
|
+
collection.data = [...new Set([event.eventId, ...collection.data])];
|
|
31985
|
+
}
|
|
31986
|
+
if (action === EventActionsEnum.OnEventDeleted) {
|
|
31987
|
+
collection.data = collection.data.filter(eventId => eventId !== event.eventId);
|
|
31988
|
+
}
|
|
31989
|
+
pushToCache(this.cacheKey, collection);
|
|
31990
|
+
this.notifyChange({ origin: "event" /* Amity.LiveDataOrigin.EVENT */, loading: false });
|
|
31991
|
+
};
|
|
31992
|
+
}
|
|
31993
|
+
subscribeRTE(createSubscriber) {
|
|
31994
|
+
return createSubscriber.map(subscriber => subscriber.fn(this.reactor(subscriber.action)));
|
|
31995
|
+
}
|
|
31996
|
+
}
|
|
31997
|
+
|
|
31998
|
+
class MyEventLiveCollectionController extends LiveCollectionController {
|
|
31999
|
+
constructor(query, callback) {
|
|
32000
|
+
const queryStreamId = hash__default["default"](query);
|
|
32001
|
+
const cacheKey = ['event', 'collection', queryStreamId];
|
|
32002
|
+
const paginationController = new MyEventPaginationController(query);
|
|
32003
|
+
super(paginationController, queryStreamId, cacheKey, callback);
|
|
32004
|
+
this.query = query;
|
|
32005
|
+
this.queryStreamController = new MyEventQueryStreamController(this.query, this.cacheKey, this.notifyChange.bind(this), prepareEventPayload);
|
|
32006
|
+
this.callback = callback.bind(this);
|
|
32007
|
+
this.loadPage({ initial: true });
|
|
32008
|
+
}
|
|
32009
|
+
setup() {
|
|
32010
|
+
var _a;
|
|
32011
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32012
|
+
if (!collection)
|
|
32013
|
+
pushToCache(this.cacheKey, { data: [], params: {} });
|
|
32014
|
+
}
|
|
32015
|
+
async persistModel(queryPayload) {
|
|
32016
|
+
await this.queryStreamController.saveToMainDB(queryPayload);
|
|
32017
|
+
}
|
|
32018
|
+
persistQueryStream({ response, direction, refresh, }) {
|
|
32019
|
+
this.queryStreamController.appendToQueryStream(response, direction, refresh);
|
|
32020
|
+
}
|
|
32021
|
+
startSubscription() {
|
|
32022
|
+
return this.queryStreamController.subscribeRTE([
|
|
32023
|
+
{ fn: onEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
32024
|
+
{ fn: onEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
32025
|
+
{ fn: onEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
32026
|
+
{ fn: onLocalEventCreated, action: EventActionsEnum.OnEventCreated },
|
|
32027
|
+
{ fn: onLocalEventUpdated, action: EventActionsEnum.OnEventUpdated },
|
|
32028
|
+
{ fn: onLocalEventDeleted, action: EventActionsEnum.OnEventDeleted },
|
|
32029
|
+
]);
|
|
32030
|
+
}
|
|
32031
|
+
notifyChange({ origin, loading, error }) {
|
|
32032
|
+
var _a, _b;
|
|
32033
|
+
const collection = (_a = pullFromCache(this.cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
|
|
32034
|
+
if (!collection)
|
|
32035
|
+
return;
|
|
32036
|
+
const data = ((_b = collection.data
|
|
32037
|
+
.map(eventId => pullFromCache(['event', 'get', eventId]))
|
|
32038
|
+
.filter(isNonNullable)
|
|
32039
|
+
.map(({ data }) => data)) !== null && _b !== void 0 ? _b : []).map(LinkedObject.event);
|
|
32040
|
+
if (!this.shouldNotify(data) && origin === "event" /* Amity.LiveDataOrigin.EVENT */)
|
|
32041
|
+
return;
|
|
32042
|
+
this.callback({
|
|
32043
|
+
data,
|
|
32044
|
+
error,
|
|
32045
|
+
loading,
|
|
32046
|
+
hasNextPage: !!this.paginationController.getNextToken(),
|
|
32047
|
+
onNextPage: () => this.loadPage({ direction: "next" /* Amity.LiveCollectionPageDirection.NEXT */ }),
|
|
32048
|
+
});
|
|
32049
|
+
}
|
|
32050
|
+
}
|
|
32051
|
+
|
|
32052
|
+
/**
|
|
32053
|
+
* Get my events
|
|
32054
|
+
*
|
|
32055
|
+
* @param params the query parameters
|
|
32056
|
+
* @param callback the callback to be called when the events are updated
|
|
32057
|
+
* @returns events
|
|
32058
|
+
*
|
|
32059
|
+
* @category Event Live Collection
|
|
32060
|
+
*
|
|
32061
|
+
*/
|
|
32062
|
+
const getMyEvents = (params, callback, config) => {
|
|
32063
|
+
const { log, cache } = getActiveClient();
|
|
32064
|
+
if (!cache)
|
|
32065
|
+
console.log(ENABLE_CACHE_MESSAGE);
|
|
32066
|
+
const timestamp = Date.now();
|
|
32067
|
+
log(`getMyEvents: (tmpid: ${timestamp}) > listen`);
|
|
32068
|
+
const myEventLiveCollection = new MyEventLiveCollectionController(params, callback);
|
|
32069
|
+
const disposers = myEventLiveCollection.startSubscription();
|
|
32070
|
+
const cacheKey = myEventLiveCollection.getCacheKey();
|
|
32071
|
+
disposers.push(() => dropFromCache(cacheKey));
|
|
32072
|
+
return () => {
|
|
32073
|
+
log(`getMyEvents (tmpid: ${timestamp}) > dispose`);
|
|
32074
|
+
disposers.forEach(fn => fn());
|
|
32075
|
+
};
|
|
32076
|
+
};
|
|
32077
|
+
|
|
32078
|
+
var index = /*#__PURE__*/Object.freeze({
|
|
32079
|
+
__proto__: null,
|
|
32080
|
+
createEvent: createEvent,
|
|
32081
|
+
updateEvent: updateEvent,
|
|
32082
|
+
deleteEvent: deleteEvent,
|
|
32083
|
+
onEventCreated: onEventCreated,
|
|
32084
|
+
onEventUpdated: onEventUpdated,
|
|
32085
|
+
onEventDeleted: onEventDeleted,
|
|
32086
|
+
onLocalEventCreated: onLocalEventCreated,
|
|
32087
|
+
onLocalEventUpdated: onLocalEventUpdated,
|
|
32088
|
+
onLocalEventDeleted: onLocalEventDeleted,
|
|
32089
|
+
getEvent: getEvent,
|
|
32090
|
+
getEvents: getEvents,
|
|
32091
|
+
getMyEvents: getMyEvents
|
|
32092
|
+
});
|
|
32093
|
+
|
|
31412
32094
|
exports.API_REGIONS = API_REGIONS;
|
|
31413
|
-
exports.AdRepository = index$
|
|
31414
|
-
exports.CategoryRepository = index$
|
|
31415
|
-
exports.ChannelRepository = index$
|
|
31416
|
-
exports.Client = index$
|
|
31417
|
-
exports.CommentRepository = index$
|
|
32095
|
+
exports.AdRepository = index$4;
|
|
32096
|
+
exports.CategoryRepository = index$d;
|
|
32097
|
+
exports.ChannelRepository = index$h;
|
|
32098
|
+
exports.Client = index$q;
|
|
32099
|
+
exports.CommentRepository = index$c;
|
|
31418
32100
|
exports.CommunityPostSettingMaps = CommunityPostSettingMaps;
|
|
31419
32101
|
exports.CommunityPostSettings = CommunityPostSettings;
|
|
31420
|
-
exports.CommunityRepository = index$
|
|
32102
|
+
exports.CommunityRepository = index$e;
|
|
31421
32103
|
exports.ContentFeedType = ContentFeedType;
|
|
31422
32104
|
exports.DefaultCommunityPostSetting = DefaultCommunityPostSetting;
|
|
31423
|
-
exports.
|
|
31424
|
-
exports.
|
|
32105
|
+
exports.EventRepository = index;
|
|
32106
|
+
exports.FeedRepository = index$b;
|
|
32107
|
+
exports.FileRepository = index$n;
|
|
31425
32108
|
exports.FileType = FileType;
|
|
31426
32109
|
exports.GET_WATCHER_URLS = GET_WATCHER_URLS;
|
|
31427
|
-
exports.InvitationRepository = index$
|
|
31428
|
-
exports.LiveReactionRepository = index;
|
|
31429
|
-
exports.LiveStreamPlayer = index$
|
|
32110
|
+
exports.InvitationRepository = index$2;
|
|
32111
|
+
exports.LiveReactionRepository = index$1;
|
|
32112
|
+
exports.LiveStreamPlayer = index$6;
|
|
31430
32113
|
exports.MessageContentType = MessageContentType;
|
|
31431
|
-
exports.MessageRepository = index$
|
|
31432
|
-
exports.PollRepository = index$
|
|
32114
|
+
exports.MessageRepository = index$l;
|
|
32115
|
+
exports.PollRepository = index$7;
|
|
31433
32116
|
exports.PostContentType = PostContentType;
|
|
31434
|
-
exports.PostRepository = index$
|
|
32117
|
+
exports.PostRepository = index$a;
|
|
31435
32118
|
exports.PostStructureType = PostStructureType;
|
|
31436
|
-
exports.ReactionRepository = index$
|
|
31437
|
-
exports.RoomRepository = index$
|
|
31438
|
-
exports.StoryRepository = index$
|
|
31439
|
-
exports.StreamRepository = index$
|
|
31440
|
-
exports.SubChannelRepository = index$
|
|
31441
|
-
exports.UserRepository = index$
|
|
32119
|
+
exports.ReactionRepository = index$m;
|
|
32120
|
+
exports.RoomRepository = index$8;
|
|
32121
|
+
exports.StoryRepository = index$5;
|
|
32122
|
+
exports.StreamRepository = index$9;
|
|
32123
|
+
exports.SubChannelRepository = index$k;
|
|
32124
|
+
exports.UserRepository = index$o;
|
|
31442
32125
|
exports.VERSION = VERSION;
|
|
31443
32126
|
exports.VideoResolution = VideoResolution;
|
|
31444
32127
|
exports.VideoSize = VideoSize;
|
|
@@ -31494,7 +32177,7 @@ exports.isPaged = isPaged;
|
|
|
31494
32177
|
exports.isReportedByMe = isReportedByMe;
|
|
31495
32178
|
exports.isSkip = isSkip;
|
|
31496
32179
|
exports.mergeInCache = mergeInCache;
|
|
31497
|
-
exports.notificationTray = index$
|
|
32180
|
+
exports.notificationTray = index$3;
|
|
31498
32181
|
exports.onChannelMarkerFetched = onChannelMarkerFetched;
|
|
31499
32182
|
exports.onFeedMarkerFetched = onFeedMarkerFetched;
|
|
31500
32183
|
exports.onFeedMarkerUpdated = onFeedMarkerUpdated;
|