@amityco/ts-sdk 0.0.1-beta.16 → 0.0.1-beta.17
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/.eslintrc.json +51 -0
- package/dist/@types/core/cache.d.ts +11 -11
- package/dist/@types/core/cache.d.ts.map +1 -1
- package/dist/@types/core/errors.d.ts +1 -1
- package/dist/@types/core/errors.d.ts.map +1 -1
- package/dist/@types/core/events.d.ts.map +1 -1
- package/dist/@types/core/model.d.ts +29 -27
- package/dist/@types/core/model.d.ts.map +1 -1
- package/dist/@types/core/paging.d.ts +2 -2
- package/dist/@types/core/paging.d.ts.map +1 -1
- package/dist/@types/core/payload.d.ts +1 -0
- package/dist/@types/core/payload.d.ts.map +1 -1
- package/dist/@types/core/permissions.d.ts.map +1 -1
- package/dist/@types/core/query.d.ts +5 -5
- package/dist/@types/core/query.d.ts.map +1 -1
- package/dist/@types/core/transport.d.ts +1 -1
- package/dist/@types/core/transport.d.ts.map +1 -1
- package/dist/@types/domains/category.d.ts.map +1 -1
- package/dist/@types/domains/channel.d.ts +1 -1
- package/dist/@types/domains/channel.d.ts.map +1 -1
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/comment.d.ts +2 -2
- package/dist/@types/domains/comment.d.ts.map +1 -1
- package/dist/@types/domains/community.d.ts.map +1 -1
- package/dist/@types/domains/content.d.ts +4 -4
- package/dist/@types/domains/content.d.ts.map +1 -1
- package/dist/@types/domains/feed.d.ts +1 -1
- package/dist/@types/domains/feed.d.ts.map +1 -1
- package/dist/@types/domains/file.d.ts +5 -5
- package/dist/@types/domains/file.d.ts.map +1 -1
- package/dist/@types/domains/follow.d.ts.map +1 -1
- package/dist/@types/domains/group.d.ts +4 -4
- package/dist/@types/domains/group.d.ts.map +1 -1
- package/dist/@types/domains/mention.d.ts +6 -6
- package/dist/@types/domains/mention.d.ts.map +1 -1
- package/dist/@types/domains/message.d.ts +2 -2
- package/dist/@types/domains/message.d.ts.map +1 -1
- package/dist/@types/domains/partials.d.ts.map +1 -1
- package/dist/@types/domains/post.d.ts +5 -5
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/@types/domains/reaction.d.ts +2 -2
- package/dist/@types/domains/reaction.d.ts.map +1 -1
- package/dist/@types/domains/stream.d.ts +3 -3
- package/dist/@types/domains/stream.d.ts.map +1 -1
- package/dist/@types/domains/user.d.ts +1 -0
- package/dist/@types/domains/user.d.ts.map +1 -1
- package/dist/@types/global.d.ts +2 -2
- package/dist/@types/global.d.ts.map +1 -1
- package/dist/@types/index.d.ts.map +1 -1
- package/dist/cache/api/backupCache.d.ts.map +1 -1
- package/dist/cache/api/disableCache.d.ts.map +1 -1
- package/dist/cache/api/dropFromCache.d.ts.map +1 -1
- package/dist/cache/api/enableCache.d.ts.map +1 -1
- package/dist/cache/api/index.d.ts.map +1 -1
- package/dist/cache/api/ingestInCache.d.ts.map +1 -1
- package/dist/cache/api/mergeInCache.d.ts +1 -1
- package/dist/cache/api/mergeInCache.d.ts.map +1 -1
- package/dist/cache/api/pullFromCache.d.ts.map +1 -1
- package/dist/cache/api/pushToCache.d.ts.map +1 -1
- package/dist/cache/api/queryCache.d.ts.map +1 -1
- package/dist/cache/api/restoreCache.d.ts.map +1 -1
- package/dist/cache/api/snipeIdFromCollection.d.ts.map +1 -1
- package/dist/cache/api/upsertInCache.d.ts +1 -1
- package/dist/cache/api/upsertInCache.d.ts.map +1 -1
- package/dist/cache/api/wipeCache.d.ts.map +1 -1
- package/dist/cache/utils/index.d.ts.map +1 -1
- package/dist/category/api/getCategory.d.ts +18 -2
- package/dist/category/api/getCategory.d.ts.map +1 -1
- package/dist/category/api/index.d.ts.map +1 -1
- package/dist/category/api/queryCategories.d.ts +24 -12
- package/dist/category/api/queryCategories.d.ts.map +1 -1
- package/dist/channel/api/addChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/addChannelMembersRole.d.ts.map +1 -1
- package/dist/channel/api/createChannel.d.ts.map +1 -1
- package/dist/channel/api/deleteChannel.d.ts.map +1 -1
- package/dist/channel/api/getChannel.d.ts.map +1 -1
- package/dist/channel/api/getChannels.d.ts.map +1 -1
- package/dist/channel/api/index.d.ts.map +1 -1
- package/dist/channel/api/joinChannel.d.ts.map +1 -1
- package/dist/channel/api/leaveChannel.d.ts.map +1 -1
- package/dist/channel/api/queryChannelMembers.d.ts +2 -2
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/queryChannels.d.ts.map +1 -1
- package/dist/channel/api/removeChannelMembers.d.ts.map +1 -1
- package/dist/channel/api/removeChannelMembersRole.d.ts.map +1 -1
- package/dist/channel/api/updateChannel.d.ts.map +1 -1
- package/dist/channel/events/index.d.ts.map +1 -1
- package/dist/channel/events/onChannelCreated.d.ts.map +1 -1
- package/dist/channel/events/onChannelDeleted.d.ts.map +1 -1
- package/dist/channel/events/onChannelJoined.d.ts.map +1 -1
- package/dist/channel/events/onChannelLeft.d.ts.map +1 -1
- package/dist/channel/events/onChannelUpdated.d.ts.map +1 -1
- package/dist/channel/events/onMemberAdded.d.ts.map +1 -1
- package/dist/channel/events/onMemberRemoved.d.ts.map +1 -1
- package/dist/channel/observers/index.d.ts.map +1 -1
- package/dist/channel/observers/observeChannel.d.ts.map +1 -1
- package/dist/client/api/activeClient.d.ts.map +1 -1
- package/dist/client/api/activeUser.d.ts.map +1 -1
- package/dist/client/api/connectClient.d.ts.map +1 -1
- package/dist/client/api/createClient.d.ts +1 -1
- package/dist/client/api/createClient.d.ts.map +1 -1
- package/dist/client/api/disconnectClient.d.ts.map +1 -1
- package/dist/client/api/getToken.d.ts.map +1 -1
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/isConnected.d.ts.map +1 -1
- package/dist/client/events/index.d.ts.map +1 -1
- package/dist/client/events/onClientBanned.d.ts.map +1 -1
- package/dist/client/events/onClientDisconnected.d.ts.map +1 -1
- package/dist/client/events/onConnectionError.d.ts.map +1 -1
- package/dist/client/utils/endpoints.d.ts.map +1 -1
- package/dist/comment/api/createComment.d.ts.map +1 -1
- package/dist/comment/api/deleteComment.d.ts.map +1 -1
- package/dist/comment/api/getComment.d.ts.map +1 -1
- package/dist/comment/api/getComments.d.ts.map +1 -1
- package/dist/comment/api/index.d.ts.map +1 -1
- package/dist/comment/api/queryComments.d.ts.map +1 -1
- package/dist/comment/api/updateComment.d.ts.map +1 -1
- package/dist/comment/events/index.d.ts.map +1 -1
- package/dist/comment/events/onCommentCreated.d.ts.map +1 -1
- package/dist/comment/events/onCommentDeleted.d.ts.map +1 -1
- package/dist/comment/events/onCommentFlagged.d.ts.map +1 -1
- package/dist/comment/events/onCommentReactionAdded.d.ts.map +1 -1
- package/dist/comment/events/onCommentReactionRemoved.d.ts.map +1 -1
- package/dist/comment/events/onCommentUnflagged.d.ts.map +1 -1
- package/dist/comment/events/onCommentUpdated.d.ts.map +1 -1
- package/dist/comment/events/utils.d.ts.map +1 -1
- package/dist/comment/observers/index.d.ts.map +1 -1
- package/dist/comment/observers/observeComment.d.ts.map +1 -1
- package/dist/comment/observers/observeComments.d.ts.map +1 -1
- package/dist/community/api/addCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/addCommunityMembersRoles.d.ts +18 -0
- package/dist/community/api/addCommunityMembersRoles.d.ts.map +1 -0
- package/dist/community/api/createCommunity.d.ts.map +1 -1
- package/dist/community/api/deleteCommunity.d.ts.map +1 -1
- package/dist/community/api/getCommunities.d.ts.map +1 -1
- package/dist/community/api/getCommunity.d.ts.map +1 -1
- package/dist/community/api/getRecommendedCommunities.d.ts.map +1 -1
- package/dist/community/api/getTopTrendingCommunities.d.ts.map +1 -1
- package/dist/community/api/index.d.ts +2 -2
- package/dist/community/api/index.d.ts.map +1 -1
- package/dist/community/api/joinCommunity.d.ts.map +1 -1
- package/dist/community/api/leaveCommunity.d.ts.map +1 -1
- package/dist/community/api/queryCommunities.d.ts.map +1 -1
- package/dist/community/api/queryCommunityMembers.d.ts +2 -2
- package/dist/community/api/queryCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/removeCommunityMembers.d.ts.map +1 -1
- package/dist/community/api/removeCommunityMembersRoles.d.ts +18 -0
- package/dist/community/api/removeCommunityMembersRoles.d.ts.map +1 -0
- package/dist/community/api/updateCommunity.d.ts.map +1 -1
- package/dist/community/events/index.d.ts.map +1 -1
- package/dist/community/events/onCommunityCreated.d.ts.map +1 -1
- package/dist/community/events/onCommunityDeleted.d.ts.map +1 -1
- package/dist/community/events/onCommunityJoined.d.ts.map +1 -1
- package/dist/community/events/onCommunityLeft.d.ts.map +1 -1
- package/dist/community/events/onCommunityUpdated.d.ts.map +1 -1
- package/dist/community/events/onCommunityUserAdded.d.ts.map +1 -1
- package/dist/community/events/onCommunityUserBanned.d.ts.map +1 -1
- package/dist/community/events/onCommunityUserRemoved.d.ts.map +1 -1
- package/dist/community/events/onCommunityUserUnbanned.d.ts.map +1 -1
- package/dist/community/events/utils.d.ts.map +1 -1
- package/dist/community/observers/index.d.ts.map +1 -1
- package/dist/community/observers/observeCommunity.d.ts.map +1 -1
- package/dist/core/debug.d.ts.map +1 -1
- package/dist/core/device.d.ts.map +1 -1
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/events.d.ts +1 -1
- package/dist/core/events.d.ts.map +1 -1
- package/dist/core/microtasks.d.ts.map +1 -1
- package/dist/core/model/idResolvers.d.ts.map +1 -1
- package/dist/core/model/identifyModel.d.ts.map +1 -1
- package/dist/core/model/index.d.ts.map +1 -1
- package/dist/core/query/filtering.d.ts +1 -1
- package/dist/core/query/filtering.d.ts.map +1 -1
- package/dist/core/query/index.d.ts.map +1 -1
- package/dist/core/query/paging.d.ts +3 -3
- package/dist/core/query/paging.d.ts.map +1 -1
- package/dist/core/query/query.d.ts.map +1 -1
- package/dist/core/query/sorting.d.ts +1 -1
- package/dist/core/query/sorting.d.ts.map +1 -1
- package/dist/core/subscription.d.ts.map +1 -1
- package/dist/core/transports/http.d.ts.map +1 -1
- package/dist/core/transports/mqtt.d.ts.map +1 -1
- package/dist/core/transports/utils.d.ts.map +1 -1
- package/dist/core/transports/ws.d.ts +1 -1
- package/dist/core/transports/ws.d.ts.map +1 -1
- package/dist/core/uuid.d.ts.map +1 -1
- package/dist/feed/api/index.d.ts.map +1 -1
- package/dist/feed/api/queryGlobalFeed.d.ts +2 -2
- package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -1
- package/dist/file/api/createFile.d.ts +1 -0
- package/dist/file/api/createFile.d.ts.map +1 -1
- package/dist/file/api/createVideo.d.ts +17 -0
- package/dist/file/api/createVideo.d.ts.map +1 -0
- package/dist/file/api/deleteFile.d.ts.map +1 -1
- package/dist/file/api/fileUrlWithSize.d.ts.map +1 -1
- package/dist/file/api/getFile.d.ts +1 -1
- package/dist/file/api/getFile.d.ts.map +1 -1
- package/dist/file/api/index.d.ts +1 -0
- package/dist/file/api/index.d.ts.map +1 -1
- package/dist/file/observers/index.d.ts.map +1 -1
- package/dist/file/observers/observeFile.d.ts.map +1 -1
- package/dist/follow/api/acceptFollower.d.ts.map +1 -1
- package/dist/follow/api/declineFollower.d.ts.map +1 -1
- package/dist/follow/api/follow.d.ts.map +1 -1
- package/dist/follow/api/getFollowInfo.d.ts.map +1 -1
- package/dist/follow/api/index.d.ts.map +1 -1
- package/dist/follow/api/queryFollowers.d.ts.map +1 -1
- package/dist/follow/api/queryFollowings.d.ts.map +1 -1
- package/dist/follow/api/unfollow.d.ts.map +1 -1
- package/dist/follow/api/utils.d.ts.map +1 -1
- package/dist/follow/events/index.d.ts.map +1 -1
- package/dist/follow/events/onFollowInfoUpdated.d.ts.map +1 -1
- package/dist/follow/events/onFollowRequestAccepted.d.ts.map +1 -1
- package/dist/follow/events/onFollowRequestCanceled.d.ts.map +1 -1
- package/dist/follow/events/onFollowRequestDeclined.d.ts.map +1 -1
- package/dist/follow/events/onFollowerDeleted.d.ts.map +1 -1
- package/dist/follow/events/onFollowerRequested.d.ts.map +1 -1
- package/dist/follow/events/onUserFollowed.d.ts.map +1 -1
- package/dist/follow/events/onUserUnfollowed.d.ts.map +1 -1
- package/dist/follow/events/utils.d.ts.map +1 -1
- package/dist/follow/observers/index.d.ts.map +1 -1
- package/dist/follow/observers/observeFollowInfo.d.ts.map +1 -1
- package/dist/follow/observers/observeFollowers.d.ts.map +1 -1
- package/dist/follow/observers/observeFollowings.d.ts.map +1 -1
- package/dist/index.cjs.js +487 -213
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +483 -212
- package/dist/index.umd.js +5 -5
- package/dist/message/api/createMessage.d.ts +2 -2
- package/dist/message/api/createMessage.d.ts.map +1 -1
- package/dist/message/api/deleteMessage.d.ts.map +1 -1
- package/dist/message/api/getMessage.d.ts.map +1 -1
- package/dist/message/api/getMessages.d.ts.map +1 -1
- package/dist/message/api/index.d.ts.map +1 -1
- package/dist/message/api/queryMessages.d.ts.map +1 -1
- package/dist/message/api/updateMessage.d.ts.map +1 -1
- package/dist/message/events/index.d.ts.map +1 -1
- package/dist/message/events/onMessageCreated.d.ts.map +1 -1
- package/dist/message/events/onMessageDeleted.d.ts.map +1 -1
- package/dist/message/events/onMessageUpdated.d.ts.map +1 -1
- package/dist/message/observers/index.d.ts.map +1 -1
- package/dist/message/observers/observeMessage.d.ts.map +1 -1
- package/dist/message/observers/observeMessages.d.ts +5 -1
- package/dist/message/observers/observeMessages.d.ts.map +1 -1
- package/dist/post/api/createPost.d.ts +1 -1
- package/dist/post/api/createPost.d.ts.map +1 -1
- package/dist/post/api/deletePost.d.ts.map +1 -1
- package/dist/post/api/getPost.d.ts +1 -1
- package/dist/post/api/getPost.d.ts.map +1 -1
- package/dist/post/api/getPosts.d.ts.map +1 -1
- package/dist/post/api/index.d.ts.map +1 -1
- package/dist/post/api/queryPosts.d.ts.map +1 -1
- package/dist/post/api/updatePost.d.ts +1 -1
- package/dist/post/api/updatePost.d.ts.map +1 -1
- package/dist/post/events/index.d.ts.map +1 -1
- package/dist/post/events/onPostApproved.d.ts.map +1 -1
- package/dist/post/events/onPostCreated.d.ts.map +1 -1
- package/dist/post/events/onPostDeclined.d.ts.map +1 -1
- package/dist/post/events/onPostDeleted.d.ts.map +1 -1
- package/dist/post/events/onPostFlagged.d.ts.map +1 -1
- package/dist/post/events/onPostReactionAdded.d.ts.map +1 -1
- package/dist/post/events/onPostReactionRemoved.d.ts.map +1 -1
- package/dist/post/events/onPostUnflagged.d.ts.map +1 -1
- package/dist/post/events/onPostUpdated.d.ts.map +1 -1
- package/dist/post/events/utils.d.ts.map +1 -1
- package/dist/post/observers/index.d.ts.map +1 -1
- package/dist/post/observers/observePost.d.ts.map +1 -1
- package/dist/post/observers/observePosts.d.ts +11 -1
- package/dist/post/observers/observePosts.d.ts.map +1 -1
- package/dist/reaction/api/addReaction.d.ts +2 -2
- package/dist/reaction/api/addReaction.d.ts.map +1 -1
- package/dist/reaction/api/index.d.ts.map +1 -1
- package/dist/reaction/api/removeReaction.d.ts +2 -2
- package/dist/reaction/api/removeReaction.d.ts.map +1 -1
- package/dist/reaction/events/index.d.ts.map +1 -1
- package/dist/reaction/events/onReactionAdded.d.ts +1 -1
- package/dist/reaction/events/onReactionAdded.d.ts.map +1 -1
- package/dist/reaction/events/onReactionRemoved.d.ts +1 -1
- package/dist/reaction/events/onReactionRemoved.d.ts.map +1 -1
- package/dist/reaction/utils/dispatchReactable.d.ts.map +1 -1
- package/dist/reaction/utils/fetchReference.d.ts.map +1 -1
- package/dist/reaction/utils/index.d.ts.map +1 -1
- package/dist/reaction/utils/preparePayloadForCache.d.ts.map +1 -1
- package/dist/report/api/createReport.d.ts +1 -1
- package/dist/report/api/createReport.d.ts.map +1 -1
- package/dist/report/api/deleteReport.d.ts +1 -1
- package/dist/report/api/deleteReport.d.ts.map +1 -1
- package/dist/report/api/index.d.ts.map +1 -1
- package/dist/report/api/isReportedByMe.d.ts +1 -1
- package/dist/report/api/isReportedByMe.d.ts.map +1 -1
- package/dist/report/constants/referenceTypes.d.ts.map +1 -1
- package/dist/role/api/getRole.d.ts.map +1 -1
- package/dist/role/api/index.d.ts.map +1 -1
- package/dist/role/api/queryRoles.d.ts.map +1 -1
- package/dist/stream/api/createStream.d.ts.map +1 -1
- package/dist/stream/api/deleteStream.d.ts.map +1 -1
- package/dist/stream/api/disposeStream.d.ts.map +1 -1
- package/dist/stream/api/getStream.d.ts.map +1 -1
- package/dist/stream/api/index.d.ts.map +1 -1
- package/dist/stream/api/queryStreams.d.ts.map +1 -1
- package/dist/stream/api/updateStream.d.ts.map +1 -1
- package/dist/stream/events/index.d.ts.map +1 -1
- package/dist/stream/events/onStreamRecorded.d.ts.map +1 -1
- package/dist/stream/events/onStreamStarted.d.ts.map +1 -1
- package/dist/stream/events/onStreamStopped.d.ts.map +1 -1
- package/dist/user/api/getUser.d.ts.map +1 -1
- package/dist/user/api/getUsers.d.ts.map +1 -1
- package/dist/user/api/index.d.ts.map +1 -1
- package/dist/user/api/queryUsers.d.ts.map +1 -1
- package/dist/user/api/updateUser.d.ts +1 -1
- package/dist/user/api/updateUser.d.ts.map +1 -1
- package/dist/user/events/index.d.ts.map +1 -1
- package/dist/user/events/onUserFlagCleared.d.ts.map +1 -1
- package/dist/user/events/onUserFlagged.d.ts.map +1 -1
- package/dist/user/events/onUserUnflagged.d.ts.map +1 -1
- package/dist/user/events/onUserUpdated.d.ts.map +1 -1
- package/dist/user/events/utils.d.ts.map +1 -1
- package/dist/user/observers/index.d.ts.map +1 -1
- package/dist/user/observers/observeUser.d.ts.map +1 -1
- package/dist/utils/env.d.ts +1 -1
- package/dist/utils/env.d.ts.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/package.json +1 -1
- package/rollup.config.js +11 -11
- package/src/@types/core/cache.ts +29 -28
- package/src/@types/core/errors.ts +3 -3
- package/src/@types/core/events.ts +95 -92
- package/src/@types/core/model.ts +37 -38
- package/src/@types/core/paging.ts +27 -27
- package/src/@types/core/payload.ts +79 -79
- package/src/@types/core/permissions.ts +6 -7
- package/src/@types/core/query.ts +38 -37
- package/src/@types/core/transport.ts +37 -28
- package/src/@types/domains/category.ts +7 -8
- package/src/@types/domains/channel.ts +29 -30
- package/src/@types/domains/client.ts +24 -24
- package/src/@types/domains/comment.ts +19 -20
- package/src/@types/domains/community.ts +22 -23
- package/src/@types/domains/content.ts +26 -22
- package/src/@types/domains/feed.ts +8 -9
- package/src/@types/domains/file.ts +28 -28
- package/src/@types/domains/follow.ts +13 -15
- package/src/@types/domains/group.ts +24 -26
- package/src/@types/domains/mention.ts +13 -12
- package/src/@types/domains/message.ts +15 -16
- package/src/@types/domains/partials.ts +29 -29
- package/src/@types/domains/post.ts +24 -24
- package/src/@types/domains/reaction.ts +17 -18
- package/src/@types/domains/stream.ts +37 -38
- package/src/@types/domains/user.ts +13 -13
- package/src/@types/global.ts +20 -17
- package/src/@types/index.ts +24 -24
- package/src/cache/api/backupCache.ts +14 -18
- package/src/cache/api/disableCache.ts +6 -6
- package/src/cache/api/dropFromCache.ts +13 -16
- package/src/cache/api/enableCache.ts +6 -6
- package/src/cache/api/index.ts +11 -11
- package/src/cache/api/ingestInCache.ts +15 -16
- package/src/cache/api/mergeInCache.ts +10 -12
- package/src/cache/api/pullFromCache.ts +9 -11
- package/src/cache/api/pushToCache.ts +14 -12
- package/src/cache/api/queryCache.ts +11 -12
- package/src/cache/api/restoreCache.ts +16 -15
- package/src/cache/api/snipeIdFromCollection.ts +19 -24
- package/src/cache/api/upsertInCache.ts +11 -13
- package/src/cache/api/wipeCache.ts +10 -12
- package/src/cache/utils/index.ts +15 -25
- package/src/category/api/getCategory.ts +50 -14
- package/src/category/api/index.ts +2 -2
- package/src/category/api/queryCategories.ts +88 -27
- package/src/channel/api/addChannelMembers.ts +14 -15
- package/src/channel/api/addChannelMembersRole.ts +12 -13
- package/src/channel/api/createChannel.ts +18 -13
- package/src/channel/api/deleteChannel.ts +9 -9
- package/src/channel/api/getChannel.ts +18 -19
- package/src/channel/api/getChannels.ts +22 -24
- package/src/channel/api/index.ts +13 -13
- package/src/channel/api/joinChannel.ts +12 -15
- package/src/channel/api/leaveChannel.ts +12 -15
- package/src/channel/api/queryChannelMembers.ts +35 -36
- package/src/channel/api/queryChannels.ts +44 -47
- package/src/channel/api/removeChannelMembers.ts +14 -15
- package/src/channel/api/removeChannelMembersRole.ts +12 -13
- package/src/channel/api/updateChannel.ts +12 -11
- package/src/channel/events/index.ts +6 -6
- package/src/channel/events/onChannelCreated.ts +9 -14
- package/src/channel/events/onChannelDeleted.ts +9 -14
- package/src/channel/events/onChannelJoined.ts +9 -14
- package/src/channel/events/onChannelLeft.ts +9 -14
- package/src/channel/events/onChannelUpdated.ts +9 -14
- package/src/channel/events/onMemberAdded.ts +9 -14
- package/src/channel/events/onMemberRemoved.ts +9 -14
- package/src/channel/observers/index.ts +1 -1
- package/src/channel/observers/observeChannel.ts +24 -30
- package/src/client/api/activeClient.ts +7 -7
- package/src/client/api/activeUser.ts +7 -7
- package/src/client/api/connectClient.ts +32 -30
- package/src/client/api/createClient.ts +22 -18
- package/src/client/api/disconnectClient.ts +14 -14
- package/src/client/api/getToken.ts +22 -17
- package/src/client/api/index.ts +5 -5
- package/src/client/api/isConnected.ts +8 -8
- package/src/client/events/index.ts +3 -3
- package/src/client/events/onClientBanned.ts +5 -7
- package/src/client/events/onClientDisconnected.ts +5 -7
- package/src/client/events/onConnectionError.ts +17 -24
- package/src/client/utils/endpoints.ts +3 -3
- package/src/comment/api/createComment.ts +19 -18
- package/src/comment/api/deleteComment.ts +21 -22
- package/src/comment/api/getComment.ts +22 -23
- package/src/comment/api/getComments.ts +24 -26
- package/src/comment/api/index.ts +6 -6
- package/src/comment/api/queryComments.ts +53 -50
- package/src/comment/api/updateComment.ts +14 -13
- package/src/comment/events/index.ts +7 -7
- package/src/comment/events/onCommentCreated.ts +3 -5
- package/src/comment/events/onCommentDeleted.ts +3 -5
- package/src/comment/events/onCommentFlagged.ts +3 -5
- package/src/comment/events/onCommentReactionAdded.ts +20 -20
- package/src/comment/events/onCommentReactionRemoved.ts +20 -20
- package/src/comment/events/onCommentUnflagged.ts +3 -5
- package/src/comment/events/onCommentUpdated.ts +3 -5
- package/src/comment/events/utils.ts +19 -20
- package/src/comment/observers/index.ts +2 -2
- package/src/comment/observers/observeComment.ts +48 -37
- package/src/comment/observers/observeComments.ts +34 -19
- package/src/community/api/addCommunityMembers.ts +14 -15
- package/src/community/api/addCommunityMembersRoles.ts +42 -0
- package/src/community/api/createCommunity.ts +26 -19
- package/src/community/api/deleteCommunity.ts +10 -12
- package/src/community/api/getCommunities.ts +24 -26
- package/src/community/api/getCommunity.ts +20 -21
- package/src/community/api/getRecommendedCommunities.ts +29 -28
- package/src/community/api/getTopTrendingCommunities.ts +29 -28
- package/src/community/api/index.ts +15 -16
- package/src/community/api/joinCommunity.ts +16 -16
- package/src/community/api/leaveCommunity.ts +16 -16
- package/src/community/api/queryCommunities.ts +48 -50
- package/src/community/api/queryCommunityMembers.ts +34 -35
- package/src/community/api/removeCommunityMembers.ts +14 -15
- package/src/community/api/removeCommunityMembersRoles.ts +42 -0
- package/src/community/api/updateCommunity.ts +18 -14
- package/src/community/events/index.ts +9 -9
- package/src/community/events/onCommunityCreated.ts +2 -2
- package/src/community/events/onCommunityDeleted.ts +2 -2
- package/src/community/events/onCommunityJoined.ts +4 -3
- package/src/community/events/onCommunityLeft.ts +4 -3
- package/src/community/events/onCommunityUpdated.ts +2 -2
- package/src/community/events/onCommunityUserAdded.ts +4 -3
- package/src/community/events/onCommunityUserBanned.ts +4 -3
- package/src/community/events/onCommunityUserRemoved.ts +4 -3
- package/src/community/events/onCommunityUserUnbanned.ts +4 -3
- package/src/community/events/utils.ts +46 -44
- package/src/community/observers/index.ts +1 -1
- package/src/community/observers/observeCommunity.ts +57 -39
- package/src/core/debug.ts +10 -12
- package/src/core/device.ts +11 -12
- package/src/core/errors.ts +16 -19
- package/src/core/events.ts +47 -47
- package/src/core/microtasks.ts +12 -11
- package/src/core/model/idResolvers.ts +6 -7
- package/src/core/model/identifyModel.ts +14 -12
- package/src/core/model/index.ts +6 -5
- package/src/core/query/filtering.ts +5 -3
- package/src/core/query/index.ts +4 -4
- package/src/core/query/paging.ts +44 -49
- package/src/core/query/query.ts +58 -64
- package/src/core/query/sorting.ts +21 -15
- package/src/core/subscription.ts +24 -20
- package/src/core/transports/http.ts +27 -25
- package/src/core/transports/mqtt.ts +70 -51
- package/src/core/transports/utils.ts +8 -7
- package/src/core/transports/ws.ts +16 -17
- package/src/core/uuid.ts +3 -2
- package/src/feed/api/index.ts +1 -1
- package/src/feed/api/queryGlobalFeed.ts +53 -43
- package/src/file/api/createFile.ts +20 -19
- package/src/file/api/createVideo.ts +58 -0
- package/src/file/api/deleteFile.ts +9 -11
- package/src/file/api/fileUrlWithSize.ts +2 -2
- package/src/file/api/getFile.ts +19 -24
- package/src/file/api/index.ts +5 -4
- package/src/file/observers/index.ts +1 -1
- package/src/file/observers/observeFile.ts +17 -23
- package/src/follow/api/acceptFollower.ts +12 -10
- package/src/follow/api/declineFollower.ts +12 -10
- package/src/follow/api/follow.ts +16 -12
- package/src/follow/api/getFollowInfo.ts +28 -20
- package/src/follow/api/index.ts +7 -7
- package/src/follow/api/queryFollowers.ts +7 -10
- package/src/follow/api/queryFollowings.ts +7 -10
- package/src/follow/api/unfollow.ts +12 -10
- package/src/follow/api/utils.ts +40 -35
- package/src/follow/events/index.ts +8 -8
- package/src/follow/events/onFollowInfoUpdated.ts +15 -13
- package/src/follow/events/onFollowRequestAccepted.ts +4 -3
- package/src/follow/events/onFollowRequestCanceled.ts +4 -3
- package/src/follow/events/onFollowRequestDeclined.ts +4 -3
- package/src/follow/events/onFollowerDeleted.ts +4 -3
- package/src/follow/events/onFollowerRequested.ts +4 -3
- package/src/follow/events/onUserFollowed.ts +2 -2
- package/src/follow/events/onUserUnfollowed.ts +4 -3
- package/src/follow/events/utils.ts +15 -20
- package/src/follow/observers/index.ts +3 -3
- package/src/follow/observers/observeFollowInfo.ts +27 -31
- package/src/follow/observers/observeFollowers.ts +29 -30
- package/src/follow/observers/observeFollowings.ts +29 -30
- package/src/index.ts +40 -38
- package/src/message/api/createMessage.ts +31 -29
- package/src/message/api/deleteMessage.ts +22 -22
- package/src/message/api/getMessage.ts +18 -19
- package/src/message/api/getMessages.ts +22 -24
- package/src/message/api/index.ts +6 -6
- package/src/message/api/queryMessages.ts +55 -47
- package/src/message/api/updateMessage.ts +26 -25
- package/src/message/events/index.ts +3 -3
- package/src/message/events/onMessageCreated.ts +10 -17
- package/src/message/events/onMessageDeleted.ts +10 -17
- package/src/message/events/onMessageUpdated.ts +10 -17
- package/src/message/observers/index.ts +2 -2
- package/src/message/observers/observeMessage.ts +23 -29
- package/src/message/observers/observeMessages.ts +20 -22
- package/src/post/api/createPost.ts +20 -20
- package/src/post/api/deletePost.ts +22 -25
- package/src/post/api/getPost.ts +23 -28
- package/src/post/api/getPosts.ts +24 -28
- package/src/post/api/index.ts +6 -6
- package/src/post/api/queryPosts.ts +48 -50
- package/src/post/api/updatePost.ts +15 -15
- package/src/post/events/index.ts +9 -9
- package/src/post/events/onPostApproved.ts +2 -2
- package/src/post/events/onPostCreated.ts +2 -2
- package/src/post/events/onPostDeclined.ts +2 -2
- package/src/post/events/onPostDeleted.ts +2 -2
- package/src/post/events/onPostFlagged.ts +2 -2
- package/src/post/events/onPostReactionAdded.ts +15 -19
- package/src/post/events/onPostReactionRemoved.ts +15 -19
- package/src/post/events/onPostUnflagged.ts +2 -2
- package/src/post/events/onPostUpdated.ts +2 -2
- package/src/post/events/utils.ts +19 -24
- package/src/post/observers/index.ts +2 -2
- package/src/post/observers/observePost.ts +46 -34
- package/src/post/observers/observePosts.ts +47 -24
- package/src/reaction/api/addReaction.ts +32 -27
- package/src/reaction/api/index.ts +2 -2
- package/src/reaction/api/removeReaction.ts +30 -27
- package/src/reaction/events/index.ts +1 -1
- package/src/reaction/events/onReactionAdded.ts +26 -22
- package/src/reaction/events/onReactionRemoved.ts +26 -22
- package/src/reaction/utils/dispatchReactable.ts +5 -7
- package/src/reaction/utils/fetchReference.ts +8 -11
- package/src/reaction/utils/index.ts +3 -3
- package/src/reaction/utils/preparePayloadForCache.ts +27 -19
- package/src/report/api/createReport.ts +20 -19
- package/src/report/api/deleteReport.ts +20 -19
- package/src/report/api/index.ts +3 -3
- package/src/report/api/isReportedByMe.ts +13 -13
- package/src/report/constants/referenceTypes.ts +1 -1
- package/src/role/api/getRole.ts +19 -26
- package/src/role/api/index.ts +2 -2
- package/src/role/api/queryRoles.ts +29 -32
- package/src/stream/api/createStream.ts +11 -13
- package/src/stream/api/deleteStream.ts +14 -16
- package/src/stream/api/disposeStream.ts +11 -11
- package/src/stream/api/getStream.ts +21 -21
- package/src/stream/api/index.ts +6 -6
- package/src/stream/api/queryStreams.ts +36 -37
- package/src/stream/api/updateStream.ts +12 -12
- package/src/stream/events/index.ts +3 -3
- package/src/stream/events/onStreamRecorded.ts +10 -12
- package/src/stream/events/onStreamStarted.ts +10 -12
- package/src/stream/events/onStreamStopped.ts +10 -17
- package/src/user/api/getUser.ts +18 -22
- package/src/user/api/getUsers.ts +23 -27
- package/src/user/api/index.ts +4 -4
- package/src/user/api/queryUsers.ts +42 -46
- package/src/user/api/updateUser.ts +18 -13
- package/src/user/events/index.ts +4 -4
- package/src/user/events/onUserFlagCleared.ts +2 -2
- package/src/user/events/onUserFlagged.ts +2 -2
- package/src/user/events/onUserUnflagged.ts +2 -2
- package/src/user/events/onUserUpdated.ts +2 -2
- package/src/user/events/utils.ts +10 -15
- package/src/user/observers/index.ts +1 -1
- package/src/user/observers/observeUser.ts +25 -34
- package/src/utils/env.ts +6 -3
- package/src/version.ts +2 -2
- package/dist/community/api/addCommunityMembersRole.d.ts +0 -18
- package/dist/community/api/addCommunityMembersRole.d.ts.map +0 -1
- package/dist/community/api/removeCommunityMembersRole.d.ts +0 -18
- package/dist/community/api/removeCommunityMembersRole.d.ts.map +0 -1
- package/src/community/api/addCommunityMembersRole.ts +0 -41
- package/src/community/api/removeCommunityMembersRole.ts +0 -41
package/dist/index.esm.js
CHANGED
|
@@ -7,6 +7,7 @@ import mitt from 'mitt';
|
|
|
7
7
|
import AsyncStorage from '@react-native-async-storage/async-storage';
|
|
8
8
|
|
|
9
9
|
var _a$1;
|
|
10
|
+
/* eslint-disable no-undef */
|
|
10
11
|
const theGlobal = globalThis || global || window;
|
|
11
12
|
const { process: safeProcess = {} } = theGlobal;
|
|
12
13
|
const isProduction = ((_a$1 = safeProcess.env) === null || _a$1 === void 0 ? void 0 : _a$1.NODE_ENV) === 'production';
|
|
@@ -22,7 +23,7 @@ const VERSION$1 = (_b = (_a = safeProcess.env) === null || _a === void 0 ? void
|
|
|
22
23
|
*
|
|
23
24
|
* @hidden
|
|
24
25
|
*/
|
|
25
|
-
const isSkipLimit = (json) =>
|
|
26
|
+
const isSkipLimit = (json) => ['skip', 'limit'].some(prop => prop in json);
|
|
26
27
|
/**
|
|
27
28
|
* Type guard to find if the a given decoded backend token uses "after/before" pagination style
|
|
28
29
|
*
|
|
@@ -31,7 +32,7 @@ const isSkipLimit = (json) => (['skip', 'limit'].some(prop => prop in json));
|
|
|
31
32
|
*
|
|
32
33
|
* @hidden
|
|
33
34
|
*/
|
|
34
|
-
const isAfterBefore = (json) =>
|
|
35
|
+
const isAfterBefore = (json) => ['after', 'before', 'first', 'last', 'limit'].some(prop => prop in json);
|
|
35
36
|
/**
|
|
36
37
|
* Type guard to find if the a given decoded backend token uses v4 or newer "after/before" pagination style
|
|
37
38
|
*
|
|
@@ -40,7 +41,7 @@ const isAfterBefore = (json) => (['after', 'before', 'first', 'last', 'limit'].s
|
|
|
40
41
|
*
|
|
41
42
|
* @hidden
|
|
42
43
|
*/
|
|
43
|
-
const isAfterBeforeRaw = (json) =>
|
|
44
|
+
const isAfterBeforeRaw = (json) => 'limit' in json;
|
|
44
45
|
/**
|
|
45
46
|
* Type guard to find if the a given object is wrapped around Amity.Paged<>
|
|
46
47
|
*
|
|
@@ -50,9 +51,9 @@ const isAfterBeforeRaw = (json) => ('limit' in json);
|
|
|
50
51
|
* @hidden
|
|
51
52
|
*/
|
|
52
53
|
const isPaged = (payload) => {
|
|
53
|
-
return ((payload === null || payload === void 0 ? void 0 : payload.hasOwnProperty('data'))
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
return ((payload === null || payload === void 0 ? void 0 : payload.hasOwnProperty('data')) &&
|
|
55
|
+
(payload === null || payload === void 0 ? void 0 : payload.hasOwnProperty('nextPage')) &&
|
|
56
|
+
(payload === null || payload === void 0 ? void 0 : payload.hasOwnProperty('prevPage')));
|
|
56
57
|
};
|
|
57
58
|
/**
|
|
58
59
|
* Converts a paging object into a b64 string token
|
|
@@ -82,19 +83,19 @@ const toToken = (paging, style) => {
|
|
|
82
83
|
"before" or "after" value. if that would change,
|
|
83
84
|
we'd need to move toward a more simple: `!paging.before`
|
|
84
85
|
*/
|
|
85
|
-
if (!isNaN(paging === null || paging === void 0 ? void 0 : paging.before)) {
|
|
86
|
+
if (!Number.isNaN(paging === null || paging === void 0 ? void 0 : paging.before)) {
|
|
86
87
|
payload = {
|
|
87
88
|
before: paging.before,
|
|
88
89
|
last: paging.limit,
|
|
89
90
|
};
|
|
90
91
|
}
|
|
91
|
-
else if (!isNaN(paging === null || paging === void 0 ? void 0 : paging.after)) {
|
|
92
|
+
else if (!Number.isNaN(paging === null || paging === void 0 ? void 0 : paging.after)) {
|
|
92
93
|
payload = {
|
|
93
94
|
after: paging.after,
|
|
94
95
|
first: paging.limit,
|
|
95
96
|
};
|
|
96
97
|
}
|
|
97
|
-
else if (!isNaN(paging === null || paging === void 0 ? void 0 : paging.limit)) {
|
|
98
|
+
else if (!Number.isNaN(paging === null || paging === void 0 ? void 0 : paging.limit)) {
|
|
98
99
|
payload = {
|
|
99
100
|
last: paging.limit,
|
|
100
101
|
};
|
|
@@ -128,14 +129,14 @@ const toPage = (token) => {
|
|
|
128
129
|
limit: json.limit,
|
|
129
130
|
};
|
|
130
131
|
}
|
|
131
|
-
|
|
132
|
+
if (isAfterBefore(json)) {
|
|
132
133
|
if ('before' in json) {
|
|
133
134
|
return {
|
|
134
135
|
before: json.before,
|
|
135
136
|
limit: json.last,
|
|
136
137
|
};
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
+
if ('after' in json) {
|
|
139
140
|
return {
|
|
140
141
|
after: json.after,
|
|
141
142
|
limit: json.first,
|
|
@@ -163,6 +164,7 @@ const toPageRaw = (token) => {
|
|
|
163
164
|
return undefined;
|
|
164
165
|
};
|
|
165
166
|
|
|
167
|
+
/* eslint-disable no-use-before-define */
|
|
166
168
|
/**
|
|
167
169
|
* Type guard to check and cast that a given async function is has the ".locally" property
|
|
168
170
|
*
|
|
@@ -171,7 +173,7 @@ const toPageRaw = (token) => {
|
|
|
171
173
|
*
|
|
172
174
|
* @hidden
|
|
173
175
|
*/
|
|
174
|
-
const isFetcher = (func) =>
|
|
176
|
+
const isFetcher = (func) => 'locally' in func;
|
|
175
177
|
/**
|
|
176
178
|
* Type guard to check and cast that a given async function is has the ".optimistically" property
|
|
177
179
|
*
|
|
@@ -180,7 +182,7 @@ const isFetcher = (func) => ('locally' in func);
|
|
|
180
182
|
*
|
|
181
183
|
* @hidden
|
|
182
184
|
*/
|
|
183
|
-
const isMutator = (func) =>
|
|
185
|
+
const isMutator = (func) => 'optimistically' in func;
|
|
184
186
|
/**
|
|
185
187
|
* Type guard to check and cast that a given async function is has
|
|
186
188
|
* the ".locally" or ".optimistically" property
|
|
@@ -199,7 +201,7 @@ const isOffline = (func) => isFetcher(func) || isMutator(func);
|
|
|
199
201
|
*
|
|
200
202
|
* @hidden
|
|
201
203
|
*/
|
|
202
|
-
const isCachable = (model) =>
|
|
204
|
+
const isCachable = (model) => model === null || model === void 0 ? void 0 : model.hasOwnProperty('cachedAt');
|
|
203
205
|
/**
|
|
204
206
|
* Checks if a model is considered local (cachedAt === -1)
|
|
205
207
|
*
|
|
@@ -257,7 +259,7 @@ const createQuery = (func, ...args) => ({ func, args });
|
|
|
257
259
|
const queryOptions = (policy, lifeSpan = 2 * 60 * 1000) => {
|
|
258
260
|
if (policy === 'cache_only')
|
|
259
261
|
return { lifeSpan: Infinity };
|
|
260
|
-
|
|
262
|
+
if (policy === 'server_only')
|
|
261
263
|
return { lifeSpan: 0 };
|
|
262
264
|
return { lifeSpan };
|
|
263
265
|
};
|
|
@@ -283,9 +285,7 @@ const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_s
|
|
|
283
285
|
// offline first
|
|
284
286
|
if (isOffline(func) && options.lifeSpan !== 0) {
|
|
285
287
|
try {
|
|
286
|
-
local = isMutator(func)
|
|
287
|
-
? func.optimistically(...args)
|
|
288
|
-
: func.locally(...args);
|
|
288
|
+
local = isMutator(func) ? func.optimistically(...args) : func.locally(...args);
|
|
289
289
|
}
|
|
290
290
|
catch (error) {
|
|
291
291
|
callback === null || callback === void 0 ? void 0 : callback(createSnapshot(undefined, {
|
|
@@ -297,7 +297,7 @@ const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_s
|
|
|
297
297
|
const shouldAbort = isCachable(local) && isFresh(local, options.lifeSpan);
|
|
298
298
|
callback === null || callback === void 0 ? void 0 : callback(createSnapshot(local, {
|
|
299
299
|
origin: 'local',
|
|
300
|
-
loading: !(isFetcher(func) && shouldAbort)
|
|
300
|
+
loading: !(isFetcher(func) && shouldAbort),
|
|
301
301
|
}));
|
|
302
302
|
if (shouldAbort)
|
|
303
303
|
return;
|
|
@@ -305,13 +305,13 @@ const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_s
|
|
|
305
305
|
else {
|
|
306
306
|
callback === null || callback === void 0 ? void 0 : callback(createSnapshot(undefined, {
|
|
307
307
|
origin: 'local',
|
|
308
|
-
loading: true
|
|
308
|
+
loading: true,
|
|
309
309
|
}));
|
|
310
310
|
}
|
|
311
311
|
func(...args)
|
|
312
312
|
.then(fresh => {
|
|
313
313
|
// @ts-ignore i know.
|
|
314
|
-
//
|
|
314
|
+
// isLocal(local) && syncInCache(local, fresh)
|
|
315
315
|
callback === null || callback === void 0 ? void 0 : callback(createSnapshot(fresh, {
|
|
316
316
|
origin: 'server',
|
|
317
317
|
loading: false,
|
|
@@ -325,6 +325,7 @@ const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_s
|
|
|
325
325
|
}));
|
|
326
326
|
});
|
|
327
327
|
};
|
|
328
|
+
// eslint-disable-next-line no-redeclare
|
|
328
329
|
function createSnapshot(data, options) {
|
|
329
330
|
if (isPaged(data) || isCachable(data))
|
|
330
331
|
return Object.assign(Object.assign({}, options), data);
|
|
@@ -378,6 +379,7 @@ const sortByLastCreated = ({ createdAt: a }, { createdAt: b }) => new Date(b).va
|
|
|
378
379
|
*/
|
|
379
380
|
const sortByLastActivity = ({ lastActivity: a }, { lastActivity: b }) => new Date(b).valueOf() - new Date(a).valueOf();
|
|
380
381
|
|
|
382
|
+
/* eslint-disable max-classes-per-file */
|
|
381
383
|
/**
|
|
382
384
|
* Generic ASC error
|
|
383
385
|
* @category Errors
|
|
@@ -407,6 +409,7 @@ class ASCApiError extends ASCError {
|
|
|
407
409
|
* @param code A normalized error code
|
|
408
410
|
* @param level A normalized failure level descriptor
|
|
409
411
|
*/
|
|
412
|
+
// eslint-disable-next-line no-useless-constructor
|
|
410
413
|
constructor(message, code, level) {
|
|
411
414
|
super(message, code, level);
|
|
412
415
|
}
|
|
@@ -433,7 +436,9 @@ class ASCConnectionError extends ASCError {
|
|
|
433
436
|
* @param message A custom error message
|
|
434
437
|
*/
|
|
435
438
|
constructor(event, message = 'SDK client is having connection issues') {
|
|
436
|
-
super(`${message} (${event})`, event === 'disconnected'
|
|
439
|
+
super(`${message} (${event})`, event === 'disconnected'
|
|
440
|
+
? 800211 /* DISCONNECTED */
|
|
441
|
+
: 800210 /* CONNECTION_ERROR */, "error" /* ERROR */);
|
|
437
442
|
this.event = event;
|
|
438
443
|
}
|
|
439
444
|
}
|
|
@@ -473,12 +478,12 @@ const setActiveClient = (client) => {
|
|
|
473
478
|
* @hidden
|
|
474
479
|
*/
|
|
475
480
|
const createLogger = (session) => {
|
|
476
|
-
const active =
|
|
477
|
-
&& !isProduction);
|
|
481
|
+
const active = `${session === null || session === void 0 ? void 0 : session.trim()}`.length > 0 && !isProduction;
|
|
478
482
|
const logger = debug(session);
|
|
479
483
|
const print = (topic, ...args) => {
|
|
480
484
|
active && logger(topic, args);
|
|
481
485
|
};
|
|
486
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
482
487
|
print.__instance__ = logger;
|
|
483
488
|
return print;
|
|
484
489
|
};
|
|
@@ -511,7 +516,7 @@ const unwrapPayload = (response) => {
|
|
|
511
516
|
if (response.status === 'success') {
|
|
512
517
|
return response.data;
|
|
513
518
|
}
|
|
514
|
-
|
|
519
|
+
if (response.status === 'fail') {
|
|
515
520
|
throw new ASCUnknownError(response.code);
|
|
516
521
|
}
|
|
517
522
|
else if (response.status === 'error') {
|
|
@@ -533,9 +538,10 @@ const stringify = (params, prefix) => {
|
|
|
533
538
|
if (Array.isArray(value)) {
|
|
534
539
|
return value.map(item => `${key}[]=${item}`).join('&');
|
|
535
540
|
}
|
|
536
|
-
|
|
541
|
+
if (typeof value !== 'object') {
|
|
537
542
|
return `${key}=${value}`;
|
|
538
543
|
}
|
|
544
|
+
// @ts-ignore
|
|
539
545
|
return stringify(value, prefix !== null && prefix !== void 0 ? prefix : name);
|
|
540
546
|
})
|
|
541
547
|
.join('&');
|
|
@@ -562,9 +568,10 @@ const createHttpTransport = (endpoint) => {
|
|
|
562
568
|
httpsAgent: new HttpsAgent(options),
|
|
563
569
|
paramsSerializer: stringify,
|
|
564
570
|
});
|
|
565
|
-
instance.interceptors.response.use(
|
|
571
|
+
instance.interceptors.response.use(response => response, error => {
|
|
566
572
|
var _a;
|
|
567
573
|
const { response } = error;
|
|
574
|
+
// eslint-disable-next-line no-console
|
|
568
575
|
console.error((_a = response === null || response === void 0 ? void 0 : response.data) !== null && _a !== void 0 ? _a : error);
|
|
569
576
|
if (response)
|
|
570
577
|
unwrapPayload(response.data);
|
|
@@ -14582,6 +14589,7 @@ function extend() {
|
|
|
14582
14589
|
|
|
14583
14590
|
var mqtt = mqtt$1.exports;
|
|
14584
14591
|
|
|
14592
|
+
/* eslint-disable no-console */
|
|
14585
14593
|
const QOS_FAILURE_CODE = 128;
|
|
14586
14594
|
const RETRY_BASE_TIMEOUT = 1000;
|
|
14587
14595
|
const RETRY_COUNT_MAX = 10;
|
|
@@ -14596,7 +14604,7 @@ function getMqttOptions(params) {
|
|
|
14596
14604
|
topic: 'WillMsg',
|
|
14597
14605
|
payload: 'Connection Closed abnormally..!',
|
|
14598
14606
|
qos: 0,
|
|
14599
|
-
retain: false
|
|
14607
|
+
retain: false,
|
|
14600
14608
|
} }, params);
|
|
14601
14609
|
}
|
|
14602
14610
|
/**
|
|
@@ -14612,6 +14620,12 @@ const createMqttTransport = (endpoint) => {
|
|
|
14612
14620
|
let mqttClient;
|
|
14613
14621
|
let retryCount = 0;
|
|
14614
14622
|
let allowReconnection = true;
|
|
14623
|
+
const reconnect = () => {
|
|
14624
|
+
setTimeout(() => {
|
|
14625
|
+
retryCount += 1;
|
|
14626
|
+
mqttClient.reconnect();
|
|
14627
|
+
}, RETRY_BASE_TIMEOUT * 2 ** (retryCount > RETRY_COUNT_MAX ? RETRY_COUNT_MAX : retryCount));
|
|
14628
|
+
};
|
|
14615
14629
|
async function connect(params) {
|
|
14616
14630
|
if (mqttClient) {
|
|
14617
14631
|
mqttClient.removeAllListeners();
|
|
@@ -14623,6 +14637,7 @@ const createMqttTransport = (endpoint) => {
|
|
|
14623
14637
|
allowReconnection = true;
|
|
14624
14638
|
});
|
|
14625
14639
|
mqttClient.on('error', (error) => {
|
|
14640
|
+
// eslint-disable-next-line default-case
|
|
14626
14641
|
switch (error.code) {
|
|
14627
14642
|
case 2 /* IDENTIFIER_REJECTED */:
|
|
14628
14643
|
case 4 /* BAD_USERNAME_OR_PASSWORD */:
|
|
@@ -14637,12 +14652,6 @@ const createMqttTransport = (endpoint) => {
|
|
|
14637
14652
|
});
|
|
14638
14653
|
return new Promise(resolve => mqttClient.once('connect', () => resolve()));
|
|
14639
14654
|
}
|
|
14640
|
-
const reconnect = () => {
|
|
14641
|
-
setTimeout(() => {
|
|
14642
|
-
retryCount = retryCount + 1;
|
|
14643
|
-
mqttClient.reconnect();
|
|
14644
|
-
}, RETRY_BASE_TIMEOUT * Math.pow(2, retryCount > RETRY_COUNT_MAX ? RETRY_COUNT_MAX : retryCount));
|
|
14645
|
-
};
|
|
14646
14655
|
return {
|
|
14647
14656
|
connect,
|
|
14648
14657
|
async disconnect() {
|
|
@@ -14676,8 +14685,8 @@ const createMqttTransport = (endpoint) => {
|
|
|
14676
14685
|
if (error || granted[0].qos === QOS_FAILURE_CODE) {
|
|
14677
14686
|
const ascError = error
|
|
14678
14687
|
? new ASCError(error.message, 800000 /* UNKNOWN_ERROR */, "error" /* ERROR */)
|
|
14679
|
-
// TODO throw the actual error, once BE can tell us the actual error code
|
|
14680
|
-
|
|
14688
|
+
: // TODO throw the actual error, once BE can tell us the actual error code
|
|
14689
|
+
new ASCUnknownError(800000 /* UNKNOWN_ERROR */, "error" /* ERROR */);
|
|
14681
14690
|
console.error(`Failed to subscribe to topic ${topic}`, ascError);
|
|
14682
14691
|
callback === null || callback === void 0 ? void 0 : callback(ascError);
|
|
14683
14692
|
}
|
|
@@ -14696,10 +14705,11 @@ const createMqttTransport = (endpoint) => {
|
|
|
14696
14705
|
},
|
|
14697
14706
|
unsubscribe(topic) {
|
|
14698
14707
|
mqttClient === null || mqttClient === void 0 ? void 0 : mqttClient.unsubscribe(topic);
|
|
14699
|
-
}
|
|
14708
|
+
},
|
|
14700
14709
|
};
|
|
14701
14710
|
};
|
|
14702
14711
|
|
|
14712
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
14703
14713
|
let tasks = [];
|
|
14704
14714
|
let timer;
|
|
14705
14715
|
/**
|
|
@@ -14716,6 +14726,7 @@ const scheduleTask = (task) => {
|
|
|
14716
14726
|
}, 0);
|
|
14717
14727
|
};
|
|
14718
14728
|
|
|
14729
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
14719
14730
|
// need to sync up the list
|
|
14720
14731
|
const WS_EVENTS = [
|
|
14721
14732
|
'disconnected',
|
|
@@ -14742,7 +14753,7 @@ const MQTT_EVENTS = [
|
|
|
14742
14753
|
'error',
|
|
14743
14754
|
'close',
|
|
14744
14755
|
'end',
|
|
14745
|
-
'reconnect'
|
|
14756
|
+
'reconnect',
|
|
14746
14757
|
];
|
|
14747
14758
|
/** @hidden */
|
|
14748
14759
|
const createEventEmitter = () => {
|
|
@@ -14806,7 +14817,9 @@ const createEventSubscriber = (client, namespace, event, fn) => {
|
|
|
14806
14817
|
*/
|
|
14807
14818
|
const fireEvent = (event, payload) => {
|
|
14808
14819
|
const { emitter } = getActiveClient();
|
|
14809
|
-
scheduleTask(() => {
|
|
14820
|
+
scheduleTask(() => {
|
|
14821
|
+
emitter.emit(event, payload);
|
|
14822
|
+
});
|
|
14810
14823
|
};
|
|
14811
14824
|
|
|
14812
14825
|
/**
|
|
@@ -14823,7 +14836,7 @@ const fireEvent = (event, payload) => {
|
|
|
14823
14836
|
* @returns A {@link Amity.Client} instance
|
|
14824
14837
|
*
|
|
14825
14838
|
* @category Client API
|
|
14826
|
-
|
|
14839
|
+
* */
|
|
14827
14840
|
const createClient = (apiKey, apiRegion = API_REGIONS.SG, debugSession = 'amity') => {
|
|
14828
14841
|
const log = createLogger(debugSession);
|
|
14829
14842
|
log('client/api/createClient', {
|
|
@@ -14951,8 +14964,8 @@ const getToken = async (params) => {
|
|
|
14951
14964
|
client.log('client/api/getToken', params);
|
|
14952
14965
|
const deviceInfo = await getDeviceInfo();
|
|
14953
14966
|
const { data } = await client.http.post('/v1/device', Object.assign(Object.assign({}, params), { deviceInfo }), {
|
|
14954
|
-
|
|
14955
|
-
headers: { 'X-API-Key': client.apiKey }
|
|
14967
|
+
// @ts-ignore
|
|
14968
|
+
headers: { 'X-API-Key': client.apiKey },
|
|
14956
14969
|
});
|
|
14957
14970
|
return data;
|
|
14958
14971
|
};
|
|
@@ -14981,12 +14994,12 @@ const EVENTS = [
|
|
|
14981
14994
|
*/
|
|
14982
14995
|
const onConnectionError = (callback) => {
|
|
14983
14996
|
const client = getActiveClient();
|
|
14984
|
-
const subscribers = EVENTS.map(event =>
|
|
14997
|
+
const subscribers = EVENTS.map(event => createEventSubscriber(client, `client/onConnectionError(${event})`, event, response => {
|
|
14985
14998
|
const error = (response === null || response === void 0 ? void 0 : response.code)
|
|
14986
14999
|
? new ASCError(response.message, response.code, "fatal" /* FATAL */)
|
|
14987
15000
|
: new ASCConnectionError(event);
|
|
14988
15001
|
callback(error);
|
|
14989
|
-
}))
|
|
15002
|
+
}));
|
|
14990
15003
|
return () => {
|
|
14991
15004
|
subscribers.forEach(fn => fn());
|
|
14992
15005
|
};
|
|
@@ -15034,6 +15047,7 @@ const onClientBanned = (callback) => {
|
|
|
15034
15047
|
});
|
|
15035
15048
|
};
|
|
15036
15049
|
|
|
15050
|
+
/* eslint-disable no-param-reassign */
|
|
15037
15051
|
/**
|
|
15038
15052
|
* ```js
|
|
15039
15053
|
* import { connectClient } from '@amityco/ts-sdk/client/api'
|
|
@@ -15064,7 +15078,7 @@ const connectClient = async (params) => {
|
|
|
15064
15078
|
// ignored since we enforce default values just before.
|
|
15065
15079
|
const { accessToken, users } = await getToken(params);
|
|
15066
15080
|
// manually setup the token for http transport
|
|
15067
|
-
client.http.defaults.headers.common
|
|
15081
|
+
client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
15068
15082
|
// manually setup the token for ws transport
|
|
15069
15083
|
client.ws.io.opts.query = { token: accessToken };
|
|
15070
15084
|
// FIXME: events are duplicated if connectClient is called few times without disconnectClient
|
|
@@ -15102,9 +15116,9 @@ const isConnected = () => {
|
|
|
15102
15116
|
var _a, _b;
|
|
15103
15117
|
const client = getActiveClient();
|
|
15104
15118
|
client.log('client/api/isConnected', client);
|
|
15105
|
-
return !!(client.userId
|
|
15106
|
-
|
|
15107
|
-
|
|
15119
|
+
return !!(client.userId &&
|
|
15120
|
+
((_b = (_a = client.http.defaults.headers.common) === null || _a === void 0 ? void 0 : _a.Authorization) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
15121
|
+
client.ws.connected);
|
|
15108
15122
|
};
|
|
15109
15123
|
|
|
15110
15124
|
var SubscriptionLevels;
|
|
@@ -15115,7 +15129,7 @@ var SubscriptionLevels;
|
|
|
15115
15129
|
SubscriptionLevels["POST_AND_COMMENT"] = "post_and_comment";
|
|
15116
15130
|
SubscriptionLevels["USER"] = "user";
|
|
15117
15131
|
})(SubscriptionLevels || (SubscriptionLevels = {}));
|
|
15118
|
-
const getCommunityUserTopic = (
|
|
15132
|
+
const getCommunityUserTopic = (path, level) => {
|
|
15119
15133
|
switch (level) {
|
|
15120
15134
|
case 'post':
|
|
15121
15135
|
return `${path}/post/+`;
|
|
@@ -15127,8 +15141,10 @@ const getCommunityUserTopic = ({ path }, level) => {
|
|
|
15127
15141
|
return path;
|
|
15128
15142
|
}
|
|
15129
15143
|
};
|
|
15130
|
-
const getCommunityTopic = ({ path }, level = SubscriptionLevels.COMMUNITY) => getCommunityUserTopic(
|
|
15131
|
-
const getUserTopic = ({ path }, level = SubscriptionLevels.USER) => getCommunityUserTopic(
|
|
15144
|
+
const getCommunityTopic = ({ path }, level = SubscriptionLevels.COMMUNITY) => getCommunityUserTopic(path, level);
|
|
15145
|
+
const getUserTopic = ({ path }, level = SubscriptionLevels.USER) => getCommunityUserTopic(level === SubscriptionLevels.USER
|
|
15146
|
+
? path
|
|
15147
|
+
: path.replace(/^(?<networkId>\w*)/, '$<networkId>/social'), level);
|
|
15132
15148
|
const getPostTopic = ({ path }, level = SubscriptionLevels.POST) => {
|
|
15133
15149
|
switch (level) {
|
|
15134
15150
|
case 'comment':
|
|
@@ -15240,12 +15256,15 @@ const restoreCache = async (storageKey = 'amitySdk') => {
|
|
|
15240
15256
|
try {
|
|
15241
15257
|
cache = JSON.parse(serializedData);
|
|
15242
15258
|
}
|
|
15243
|
-
catch (err) {
|
|
15259
|
+
catch (err) {
|
|
15260
|
+
//
|
|
15261
|
+
}
|
|
15244
15262
|
// current cache should override. in case there's something fresher.
|
|
15245
15263
|
client.cache.data = Object.assign(Object.assign({}, cache), client.cache.data);
|
|
15246
15264
|
return true;
|
|
15247
15265
|
};
|
|
15248
15266
|
|
|
15267
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
15249
15268
|
/**
|
|
15250
15269
|
* ```js
|
|
15251
15270
|
* import { backupCache } from '@amityco/ts-sdk'
|
|
@@ -15275,8 +15294,7 @@ const backupCache = async (storageKey = 'amitySdk', persistIf = (entry) => entry
|
|
|
15275
15294
|
log('cache/api/backupCache', { storageKey });
|
|
15276
15295
|
// prepare a subset of the cache where only
|
|
15277
15296
|
// objects to backup are there
|
|
15278
|
-
const offlineEntries = Object.fromEntries(Object.entries(cache.data)
|
|
15279
|
-
.filter(([_, entry]) => persistIf(entry)));
|
|
15297
|
+
const offlineEntries = Object.fromEntries(Object.entries(cache.data).filter(([_, entry]) => persistIf(entry)));
|
|
15280
15298
|
// nothing to backup, abort
|
|
15281
15299
|
if (!Object.keys(offlineEntries).length)
|
|
15282
15300
|
return false;
|
|
@@ -15322,9 +15340,9 @@ const wipeCache = async (storageKey = 'amitySdk') => {
|
|
|
15322
15340
|
* @category Cache
|
|
15323
15341
|
* @hidden
|
|
15324
15342
|
*/
|
|
15325
|
-
const normalize = (source) =>
|
|
15343
|
+
const normalize = (source) => Object.keys(source)
|
|
15326
15344
|
.sort()
|
|
15327
|
-
.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: source[key] })), {})
|
|
15345
|
+
.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: source[key] })), {});
|
|
15328
15346
|
/**
|
|
15329
15347
|
* Encodes a given {@link Amity.CacheKey} to a plain string
|
|
15330
15348
|
*
|
|
@@ -15334,7 +15352,7 @@ const normalize = (source) => (Object.keys(source)
|
|
|
15334
15352
|
* @category Cache
|
|
15335
15353
|
* @hidden
|
|
15336
15354
|
*/
|
|
15337
|
-
const encodeKey = (key) =>
|
|
15355
|
+
const encodeKey = (key) => JSON.stringify(key, (_, val) => (typeof val === 'object' ? normalize(val) : val));
|
|
15338
15356
|
/**
|
|
15339
15357
|
* Decodes a string back into a {@link Amity.CacheKey}
|
|
15340
15358
|
|
|
@@ -15359,14 +15377,14 @@ const partialMatch = (predicate, candidate) => {
|
|
|
15359
15377
|
if (predicate === candidate)
|
|
15360
15378
|
return true;
|
|
15361
15379
|
// if one or the other is nullish, there can't be equality
|
|
15362
|
-
|
|
15380
|
+
if (!predicate || !candidate)
|
|
15363
15381
|
return false;
|
|
15364
15382
|
// we only perform recursive check on objects
|
|
15365
|
-
|
|
15383
|
+
if (typeof predicate !== 'object') {
|
|
15366
15384
|
return false;
|
|
15367
15385
|
}
|
|
15368
15386
|
// recursively call for partial match based on the predicate
|
|
15369
|
-
return Object.keys(predicate).every(
|
|
15387
|
+
return Object.keys(predicate).every(key => partialMatch(predicate[key], candidate[key]));
|
|
15370
15388
|
};
|
|
15371
15389
|
|
|
15372
15390
|
/**
|
|
@@ -15389,8 +15407,7 @@ const queryCache = (key) => {
|
|
|
15389
15407
|
if (!cache)
|
|
15390
15408
|
return;
|
|
15391
15409
|
log('cache/api/queryCache', { key });
|
|
15392
|
-
return Object
|
|
15393
|
-
.keys(cache.data)
|
|
15410
|
+
return Object.keys(cache.data)
|
|
15394
15411
|
.filter(stringKey => {
|
|
15395
15412
|
const decodedKey = decodeKey(stringKey);
|
|
15396
15413
|
return partialMatch(key, decodedKey);
|
|
@@ -15419,9 +15436,7 @@ const pullFromCache = (key) => {
|
|
|
15419
15436
|
return;
|
|
15420
15437
|
log('cache/api/pullFromCache', key);
|
|
15421
15438
|
const str = encodeKey(key);
|
|
15422
|
-
return
|
|
15423
|
-
? cache.data[str]
|
|
15424
|
-
: undefined;
|
|
15439
|
+
return cache.data[str] ? cache.data[str] : undefined;
|
|
15425
15440
|
};
|
|
15426
15441
|
|
|
15427
15442
|
/**
|
|
@@ -15447,8 +15462,10 @@ const pushToCache = (key, data, options = { cachedAt: Date.now() }) => {
|
|
|
15447
15462
|
// if consumer did not pass offline but a offline policy is
|
|
15448
15463
|
// defined, use the fn to determine if the object needs to
|
|
15449
15464
|
// be saved in persistent storage or not.
|
|
15450
|
-
if (!(options === null || options === void 0 ? void 0 : options.hasOwnProperty('offline')) && cache.persistIf)
|
|
15465
|
+
if (!(options === null || options === void 0 ? void 0 : options.hasOwnProperty('offline')) && cache.persistIf) {
|
|
15466
|
+
// eslint-disable-next-line no-param-reassign
|
|
15451
15467
|
options.offline = cache.persistIf(key, data);
|
|
15468
|
+
}
|
|
15452
15469
|
const encodedKey = encodeKey(key);
|
|
15453
15470
|
cache.data[encodedKey] = Object.assign({ key, data }, options);
|
|
15454
15471
|
return true;
|
|
@@ -15480,9 +15497,7 @@ const mergeInCache = (key, mutation, options) => {
|
|
|
15480
15497
|
const oldVal = pullFromCache(key);
|
|
15481
15498
|
if (!oldVal)
|
|
15482
15499
|
return false;
|
|
15483
|
-
const newVal = typeof mutation === 'function'
|
|
15484
|
-
? mutation(oldVal.data)
|
|
15485
|
-
: Object.assign(Object.assign({}, oldVal.data), mutation);
|
|
15500
|
+
const newVal = typeof mutation === 'function' ? mutation(oldVal.data) : Object.assign(Object.assign({}, oldVal.data), mutation);
|
|
15486
15501
|
pushToCache(key, newVal, options);
|
|
15487
15502
|
return true;
|
|
15488
15503
|
};
|
|
@@ -15510,9 +15525,7 @@ const upsertInCache = (key, data, options = { cachedAt: Date.now() }) => {
|
|
|
15510
15525
|
return false;
|
|
15511
15526
|
log('cache/api/upsertInCache', { key, data, options });
|
|
15512
15527
|
const cached = pullFromCache(key);
|
|
15513
|
-
return cached
|
|
15514
|
-
? mergeInCache(key, data, options)
|
|
15515
|
-
: pushToCache(key, data, options);
|
|
15528
|
+
return cached ? mergeInCache(key, data, options) : pushToCache(key, data, options);
|
|
15516
15529
|
};
|
|
15517
15530
|
|
|
15518
15531
|
/**
|
|
@@ -15536,7 +15549,7 @@ const dropFromCache = (key, exact = false) => {
|
|
|
15536
15549
|
return false;
|
|
15537
15550
|
log('cache/api/dropFromCache', { key, exact });
|
|
15538
15551
|
if (!exact) {
|
|
15539
|
-
return
|
|
15552
|
+
return Object.keys(cache.data)
|
|
15540
15553
|
.map(stringKey => decodeKey(stringKey))
|
|
15541
15554
|
.filter(candidate => partialMatch(key, candidate))
|
|
15542
15555
|
.map(filteredKey => dropFromCache(filteredKey, true))
|
|
@@ -15559,6 +15572,7 @@ const idResolvers = {
|
|
|
15559
15572
|
channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
|
|
15560
15573
|
message: ({ messageId }) => messageId,
|
|
15561
15574
|
community: ({ communityId }) => communityId,
|
|
15575
|
+
category: ({ categoryId }) => categoryId,
|
|
15562
15576
|
communityUsers: ({ communityId, userId }) => `${communityId}#${userId}`,
|
|
15563
15577
|
post: ({ postId }) => postId,
|
|
15564
15578
|
comment: ({ commentId }) => commentId,
|
|
@@ -15572,7 +15586,7 @@ const idResolvers = {
|
|
|
15572
15586
|
* @param name the domain name for the resolve
|
|
15573
15587
|
* @returns an idResolver function for the given domain name
|
|
15574
15588
|
*/
|
|
15575
|
-
const getResolver = (name) =>
|
|
15589
|
+
const getResolver = (name) => idResolvers[name];
|
|
15576
15590
|
|
|
15577
15591
|
/**
|
|
15578
15592
|
* A map of v3 response keys to a store name.
|
|
@@ -15586,13 +15600,14 @@ const PAYLOAD2MODEL = {
|
|
|
15586
15600
|
channelUsers: 'channelUsers',
|
|
15587
15601
|
messages: 'message',
|
|
15588
15602
|
communities: 'community',
|
|
15603
|
+
categories: 'category',
|
|
15589
15604
|
communityUsers: 'communityUsers',
|
|
15590
15605
|
posts: 'post',
|
|
15591
15606
|
postChildren: 'post',
|
|
15592
15607
|
comments: 'comment',
|
|
15593
15608
|
videoStreamings: 'stream',
|
|
15594
15609
|
follows: 'follow',
|
|
15595
|
-
followCounts: 'followCount'
|
|
15610
|
+
followCounts: 'followCount',
|
|
15596
15611
|
};
|
|
15597
15612
|
|
|
15598
15613
|
/**
|
|
@@ -15605,8 +15620,7 @@ const PAYLOAD2MODEL = {
|
|
|
15605
15620
|
* @hidden
|
|
15606
15621
|
*/
|
|
15607
15622
|
const ingestInCache = (payload = {}, options) => {
|
|
15608
|
-
Object.entries(payload)
|
|
15609
|
-
.forEach(([key, models]) => {
|
|
15623
|
+
Object.entries(payload).forEach(([key, models]) => {
|
|
15610
15624
|
const type = PAYLOAD2MODEL[key];
|
|
15611
15625
|
if (!type)
|
|
15612
15626
|
return;
|
|
@@ -15686,13 +15700,15 @@ const getUsers = async (userIds) => {
|
|
|
15686
15700
|
client.log('user/getUsers', userIds);
|
|
15687
15701
|
const encodedUserIds = userIds.map(userId => encodeURIComponent(userId));
|
|
15688
15702
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
15689
|
-
const { data } = await client.http.get(`/api/v3/users/list`, {
|
|
15703
|
+
const { data } = await client.http.get(`/api/v3/users/list`, {
|
|
15704
|
+
params: { userIds: encodedUserIds },
|
|
15705
|
+
});
|
|
15690
15706
|
const cachedAt = client.cache && Date.now();
|
|
15691
15707
|
if (client.cache)
|
|
15692
15708
|
ingestInCache(data, { cachedAt });
|
|
15693
15709
|
return {
|
|
15694
15710
|
data: data.users,
|
|
15695
|
-
cachedAt
|
|
15711
|
+
cachedAt,
|
|
15696
15712
|
};
|
|
15697
15713
|
};
|
|
15698
15714
|
/**
|
|
@@ -15718,7 +15734,7 @@ getUsers.locally = (userIds) => {
|
|
|
15718
15734
|
.map(userId => pullFromCache(['user', 'get', userId]))
|
|
15719
15735
|
.filter(Boolean);
|
|
15720
15736
|
const users = cached.map(({ data }) => data);
|
|
15721
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
15737
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
15722
15738
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < userIds.length)
|
|
15723
15739
|
return;
|
|
15724
15740
|
return {
|
|
@@ -15772,14 +15788,14 @@ function __rest(s, e) {
|
|
|
15772
15788
|
const queryUsers = async (query = {}) => {
|
|
15773
15789
|
const client = getActiveClient();
|
|
15774
15790
|
client.log('user/queryUsers', query);
|
|
15775
|
-
const { page, displayName, filter = 'all', sortBy = 'displayName' } = query, params = __rest(query
|
|
15776
|
-
// API-FIX: parameters should be querystring.
|
|
15777
|
-
, ["page", "displayName", "filter", "sortBy"]);
|
|
15791
|
+
const { page, displayName, filter = 'all', sortBy = 'displayName' } = query, params = __rest(query, ["page", "displayName", "filter", "sortBy"]);
|
|
15778
15792
|
// API-FIX: parameters should be querystring.
|
|
15779
|
-
const { data } = await client.http.get(`/api/v3/users`, {
|
|
15793
|
+
const { data } = await client.http.get(`/api/v3/users`, {
|
|
15794
|
+
params: Object.assign(Object.assign({}, params), { keyword: displayName, filter,
|
|
15780
15795
|
sortBy, options: {
|
|
15781
15796
|
token: toToken(page, 'skiplimit'),
|
|
15782
|
-
} })
|
|
15797
|
+
} }),
|
|
15798
|
+
});
|
|
15783
15799
|
// unpacking
|
|
15784
15800
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
15785
15801
|
const { users } = payload;
|
|
@@ -15985,7 +16001,7 @@ const observeUser = (userId, callback) => {
|
|
|
15985
16001
|
*
|
|
15986
16002
|
* Fetches a {@link Amity.File} object
|
|
15987
16003
|
*
|
|
15988
|
-
* @param
|
|
16004
|
+
* @param fileId the ID of the {@link Amity.File} to fetch
|
|
15989
16005
|
* @returns the associated {@link Amity.File} object
|
|
15990
16006
|
*
|
|
15991
16007
|
* @category File API
|
|
@@ -16041,6 +16057,7 @@ getFile.locally = (fileId) => {
|
|
|
16041
16057
|
* Creates an {@link Amity.File}
|
|
16042
16058
|
*
|
|
16043
16059
|
* @param formData The data necessary to create a new {@link Amity.File}
|
|
16060
|
+
* @param onProgress The callback to track the upload progress
|
|
16044
16061
|
* @returns The newly created {@link Amity.File}
|
|
16045
16062
|
*
|
|
16046
16063
|
* @category File API
|
|
@@ -16055,9 +16072,10 @@ const createFile = async (formData, onProgress) => {
|
|
|
16055
16072
|
? formData.getHeaders()
|
|
16056
16073
|
: { 'content-type': 'multipart/form-data' };
|
|
16057
16074
|
const { data } = await client.http.post('/api/v3/files', formData, {
|
|
16058
|
-
headers,
|
|
16075
|
+
headers,
|
|
16076
|
+
onUploadProgress({ loaded, total }) {
|
|
16059
16077
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
16060
|
-
}
|
|
16078
|
+
},
|
|
16061
16079
|
});
|
|
16062
16080
|
// API-FIX: payload should be serialized properly
|
|
16063
16081
|
// const { files } = data
|
|
@@ -16105,6 +16123,47 @@ const fileUrlWithSize = (fileUrl, size) => {
|
|
|
16105
16123
|
return `${fileUrl}?size=${size}`;
|
|
16106
16124
|
};
|
|
16107
16125
|
|
|
16126
|
+
/**
|
|
16127
|
+
* ```js
|
|
16128
|
+
* import { createVideo } from '@amityco/ts-sdk'
|
|
16129
|
+
* const created = await createVideo(formData)
|
|
16130
|
+
* ```
|
|
16131
|
+
*
|
|
16132
|
+
* Creates an {@link Amity.File<'video'>}
|
|
16133
|
+
*
|
|
16134
|
+
* @param formData The data necessary to create a new {@link Amity.File<'video'>}
|
|
16135
|
+
* @param onProgress The callback to track the upload progress
|
|
16136
|
+
* @returns The newly created {@link Amity.File<'video'>}
|
|
16137
|
+
*
|
|
16138
|
+
* @category File API
|
|
16139
|
+
* @async
|
|
16140
|
+
*/
|
|
16141
|
+
const createVideo = async (formData, onProgress) => {
|
|
16142
|
+
const client = getActiveClient();
|
|
16143
|
+
client.log('file/createVideo', formData);
|
|
16144
|
+
if (!formData.getAll('files').length)
|
|
16145
|
+
throw new Error('The formData object must have a `files` key.');
|
|
16146
|
+
const headers = 'getHeaders' in formData
|
|
16147
|
+
? formData.getHeaders()
|
|
16148
|
+
: { 'content-type': 'multipart/form-data' };
|
|
16149
|
+
const { data } = await client.http.post('/api/v4/videos', formData, {
|
|
16150
|
+
headers,
|
|
16151
|
+
onUploadProgress({ loaded, total }) {
|
|
16152
|
+
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
16153
|
+
},
|
|
16154
|
+
});
|
|
16155
|
+
// API-FIX: payload should be serialized properly
|
|
16156
|
+
// const { files } = data
|
|
16157
|
+
const cachedAt = client.cache && Date.now();
|
|
16158
|
+
if (client.cache)
|
|
16159
|
+
ingestInCache({ files: data }, { cachedAt });
|
|
16160
|
+
return {
|
|
16161
|
+
data,
|
|
16162
|
+
cachedAt,
|
|
16163
|
+
};
|
|
16164
|
+
};
|
|
16165
|
+
// TODO: consider doing local creation with URL.createObjectURL()
|
|
16166
|
+
|
|
16108
16167
|
/**
|
|
16109
16168
|
* ```js
|
|
16110
16169
|
* import { observeFile } from '@amityco/ts-sdk'
|
|
@@ -16336,13 +16395,15 @@ const getMessages = async (messageIds) => {
|
|
|
16336
16395
|
const client = getActiveClient();
|
|
16337
16396
|
client.log('message/getMessages', messageIds);
|
|
16338
16397
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
16339
|
-
const { data } = await client.http.get(`/api/v3/messages/list`, {
|
|
16398
|
+
const { data } = await client.http.get(`/api/v3/messages/list`, {
|
|
16399
|
+
params: { messageIds },
|
|
16400
|
+
});
|
|
16340
16401
|
const cachedAt = client.cache && Date.now();
|
|
16341
16402
|
if (client.cache)
|
|
16342
16403
|
ingestInCache(data, { cachedAt });
|
|
16343
16404
|
return {
|
|
16344
16405
|
data: data.messages,
|
|
16345
|
-
cachedAt
|
|
16406
|
+
cachedAt,
|
|
16346
16407
|
};
|
|
16347
16408
|
};
|
|
16348
16409
|
/**
|
|
@@ -16368,7 +16429,7 @@ getMessages.locally = (messageIds) => {
|
|
|
16368
16429
|
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
16369
16430
|
.filter(Boolean);
|
|
16370
16431
|
const messages = cached.map(({ data }) => data);
|
|
16371
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
16432
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
16372
16433
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < messageIds.length)
|
|
16373
16434
|
return;
|
|
16374
16435
|
return {
|
|
@@ -16394,19 +16455,16 @@ getMessages.locally = (messageIds) => {
|
|
|
16394
16455
|
const queryMessages = async (query) => {
|
|
16395
16456
|
const client = getActiveClient();
|
|
16396
16457
|
client.log('message/queryMessages', query);
|
|
16397
|
-
const { page = { limit: 10 } } = query, params = __rest(query
|
|
16398
|
-
// API-FIX: parameters should be querystring. (1)
|
|
16399
|
-
// API-FIX: backend should answer Amity.Response (2)
|
|
16400
|
-
// API-FIX: pagination should not be indexed on channelSegment (3)
|
|
16401
|
-
// const { data } = await client.http.get<Amity.Response<Amity.Paged<Amity.MessagePayload>>>(
|
|
16402
|
-
, ["page"]);
|
|
16458
|
+
const { page = { limit: 10 } } = query, params = __rest(query, ["page"]);
|
|
16403
16459
|
// API-FIX: parameters should be querystring. (1)
|
|
16404
16460
|
// API-FIX: backend should answer Amity.Response (2)
|
|
16405
16461
|
// API-FIX: pagination should not be indexed on channelSegment (3)
|
|
16406
16462
|
// const { data } = await client.http.get<Amity.Response<Amity.Paged<Amity.MessagePayload>>>(
|
|
16407
|
-
const { data } = await client.http.get(`/api/v3/messages`, {
|
|
16463
|
+
const { data } = await client.http.get(`/api/v3/messages`, {
|
|
16464
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
16408
16465
|
token: toToken(page, 'afterbefore'),
|
|
16409
|
-
} }),
|
|
16466
|
+
} }),
|
|
16467
|
+
});
|
|
16410
16468
|
// API-FIX: backend should answer Amity.Response (2)
|
|
16411
16469
|
// const { paging, messages } = unwrapPayload(data)
|
|
16412
16470
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
@@ -16414,7 +16472,11 @@ const queryMessages = async (query) => {
|
|
|
16414
16472
|
const cachedAt = client.cache && Date.now();
|
|
16415
16473
|
if (client.cache) {
|
|
16416
16474
|
ingestInCache(payload, { cachedAt });
|
|
16417
|
-
const cacheKey = [
|
|
16475
|
+
const cacheKey = [
|
|
16476
|
+
'message',
|
|
16477
|
+
'query',
|
|
16478
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
16479
|
+
];
|
|
16418
16480
|
pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
|
|
16419
16481
|
}
|
|
16420
16482
|
const nextPage = toPage(paging.next);
|
|
@@ -16516,7 +16578,7 @@ createMessage.optimistically = (bundle) => {
|
|
|
16516
16578
|
fireEvent('v3.message.didCreate', { messages: [message] });
|
|
16517
16579
|
return {
|
|
16518
16580
|
data: message,
|
|
16519
|
-
cachedAt: -1
|
|
16581
|
+
cachedAt: -1,
|
|
16520
16582
|
};
|
|
16521
16583
|
};
|
|
16522
16584
|
|
|
@@ -16580,7 +16642,7 @@ updateMessage.optimistically = (messageId, patch) => {
|
|
|
16580
16642
|
fireEvent('v3.message.didUpdate', { messages: [updated] });
|
|
16581
16643
|
return {
|
|
16582
16644
|
data: updated,
|
|
16583
|
-
cachedAt
|
|
16645
|
+
cachedAt,
|
|
16584
16646
|
};
|
|
16585
16647
|
};
|
|
16586
16648
|
|
|
@@ -16632,7 +16694,7 @@ deleteMessage.optimistically = (messageId) => {
|
|
|
16632
16694
|
fireEvent('v3.message.didDelete', { messages: [deleted] });
|
|
16633
16695
|
return {
|
|
16634
16696
|
data: deleted,
|
|
16635
|
-
cachedAt
|
|
16697
|
+
cachedAt,
|
|
16636
16698
|
};
|
|
16637
16699
|
};
|
|
16638
16700
|
|
|
@@ -16653,17 +16715,15 @@ deleteMessage.optimistically = (messageId) => {
|
|
|
16653
16715
|
const queryPosts = async (query) => {
|
|
16654
16716
|
const client = getActiveClient();
|
|
16655
16717
|
client.log('post/queryPosts', query);
|
|
16656
|
-
const { page = { limit: 10 } } = query, params = __rest(query
|
|
16657
|
-
// API-FIX: parameters should be querystring. (1)
|
|
16658
|
-
// API-FIX: backend should answer Amity.Response (2)
|
|
16659
|
-
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
|
|
16660
|
-
, ["page"]);
|
|
16718
|
+
const { page = { limit: 10 } } = query, params = __rest(query, ["page"]);
|
|
16661
16719
|
// API-FIX: parameters should be querystring. (1)
|
|
16662
16720
|
// API-FIX: backend should answer Amity.Response (2)
|
|
16663
16721
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
|
|
16664
|
-
const { data } = await client.http.get(`/api/v4/posts`, {
|
|
16722
|
+
const { data } = await client.http.get(`/api/v4/posts`, {
|
|
16723
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
16665
16724
|
token: toToken(page, 'afterbeforeraw'),
|
|
16666
|
-
} }),
|
|
16725
|
+
} }),
|
|
16726
|
+
});
|
|
16667
16727
|
// API-FIX: backend should answer Amity.Response (2)
|
|
16668
16728
|
// const { paging, posts } = unwrapPayload(data)
|
|
16669
16729
|
// unpacking
|
|
@@ -16733,13 +16793,15 @@ const getPosts = async (postIds) => {
|
|
|
16733
16793
|
client.log('post/getPosts', postIds);
|
|
16734
16794
|
const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
|
|
16735
16795
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
16736
|
-
const { data } = await client.http.get(`/api/v3/posts/list`, {
|
|
16796
|
+
const { data } = await client.http.get(`/api/v3/posts/list`, {
|
|
16797
|
+
params: { postIds: encodedPostIds },
|
|
16798
|
+
});
|
|
16737
16799
|
const cachedAt = client.cache && Date.now();
|
|
16738
16800
|
if (client.cache)
|
|
16739
16801
|
ingestInCache(data, { cachedAt });
|
|
16740
16802
|
return {
|
|
16741
16803
|
data: data.posts,
|
|
16742
|
-
cachedAt
|
|
16804
|
+
cachedAt,
|
|
16743
16805
|
};
|
|
16744
16806
|
};
|
|
16745
16807
|
/**
|
|
@@ -16765,7 +16827,7 @@ getPosts.locally = (postIds) => {
|
|
|
16765
16827
|
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
16766
16828
|
.filter(Boolean);
|
|
16767
16829
|
const posts = cached.map(({ data }) => data);
|
|
16768
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
16830
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
16769
16831
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
16770
16832
|
return;
|
|
16771
16833
|
return {
|
|
@@ -16816,7 +16878,7 @@ const getPost = async (postId) => {
|
|
|
16816
16878
|
/**
|
|
16817
16879
|
* ```js
|
|
16818
16880
|
* import { getPost } from '@amityco/ts-sdk'
|
|
16819
|
-
* const { data
|
|
16881
|
+
* const { data: post } = getPost.locally('foobar')
|
|
16820
16882
|
* ```
|
|
16821
16883
|
*
|
|
16822
16884
|
* Fetches a {@link Amity.Post} object from cache
|
|
@@ -16862,8 +16924,10 @@ const createPost = async (bundle) => {
|
|
|
16862
16924
|
const client = getActiveClient();
|
|
16863
16925
|
client.log('post/createPost', bundle);
|
|
16864
16926
|
// API-FIX: backend rejects that we pass the dataType manually T_T
|
|
16865
|
-
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType))
|
|
16927
|
+
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
|
|
16928
|
+
// eslint-disable-next-line no-param-reassign
|
|
16866
16929
|
delete bundle.dataType;
|
|
16930
|
+
}
|
|
16867
16931
|
const { data } = await client.http.post('/api/v4/posts', bundle);
|
|
16868
16932
|
const cachedAt = client.cache && Date.now();
|
|
16869
16933
|
if (client.cache)
|
|
@@ -16931,15 +16995,21 @@ const queryCommunities = async (query) => {
|
|
|
16931
16995
|
// API-FIX: parameters should be querystring.
|
|
16932
16996
|
// API-FIX: backend doesnt answer Amity.Response
|
|
16933
16997
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
|
|
16934
|
-
const { data } = await client.http.get(`/api/v3/communities`, {
|
|
16935
|
-
|
|
16936
|
-
|
|
16998
|
+
const { data } = await client.http.get(`/api/v3/communities`, {
|
|
16999
|
+
params: Object.assign(Object.assign({}, params), { keyword: displayName, filter: membership, options: {
|
|
17000
|
+
token: toToken(page, 'skiplimit'),
|
|
17001
|
+
} }),
|
|
17002
|
+
});
|
|
16937
17003
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
16938
17004
|
const { communities } = payload;
|
|
16939
17005
|
const cachedAt = client.cache && Date.now();
|
|
16940
17006
|
if (client.cache) {
|
|
16941
17007
|
ingestInCache(payload, { cachedAt });
|
|
16942
|
-
const cacheKey = [
|
|
17008
|
+
const cacheKey = [
|
|
17009
|
+
'community',
|
|
17010
|
+
'query',
|
|
17011
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
17012
|
+
];
|
|
16943
17013
|
pushToCache(cacheKey, { communities: communities.map(getResolver('community')), paging });
|
|
16944
17014
|
}
|
|
16945
17015
|
const nextPage = toPage(paging.next);
|
|
@@ -16983,13 +17053,15 @@ const getCommunities = async (communityIds) => {
|
|
|
16983
17053
|
const client = getActiveClient();
|
|
16984
17054
|
client.log('community/getCommunities', communityIds);
|
|
16985
17055
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
16986
|
-
const { data } = await client.http.get(`/api/v3/communities/list`, {
|
|
17056
|
+
const { data } = await client.http.get(`/api/v3/communities/list`, {
|
|
17057
|
+
params: { communityIds },
|
|
17058
|
+
});
|
|
16987
17059
|
const cachedAt = client.cache && Date.now();
|
|
16988
17060
|
if (client.cache)
|
|
16989
17061
|
ingestInCache(data, { cachedAt });
|
|
16990
17062
|
return {
|
|
16991
17063
|
data: data.communities,
|
|
16992
|
-
cachedAt
|
|
17064
|
+
cachedAt,
|
|
16993
17065
|
};
|
|
16994
17066
|
};
|
|
16995
17067
|
/**
|
|
@@ -17015,7 +17087,7 @@ getCommunities.locally = (communityIds) => {
|
|
|
17015
17087
|
.map(communityId => pullFromCache(['community', 'get', communityId]))
|
|
17016
17088
|
.filter(Boolean);
|
|
17017
17089
|
const communities = cached.map(({ data }) => data);
|
|
17018
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
17090
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
17019
17091
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < communityIds.length)
|
|
17020
17092
|
return;
|
|
17021
17093
|
return {
|
|
@@ -17185,8 +17257,7 @@ const joinCommunity = async (communityId) => {
|
|
|
17185
17257
|
ingestInCache(data, { cachedAt });
|
|
17186
17258
|
fireEvent('community.joined', data);
|
|
17187
17259
|
const { communityUsers } = data;
|
|
17188
|
-
return !!communityUsers.find(communityUser =>
|
|
17189
|
-
&& communityUser.communityMembership === 'member'));
|
|
17260
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
17190
17261
|
};
|
|
17191
17262
|
|
|
17192
17263
|
/**
|
|
@@ -17212,8 +17283,7 @@ const leaveCommunity = async (communityId) => {
|
|
|
17212
17283
|
ingestInCache(data, { cachedAt });
|
|
17213
17284
|
fireEvent('community.left', data);
|
|
17214
17285
|
const { communityUsers } = data;
|
|
17215
|
-
return !!communityUsers.find(communityUser =>
|
|
17216
|
-
&& communityUser.communityMembership !== 'member'));
|
|
17286
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
17217
17287
|
};
|
|
17218
17288
|
|
|
17219
17289
|
/**
|
|
@@ -17229,7 +17299,7 @@ const leaveCommunity = async (communityId) => {
|
|
|
17229
17299
|
*
|
|
17230
17300
|
* @category Community API
|
|
17231
17301
|
* @async
|
|
17232
|
-
|
|
17302
|
+
* */
|
|
17233
17303
|
const queryCommunityMembers = async (query) => {
|
|
17234
17304
|
const client = getActiveClient();
|
|
17235
17305
|
client.log('community/queryCommunityMembers', query);
|
|
@@ -17291,8 +17361,7 @@ const addCommunityMembers = async (communityId, userIds) => {
|
|
|
17291
17361
|
ingestInCache(data);
|
|
17292
17362
|
fireEvent('community.userAdded', data);
|
|
17293
17363
|
const { communityUsers } = data;
|
|
17294
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17295
|
-
communityUser.communityMembership === 'member');
|
|
17364
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
17296
17365
|
};
|
|
17297
17366
|
|
|
17298
17367
|
/**
|
|
@@ -17318,60 +17387,61 @@ const removeCommunityMembers = async (communityId, userIds) => {
|
|
|
17318
17387
|
ingestInCache(data);
|
|
17319
17388
|
fireEvent('community.userRemoved', data);
|
|
17320
17389
|
const { communityUsers } = data;
|
|
17321
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17322
|
-
communityUser.communityMembership !== 'member');
|
|
17390
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
17323
17391
|
};
|
|
17324
17392
|
|
|
17325
17393
|
/**
|
|
17326
17394
|
* ```js
|
|
17327
|
-
* import {
|
|
17328
|
-
* const updated = await
|
|
17395
|
+
* import { addCommunityMembersRoles } from '@amityco/ts-sdk'
|
|
17396
|
+
* const updated = await addCommunityMembersRoles(communityId, ['foo'], ['bar'])
|
|
17329
17397
|
* ```
|
|
17330
17398
|
*
|
|
17331
|
-
* Adds
|
|
17399
|
+
* Adds a list of {@link Amity.Role} to a list of {@link Amity.User} on a {@link Amity.Community}
|
|
17332
17400
|
*
|
|
17333
17401
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
17334
|
-
* @param
|
|
17402
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
17335
17403
|
* @param userId Array of IDs of the {@link Amity.User} to perform
|
|
17336
17404
|
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
17337
17405
|
*
|
|
17338
17406
|
* @category Community API
|
|
17339
17407
|
* @async
|
|
17340
17408
|
*/
|
|
17341
|
-
const
|
|
17409
|
+
const addCommunityMembersRoles = async (communityId, roleIds, userIds) => {
|
|
17342
17410
|
const client = getActiveClient();
|
|
17343
|
-
client.log('community/
|
|
17344
|
-
const { data } = await client.http.post(`/api/
|
|
17411
|
+
client.log('community/addCommunityMembersRoles', communityId, roleIds, userIds);
|
|
17412
|
+
const { data } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
17345
17413
|
if (client.cache)
|
|
17346
17414
|
ingestInCache(data);
|
|
17347
17415
|
const { communityUsers } = data;
|
|
17348
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17416
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17417
|
+
roleIds.some(role => communityUser.roles.includes(role)));
|
|
17349
17418
|
};
|
|
17350
17419
|
|
|
17351
17420
|
/**
|
|
17352
17421
|
* ```js
|
|
17353
|
-
* import {
|
|
17354
|
-
* const updated = await
|
|
17422
|
+
* import { removeCommunityMembersRoles } from '@amityco/ts-sdk'
|
|
17423
|
+
* const updated = await removeCommunityMembersRoles(communityId, ['foo'], ['bar'])
|
|
17355
17424
|
* ```
|
|
17356
17425
|
*
|
|
17357
|
-
* Removes
|
|
17426
|
+
* Removes a list of {@link Amity.Role} from a list of {@link Amity.User} on a {@link Amity.Community}
|
|
17358
17427
|
*
|
|
17359
17428
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
17360
|
-
* @param
|
|
17429
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
17361
17430
|
* @param userId Array of IDs of the {@link Amity.User} to perform
|
|
17362
17431
|
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
17363
17432
|
*
|
|
17364
17433
|
* @category Community API
|
|
17365
17434
|
* @async
|
|
17366
17435
|
*/
|
|
17367
|
-
const
|
|
17436
|
+
const removeCommunityMembersRoles = async (communityId, roleIds, userIds) => {
|
|
17368
17437
|
const client = getActiveClient();
|
|
17369
|
-
client.log('community/
|
|
17370
|
-
const { data } = await client.http.delete(`/api/
|
|
17438
|
+
client.log('community/removeCommunityMembersRoles', communityId, roleIds, userIds);
|
|
17439
|
+
const { data } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
17371
17440
|
if (client.cache)
|
|
17372
17441
|
ingestInCache(data);
|
|
17373
17442
|
const { communityUsers } = data;
|
|
17374
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17443
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17444
|
+
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
17375
17445
|
};
|
|
17376
17446
|
|
|
17377
17447
|
/**
|
|
@@ -17517,7 +17587,7 @@ getRecommendedCommunities.locally = (query) => {
|
|
|
17517
17587
|
const deletePost = async (postId, permanent = false) => {
|
|
17518
17588
|
const client = getActiveClient();
|
|
17519
17589
|
client.log('post/deletePost', postId);
|
|
17520
|
-
|
|
17590
|
+
const post = await getPost(postId);
|
|
17521
17591
|
// API-FIX: This endpoint has not been implemented yet.
|
|
17522
17592
|
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
17523
17593
|
params: {
|
|
@@ -17564,12 +17634,7 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
17564
17634
|
const queryComments = async (query) => {
|
|
17565
17635
|
const client = getActiveClient();
|
|
17566
17636
|
client.log('comment/queryComments', query);
|
|
17567
|
-
const { page = { limit: 10 } } = query, params = __rest(query
|
|
17568
|
-
// const filterByParentId = query.parentId !== undefined
|
|
17569
|
-
// API-FIX: parameters should be querystring. (1)
|
|
17570
|
-
// API-FIX: backend should answer Amity.Response (2)
|
|
17571
|
-
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.CommentPayload>>>(
|
|
17572
|
-
, ["page"]);
|
|
17637
|
+
const { page = { limit: 10 } } = query, params = __rest(query, ["page"]);
|
|
17573
17638
|
// const filterByParentId = query.parentId !== undefined
|
|
17574
17639
|
// API-FIX: parameters should be querystring. (1)
|
|
17575
17640
|
// API-FIX: backend should answer Amity.Response (2)
|
|
@@ -17588,7 +17653,11 @@ const queryComments = async (query) => {
|
|
|
17588
17653
|
const cachedAt = client.cache && Date.now();
|
|
17589
17654
|
if (client.cache) {
|
|
17590
17655
|
ingestInCache(payload, { cachedAt });
|
|
17591
|
-
const cacheKey = [
|
|
17656
|
+
const cacheKey = [
|
|
17657
|
+
'comment',
|
|
17658
|
+
'query',
|
|
17659
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
17660
|
+
];
|
|
17592
17661
|
pushToCache(cacheKey, { comments: comments.map(getResolver('comment')), paging });
|
|
17593
17662
|
}
|
|
17594
17663
|
const nextPage = toPage(paging.next);
|
|
@@ -17649,13 +17718,15 @@ const getComments = async (commentIds) => {
|
|
|
17649
17718
|
client.log('comment/getComments', commentIds);
|
|
17650
17719
|
const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
|
|
17651
17720
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
17652
|
-
const { data } = await client.http.get(`/api/v3/comments/list`, {
|
|
17721
|
+
const { data } = await client.http.get(`/api/v3/comments/list`, {
|
|
17722
|
+
params: { commentIds: encodedCommentIds },
|
|
17723
|
+
});
|
|
17653
17724
|
const cachedAt = client.cache && Date.now();
|
|
17654
17725
|
if (client.cache)
|
|
17655
17726
|
ingestInCache(data, { cachedAt });
|
|
17656
17727
|
return {
|
|
17657
17728
|
data: data.comments,
|
|
17658
|
-
cachedAt
|
|
17729
|
+
cachedAt,
|
|
17659
17730
|
};
|
|
17660
17731
|
};
|
|
17661
17732
|
/**
|
|
@@ -17681,7 +17752,7 @@ getComments.locally = (commentIds) => {
|
|
|
17681
17752
|
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
17682
17753
|
.filter(Boolean);
|
|
17683
17754
|
const comments = cached.map(({ data }) => data);
|
|
17684
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
17755
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
17685
17756
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
17686
17757
|
return;
|
|
17687
17758
|
return {
|
|
@@ -17864,9 +17935,9 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
17864
17935
|
const fetchReference = async (referenceType, referenceId) => {
|
|
17865
17936
|
if (referenceType === 'message')
|
|
17866
17937
|
return getMessage(referenceId);
|
|
17867
|
-
|
|
17938
|
+
if (referenceType === 'post')
|
|
17868
17939
|
return getPost(referenceId);
|
|
17869
|
-
|
|
17940
|
+
if (referenceType === 'comment')
|
|
17870
17941
|
return getComment(referenceId);
|
|
17871
17942
|
throw new Error(`Incorrect referenceType: ${referenceType}`);
|
|
17872
17943
|
};
|
|
@@ -17903,7 +17974,9 @@ const preparePayloadForCache = (event, payload) => {
|
|
|
17903
17974
|
if (!cached.myReactions.includes(payload.reactor.reactionName)) {
|
|
17904
17975
|
return;
|
|
17905
17976
|
}
|
|
17906
|
-
Object.assign(model, {
|
|
17977
|
+
Object.assign(model, {
|
|
17978
|
+
myReactions: cached.myReactions.filter(x => x !== payload.reactor.reactionName),
|
|
17979
|
+
});
|
|
17907
17980
|
}
|
|
17908
17981
|
};
|
|
17909
17982
|
|
|
@@ -17922,7 +17995,7 @@ const preparePayloadForCache = (event, payload) => {
|
|
|
17922
17995
|
*
|
|
17923
17996
|
* @category Reaction API
|
|
17924
17997
|
* @async
|
|
17925
|
-
|
|
17998
|
+
* */
|
|
17926
17999
|
const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
17927
18000
|
var _a, _b;
|
|
17928
18001
|
const client = getActiveClient();
|
|
@@ -17931,7 +18004,11 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
17931
18004
|
referenceType,
|
|
17932
18005
|
reactionName,
|
|
17933
18006
|
});
|
|
17934
|
-
await client.http.post('/api/v2/reactions', {
|
|
18007
|
+
await client.http.post('/api/v2/reactions', {
|
|
18008
|
+
referenceId,
|
|
18009
|
+
referenceType,
|
|
18010
|
+
reactionName,
|
|
18011
|
+
});
|
|
17935
18012
|
const model = await fetchReference(referenceType, referenceId);
|
|
17936
18013
|
dispatchReactable(referenceType, model.data);
|
|
17937
18014
|
return (_b = (_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)) !== null && _b !== void 0 ? _b : false;
|
|
@@ -17950,7 +18027,7 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
17950
18027
|
* @returns The added result.
|
|
17951
18028
|
*
|
|
17952
18029
|
* @category Reaction API
|
|
17953
|
-
|
|
18030
|
+
* */
|
|
17954
18031
|
addReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
17955
18032
|
var _a, _b, _c, _d, _e;
|
|
17956
18033
|
const client = getActiveClient();
|
|
@@ -17961,7 +18038,11 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
17961
18038
|
});
|
|
17962
18039
|
if (!client.cache)
|
|
17963
18040
|
return;
|
|
17964
|
-
const model = pullFromCache([
|
|
18041
|
+
const model = pullFromCache([
|
|
18042
|
+
referenceType,
|
|
18043
|
+
'get',
|
|
18044
|
+
referenceId,
|
|
18045
|
+
]);
|
|
17965
18046
|
if (!(model === null || model === void 0 ? void 0 : model.data) || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
17966
18047
|
return;
|
|
17967
18048
|
const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }) });
|
|
@@ -17985,7 +18066,7 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
17985
18066
|
*
|
|
17986
18067
|
* @category Reaction API
|
|
17987
18068
|
* @async
|
|
17988
|
-
|
|
18069
|
+
* */
|
|
17989
18070
|
const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
17990
18071
|
var _a, _b;
|
|
17991
18072
|
const client = getActiveClient();
|
|
@@ -17994,7 +18075,9 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
17994
18075
|
referenceType,
|
|
17995
18076
|
reactionName,
|
|
17996
18077
|
});
|
|
17997
|
-
await client.http.delete(`/api/v2/reactions`, {
|
|
18078
|
+
await client.http.delete(`/api/v2/reactions`, {
|
|
18079
|
+
data: { referenceId, referenceType, reactionName },
|
|
18080
|
+
});
|
|
17998
18081
|
const model = await fetchReference(referenceType, referenceId);
|
|
17999
18082
|
dispatchReactable(referenceType, model.data);
|
|
18000
18083
|
return (_b = !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName))) !== null && _b !== void 0 ? _b : false;
|
|
@@ -18013,7 +18096,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
18013
18096
|
* @returns The added result.
|
|
18014
18097
|
*
|
|
18015
18098
|
* @category Reaction API
|
|
18016
|
-
|
|
18099
|
+
* */
|
|
18017
18100
|
removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
18018
18101
|
var _a, _b, _c, _d, _e;
|
|
18019
18102
|
const client = getActiveClient();
|
|
@@ -18024,7 +18107,11 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
18024
18107
|
});
|
|
18025
18108
|
if (!client.cache)
|
|
18026
18109
|
return;
|
|
18027
|
-
const model = pullFromCache([
|
|
18110
|
+
const model = pullFromCache([
|
|
18111
|
+
referenceType,
|
|
18112
|
+
'get',
|
|
18113
|
+
referenceId,
|
|
18114
|
+
]);
|
|
18028
18115
|
if (!(model === null || model === void 0 ? void 0 : model.data) || !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
18029
18116
|
return;
|
|
18030
18117
|
const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) - 1) }) });
|
|
@@ -18203,6 +18290,7 @@ const onPostReactionAdded = (callback) => {
|
|
|
18203
18290
|
}
|
|
18204
18291
|
else {
|
|
18205
18292
|
preparePayloadForCache('post.addReaction', payload);
|
|
18293
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18206
18294
|
const postPayload = __rest(payload, ["reactor"]);
|
|
18207
18295
|
ingestInCache(postPayload);
|
|
18208
18296
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
@@ -18235,6 +18323,7 @@ const onPostReactionRemoved = (callback) => {
|
|
|
18235
18323
|
}
|
|
18236
18324
|
else {
|
|
18237
18325
|
preparePayloadForCache('post.removeReaction', payload);
|
|
18326
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18238
18327
|
const postPayload = __rest(payload, ["reactor"]);
|
|
18239
18328
|
ingestInCache(postPayload);
|
|
18240
18329
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
@@ -18254,7 +18343,11 @@ const createCommentEventSubscriber = (event, callback) => {
|
|
|
18254
18343
|
}
|
|
18255
18344
|
else {
|
|
18256
18345
|
ingestInCache(payload);
|
|
18257
|
-
const comment = pullFromCache([
|
|
18346
|
+
const comment = pullFromCache([
|
|
18347
|
+
'comment',
|
|
18348
|
+
'get',
|
|
18349
|
+
payload.comments[0].commentId,
|
|
18350
|
+
]);
|
|
18258
18351
|
if (['comment.created'].includes(event)) {
|
|
18259
18352
|
const queries = (_a = queryCache(['comment', 'query'])) === null || _a === void 0 ? void 0 : _a.filter(({ key }) => { var _a; return ((_a = key[2]) === null || _a === void 0 ? void 0 : _a.referenceId) === comment.data.referenceId; });
|
|
18260
18353
|
queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
|
|
@@ -18373,9 +18466,14 @@ const onCommentReactionAdded = (callback) => {
|
|
|
18373
18466
|
}
|
|
18374
18467
|
else {
|
|
18375
18468
|
preparePayloadForCache('comment.addReaction', payload);
|
|
18469
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18376
18470
|
const commentPayload = __rest(payload, ["reactor"]);
|
|
18377
18471
|
ingestInCache(commentPayload);
|
|
18378
|
-
const comment = pullFromCache([
|
|
18472
|
+
const comment = pullFromCache([
|
|
18473
|
+
'comment',
|
|
18474
|
+
'get',
|
|
18475
|
+
payload.comments[0].commentId,
|
|
18476
|
+
]);
|
|
18379
18477
|
callback(comment.data);
|
|
18380
18478
|
}
|
|
18381
18479
|
};
|
|
@@ -18405,9 +18503,14 @@ const onCommentReactionRemoved = (callback) => {
|
|
|
18405
18503
|
}
|
|
18406
18504
|
else {
|
|
18407
18505
|
preparePayloadForCache('comment.removeReaction', payload);
|
|
18506
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18408
18507
|
const commentPayload = __rest(payload, ["reactor"]);
|
|
18409
18508
|
ingestInCache(commentPayload);
|
|
18410
|
-
const comment = pullFromCache([
|
|
18509
|
+
const comment = pullFromCache([
|
|
18510
|
+
'comment',
|
|
18511
|
+
'get',
|
|
18512
|
+
payload.comments[0].commentId,
|
|
18513
|
+
]);
|
|
18411
18514
|
callback(comment.data);
|
|
18412
18515
|
}
|
|
18413
18516
|
};
|
|
@@ -18430,7 +18533,7 @@ const onCommentReactionRemoved = (callback) => {
|
|
|
18430
18533
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
18431
18534
|
*
|
|
18432
18535
|
* @category Message Events
|
|
18433
|
-
|
|
18536
|
+
* */
|
|
18434
18537
|
const onReactionRemoved = (referenceType, referenceId, callback) => {
|
|
18435
18538
|
const callbackWrapper = (model) => {
|
|
18436
18539
|
if (getResolver(referenceType)(model) === referenceId) {
|
|
@@ -18441,7 +18544,11 @@ const onReactionRemoved = (referenceType, referenceId, callback) => {
|
|
|
18441
18544
|
const client = getActiveClient();
|
|
18442
18545
|
const filter = (payload) => {
|
|
18443
18546
|
var _a;
|
|
18444
|
-
const cached = pullFromCache([
|
|
18547
|
+
const cached = pullFromCache([
|
|
18548
|
+
'message',
|
|
18549
|
+
'get',
|
|
18550
|
+
payload.messages[0].messageId,
|
|
18551
|
+
]);
|
|
18445
18552
|
const isReactionEvent = ((_a = cached === null || cached === void 0 ? void 0 : cached.data) === null || _a === void 0 ? void 0 : _a.reactionsCount) !== payload.messages[0].reactionsCount;
|
|
18446
18553
|
ingestInCache(payload);
|
|
18447
18554
|
if (isReactionEvent) {
|
|
@@ -18491,12 +18598,12 @@ var REFERENCE_TYPES = {
|
|
|
18491
18598
|
*
|
|
18492
18599
|
* @category Report API
|
|
18493
18600
|
* @async
|
|
18494
|
-
|
|
18601
|
+
* */
|
|
18495
18602
|
const createReport = async (referenceType, referenceId) => {
|
|
18496
18603
|
const client = getActiveClient();
|
|
18497
18604
|
client.log('report/createReport', { referenceType, referenceId });
|
|
18498
18605
|
const { domainName } = REFERENCE_TYPES[referenceType];
|
|
18499
|
-
const { data } = await client.http.post(`/api/v3/${domainName}/${
|
|
18606
|
+
const { data } = await client.http.post(`/api/v3/${domainName}/${encodeURIComponent(referenceId)}/flag`);
|
|
18500
18607
|
if (client.cache)
|
|
18501
18608
|
ingestInCache(data);
|
|
18502
18609
|
const event = referenceType === 'message'
|
|
@@ -18518,7 +18625,7 @@ const createReport = async (referenceType, referenceId) => {
|
|
|
18518
18625
|
*
|
|
18519
18626
|
* @category Report API
|
|
18520
18627
|
* @async
|
|
18521
|
-
|
|
18628
|
+
* */
|
|
18522
18629
|
const deleteReport = async (referenceType, referenceId) => {
|
|
18523
18630
|
const client = getActiveClient();
|
|
18524
18631
|
client.log('report/deleteReport', { referenceType, referenceId });
|
|
@@ -18545,7 +18652,7 @@ const deleteReport = async (referenceType, referenceId) => {
|
|
|
18545
18652
|
*
|
|
18546
18653
|
* @category Report API
|
|
18547
18654
|
* @async
|
|
18548
|
-
|
|
18655
|
+
* */
|
|
18549
18656
|
const isReportedByMe = async (referenceType, referenceId) => {
|
|
18550
18657
|
var _a, _b;
|
|
18551
18658
|
const client = getActiveClient();
|
|
@@ -18580,15 +18687,21 @@ const queryChannels = async (query) => {
|
|
|
18580
18687
|
// API-FIX: parameters should be querystring.
|
|
18581
18688
|
// API-FIX: backend doesnt answer Amity.Response
|
|
18582
18689
|
// const { data } = await client.http.get<Amity.Response<Amity.Paged<ChannelPayload>>>(
|
|
18583
|
-
const { data } = await client.http.get(`/api/v3/channels`, {
|
|
18690
|
+
const { data } = await client.http.get(`/api/v3/channels`, {
|
|
18691
|
+
params: Object.assign(Object.assign({}, params), { keyword: displayName, filter: membership, options: {
|
|
18584
18692
|
token: toToken(page, 'skiplimit'),
|
|
18585
|
-
} })
|
|
18693
|
+
} }),
|
|
18694
|
+
});
|
|
18586
18695
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
18587
18696
|
const { channels } = payload;
|
|
18588
18697
|
const cachedAt = client.cache && Date.now();
|
|
18589
18698
|
if (client.cache) {
|
|
18590
18699
|
ingestInCache(payload, { cachedAt });
|
|
18591
|
-
const cacheKey = [
|
|
18700
|
+
const cacheKey = [
|
|
18701
|
+
'channel',
|
|
18702
|
+
'query',
|
|
18703
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
18704
|
+
];
|
|
18592
18705
|
pushToCache(cacheKey, { channels: channels.map(getResolver('channel')), paging });
|
|
18593
18706
|
}
|
|
18594
18707
|
const nextPage = toPage(paging.next);
|
|
@@ -18633,13 +18746,15 @@ const getChannels = async (channelIds) => {
|
|
|
18633
18746
|
client.log('channel/getChannels', channelIds);
|
|
18634
18747
|
const encodedChannelIds = channelIds.map(channelId => encodeURIComponent(channelId));
|
|
18635
18748
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
18636
|
-
const { data } = await client.http.get(`/api/v3/channels/list`, {
|
|
18749
|
+
const { data } = await client.http.get(`/api/v3/channels/list`, {
|
|
18750
|
+
params: { channelIds: encodedChannelIds },
|
|
18751
|
+
});
|
|
18637
18752
|
const cachedAt = client.cache && Date.now();
|
|
18638
18753
|
if (client.cache)
|
|
18639
18754
|
ingestInCache(data, { cachedAt });
|
|
18640
18755
|
return {
|
|
18641
18756
|
data: data.channels,
|
|
18642
|
-
cachedAt
|
|
18757
|
+
cachedAt,
|
|
18643
18758
|
};
|
|
18644
18759
|
};
|
|
18645
18760
|
/**
|
|
@@ -18665,7 +18780,7 @@ getChannels.locally = (channelIds) => {
|
|
|
18665
18780
|
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
18666
18781
|
.filter(Boolean);
|
|
18667
18782
|
const channels = cached.map(({ data }) => data);
|
|
18668
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
18783
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
18669
18784
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < channelIds.length)
|
|
18670
18785
|
return;
|
|
18671
18786
|
return {
|
|
@@ -18837,8 +18952,7 @@ const joinChannel = async (channelId) => {
|
|
|
18837
18952
|
if (client.cache)
|
|
18838
18953
|
ingestInCache(data);
|
|
18839
18954
|
const { channelUsers } = data;
|
|
18840
|
-
return !!channelUsers.find(channelUser =>
|
|
18841
|
-
&& channelUser.membership === 'member'));
|
|
18955
|
+
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership === 'member');
|
|
18842
18956
|
};
|
|
18843
18957
|
|
|
18844
18958
|
/**
|
|
@@ -18862,8 +18976,7 @@ const leaveChannel = async (channelId) => {
|
|
|
18862
18976
|
if (client.cache)
|
|
18863
18977
|
ingestInCache(data);
|
|
18864
18978
|
const { channelUsers } = data;
|
|
18865
|
-
return !!channelUsers.find(channelUser =>
|
|
18866
|
-
&& channelUser.membership !== 'member'));
|
|
18979
|
+
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership !== 'member');
|
|
18867
18980
|
};
|
|
18868
18981
|
|
|
18869
18982
|
/**
|
|
@@ -18879,7 +18992,7 @@ const leaveChannel = async (channelId) => {
|
|
|
18879
18992
|
*
|
|
18880
18993
|
* @category Channel API
|
|
18881
18994
|
* @async
|
|
18882
|
-
|
|
18995
|
+
* */
|
|
18883
18996
|
const queryChannelMembers = async (query) => {
|
|
18884
18997
|
const client = getActiveClient();
|
|
18885
18998
|
client.log('channel/queryChannelMembers', query);
|
|
@@ -19375,7 +19488,11 @@ const createCommunityEventSubscriber = (event, callback) => {
|
|
|
19375
19488
|
}
|
|
19376
19489
|
else {
|
|
19377
19490
|
ingestInCache(payload);
|
|
19378
|
-
const community = pullFromCache([
|
|
19491
|
+
const community = pullFromCache([
|
|
19492
|
+
'community',
|
|
19493
|
+
'get',
|
|
19494
|
+
payload.communities[0].communityId,
|
|
19495
|
+
]);
|
|
19379
19496
|
callback(community.data);
|
|
19380
19497
|
}
|
|
19381
19498
|
};
|
|
@@ -19385,8 +19502,8 @@ function hasPermission(member, payload, permission) {
|
|
|
19385
19502
|
if (member.permissions.some(x => x === permission)) {
|
|
19386
19503
|
return true;
|
|
19387
19504
|
}
|
|
19388
|
-
return payload
|
|
19389
|
-
.find(user => user.userId === member.userId)
|
|
19505
|
+
return payload
|
|
19506
|
+
.users.find(user => user.userId === member.userId)
|
|
19390
19507
|
.permissions.some(x => x === permission);
|
|
19391
19508
|
}
|
|
19392
19509
|
function getEventRelatedMember(event, payload) {
|
|
@@ -19416,11 +19533,15 @@ const createCommunityMemberEventSubscriber = (event, callback) => {
|
|
|
19416
19533
|
}
|
|
19417
19534
|
else {
|
|
19418
19535
|
ingestInCache(payload);
|
|
19419
|
-
const community = pullFromCache([
|
|
19536
|
+
const community = pullFromCache([
|
|
19537
|
+
'community',
|
|
19538
|
+
'get',
|
|
19539
|
+
payload.communities[0].communityId,
|
|
19540
|
+
]);
|
|
19420
19541
|
const member = pullFromCache([
|
|
19421
19542
|
'communityUsers',
|
|
19422
19543
|
'get',
|
|
19423
|
-
getResolver('communityUsers')(getEventRelatedMember(event, payload))
|
|
19544
|
+
getResolver('communityUsers')(getEventRelatedMember(event, payload)),
|
|
19424
19545
|
]);
|
|
19425
19546
|
callback(community.data, member.data);
|
|
19426
19547
|
}
|
|
@@ -19625,6 +19746,134 @@ const observeCommunity = (communityId, callback) => {
|
|
|
19625
19746
|
};
|
|
19626
19747
|
};
|
|
19627
19748
|
|
|
19749
|
+
/**
|
|
19750
|
+
* ```js
|
|
19751
|
+
* import { queryCategories } from '@amityco/ts-sdk'
|
|
19752
|
+
* const { data: categories, prevPage, nextPage } = await queryCategories()
|
|
19753
|
+
* ```
|
|
19754
|
+
*
|
|
19755
|
+
* Queries a paginable list of {@link Amity.Category} objects
|
|
19756
|
+
*
|
|
19757
|
+
* @param query The query parameters
|
|
19758
|
+
* @returns A page of {@link Amity.Category} objects
|
|
19759
|
+
*
|
|
19760
|
+
* @category Category API
|
|
19761
|
+
* @async
|
|
19762
|
+
* */
|
|
19763
|
+
const queryCategories = async (query) => {
|
|
19764
|
+
const client = getActiveClient();
|
|
19765
|
+
client.log('category/queryCategories', query);
|
|
19766
|
+
const _a = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 } } = _a, params = __rest(_a, ["page"]);
|
|
19767
|
+
const { data } = await client.http.get(`/api/v3/community-categories`, {
|
|
19768
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
19769
|
+
token: toToken(page, 'skiplimit'),
|
|
19770
|
+
} }),
|
|
19771
|
+
});
|
|
19772
|
+
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
19773
|
+
const { categories } = payload;
|
|
19774
|
+
const cachedAt = client.cache && Date.now();
|
|
19775
|
+
if (client.cache) {
|
|
19776
|
+
ingestInCache(payload, { cachedAt });
|
|
19777
|
+
const cacheKey = [
|
|
19778
|
+
'category',
|
|
19779
|
+
'query',
|
|
19780
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
19781
|
+
];
|
|
19782
|
+
pushToCache(cacheKey, { categories: categories.map(getResolver('category')), paging });
|
|
19783
|
+
}
|
|
19784
|
+
const nextPage = toPage(paging.next);
|
|
19785
|
+
const prevPage = toPage(paging.previous);
|
|
19786
|
+
return { data: categories, cachedAt, prevPage, nextPage };
|
|
19787
|
+
};
|
|
19788
|
+
/**
|
|
19789
|
+
* ```js
|
|
19790
|
+
* import { queryCategories } from '@amityco/ts-sdk'
|
|
19791
|
+
* const { data: categories, prevPage, nextPage } = queryCategories.locally()
|
|
19792
|
+
* ```
|
|
19793
|
+
*
|
|
19794
|
+
* Queries a paginable list of {@link Amity.Category} objects from cache
|
|
19795
|
+
*
|
|
19796
|
+
* @param query The query parameters
|
|
19797
|
+
* @returns categories
|
|
19798
|
+
*
|
|
19799
|
+
* @category category API
|
|
19800
|
+
*/
|
|
19801
|
+
queryCategories.locally = (query) => {
|
|
19802
|
+
var _a, _b;
|
|
19803
|
+
const client = getActiveClient();
|
|
19804
|
+
client.log('category/queryCategories.locally', query);
|
|
19805
|
+
if (!client.cache)
|
|
19806
|
+
return;
|
|
19807
|
+
const _c = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 } } = _c, params = __rest(_c, ["page"]);
|
|
19808
|
+
const queryKey = ['category', 'query', Object.assign(Object.assign({}, params), { options: Object.assign({}, page) })];
|
|
19809
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
19810
|
+
if (!(data === null || data === void 0 ? void 0 : data.categories.length))
|
|
19811
|
+
return;
|
|
19812
|
+
const categories = data.categories
|
|
19813
|
+
.map(categoryId => pullFromCache(['category', 'get', categoryId]))
|
|
19814
|
+
.filter(Boolean)
|
|
19815
|
+
.map(({ data }) => data);
|
|
19816
|
+
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
19817
|
+
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
19818
|
+
return categories.length === ((_b = data === null || data === void 0 ? void 0 : data.categories) === null || _b === void 0 ? void 0 : _b.length)
|
|
19819
|
+
? { data: categories, cachedAt, prevPage, nextPage }
|
|
19820
|
+
: undefined;
|
|
19821
|
+
};
|
|
19822
|
+
|
|
19823
|
+
/**
|
|
19824
|
+
* ```js
|
|
19825
|
+
* import { getCategory } from '@amityco/ts-sdk'
|
|
19826
|
+
* const { data: category } = await getCategory('foo')
|
|
19827
|
+
* ```
|
|
19828
|
+
*
|
|
19829
|
+
* Fetches a {@link Amity.Category} object
|
|
19830
|
+
*
|
|
19831
|
+
* @param categoryId the ID of the {@link Amity.Category} to fetch
|
|
19832
|
+
* @returns the associated {@link Amity.Category} object
|
|
19833
|
+
*
|
|
19834
|
+
* @category Category API
|
|
19835
|
+
* @async
|
|
19836
|
+
*/
|
|
19837
|
+
const getCategory = async (categoryId) => {
|
|
19838
|
+
const client = getActiveClient();
|
|
19839
|
+
client.log('category/getCategory', categoryId);
|
|
19840
|
+
const { data } = await client.http.get(`/api/v3/community-categories/${encodeURIComponent(categoryId)}`);
|
|
19841
|
+
const cachedAt = client.cache && Date.now();
|
|
19842
|
+
if (client.cache)
|
|
19843
|
+
ingestInCache(data, { cachedAt });
|
|
19844
|
+
const { categories } = data;
|
|
19845
|
+
return {
|
|
19846
|
+
data: categories.find(category => category.categoryId === categoryId),
|
|
19847
|
+
cachedAt,
|
|
19848
|
+
};
|
|
19849
|
+
};
|
|
19850
|
+
/**
|
|
19851
|
+
* ```js
|
|
19852
|
+
* import { getCategory } from '@amityco/ts-sdk'
|
|
19853
|
+
* const { data: category } = getCategory.locally('foobar')
|
|
19854
|
+
* ```
|
|
19855
|
+
*
|
|
19856
|
+
* Fetches a {@link Amity.Category} object from cache
|
|
19857
|
+
*
|
|
19858
|
+
* @param categoryId the ID of the {@link Amity.Category} to fetch
|
|
19859
|
+
* @returns the associated {@link Amity.Category} object
|
|
19860
|
+
*
|
|
19861
|
+
* @category Category API
|
|
19862
|
+
*/
|
|
19863
|
+
getCategory.locally = (categoryId) => {
|
|
19864
|
+
const client = getActiveClient();
|
|
19865
|
+
client.log('category/getCategory.locally', categoryId);
|
|
19866
|
+
if (!client.cache)
|
|
19867
|
+
return;
|
|
19868
|
+
const cached = pullFromCache(['category', 'get', categoryId]);
|
|
19869
|
+
if (!cached)
|
|
19870
|
+
return;
|
|
19871
|
+
return {
|
|
19872
|
+
data: cached.data,
|
|
19873
|
+
cachedAt: cached.cachedAt,
|
|
19874
|
+
};
|
|
19875
|
+
};
|
|
19876
|
+
|
|
19628
19877
|
/**
|
|
19629
19878
|
* ```js
|
|
19630
19879
|
* import { queryGlobalFeed } from '@amityco/ts-sdk'
|
|
@@ -19638,20 +19887,26 @@ const observeCommunity = (communityId, callback) => {
|
|
|
19638
19887
|
*
|
|
19639
19888
|
* @category Feed API
|
|
19640
19889
|
* @async
|
|
19641
|
-
|
|
19890
|
+
* */
|
|
19642
19891
|
const queryGlobalFeed = async (query) => {
|
|
19643
19892
|
const client = getActiveClient();
|
|
19644
19893
|
client.log('feed/queryGlobalFeed', query);
|
|
19645
19894
|
const _a = query !== null && query !== void 0 ? query : {}, { useCustomRanking, page } = _a, params = __rest(_a, ["useCustomRanking", "page"]);
|
|
19646
|
-
const { data } = await client.http.get(useCustomRanking ? `/api/v5/me/global-feeds` : `/api/v4/me/global-feeds`, {
|
|
19647
|
-
|
|
19648
|
-
|
|
19895
|
+
const { data } = await client.http.get(useCustomRanking ? `/api/v5/me/global-feeds` : `/api/v4/me/global-feeds`, {
|
|
19896
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
19897
|
+
token: toToken(page, 'skiplimit'),
|
|
19898
|
+
} }),
|
|
19899
|
+
});
|
|
19649
19900
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
19650
19901
|
const { posts } = payload;
|
|
19651
19902
|
const cachedAt = client.cache && Date.now();
|
|
19652
19903
|
if (client.cache) {
|
|
19653
19904
|
ingestInCache(payload);
|
|
19654
|
-
const cacheKey = [
|
|
19905
|
+
const cacheKey = [
|
|
19906
|
+
'globalFeed',
|
|
19907
|
+
'query',
|
|
19908
|
+
Object.assign(Object.assign({}, params), { useCustomRanking, options: Object.assign({}, page) }),
|
|
19909
|
+
];
|
|
19655
19910
|
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
19656
19911
|
}
|
|
19657
19912
|
const nextPage = toPage(paging.next);
|
|
@@ -19671,7 +19926,7 @@ const queryGlobalFeed = async (query) => {
|
|
|
19671
19926
|
*
|
|
19672
19927
|
* @category Feed API
|
|
19673
19928
|
* @async
|
|
19674
|
-
|
|
19929
|
+
* */
|
|
19675
19930
|
queryGlobalFeed.locally = (query) => {
|
|
19676
19931
|
var _a, _b;
|
|
19677
19932
|
const client = getActiveClient();
|
|
@@ -19679,7 +19934,11 @@ queryGlobalFeed.locally = (query) => {
|
|
|
19679
19934
|
if (!client.cache)
|
|
19680
19935
|
return;
|
|
19681
19936
|
const _c = query !== null && query !== void 0 ? query : {}, { useCustomRanking, page } = _c, params = __rest(_c, ["useCustomRanking", "page"]);
|
|
19682
|
-
const queryKey = [
|
|
19937
|
+
const queryKey = [
|
|
19938
|
+
'globalFeed',
|
|
19939
|
+
'query',
|
|
19940
|
+
Object.assign(Object.assign({}, params), { useCustomRanking, options: Object.assign({}, page) }),
|
|
19941
|
+
];
|
|
19683
19942
|
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
19684
19943
|
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
19685
19944
|
return;
|
|
@@ -19706,7 +19965,11 @@ const queryFollows = async (key, query) => {
|
|
|
19706
19965
|
const cachedAt = client.cache && Date.now();
|
|
19707
19966
|
if (client.cache) {
|
|
19708
19967
|
ingestInCache(payload, { cachedAt });
|
|
19709
|
-
const cacheKey = [
|
|
19968
|
+
const cacheKey = [
|
|
19969
|
+
key,
|
|
19970
|
+
'query',
|
|
19971
|
+
Object.assign(Object.assign({}, params), { userId, options: Object.assign({}, page) }),
|
|
19972
|
+
];
|
|
19710
19973
|
pushToCache(cacheKey, { follows: follows.map(getResolver('follow')), paging });
|
|
19711
19974
|
}
|
|
19712
19975
|
const nextPage = toPage(paging.next);
|
|
@@ -19796,7 +20059,11 @@ const queryFollowings = async (query) => queryFollows('following', query);
|
|
|
19796
20059
|
*/
|
|
19797
20060
|
queryFollowings.locally = (query) => queryFollows.locally('following', query);
|
|
19798
20061
|
|
|
19799
|
-
const getCacheKey = (userId) => [
|
|
20062
|
+
const getCacheKey = (userId) => [
|
|
20063
|
+
'followInfo',
|
|
20064
|
+
'get',
|
|
20065
|
+
`${getActiveClient().userId}#${userId}`,
|
|
20066
|
+
];
|
|
19800
20067
|
/**
|
|
19801
20068
|
* ```js
|
|
19802
20069
|
* import { getFollowInfo } from '@amityco/ts-sdk'
|
|
@@ -19969,8 +20236,8 @@ const createFollowEventSubscriber = (event, callback) => {
|
|
|
19969
20236
|
else {
|
|
19970
20237
|
ingestInCache({ follows: [payload] });
|
|
19971
20238
|
const queries = [
|
|
19972
|
-
...(_a = queryCache(['followers', 'query'])) !== null && _a !== void 0 ? _a : [],
|
|
19973
|
-
...(_b = queryCache(['followings', 'query'])) !== null && _b !== void 0 ? _b : [],
|
|
20239
|
+
...((_a = queryCache(['followers', 'query'])) !== null && _a !== void 0 ? _a : []),
|
|
20240
|
+
...((_b = queryCache(['followings', 'query'])) !== null && _b !== void 0 ? _b : []),
|
|
19974
20241
|
];
|
|
19975
20242
|
queries
|
|
19976
20243
|
// @ts-ignore
|
|
@@ -20118,7 +20385,10 @@ const onFollowRequestDeclined = (callback) => createFollowEventSubscriber('follo
|
|
|
20118
20385
|
*/
|
|
20119
20386
|
const onFollowInfoUpdated = (callback) => {
|
|
20120
20387
|
const handler = async (payload) => {
|
|
20121
|
-
const [{ data: followInfoFrom }, { data: followInfoTo }
|
|
20388
|
+
const [{ data: followInfoFrom }, { data: followInfoTo }] = await Promise.all([
|
|
20389
|
+
getFollowInfo(payload.from),
|
|
20390
|
+
getFollowInfo(payload.to),
|
|
20391
|
+
]);
|
|
20122
20392
|
callback(followInfoFrom);
|
|
20123
20393
|
callback(followInfoTo);
|
|
20124
20394
|
};
|
|
@@ -20284,8 +20554,7 @@ const observePosts = (params, callback) => {
|
|
|
20284
20554
|
const disposers = [];
|
|
20285
20555
|
const router = (post, action) => {
|
|
20286
20556
|
var _a, _b;
|
|
20287
|
-
if (params.targetId !== post.targetId
|
|
20288
|
-
|| params.targetType !== post.targetType)
|
|
20557
|
+
if (params.targetId !== post.targetId || params.targetType !== post.targetType)
|
|
20289
20558
|
return;
|
|
20290
20559
|
if (callback instanceof Function)
|
|
20291
20560
|
return callback(post);
|
|
@@ -20496,9 +20765,11 @@ const queryStreams = async (query) => {
|
|
|
20496
20765
|
const client = getActiveClient();
|
|
20497
20766
|
client.log('stream/queryStreams', query);
|
|
20498
20767
|
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
20499
|
-
const { data } = await client.http.get(`/api/v3/video-streaming`, {
|
|
20768
|
+
const { data } = await client.http.get(`/api/v3/video-streaming`, {
|
|
20769
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
20500
20770
|
token: toToken(page, 'skiplimit'),
|
|
20501
|
-
} })
|
|
20771
|
+
} }),
|
|
20772
|
+
});
|
|
20502
20773
|
// API-FIX: backend to response Amity.Response: const { paging, videoStreamings } = unwrapPayload(data)
|
|
20503
20774
|
// API-FIX: seems returned data has a results identifier on top of data, like no other apis, and this is beautiful
|
|
20504
20775
|
const { paging, results: payload } = data;
|
|
@@ -20604,7 +20875,7 @@ const updateStream = async (streamId, patch) => {
|
|
|
20604
20875
|
const deleteStream = async (streamId) => {
|
|
20605
20876
|
const client = getActiveClient();
|
|
20606
20877
|
client.log('stream/deleteStream', streamId);
|
|
20607
|
-
|
|
20878
|
+
const stream = await getStream(streamId);
|
|
20608
20879
|
// API-FIX: it returns { success: boolean } but seems it should be Amity.Response<{ success: boolean }
|
|
20609
20880
|
// API-FIX: swagger docs are wrong!
|
|
20610
20881
|
const { data } = await client.http.delete(`/api/v3/video-streaming/${streamId}`);
|
|
@@ -20715,4 +20986,4 @@ const onStreamRecorded = (callback) => {
|
|
|
20715
20986
|
return createEventSubscriber(client, 'stream/onStreamRecorded', 'video-streaming.didRecord', filter);
|
|
20716
20987
|
};
|
|
20717
20988
|
|
|
20718
|
-
export { API_REGIONS, SubscriptionLevels, VERSION$1 as VERSION, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers,
|
|
20989
|
+
export { API_REGIONS, SubscriptionLevels, VERSION$1 as VERSION, acceptFollower, addChannelMembers, addChannelMembersRole, addCommunityMembers, addCommunityMembersRoles, addReaction, backupCache, connectClient, createChannel, createClient, createComment, createCommunity, createFile, createMessage, createPost, createQuery, createReport, createStream, createVideo, declineFollower, deleteChannel, deleteComment, deleteCommunity, deleteFile, deleteMessage, deletePost, deleteReport, deleteStream, disableCache, disconnectClient, disposeStream, dropFromCache, enableCache, fileUrlWithSize, filterByPropEquality, follow, getActiveClient, getCategory, getChannel, getChannels, getComment, getCommentTopic, getComments, getCommunities, getCommunity, getCommunityTopic, getFile, getFollowInfo, getMessage, getMessages, getMyFollowersTopic, getMyFollowingsTopic, getPost, getPostTopic, getPosts, getRecommendedCommunities, getRole, getStream, getTopTrendingCommunities, getUser, getUserTopic, getUsers, isAfterBefore, isAfterBeforeRaw, isCachable, isConnected, isFetcher, isFresh, isLocal, isMutator, isOffline, isPaged, isReportedByMe, isSkipLimit, joinChannel, joinCommunity, leaveChannel, leaveCommunity, mergeInCache, observeChannel, observeComment, observeComments, observeCommunity, observeFile, observeFollowInfo, observeFollowers, observeFollowings, observeMessage, observeMessages, observePost, observePosts, observeUser, onChannelDeleted, onChannelJoined, onChannelLeft, onChannelUpdated, onClientBanned, onClientDisconnected, onCommentCreated, onCommentDeleted, onCommentFlagged, onCommentReactionAdded, onCommentReactionRemoved, onCommentUnflagged, onCommentUpdated, onCommunityCreated, onCommunityDeleted, onCommunityJoined, onCommunityLeft, onCommunityUpdated, onCommunityUserAdded, onCommunityUserBanned, onCommunityUserRemoved, onCommunityUserUnbanned, onConnectionError, onFollowInfoUpdated, onFollowRequestAccepted, onFollowRequestCanceled, onFollowRequestDeclined, onFollowerDeleted, onFollowerRequested, onMemberAdded, onMemberRemoved, onMessageCreated, onMessageDeleted, onMessageUpdated, onPostApproved, onPostCreated, onPostDeclined, onPostDeleted, onPostFlagged, onPostReactionAdded, onPostReactionRemoved, onPostUnflagged, onPostUpdated, onReactionRemoved, onStreamRecorded, onStreamStarted, onStreamStopped, onUserFlagCleared, onUserFlagged, onUserFollowed, onUserUnflagged, onUserUnfollowed, onUserUpdated, pullFromCache, pushToCache, queryCache, queryCategories, queryChannelMembers, queryChannels, queryComments, queryCommunities, queryCommunityMembers, queryFollowers, queryFollowings, queryGlobalFeed, queryMessages, queryOptions, queryPosts, queryRoles, queryStreams, queryUsers, removeChannelMembers, removeChannelMembersRole, removeCommunityMembers, removeCommunityMembersRoles, removeReaction, restoreCache, runQuery, sortByChannelSegment, sortByDisplayName, sortByFirstCreated, sortByLastActivity, sortByLastCreated, sortBySegmentNumber, subscribeTopic, toPage, toPageRaw, toToken, unfollow, updateChannel, updateComment, updateCommunity, updateMessage, updatePost, updateStream, updateUser, upsertInCache, wipeCache };
|