@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.cjs.js
CHANGED
|
@@ -20,6 +20,7 @@ var mitt__default = /*#__PURE__*/_interopDefaultLegacy(mitt);
|
|
|
20
20
|
var AsyncStorage__default = /*#__PURE__*/_interopDefaultLegacy(AsyncStorage);
|
|
21
21
|
|
|
22
22
|
var _a$1;
|
|
23
|
+
/* eslint-disable no-undef */
|
|
23
24
|
const theGlobal = globalThis || global || window;
|
|
24
25
|
const { process: safeProcess = {} } = theGlobal;
|
|
25
26
|
const isProduction = ((_a$1 = safeProcess.env) === null || _a$1 === void 0 ? void 0 : _a$1.NODE_ENV) === 'production';
|
|
@@ -35,7 +36,7 @@ const VERSION$1 = (_b = (_a = safeProcess.env) === null || _a === void 0 ? void
|
|
|
35
36
|
*
|
|
36
37
|
* @hidden
|
|
37
38
|
*/
|
|
38
|
-
const isSkipLimit = (json) =>
|
|
39
|
+
const isSkipLimit = (json) => ['skip', 'limit'].some(prop => prop in json);
|
|
39
40
|
/**
|
|
40
41
|
* Type guard to find if the a given decoded backend token uses "after/before" pagination style
|
|
41
42
|
*
|
|
@@ -44,7 +45,7 @@ const isSkipLimit = (json) => (['skip', 'limit'].some(prop => prop in json));
|
|
|
44
45
|
*
|
|
45
46
|
* @hidden
|
|
46
47
|
*/
|
|
47
|
-
const isAfterBefore = (json) =>
|
|
48
|
+
const isAfterBefore = (json) => ['after', 'before', 'first', 'last', 'limit'].some(prop => prop in json);
|
|
48
49
|
/**
|
|
49
50
|
* Type guard to find if the a given decoded backend token uses v4 or newer "after/before" pagination style
|
|
50
51
|
*
|
|
@@ -53,7 +54,7 @@ const isAfterBefore = (json) => (['after', 'before', 'first', 'last', 'limit'].s
|
|
|
53
54
|
*
|
|
54
55
|
* @hidden
|
|
55
56
|
*/
|
|
56
|
-
const isAfterBeforeRaw = (json) =>
|
|
57
|
+
const isAfterBeforeRaw = (json) => 'limit' in json;
|
|
57
58
|
/**
|
|
58
59
|
* Type guard to find if the a given object is wrapped around Amity.Paged<>
|
|
59
60
|
*
|
|
@@ -63,9 +64,9 @@ const isAfterBeforeRaw = (json) => ('limit' in json);
|
|
|
63
64
|
* @hidden
|
|
64
65
|
*/
|
|
65
66
|
const isPaged = (payload) => {
|
|
66
|
-
return ((payload === null || payload === void 0 ? void 0 : payload.hasOwnProperty('data'))
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
return ((payload === null || payload === void 0 ? void 0 : payload.hasOwnProperty('data')) &&
|
|
68
|
+
(payload === null || payload === void 0 ? void 0 : payload.hasOwnProperty('nextPage')) &&
|
|
69
|
+
(payload === null || payload === void 0 ? void 0 : payload.hasOwnProperty('prevPage')));
|
|
69
70
|
};
|
|
70
71
|
/**
|
|
71
72
|
* Converts a paging object into a b64 string token
|
|
@@ -95,19 +96,19 @@ const toToken = (paging, style) => {
|
|
|
95
96
|
"before" or "after" value. if that would change,
|
|
96
97
|
we'd need to move toward a more simple: `!paging.before`
|
|
97
98
|
*/
|
|
98
|
-
if (!isNaN(paging === null || paging === void 0 ? void 0 : paging.before)) {
|
|
99
|
+
if (!Number.isNaN(paging === null || paging === void 0 ? void 0 : paging.before)) {
|
|
99
100
|
payload = {
|
|
100
101
|
before: paging.before,
|
|
101
102
|
last: paging.limit,
|
|
102
103
|
};
|
|
103
104
|
}
|
|
104
|
-
else if (!isNaN(paging === null || paging === void 0 ? void 0 : paging.after)) {
|
|
105
|
+
else if (!Number.isNaN(paging === null || paging === void 0 ? void 0 : paging.after)) {
|
|
105
106
|
payload = {
|
|
106
107
|
after: paging.after,
|
|
107
108
|
first: paging.limit,
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
|
-
else if (!isNaN(paging === null || paging === void 0 ? void 0 : paging.limit)) {
|
|
111
|
+
else if (!Number.isNaN(paging === null || paging === void 0 ? void 0 : paging.limit)) {
|
|
111
112
|
payload = {
|
|
112
113
|
last: paging.limit,
|
|
113
114
|
};
|
|
@@ -141,14 +142,14 @@ const toPage = (token) => {
|
|
|
141
142
|
limit: json.limit,
|
|
142
143
|
};
|
|
143
144
|
}
|
|
144
|
-
|
|
145
|
+
if (isAfterBefore(json)) {
|
|
145
146
|
if ('before' in json) {
|
|
146
147
|
return {
|
|
147
148
|
before: json.before,
|
|
148
149
|
limit: json.last,
|
|
149
150
|
};
|
|
150
151
|
}
|
|
151
|
-
|
|
152
|
+
if ('after' in json) {
|
|
152
153
|
return {
|
|
153
154
|
after: json.after,
|
|
154
155
|
limit: json.first,
|
|
@@ -176,6 +177,7 @@ const toPageRaw = (token) => {
|
|
|
176
177
|
return undefined;
|
|
177
178
|
};
|
|
178
179
|
|
|
180
|
+
/* eslint-disable no-use-before-define */
|
|
179
181
|
/**
|
|
180
182
|
* Type guard to check and cast that a given async function is has the ".locally" property
|
|
181
183
|
*
|
|
@@ -184,7 +186,7 @@ const toPageRaw = (token) => {
|
|
|
184
186
|
*
|
|
185
187
|
* @hidden
|
|
186
188
|
*/
|
|
187
|
-
const isFetcher = (func) =>
|
|
189
|
+
const isFetcher = (func) => 'locally' in func;
|
|
188
190
|
/**
|
|
189
191
|
* Type guard to check and cast that a given async function is has the ".optimistically" property
|
|
190
192
|
*
|
|
@@ -193,7 +195,7 @@ const isFetcher = (func) => ('locally' in func);
|
|
|
193
195
|
*
|
|
194
196
|
* @hidden
|
|
195
197
|
*/
|
|
196
|
-
const isMutator = (func) =>
|
|
198
|
+
const isMutator = (func) => 'optimistically' in func;
|
|
197
199
|
/**
|
|
198
200
|
* Type guard to check and cast that a given async function is has
|
|
199
201
|
* the ".locally" or ".optimistically" property
|
|
@@ -212,7 +214,7 @@ const isOffline = (func) => isFetcher(func) || isMutator(func);
|
|
|
212
214
|
*
|
|
213
215
|
* @hidden
|
|
214
216
|
*/
|
|
215
|
-
const isCachable = (model) =>
|
|
217
|
+
const isCachable = (model) => model === null || model === void 0 ? void 0 : model.hasOwnProperty('cachedAt');
|
|
216
218
|
/**
|
|
217
219
|
* Checks if a model is considered local (cachedAt === -1)
|
|
218
220
|
*
|
|
@@ -270,7 +272,7 @@ const createQuery = (func, ...args) => ({ func, args });
|
|
|
270
272
|
const queryOptions = (policy, lifeSpan = 2 * 60 * 1000) => {
|
|
271
273
|
if (policy === 'cache_only')
|
|
272
274
|
return { lifeSpan: Infinity };
|
|
273
|
-
|
|
275
|
+
if (policy === 'server_only')
|
|
274
276
|
return { lifeSpan: 0 };
|
|
275
277
|
return { lifeSpan };
|
|
276
278
|
};
|
|
@@ -296,9 +298,7 @@ const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_s
|
|
|
296
298
|
// offline first
|
|
297
299
|
if (isOffline(func) && options.lifeSpan !== 0) {
|
|
298
300
|
try {
|
|
299
|
-
local = isMutator(func)
|
|
300
|
-
? func.optimistically(...args)
|
|
301
|
-
: func.locally(...args);
|
|
301
|
+
local = isMutator(func) ? func.optimistically(...args) : func.locally(...args);
|
|
302
302
|
}
|
|
303
303
|
catch (error) {
|
|
304
304
|
callback === null || callback === void 0 ? void 0 : callback(createSnapshot(undefined, {
|
|
@@ -310,7 +310,7 @@ const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_s
|
|
|
310
310
|
const shouldAbort = isCachable(local) && isFresh(local, options.lifeSpan);
|
|
311
311
|
callback === null || callback === void 0 ? void 0 : callback(createSnapshot(local, {
|
|
312
312
|
origin: 'local',
|
|
313
|
-
loading: !(isFetcher(func) && shouldAbort)
|
|
313
|
+
loading: !(isFetcher(func) && shouldAbort),
|
|
314
314
|
}));
|
|
315
315
|
if (shouldAbort)
|
|
316
316
|
return;
|
|
@@ -318,13 +318,13 @@ const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_s
|
|
|
318
318
|
else {
|
|
319
319
|
callback === null || callback === void 0 ? void 0 : callback(createSnapshot(undefined, {
|
|
320
320
|
origin: 'local',
|
|
321
|
-
loading: true
|
|
321
|
+
loading: true,
|
|
322
322
|
}));
|
|
323
323
|
}
|
|
324
324
|
func(...args)
|
|
325
325
|
.then(fresh => {
|
|
326
326
|
// @ts-ignore i know.
|
|
327
|
-
//
|
|
327
|
+
// isLocal(local) && syncInCache(local, fresh)
|
|
328
328
|
callback === null || callback === void 0 ? void 0 : callback(createSnapshot(fresh, {
|
|
329
329
|
origin: 'server',
|
|
330
330
|
loading: false,
|
|
@@ -338,6 +338,7 @@ const runQuery = ({ func, args }, callback, options = queryOptions('cache_then_s
|
|
|
338
338
|
}));
|
|
339
339
|
});
|
|
340
340
|
};
|
|
341
|
+
// eslint-disable-next-line no-redeclare
|
|
341
342
|
function createSnapshot(data, options) {
|
|
342
343
|
if (isPaged(data) || isCachable(data))
|
|
343
344
|
return Object.assign(Object.assign({}, options), data);
|
|
@@ -391,6 +392,7 @@ const sortByLastCreated = ({ createdAt: a }, { createdAt: b }) => new Date(b).va
|
|
|
391
392
|
*/
|
|
392
393
|
const sortByLastActivity = ({ lastActivity: a }, { lastActivity: b }) => new Date(b).valueOf() - new Date(a).valueOf();
|
|
393
394
|
|
|
395
|
+
/* eslint-disable max-classes-per-file */
|
|
394
396
|
/**
|
|
395
397
|
* Generic ASC error
|
|
396
398
|
* @category Errors
|
|
@@ -420,6 +422,7 @@ class ASCApiError extends ASCError {
|
|
|
420
422
|
* @param code A normalized error code
|
|
421
423
|
* @param level A normalized failure level descriptor
|
|
422
424
|
*/
|
|
425
|
+
// eslint-disable-next-line no-useless-constructor
|
|
423
426
|
constructor(message, code, level) {
|
|
424
427
|
super(message, code, level);
|
|
425
428
|
}
|
|
@@ -446,7 +449,9 @@ class ASCConnectionError extends ASCError {
|
|
|
446
449
|
* @param message A custom error message
|
|
447
450
|
*/
|
|
448
451
|
constructor(event, message = 'SDK client is having connection issues') {
|
|
449
|
-
super(`${message} (${event})`, event === 'disconnected'
|
|
452
|
+
super(`${message} (${event})`, event === 'disconnected'
|
|
453
|
+
? 800211 /* DISCONNECTED */
|
|
454
|
+
: 800210 /* CONNECTION_ERROR */, "error" /* ERROR */);
|
|
450
455
|
this.event = event;
|
|
451
456
|
}
|
|
452
457
|
}
|
|
@@ -486,12 +491,12 @@ const setActiveClient = (client) => {
|
|
|
486
491
|
* @hidden
|
|
487
492
|
*/
|
|
488
493
|
const createLogger = (session) => {
|
|
489
|
-
const active =
|
|
490
|
-
&& !isProduction);
|
|
494
|
+
const active = `${session === null || session === void 0 ? void 0 : session.trim()}`.length > 0 && !isProduction;
|
|
491
495
|
const logger = debug__default['default'](session);
|
|
492
496
|
const print = (topic, ...args) => {
|
|
493
497
|
active && logger(topic, args);
|
|
494
498
|
};
|
|
499
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
495
500
|
print.__instance__ = logger;
|
|
496
501
|
return print;
|
|
497
502
|
};
|
|
@@ -524,7 +529,7 @@ const unwrapPayload = (response) => {
|
|
|
524
529
|
if (response.status === 'success') {
|
|
525
530
|
return response.data;
|
|
526
531
|
}
|
|
527
|
-
|
|
532
|
+
if (response.status === 'fail') {
|
|
528
533
|
throw new ASCUnknownError(response.code);
|
|
529
534
|
}
|
|
530
535
|
else if (response.status === 'error') {
|
|
@@ -546,9 +551,10 @@ const stringify = (params, prefix) => {
|
|
|
546
551
|
if (Array.isArray(value)) {
|
|
547
552
|
return value.map(item => `${key}[]=${item}`).join('&');
|
|
548
553
|
}
|
|
549
|
-
|
|
554
|
+
if (typeof value !== 'object') {
|
|
550
555
|
return `${key}=${value}`;
|
|
551
556
|
}
|
|
557
|
+
// @ts-ignore
|
|
552
558
|
return stringify(value, prefix !== null && prefix !== void 0 ? prefix : name);
|
|
553
559
|
})
|
|
554
560
|
.join('&');
|
|
@@ -575,9 +581,10 @@ const createHttpTransport = (endpoint) => {
|
|
|
575
581
|
httpsAgent: new HttpAgent.HttpsAgent(options),
|
|
576
582
|
paramsSerializer: stringify,
|
|
577
583
|
});
|
|
578
|
-
instance.interceptors.response.use(
|
|
584
|
+
instance.interceptors.response.use(response => response, error => {
|
|
579
585
|
var _a;
|
|
580
586
|
const { response } = error;
|
|
587
|
+
// eslint-disable-next-line no-console
|
|
581
588
|
console.error((_a = response === null || response === void 0 ? void 0 : response.data) !== null && _a !== void 0 ? _a : error);
|
|
582
589
|
if (response)
|
|
583
590
|
unwrapPayload(response.data);
|
|
@@ -14595,6 +14602,7 @@ function extend() {
|
|
|
14595
14602
|
|
|
14596
14603
|
var mqtt = mqtt$1.exports;
|
|
14597
14604
|
|
|
14605
|
+
/* eslint-disable no-console */
|
|
14598
14606
|
const QOS_FAILURE_CODE = 128;
|
|
14599
14607
|
const RETRY_BASE_TIMEOUT = 1000;
|
|
14600
14608
|
const RETRY_COUNT_MAX = 10;
|
|
@@ -14609,7 +14617,7 @@ function getMqttOptions(params) {
|
|
|
14609
14617
|
topic: 'WillMsg',
|
|
14610
14618
|
payload: 'Connection Closed abnormally..!',
|
|
14611
14619
|
qos: 0,
|
|
14612
|
-
retain: false
|
|
14620
|
+
retain: false,
|
|
14613
14621
|
} }, params);
|
|
14614
14622
|
}
|
|
14615
14623
|
/**
|
|
@@ -14625,6 +14633,12 @@ const createMqttTransport = (endpoint) => {
|
|
|
14625
14633
|
let mqttClient;
|
|
14626
14634
|
let retryCount = 0;
|
|
14627
14635
|
let allowReconnection = true;
|
|
14636
|
+
const reconnect = () => {
|
|
14637
|
+
setTimeout(() => {
|
|
14638
|
+
retryCount += 1;
|
|
14639
|
+
mqttClient.reconnect();
|
|
14640
|
+
}, RETRY_BASE_TIMEOUT * 2 ** (retryCount > RETRY_COUNT_MAX ? RETRY_COUNT_MAX : retryCount));
|
|
14641
|
+
};
|
|
14628
14642
|
async function connect(params) {
|
|
14629
14643
|
if (mqttClient) {
|
|
14630
14644
|
mqttClient.removeAllListeners();
|
|
@@ -14636,6 +14650,7 @@ const createMqttTransport = (endpoint) => {
|
|
|
14636
14650
|
allowReconnection = true;
|
|
14637
14651
|
});
|
|
14638
14652
|
mqttClient.on('error', (error) => {
|
|
14653
|
+
// eslint-disable-next-line default-case
|
|
14639
14654
|
switch (error.code) {
|
|
14640
14655
|
case 2 /* IDENTIFIER_REJECTED */:
|
|
14641
14656
|
case 4 /* BAD_USERNAME_OR_PASSWORD */:
|
|
@@ -14650,12 +14665,6 @@ const createMqttTransport = (endpoint) => {
|
|
|
14650
14665
|
});
|
|
14651
14666
|
return new Promise(resolve => mqttClient.once('connect', () => resolve()));
|
|
14652
14667
|
}
|
|
14653
|
-
const reconnect = () => {
|
|
14654
|
-
setTimeout(() => {
|
|
14655
|
-
retryCount = retryCount + 1;
|
|
14656
|
-
mqttClient.reconnect();
|
|
14657
|
-
}, RETRY_BASE_TIMEOUT * Math.pow(2, retryCount > RETRY_COUNT_MAX ? RETRY_COUNT_MAX : retryCount));
|
|
14658
|
-
};
|
|
14659
14668
|
return {
|
|
14660
14669
|
connect,
|
|
14661
14670
|
async disconnect() {
|
|
@@ -14689,8 +14698,8 @@ const createMqttTransport = (endpoint) => {
|
|
|
14689
14698
|
if (error || granted[0].qos === QOS_FAILURE_CODE) {
|
|
14690
14699
|
const ascError = error
|
|
14691
14700
|
? new ASCError(error.message, 800000 /* UNKNOWN_ERROR */, "error" /* ERROR */)
|
|
14692
|
-
// TODO throw the actual error, once BE can tell us the actual error code
|
|
14693
|
-
|
|
14701
|
+
: // TODO throw the actual error, once BE can tell us the actual error code
|
|
14702
|
+
new ASCUnknownError(800000 /* UNKNOWN_ERROR */, "error" /* ERROR */);
|
|
14694
14703
|
console.error(`Failed to subscribe to topic ${topic}`, ascError);
|
|
14695
14704
|
callback === null || callback === void 0 ? void 0 : callback(ascError);
|
|
14696
14705
|
}
|
|
@@ -14709,10 +14718,11 @@ const createMqttTransport = (endpoint) => {
|
|
|
14709
14718
|
},
|
|
14710
14719
|
unsubscribe(topic) {
|
|
14711
14720
|
mqttClient === null || mqttClient === void 0 ? void 0 : mqttClient.unsubscribe(topic);
|
|
14712
|
-
}
|
|
14721
|
+
},
|
|
14713
14722
|
};
|
|
14714
14723
|
};
|
|
14715
14724
|
|
|
14725
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
14716
14726
|
let tasks = [];
|
|
14717
14727
|
let timer;
|
|
14718
14728
|
/**
|
|
@@ -14729,6 +14739,7 @@ const scheduleTask = (task) => {
|
|
|
14729
14739
|
}, 0);
|
|
14730
14740
|
};
|
|
14731
14741
|
|
|
14742
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
14732
14743
|
// need to sync up the list
|
|
14733
14744
|
const WS_EVENTS = [
|
|
14734
14745
|
'disconnected',
|
|
@@ -14755,7 +14766,7 @@ const MQTT_EVENTS = [
|
|
|
14755
14766
|
'error',
|
|
14756
14767
|
'close',
|
|
14757
14768
|
'end',
|
|
14758
|
-
'reconnect'
|
|
14769
|
+
'reconnect',
|
|
14759
14770
|
];
|
|
14760
14771
|
/** @hidden */
|
|
14761
14772
|
const createEventEmitter = () => {
|
|
@@ -14819,7 +14830,9 @@ const createEventSubscriber = (client, namespace, event, fn) => {
|
|
|
14819
14830
|
*/
|
|
14820
14831
|
const fireEvent = (event, payload) => {
|
|
14821
14832
|
const { emitter } = getActiveClient();
|
|
14822
|
-
scheduleTask(() => {
|
|
14833
|
+
scheduleTask(() => {
|
|
14834
|
+
emitter.emit(event, payload);
|
|
14835
|
+
});
|
|
14823
14836
|
};
|
|
14824
14837
|
|
|
14825
14838
|
/**
|
|
@@ -14836,7 +14849,7 @@ const fireEvent = (event, payload) => {
|
|
|
14836
14849
|
* @returns A {@link Amity.Client} instance
|
|
14837
14850
|
*
|
|
14838
14851
|
* @category Client API
|
|
14839
|
-
|
|
14852
|
+
* */
|
|
14840
14853
|
const createClient = (apiKey, apiRegion = API_REGIONS.SG, debugSession = 'amity') => {
|
|
14841
14854
|
const log = createLogger(debugSession);
|
|
14842
14855
|
log('client/api/createClient', {
|
|
@@ -14964,8 +14977,8 @@ const getToken = async (params) => {
|
|
|
14964
14977
|
client.log('client/api/getToken', params);
|
|
14965
14978
|
const deviceInfo = await getDeviceInfo();
|
|
14966
14979
|
const { data } = await client.http.post('/v1/device', Object.assign(Object.assign({}, params), { deviceInfo }), {
|
|
14967
|
-
|
|
14968
|
-
headers: { 'X-API-Key': client.apiKey }
|
|
14980
|
+
// @ts-ignore
|
|
14981
|
+
headers: { 'X-API-Key': client.apiKey },
|
|
14969
14982
|
});
|
|
14970
14983
|
return data;
|
|
14971
14984
|
};
|
|
@@ -14994,12 +15007,12 @@ const EVENTS = [
|
|
|
14994
15007
|
*/
|
|
14995
15008
|
const onConnectionError = (callback) => {
|
|
14996
15009
|
const client = getActiveClient();
|
|
14997
|
-
const subscribers = EVENTS.map(event =>
|
|
15010
|
+
const subscribers = EVENTS.map(event => createEventSubscriber(client, `client/onConnectionError(${event})`, event, response => {
|
|
14998
15011
|
const error = (response === null || response === void 0 ? void 0 : response.code)
|
|
14999
15012
|
? new ASCError(response.message, response.code, "fatal" /* FATAL */)
|
|
15000
15013
|
: new ASCConnectionError(event);
|
|
15001
15014
|
callback(error);
|
|
15002
|
-
}))
|
|
15015
|
+
}));
|
|
15003
15016
|
return () => {
|
|
15004
15017
|
subscribers.forEach(fn => fn());
|
|
15005
15018
|
};
|
|
@@ -15047,6 +15060,7 @@ const onClientBanned = (callback) => {
|
|
|
15047
15060
|
});
|
|
15048
15061
|
};
|
|
15049
15062
|
|
|
15063
|
+
/* eslint-disable no-param-reassign */
|
|
15050
15064
|
/**
|
|
15051
15065
|
* ```js
|
|
15052
15066
|
* import { connectClient } from '@amityco/ts-sdk/client/api'
|
|
@@ -15077,7 +15091,7 @@ const connectClient = async (params) => {
|
|
|
15077
15091
|
// ignored since we enforce default values just before.
|
|
15078
15092
|
const { accessToken, users } = await getToken(params);
|
|
15079
15093
|
// manually setup the token for http transport
|
|
15080
|
-
client.http.defaults.headers.common
|
|
15094
|
+
client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
15081
15095
|
// manually setup the token for ws transport
|
|
15082
15096
|
client.ws.io.opts.query = { token: accessToken };
|
|
15083
15097
|
// FIXME: events are duplicated if connectClient is called few times without disconnectClient
|
|
@@ -15115,9 +15129,9 @@ const isConnected = () => {
|
|
|
15115
15129
|
var _a, _b;
|
|
15116
15130
|
const client = getActiveClient();
|
|
15117
15131
|
client.log('client/api/isConnected', client);
|
|
15118
|
-
return !!(client.userId
|
|
15119
|
-
|
|
15120
|
-
|
|
15132
|
+
return !!(client.userId &&
|
|
15133
|
+
((_b = (_a = client.http.defaults.headers.common) === null || _a === void 0 ? void 0 : _a.Authorization) === null || _b === void 0 ? void 0 : _b.length) &&
|
|
15134
|
+
client.ws.connected);
|
|
15121
15135
|
};
|
|
15122
15136
|
|
|
15123
15137
|
exports.SubscriptionLevels = void 0;
|
|
@@ -15128,7 +15142,7 @@ exports.SubscriptionLevels = void 0;
|
|
|
15128
15142
|
SubscriptionLevels["POST_AND_COMMENT"] = "post_and_comment";
|
|
15129
15143
|
SubscriptionLevels["USER"] = "user";
|
|
15130
15144
|
})(exports.SubscriptionLevels || (exports.SubscriptionLevels = {}));
|
|
15131
|
-
const getCommunityUserTopic = (
|
|
15145
|
+
const getCommunityUserTopic = (path, level) => {
|
|
15132
15146
|
switch (level) {
|
|
15133
15147
|
case 'post':
|
|
15134
15148
|
return `${path}/post/+`;
|
|
@@ -15140,8 +15154,10 @@ const getCommunityUserTopic = ({ path }, level) => {
|
|
|
15140
15154
|
return path;
|
|
15141
15155
|
}
|
|
15142
15156
|
};
|
|
15143
|
-
const getCommunityTopic = ({ path }, level = exports.SubscriptionLevels.COMMUNITY) => getCommunityUserTopic(
|
|
15144
|
-
const getUserTopic = ({ path }, level = exports.SubscriptionLevels.USER) => getCommunityUserTopic(
|
|
15157
|
+
const getCommunityTopic = ({ path }, level = exports.SubscriptionLevels.COMMUNITY) => getCommunityUserTopic(path, level);
|
|
15158
|
+
const getUserTopic = ({ path }, level = exports.SubscriptionLevels.USER) => getCommunityUserTopic(level === exports.SubscriptionLevels.USER
|
|
15159
|
+
? path
|
|
15160
|
+
: path.replace(/^(?<networkId>\w*)/, '$<networkId>/social'), level);
|
|
15145
15161
|
const getPostTopic = ({ path }, level = exports.SubscriptionLevels.POST) => {
|
|
15146
15162
|
switch (level) {
|
|
15147
15163
|
case 'comment':
|
|
@@ -15253,12 +15269,15 @@ const restoreCache = async (storageKey = 'amitySdk') => {
|
|
|
15253
15269
|
try {
|
|
15254
15270
|
cache = JSON.parse(serializedData);
|
|
15255
15271
|
}
|
|
15256
|
-
catch (err) {
|
|
15272
|
+
catch (err) {
|
|
15273
|
+
//
|
|
15274
|
+
}
|
|
15257
15275
|
// current cache should override. in case there's something fresher.
|
|
15258
15276
|
client.cache.data = Object.assign(Object.assign({}, cache), client.cache.data);
|
|
15259
15277
|
return true;
|
|
15260
15278
|
};
|
|
15261
15279
|
|
|
15280
|
+
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
15262
15281
|
/**
|
|
15263
15282
|
* ```js
|
|
15264
15283
|
* import { backupCache } from '@amityco/ts-sdk'
|
|
@@ -15288,8 +15307,7 @@ const backupCache = async (storageKey = 'amitySdk', persistIf = (entry) => entry
|
|
|
15288
15307
|
log('cache/api/backupCache', { storageKey });
|
|
15289
15308
|
// prepare a subset of the cache where only
|
|
15290
15309
|
// objects to backup are there
|
|
15291
|
-
const offlineEntries = Object.fromEntries(Object.entries(cache.data)
|
|
15292
|
-
.filter(([_, entry]) => persistIf(entry)));
|
|
15310
|
+
const offlineEntries = Object.fromEntries(Object.entries(cache.data).filter(([_, entry]) => persistIf(entry)));
|
|
15293
15311
|
// nothing to backup, abort
|
|
15294
15312
|
if (!Object.keys(offlineEntries).length)
|
|
15295
15313
|
return false;
|
|
@@ -15335,9 +15353,9 @@ const wipeCache = async (storageKey = 'amitySdk') => {
|
|
|
15335
15353
|
* @category Cache
|
|
15336
15354
|
* @hidden
|
|
15337
15355
|
*/
|
|
15338
|
-
const normalize = (source) =>
|
|
15356
|
+
const normalize = (source) => Object.keys(source)
|
|
15339
15357
|
.sort()
|
|
15340
|
-
.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: source[key] })), {})
|
|
15358
|
+
.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: source[key] })), {});
|
|
15341
15359
|
/**
|
|
15342
15360
|
* Encodes a given {@link Amity.CacheKey} to a plain string
|
|
15343
15361
|
*
|
|
@@ -15347,7 +15365,7 @@ const normalize = (source) => (Object.keys(source)
|
|
|
15347
15365
|
* @category Cache
|
|
15348
15366
|
* @hidden
|
|
15349
15367
|
*/
|
|
15350
|
-
const encodeKey = (key) =>
|
|
15368
|
+
const encodeKey = (key) => JSON.stringify(key, (_, val) => (typeof val === 'object' ? normalize(val) : val));
|
|
15351
15369
|
/**
|
|
15352
15370
|
* Decodes a string back into a {@link Amity.CacheKey}
|
|
15353
15371
|
|
|
@@ -15372,14 +15390,14 @@ const partialMatch = (predicate, candidate) => {
|
|
|
15372
15390
|
if (predicate === candidate)
|
|
15373
15391
|
return true;
|
|
15374
15392
|
// if one or the other is nullish, there can't be equality
|
|
15375
|
-
|
|
15393
|
+
if (!predicate || !candidate)
|
|
15376
15394
|
return false;
|
|
15377
15395
|
// we only perform recursive check on objects
|
|
15378
|
-
|
|
15396
|
+
if (typeof predicate !== 'object') {
|
|
15379
15397
|
return false;
|
|
15380
15398
|
}
|
|
15381
15399
|
// recursively call for partial match based on the predicate
|
|
15382
|
-
return Object.keys(predicate).every(
|
|
15400
|
+
return Object.keys(predicate).every(key => partialMatch(predicate[key], candidate[key]));
|
|
15383
15401
|
};
|
|
15384
15402
|
|
|
15385
15403
|
/**
|
|
@@ -15402,8 +15420,7 @@ const queryCache = (key) => {
|
|
|
15402
15420
|
if (!cache)
|
|
15403
15421
|
return;
|
|
15404
15422
|
log('cache/api/queryCache', { key });
|
|
15405
|
-
return Object
|
|
15406
|
-
.keys(cache.data)
|
|
15423
|
+
return Object.keys(cache.data)
|
|
15407
15424
|
.filter(stringKey => {
|
|
15408
15425
|
const decodedKey = decodeKey(stringKey);
|
|
15409
15426
|
return partialMatch(key, decodedKey);
|
|
@@ -15432,9 +15449,7 @@ const pullFromCache = (key) => {
|
|
|
15432
15449
|
return;
|
|
15433
15450
|
log('cache/api/pullFromCache', key);
|
|
15434
15451
|
const str = encodeKey(key);
|
|
15435
|
-
return
|
|
15436
|
-
? cache.data[str]
|
|
15437
|
-
: undefined;
|
|
15452
|
+
return cache.data[str] ? cache.data[str] : undefined;
|
|
15438
15453
|
};
|
|
15439
15454
|
|
|
15440
15455
|
/**
|
|
@@ -15460,8 +15475,10 @@ const pushToCache = (key, data, options = { cachedAt: Date.now() }) => {
|
|
|
15460
15475
|
// if consumer did not pass offline but a offline policy is
|
|
15461
15476
|
// defined, use the fn to determine if the object needs to
|
|
15462
15477
|
// be saved in persistent storage or not.
|
|
15463
|
-
if (!(options === null || options === void 0 ? void 0 : options.hasOwnProperty('offline')) && cache.persistIf)
|
|
15478
|
+
if (!(options === null || options === void 0 ? void 0 : options.hasOwnProperty('offline')) && cache.persistIf) {
|
|
15479
|
+
// eslint-disable-next-line no-param-reassign
|
|
15464
15480
|
options.offline = cache.persistIf(key, data);
|
|
15481
|
+
}
|
|
15465
15482
|
const encodedKey = encodeKey(key);
|
|
15466
15483
|
cache.data[encodedKey] = Object.assign({ key, data }, options);
|
|
15467
15484
|
return true;
|
|
@@ -15493,9 +15510,7 @@ const mergeInCache = (key, mutation, options) => {
|
|
|
15493
15510
|
const oldVal = pullFromCache(key);
|
|
15494
15511
|
if (!oldVal)
|
|
15495
15512
|
return false;
|
|
15496
|
-
const newVal = typeof mutation === 'function'
|
|
15497
|
-
? mutation(oldVal.data)
|
|
15498
|
-
: Object.assign(Object.assign({}, oldVal.data), mutation);
|
|
15513
|
+
const newVal = typeof mutation === 'function' ? mutation(oldVal.data) : Object.assign(Object.assign({}, oldVal.data), mutation);
|
|
15499
15514
|
pushToCache(key, newVal, options);
|
|
15500
15515
|
return true;
|
|
15501
15516
|
};
|
|
@@ -15523,9 +15538,7 @@ const upsertInCache = (key, data, options = { cachedAt: Date.now() }) => {
|
|
|
15523
15538
|
return false;
|
|
15524
15539
|
log('cache/api/upsertInCache', { key, data, options });
|
|
15525
15540
|
const cached = pullFromCache(key);
|
|
15526
|
-
return cached
|
|
15527
|
-
? mergeInCache(key, data, options)
|
|
15528
|
-
: pushToCache(key, data, options);
|
|
15541
|
+
return cached ? mergeInCache(key, data, options) : pushToCache(key, data, options);
|
|
15529
15542
|
};
|
|
15530
15543
|
|
|
15531
15544
|
/**
|
|
@@ -15549,7 +15562,7 @@ const dropFromCache = (key, exact = false) => {
|
|
|
15549
15562
|
return false;
|
|
15550
15563
|
log('cache/api/dropFromCache', { key, exact });
|
|
15551
15564
|
if (!exact) {
|
|
15552
|
-
return
|
|
15565
|
+
return Object.keys(cache.data)
|
|
15553
15566
|
.map(stringKey => decodeKey(stringKey))
|
|
15554
15567
|
.filter(candidate => partialMatch(key, candidate))
|
|
15555
15568
|
.map(filteredKey => dropFromCache(filteredKey, true))
|
|
@@ -15572,6 +15585,7 @@ const idResolvers = {
|
|
|
15572
15585
|
channelUsers: ({ channelId, userId }) => `${channelId}#${userId}`,
|
|
15573
15586
|
message: ({ messageId }) => messageId,
|
|
15574
15587
|
community: ({ communityId }) => communityId,
|
|
15588
|
+
category: ({ categoryId }) => categoryId,
|
|
15575
15589
|
communityUsers: ({ communityId, userId }) => `${communityId}#${userId}`,
|
|
15576
15590
|
post: ({ postId }) => postId,
|
|
15577
15591
|
comment: ({ commentId }) => commentId,
|
|
@@ -15585,7 +15599,7 @@ const idResolvers = {
|
|
|
15585
15599
|
* @param name the domain name for the resolve
|
|
15586
15600
|
* @returns an idResolver function for the given domain name
|
|
15587
15601
|
*/
|
|
15588
|
-
const getResolver = (name) =>
|
|
15602
|
+
const getResolver = (name) => idResolvers[name];
|
|
15589
15603
|
|
|
15590
15604
|
/**
|
|
15591
15605
|
* A map of v3 response keys to a store name.
|
|
@@ -15599,13 +15613,14 @@ const PAYLOAD2MODEL = {
|
|
|
15599
15613
|
channelUsers: 'channelUsers',
|
|
15600
15614
|
messages: 'message',
|
|
15601
15615
|
communities: 'community',
|
|
15616
|
+
categories: 'category',
|
|
15602
15617
|
communityUsers: 'communityUsers',
|
|
15603
15618
|
posts: 'post',
|
|
15604
15619
|
postChildren: 'post',
|
|
15605
15620
|
comments: 'comment',
|
|
15606
15621
|
videoStreamings: 'stream',
|
|
15607
15622
|
follows: 'follow',
|
|
15608
|
-
followCounts: 'followCount'
|
|
15623
|
+
followCounts: 'followCount',
|
|
15609
15624
|
};
|
|
15610
15625
|
|
|
15611
15626
|
/**
|
|
@@ -15618,8 +15633,7 @@ const PAYLOAD2MODEL = {
|
|
|
15618
15633
|
* @hidden
|
|
15619
15634
|
*/
|
|
15620
15635
|
const ingestInCache = (payload = {}, options) => {
|
|
15621
|
-
Object.entries(payload)
|
|
15622
|
-
.forEach(([key, models]) => {
|
|
15636
|
+
Object.entries(payload).forEach(([key, models]) => {
|
|
15623
15637
|
const type = PAYLOAD2MODEL[key];
|
|
15624
15638
|
if (!type)
|
|
15625
15639
|
return;
|
|
@@ -15699,13 +15713,15 @@ const getUsers = async (userIds) => {
|
|
|
15699
15713
|
client.log('user/getUsers', userIds);
|
|
15700
15714
|
const encodedUserIds = userIds.map(userId => encodeURIComponent(userId));
|
|
15701
15715
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
15702
|
-
const { data } = await client.http.get(`/api/v3/users/list`, {
|
|
15716
|
+
const { data } = await client.http.get(`/api/v3/users/list`, {
|
|
15717
|
+
params: { userIds: encodedUserIds },
|
|
15718
|
+
});
|
|
15703
15719
|
const cachedAt = client.cache && Date.now();
|
|
15704
15720
|
if (client.cache)
|
|
15705
15721
|
ingestInCache(data, { cachedAt });
|
|
15706
15722
|
return {
|
|
15707
15723
|
data: data.users,
|
|
15708
|
-
cachedAt
|
|
15724
|
+
cachedAt,
|
|
15709
15725
|
};
|
|
15710
15726
|
};
|
|
15711
15727
|
/**
|
|
@@ -15731,7 +15747,7 @@ getUsers.locally = (userIds) => {
|
|
|
15731
15747
|
.map(userId => pullFromCache(['user', 'get', userId]))
|
|
15732
15748
|
.filter(Boolean);
|
|
15733
15749
|
const users = cached.map(({ data }) => data);
|
|
15734
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
15750
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
15735
15751
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < userIds.length)
|
|
15736
15752
|
return;
|
|
15737
15753
|
return {
|
|
@@ -15785,14 +15801,14 @@ function __rest(s, e) {
|
|
|
15785
15801
|
const queryUsers = async (query = {}) => {
|
|
15786
15802
|
const client = getActiveClient();
|
|
15787
15803
|
client.log('user/queryUsers', query);
|
|
15788
|
-
const { page, displayName, filter = 'all', sortBy = 'displayName' } = query, params = __rest(query
|
|
15789
|
-
// API-FIX: parameters should be querystring.
|
|
15790
|
-
, ["page", "displayName", "filter", "sortBy"]);
|
|
15804
|
+
const { page, displayName, filter = 'all', sortBy = 'displayName' } = query, params = __rest(query, ["page", "displayName", "filter", "sortBy"]);
|
|
15791
15805
|
// API-FIX: parameters should be querystring.
|
|
15792
|
-
const { data } = await client.http.get(`/api/v3/users`, {
|
|
15806
|
+
const { data } = await client.http.get(`/api/v3/users`, {
|
|
15807
|
+
params: Object.assign(Object.assign({}, params), { keyword: displayName, filter,
|
|
15793
15808
|
sortBy, options: {
|
|
15794
15809
|
token: toToken(page, 'skiplimit'),
|
|
15795
|
-
} })
|
|
15810
|
+
} }),
|
|
15811
|
+
});
|
|
15796
15812
|
// unpacking
|
|
15797
15813
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
15798
15814
|
const { users } = payload;
|
|
@@ -15998,7 +16014,7 @@ const observeUser = (userId, callback) => {
|
|
|
15998
16014
|
*
|
|
15999
16015
|
* Fetches a {@link Amity.File} object
|
|
16000
16016
|
*
|
|
16001
|
-
* @param
|
|
16017
|
+
* @param fileId the ID of the {@link Amity.File} to fetch
|
|
16002
16018
|
* @returns the associated {@link Amity.File} object
|
|
16003
16019
|
*
|
|
16004
16020
|
* @category File API
|
|
@@ -16054,6 +16070,7 @@ getFile.locally = (fileId) => {
|
|
|
16054
16070
|
* Creates an {@link Amity.File}
|
|
16055
16071
|
*
|
|
16056
16072
|
* @param formData The data necessary to create a new {@link Amity.File}
|
|
16073
|
+
* @param onProgress The callback to track the upload progress
|
|
16057
16074
|
* @returns The newly created {@link Amity.File}
|
|
16058
16075
|
*
|
|
16059
16076
|
* @category File API
|
|
@@ -16068,9 +16085,10 @@ const createFile = async (formData, onProgress) => {
|
|
|
16068
16085
|
? formData.getHeaders()
|
|
16069
16086
|
: { 'content-type': 'multipart/form-data' };
|
|
16070
16087
|
const { data } = await client.http.post('/api/v3/files', formData, {
|
|
16071
|
-
headers,
|
|
16088
|
+
headers,
|
|
16089
|
+
onUploadProgress({ loaded, total }) {
|
|
16072
16090
|
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
16073
|
-
}
|
|
16091
|
+
},
|
|
16074
16092
|
});
|
|
16075
16093
|
// API-FIX: payload should be serialized properly
|
|
16076
16094
|
// const { files } = data
|
|
@@ -16118,6 +16136,47 @@ const fileUrlWithSize = (fileUrl, size) => {
|
|
|
16118
16136
|
return `${fileUrl}?size=${size}`;
|
|
16119
16137
|
};
|
|
16120
16138
|
|
|
16139
|
+
/**
|
|
16140
|
+
* ```js
|
|
16141
|
+
* import { createVideo } from '@amityco/ts-sdk'
|
|
16142
|
+
* const created = await createVideo(formData)
|
|
16143
|
+
* ```
|
|
16144
|
+
*
|
|
16145
|
+
* Creates an {@link Amity.File<'video'>}
|
|
16146
|
+
*
|
|
16147
|
+
* @param formData The data necessary to create a new {@link Amity.File<'video'>}
|
|
16148
|
+
* @param onProgress The callback to track the upload progress
|
|
16149
|
+
* @returns The newly created {@link Amity.File<'video'>}
|
|
16150
|
+
*
|
|
16151
|
+
* @category File API
|
|
16152
|
+
* @async
|
|
16153
|
+
*/
|
|
16154
|
+
const createVideo = async (formData, onProgress) => {
|
|
16155
|
+
const client = getActiveClient();
|
|
16156
|
+
client.log('file/createVideo', formData);
|
|
16157
|
+
if (!formData.getAll('files').length)
|
|
16158
|
+
throw new Error('The formData object must have a `files` key.');
|
|
16159
|
+
const headers = 'getHeaders' in formData
|
|
16160
|
+
? formData.getHeaders()
|
|
16161
|
+
: { 'content-type': 'multipart/form-data' };
|
|
16162
|
+
const { data } = await client.http.post('/api/v4/videos', formData, {
|
|
16163
|
+
headers,
|
|
16164
|
+
onUploadProgress({ loaded, total }) {
|
|
16165
|
+
onProgress && onProgress(Math.round((loaded * 100) / total));
|
|
16166
|
+
},
|
|
16167
|
+
});
|
|
16168
|
+
// API-FIX: payload should be serialized properly
|
|
16169
|
+
// const { files } = data
|
|
16170
|
+
const cachedAt = client.cache && Date.now();
|
|
16171
|
+
if (client.cache)
|
|
16172
|
+
ingestInCache({ files: data }, { cachedAt });
|
|
16173
|
+
return {
|
|
16174
|
+
data,
|
|
16175
|
+
cachedAt,
|
|
16176
|
+
};
|
|
16177
|
+
};
|
|
16178
|
+
// TODO: consider doing local creation with URL.createObjectURL()
|
|
16179
|
+
|
|
16121
16180
|
/**
|
|
16122
16181
|
* ```js
|
|
16123
16182
|
* import { observeFile } from '@amityco/ts-sdk'
|
|
@@ -16349,13 +16408,15 @@ const getMessages = async (messageIds) => {
|
|
|
16349
16408
|
const client = getActiveClient();
|
|
16350
16409
|
client.log('message/getMessages', messageIds);
|
|
16351
16410
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
16352
|
-
const { data } = await client.http.get(`/api/v3/messages/list`, {
|
|
16411
|
+
const { data } = await client.http.get(`/api/v3/messages/list`, {
|
|
16412
|
+
params: { messageIds },
|
|
16413
|
+
});
|
|
16353
16414
|
const cachedAt = client.cache && Date.now();
|
|
16354
16415
|
if (client.cache)
|
|
16355
16416
|
ingestInCache(data, { cachedAt });
|
|
16356
16417
|
return {
|
|
16357
16418
|
data: data.messages,
|
|
16358
|
-
cachedAt
|
|
16419
|
+
cachedAt,
|
|
16359
16420
|
};
|
|
16360
16421
|
};
|
|
16361
16422
|
/**
|
|
@@ -16381,7 +16442,7 @@ getMessages.locally = (messageIds) => {
|
|
|
16381
16442
|
.map(messageId => pullFromCache(['message', 'get', messageId]))
|
|
16382
16443
|
.filter(Boolean);
|
|
16383
16444
|
const messages = cached.map(({ data }) => data);
|
|
16384
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
16445
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
16385
16446
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < messageIds.length)
|
|
16386
16447
|
return;
|
|
16387
16448
|
return {
|
|
@@ -16407,19 +16468,16 @@ getMessages.locally = (messageIds) => {
|
|
|
16407
16468
|
const queryMessages = async (query) => {
|
|
16408
16469
|
const client = getActiveClient();
|
|
16409
16470
|
client.log('message/queryMessages', query);
|
|
16410
|
-
const { page = { limit: 10 } } = query, params = __rest(query
|
|
16411
|
-
// API-FIX: parameters should be querystring. (1)
|
|
16412
|
-
// API-FIX: backend should answer Amity.Response (2)
|
|
16413
|
-
// API-FIX: pagination should not be indexed on channelSegment (3)
|
|
16414
|
-
// const { data } = await client.http.get<Amity.Response<Amity.Paged<Amity.MessagePayload>>>(
|
|
16415
|
-
, ["page"]);
|
|
16471
|
+
const { page = { limit: 10 } } = query, params = __rest(query, ["page"]);
|
|
16416
16472
|
// API-FIX: parameters should be querystring. (1)
|
|
16417
16473
|
// API-FIX: backend should answer Amity.Response (2)
|
|
16418
16474
|
// API-FIX: pagination should not be indexed on channelSegment (3)
|
|
16419
16475
|
// const { data } = await client.http.get<Amity.Response<Amity.Paged<Amity.MessagePayload>>>(
|
|
16420
|
-
const { data } = await client.http.get(`/api/v3/messages`, {
|
|
16476
|
+
const { data } = await client.http.get(`/api/v3/messages`, {
|
|
16477
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
16421
16478
|
token: toToken(page, 'afterbefore'),
|
|
16422
|
-
} }),
|
|
16479
|
+
} }),
|
|
16480
|
+
});
|
|
16423
16481
|
// API-FIX: backend should answer Amity.Response (2)
|
|
16424
16482
|
// const { paging, messages } = unwrapPayload(data)
|
|
16425
16483
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
@@ -16427,7 +16485,11 @@ const queryMessages = async (query) => {
|
|
|
16427
16485
|
const cachedAt = client.cache && Date.now();
|
|
16428
16486
|
if (client.cache) {
|
|
16429
16487
|
ingestInCache(payload, { cachedAt });
|
|
16430
|
-
const cacheKey = [
|
|
16488
|
+
const cacheKey = [
|
|
16489
|
+
'message',
|
|
16490
|
+
'query',
|
|
16491
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
16492
|
+
];
|
|
16431
16493
|
pushToCache(cacheKey, { messages: messages.map(getResolver('message')), paging });
|
|
16432
16494
|
}
|
|
16433
16495
|
const nextPage = toPage(paging.next);
|
|
@@ -16529,7 +16591,7 @@ createMessage.optimistically = (bundle) => {
|
|
|
16529
16591
|
fireEvent('v3.message.didCreate', { messages: [message] });
|
|
16530
16592
|
return {
|
|
16531
16593
|
data: message,
|
|
16532
|
-
cachedAt: -1
|
|
16594
|
+
cachedAt: -1,
|
|
16533
16595
|
};
|
|
16534
16596
|
};
|
|
16535
16597
|
|
|
@@ -16593,7 +16655,7 @@ updateMessage.optimistically = (messageId, patch) => {
|
|
|
16593
16655
|
fireEvent('v3.message.didUpdate', { messages: [updated] });
|
|
16594
16656
|
return {
|
|
16595
16657
|
data: updated,
|
|
16596
|
-
cachedAt
|
|
16658
|
+
cachedAt,
|
|
16597
16659
|
};
|
|
16598
16660
|
};
|
|
16599
16661
|
|
|
@@ -16645,7 +16707,7 @@ deleteMessage.optimistically = (messageId) => {
|
|
|
16645
16707
|
fireEvent('v3.message.didDelete', { messages: [deleted] });
|
|
16646
16708
|
return {
|
|
16647
16709
|
data: deleted,
|
|
16648
|
-
cachedAt
|
|
16710
|
+
cachedAt,
|
|
16649
16711
|
};
|
|
16650
16712
|
};
|
|
16651
16713
|
|
|
@@ -16666,17 +16728,15 @@ deleteMessage.optimistically = (messageId) => {
|
|
|
16666
16728
|
const queryPosts = async (query) => {
|
|
16667
16729
|
const client = getActiveClient();
|
|
16668
16730
|
client.log('post/queryPosts', query);
|
|
16669
|
-
const { page = { limit: 10 } } = query, params = __rest(query
|
|
16670
|
-
// API-FIX: parameters should be querystring. (1)
|
|
16671
|
-
// API-FIX: backend should answer Amity.Response (2)
|
|
16672
|
-
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
|
|
16673
|
-
, ["page"]);
|
|
16731
|
+
const { page = { limit: 10 } } = query, params = __rest(query, ["page"]);
|
|
16674
16732
|
// API-FIX: parameters should be querystring. (1)
|
|
16675
16733
|
// API-FIX: backend should answer Amity.Response (2)
|
|
16676
16734
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
|
|
16677
|
-
const { data } = await client.http.get(`/api/v4/posts`, {
|
|
16735
|
+
const { data } = await client.http.get(`/api/v4/posts`, {
|
|
16736
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
16678
16737
|
token: toToken(page, 'afterbeforeraw'),
|
|
16679
|
-
} }),
|
|
16738
|
+
} }),
|
|
16739
|
+
});
|
|
16680
16740
|
// API-FIX: backend should answer Amity.Response (2)
|
|
16681
16741
|
// const { paging, posts } = unwrapPayload(data)
|
|
16682
16742
|
// unpacking
|
|
@@ -16746,13 +16806,15 @@ const getPosts = async (postIds) => {
|
|
|
16746
16806
|
client.log('post/getPosts', postIds);
|
|
16747
16807
|
const encodedPostIds = postIds.map(postId => encodeURIComponent(postId));
|
|
16748
16808
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
16749
|
-
const { data } = await client.http.get(`/api/v3/posts/list`, {
|
|
16809
|
+
const { data } = await client.http.get(`/api/v3/posts/list`, {
|
|
16810
|
+
params: { postIds: encodedPostIds },
|
|
16811
|
+
});
|
|
16750
16812
|
const cachedAt = client.cache && Date.now();
|
|
16751
16813
|
if (client.cache)
|
|
16752
16814
|
ingestInCache(data, { cachedAt });
|
|
16753
16815
|
return {
|
|
16754
16816
|
data: data.posts,
|
|
16755
|
-
cachedAt
|
|
16817
|
+
cachedAt,
|
|
16756
16818
|
};
|
|
16757
16819
|
};
|
|
16758
16820
|
/**
|
|
@@ -16778,7 +16840,7 @@ getPosts.locally = (postIds) => {
|
|
|
16778
16840
|
.map(postId => pullFromCache(['post', 'get', postId]))
|
|
16779
16841
|
.filter(Boolean);
|
|
16780
16842
|
const posts = cached.map(({ data }) => data);
|
|
16781
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
16843
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
16782
16844
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < postIds.length)
|
|
16783
16845
|
return;
|
|
16784
16846
|
return {
|
|
@@ -16829,7 +16891,7 @@ const getPost = async (postId) => {
|
|
|
16829
16891
|
/**
|
|
16830
16892
|
* ```js
|
|
16831
16893
|
* import { getPost } from '@amityco/ts-sdk'
|
|
16832
|
-
* const { data
|
|
16894
|
+
* const { data: post } = getPost.locally('foobar')
|
|
16833
16895
|
* ```
|
|
16834
16896
|
*
|
|
16835
16897
|
* Fetches a {@link Amity.Post} object from cache
|
|
@@ -16875,8 +16937,10 @@ const createPost = async (bundle) => {
|
|
|
16875
16937
|
const client = getActiveClient();
|
|
16876
16938
|
client.log('post/createPost', bundle);
|
|
16877
16939
|
// API-FIX: backend rejects that we pass the dataType manually T_T
|
|
16878
|
-
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType))
|
|
16940
|
+
if (!bundle.dataType || ['text', 'image', 'file', 'video'].includes(bundle.dataType)) {
|
|
16941
|
+
// eslint-disable-next-line no-param-reassign
|
|
16879
16942
|
delete bundle.dataType;
|
|
16943
|
+
}
|
|
16880
16944
|
const { data } = await client.http.post('/api/v4/posts', bundle);
|
|
16881
16945
|
const cachedAt = client.cache && Date.now();
|
|
16882
16946
|
if (client.cache)
|
|
@@ -16944,15 +17008,21 @@ const queryCommunities = async (query) => {
|
|
|
16944
17008
|
// API-FIX: parameters should be querystring.
|
|
16945
17009
|
// API-FIX: backend doesnt answer Amity.Response
|
|
16946
17010
|
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
|
|
16947
|
-
const { data } = await client.http.get(`/api/v3/communities`, {
|
|
16948
|
-
|
|
16949
|
-
|
|
17011
|
+
const { data } = await client.http.get(`/api/v3/communities`, {
|
|
17012
|
+
params: Object.assign(Object.assign({}, params), { keyword: displayName, filter: membership, options: {
|
|
17013
|
+
token: toToken(page, 'skiplimit'),
|
|
17014
|
+
} }),
|
|
17015
|
+
});
|
|
16950
17016
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
16951
17017
|
const { communities } = payload;
|
|
16952
17018
|
const cachedAt = client.cache && Date.now();
|
|
16953
17019
|
if (client.cache) {
|
|
16954
17020
|
ingestInCache(payload, { cachedAt });
|
|
16955
|
-
const cacheKey = [
|
|
17021
|
+
const cacheKey = [
|
|
17022
|
+
'community',
|
|
17023
|
+
'query',
|
|
17024
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
17025
|
+
];
|
|
16956
17026
|
pushToCache(cacheKey, { communities: communities.map(getResolver('community')), paging });
|
|
16957
17027
|
}
|
|
16958
17028
|
const nextPage = toPage(paging.next);
|
|
@@ -16996,13 +17066,15 @@ const getCommunities = async (communityIds) => {
|
|
|
16996
17066
|
const client = getActiveClient();
|
|
16997
17067
|
client.log('community/getCommunities', communityIds);
|
|
16998
17068
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
16999
|
-
const { data } = await client.http.get(`/api/v3/communities/list`, {
|
|
17069
|
+
const { data } = await client.http.get(`/api/v3/communities/list`, {
|
|
17070
|
+
params: { communityIds },
|
|
17071
|
+
});
|
|
17000
17072
|
const cachedAt = client.cache && Date.now();
|
|
17001
17073
|
if (client.cache)
|
|
17002
17074
|
ingestInCache(data, { cachedAt });
|
|
17003
17075
|
return {
|
|
17004
17076
|
data: data.communities,
|
|
17005
|
-
cachedAt
|
|
17077
|
+
cachedAt,
|
|
17006
17078
|
};
|
|
17007
17079
|
};
|
|
17008
17080
|
/**
|
|
@@ -17028,7 +17100,7 @@ getCommunities.locally = (communityIds) => {
|
|
|
17028
17100
|
.map(communityId => pullFromCache(['community', 'get', communityId]))
|
|
17029
17101
|
.filter(Boolean);
|
|
17030
17102
|
const communities = cached.map(({ data }) => data);
|
|
17031
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
17103
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
17032
17104
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < communityIds.length)
|
|
17033
17105
|
return;
|
|
17034
17106
|
return {
|
|
@@ -17198,8 +17270,7 @@ const joinCommunity = async (communityId) => {
|
|
|
17198
17270
|
ingestInCache(data, { cachedAt });
|
|
17199
17271
|
fireEvent('community.joined', data);
|
|
17200
17272
|
const { communityUsers } = data;
|
|
17201
|
-
return !!communityUsers.find(communityUser =>
|
|
17202
|
-
&& communityUser.communityMembership === 'member'));
|
|
17273
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
17203
17274
|
};
|
|
17204
17275
|
|
|
17205
17276
|
/**
|
|
@@ -17225,8 +17296,7 @@ const leaveCommunity = async (communityId) => {
|
|
|
17225
17296
|
ingestInCache(data, { cachedAt });
|
|
17226
17297
|
fireEvent('community.left', data);
|
|
17227
17298
|
const { communityUsers } = data;
|
|
17228
|
-
return !!communityUsers.find(communityUser =>
|
|
17229
|
-
&& communityUser.communityMembership !== 'member'));
|
|
17299
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
17230
17300
|
};
|
|
17231
17301
|
|
|
17232
17302
|
/**
|
|
@@ -17242,7 +17312,7 @@ const leaveCommunity = async (communityId) => {
|
|
|
17242
17312
|
*
|
|
17243
17313
|
* @category Community API
|
|
17244
17314
|
* @async
|
|
17245
|
-
|
|
17315
|
+
* */
|
|
17246
17316
|
const queryCommunityMembers = async (query) => {
|
|
17247
17317
|
const client = getActiveClient();
|
|
17248
17318
|
client.log('community/queryCommunityMembers', query);
|
|
@@ -17304,8 +17374,7 @@ const addCommunityMembers = async (communityId, userIds) => {
|
|
|
17304
17374
|
ingestInCache(data);
|
|
17305
17375
|
fireEvent('community.userAdded', data);
|
|
17306
17376
|
const { communityUsers } = data;
|
|
17307
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17308
|
-
communityUser.communityMembership === 'member');
|
|
17377
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership === 'member');
|
|
17309
17378
|
};
|
|
17310
17379
|
|
|
17311
17380
|
/**
|
|
@@ -17331,60 +17400,61 @@ const removeCommunityMembers = async (communityId, userIds) => {
|
|
|
17331
17400
|
ingestInCache(data);
|
|
17332
17401
|
fireEvent('community.userRemoved', data);
|
|
17333
17402
|
const { communityUsers } = data;
|
|
17334
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17335
|
-
communityUser.communityMembership !== 'member');
|
|
17403
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId && communityUser.communityMembership !== 'member');
|
|
17336
17404
|
};
|
|
17337
17405
|
|
|
17338
17406
|
/**
|
|
17339
17407
|
* ```js
|
|
17340
|
-
* import {
|
|
17341
|
-
* const updated = await
|
|
17408
|
+
* import { addCommunityMembersRoles } from '@amityco/ts-sdk'
|
|
17409
|
+
* const updated = await addCommunityMembersRoles(communityId, ['foo'], ['bar'])
|
|
17342
17410
|
* ```
|
|
17343
17411
|
*
|
|
17344
|
-
* Adds
|
|
17412
|
+
* Adds a list of {@link Amity.Role} to a list of {@link Amity.User} on a {@link Amity.Community}
|
|
17345
17413
|
*
|
|
17346
17414
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
17347
|
-
* @param
|
|
17415
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
17348
17416
|
* @param userId Array of IDs of the {@link Amity.User} to perform
|
|
17349
17417
|
* @returns A success boolean if the {@link Amity.Role} were added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
17350
17418
|
*
|
|
17351
17419
|
* @category Community API
|
|
17352
17420
|
* @async
|
|
17353
17421
|
*/
|
|
17354
|
-
const
|
|
17422
|
+
const addCommunityMembersRoles = async (communityId, roleIds, userIds) => {
|
|
17355
17423
|
const client = getActiveClient();
|
|
17356
|
-
client.log('community/
|
|
17357
|
-
const { data } = await client.http.post(`/api/
|
|
17424
|
+
client.log('community/addCommunityMembersRoles', communityId, roleIds, userIds);
|
|
17425
|
+
const { data } = await client.http.post(`/api/v4/communities/${communityId}/users/roles`, { communityId, roles: roleIds, userIds });
|
|
17358
17426
|
if (client.cache)
|
|
17359
17427
|
ingestInCache(data);
|
|
17360
17428
|
const { communityUsers } = data;
|
|
17361
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17429
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17430
|
+
roleIds.some(role => communityUser.roles.includes(role)));
|
|
17362
17431
|
};
|
|
17363
17432
|
|
|
17364
17433
|
/**
|
|
17365
17434
|
* ```js
|
|
17366
|
-
* import {
|
|
17367
|
-
* const updated = await
|
|
17435
|
+
* import { removeCommunityMembersRoles } from '@amityco/ts-sdk'
|
|
17436
|
+
* const updated = await removeCommunityMembersRoles(communityId, ['foo'], ['bar'])
|
|
17368
17437
|
* ```
|
|
17369
17438
|
*
|
|
17370
|
-
* Removes
|
|
17439
|
+
* Removes a list of {@link Amity.Role} from a list of {@link Amity.User} on a {@link Amity.Community}
|
|
17371
17440
|
*
|
|
17372
17441
|
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
17373
|
-
* @param
|
|
17442
|
+
* @param roleIds Array of IDs of the {@link Amity.Role} to apply
|
|
17374
17443
|
* @param userId Array of IDs of the {@link Amity.User} to perform
|
|
17375
17444
|
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
17376
17445
|
*
|
|
17377
17446
|
* @category Community API
|
|
17378
17447
|
* @async
|
|
17379
17448
|
*/
|
|
17380
|
-
const
|
|
17449
|
+
const removeCommunityMembersRoles = async (communityId, roleIds, userIds) => {
|
|
17381
17450
|
const client = getActiveClient();
|
|
17382
|
-
client.log('community/
|
|
17383
|
-
const { data } = await client.http.delete(`/api/
|
|
17451
|
+
client.log('community/removeCommunityMembersRoles', communityId, roleIds, userIds);
|
|
17452
|
+
const { data } = await client.http.delete(`/api/v4/communities/${communityId}/users/roles`, { data: { communityId, roles: roleIds, userIds } });
|
|
17384
17453
|
if (client.cache)
|
|
17385
17454
|
ingestInCache(data);
|
|
17386
17455
|
const { communityUsers } = data;
|
|
17387
|
-
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17456
|
+
return !!communityUsers.find(communityUser => communityUser.communityId === communityId &&
|
|
17457
|
+
!roleIds.some(role => communityUser.roles.includes(role)));
|
|
17388
17458
|
};
|
|
17389
17459
|
|
|
17390
17460
|
/**
|
|
@@ -17530,7 +17600,7 @@ getRecommendedCommunities.locally = (query) => {
|
|
|
17530
17600
|
const deletePost = async (postId, permanent = false) => {
|
|
17531
17601
|
const client = getActiveClient();
|
|
17532
17602
|
client.log('post/deletePost', postId);
|
|
17533
|
-
|
|
17603
|
+
const post = await getPost(postId);
|
|
17534
17604
|
// API-FIX: This endpoint has not been implemented yet.
|
|
17535
17605
|
await client.http.delete(`/api/v4/posts/${encodeURIComponent(postId)}`, {
|
|
17536
17606
|
params: {
|
|
@@ -17577,12 +17647,7 @@ const deletePost = async (postId, permanent = false) => {
|
|
|
17577
17647
|
const queryComments = async (query) => {
|
|
17578
17648
|
const client = getActiveClient();
|
|
17579
17649
|
client.log('comment/queryComments', query);
|
|
17580
|
-
const { page = { limit: 10 } } = query, params = __rest(query
|
|
17581
|
-
// const filterByParentId = query.parentId !== undefined
|
|
17582
|
-
// API-FIX: parameters should be querystring. (1)
|
|
17583
|
-
// API-FIX: backend should answer Amity.Response (2)
|
|
17584
|
-
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.CommentPayload>>>(
|
|
17585
|
-
, ["page"]);
|
|
17650
|
+
const { page = { limit: 10 } } = query, params = __rest(query, ["page"]);
|
|
17586
17651
|
// const filterByParentId = query.parentId !== undefined
|
|
17587
17652
|
// API-FIX: parameters should be querystring. (1)
|
|
17588
17653
|
// API-FIX: backend should answer Amity.Response (2)
|
|
@@ -17601,7 +17666,11 @@ const queryComments = async (query) => {
|
|
|
17601
17666
|
const cachedAt = client.cache && Date.now();
|
|
17602
17667
|
if (client.cache) {
|
|
17603
17668
|
ingestInCache(payload, { cachedAt });
|
|
17604
|
-
const cacheKey = [
|
|
17669
|
+
const cacheKey = [
|
|
17670
|
+
'comment',
|
|
17671
|
+
'query',
|
|
17672
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
17673
|
+
];
|
|
17605
17674
|
pushToCache(cacheKey, { comments: comments.map(getResolver('comment')), paging });
|
|
17606
17675
|
}
|
|
17607
17676
|
const nextPage = toPage(paging.next);
|
|
@@ -17662,13 +17731,15 @@ const getComments = async (commentIds) => {
|
|
|
17662
17731
|
client.log('comment/getComments', commentIds);
|
|
17663
17732
|
const encodedCommentIds = commentIds.map(commentId => encodeURIComponent(commentId));
|
|
17664
17733
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
17665
|
-
const { data } = await client.http.get(`/api/v3/comments/list`, {
|
|
17734
|
+
const { data } = await client.http.get(`/api/v3/comments/list`, {
|
|
17735
|
+
params: { commentIds: encodedCommentIds },
|
|
17736
|
+
});
|
|
17666
17737
|
const cachedAt = client.cache && Date.now();
|
|
17667
17738
|
if (client.cache)
|
|
17668
17739
|
ingestInCache(data, { cachedAt });
|
|
17669
17740
|
return {
|
|
17670
17741
|
data: data.comments,
|
|
17671
|
-
cachedAt
|
|
17742
|
+
cachedAt,
|
|
17672
17743
|
};
|
|
17673
17744
|
};
|
|
17674
17745
|
/**
|
|
@@ -17694,7 +17765,7 @@ getComments.locally = (commentIds) => {
|
|
|
17694
17765
|
.map(commentId => pullFromCache(['comment', 'get', commentId]))
|
|
17695
17766
|
.filter(Boolean);
|
|
17696
17767
|
const comments = cached.map(({ data }) => data);
|
|
17697
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
17768
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
17698
17769
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < commentIds.length)
|
|
17699
17770
|
return;
|
|
17700
17771
|
return {
|
|
@@ -17877,9 +17948,9 @@ const deleteComment = async (commentId, permanent = false) => {
|
|
|
17877
17948
|
const fetchReference = async (referenceType, referenceId) => {
|
|
17878
17949
|
if (referenceType === 'message')
|
|
17879
17950
|
return getMessage(referenceId);
|
|
17880
|
-
|
|
17951
|
+
if (referenceType === 'post')
|
|
17881
17952
|
return getPost(referenceId);
|
|
17882
|
-
|
|
17953
|
+
if (referenceType === 'comment')
|
|
17883
17954
|
return getComment(referenceId);
|
|
17884
17955
|
throw new Error(`Incorrect referenceType: ${referenceType}`);
|
|
17885
17956
|
};
|
|
@@ -17916,7 +17987,9 @@ const preparePayloadForCache = (event, payload) => {
|
|
|
17916
17987
|
if (!cached.myReactions.includes(payload.reactor.reactionName)) {
|
|
17917
17988
|
return;
|
|
17918
17989
|
}
|
|
17919
|
-
Object.assign(model, {
|
|
17990
|
+
Object.assign(model, {
|
|
17991
|
+
myReactions: cached.myReactions.filter(x => x !== payload.reactor.reactionName),
|
|
17992
|
+
});
|
|
17920
17993
|
}
|
|
17921
17994
|
};
|
|
17922
17995
|
|
|
@@ -17935,7 +18008,7 @@ const preparePayloadForCache = (event, payload) => {
|
|
|
17935
18008
|
*
|
|
17936
18009
|
* @category Reaction API
|
|
17937
18010
|
* @async
|
|
17938
|
-
|
|
18011
|
+
* */
|
|
17939
18012
|
const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
17940
18013
|
var _a, _b;
|
|
17941
18014
|
const client = getActiveClient();
|
|
@@ -17944,7 +18017,11 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
17944
18017
|
referenceType,
|
|
17945
18018
|
reactionName,
|
|
17946
18019
|
});
|
|
17947
|
-
await client.http.post('/api/v2/reactions', {
|
|
18020
|
+
await client.http.post('/api/v2/reactions', {
|
|
18021
|
+
referenceId,
|
|
18022
|
+
referenceType,
|
|
18023
|
+
reactionName,
|
|
18024
|
+
});
|
|
17948
18025
|
const model = await fetchReference(referenceType, referenceId);
|
|
17949
18026
|
dispatchReactable(referenceType, model.data);
|
|
17950
18027
|
return (_b = (_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)) !== null && _b !== void 0 ? _b : false;
|
|
@@ -17963,7 +18040,7 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
17963
18040
|
* @returns The added result.
|
|
17964
18041
|
*
|
|
17965
18042
|
* @category Reaction API
|
|
17966
|
-
|
|
18043
|
+
* */
|
|
17967
18044
|
addReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
17968
18045
|
var _a, _b, _c, _d, _e;
|
|
17969
18046
|
const client = getActiveClient();
|
|
@@ -17974,7 +18051,11 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
17974
18051
|
});
|
|
17975
18052
|
if (!client.cache)
|
|
17976
18053
|
return;
|
|
17977
|
-
const model = pullFromCache([
|
|
18054
|
+
const model = pullFromCache([
|
|
18055
|
+
referenceType,
|
|
18056
|
+
'get',
|
|
18057
|
+
referenceId,
|
|
18058
|
+
]);
|
|
17978
18059
|
if (!(model === null || model === void 0 ? void 0 : model.data) || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
17979
18060
|
return;
|
|
17980
18061
|
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 }) });
|
|
@@ -17998,7 +18079,7 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
17998
18079
|
*
|
|
17999
18080
|
* @category Reaction API
|
|
18000
18081
|
* @async
|
|
18001
|
-
|
|
18082
|
+
* */
|
|
18002
18083
|
const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
18003
18084
|
var _a, _b;
|
|
18004
18085
|
const client = getActiveClient();
|
|
@@ -18007,7 +18088,9 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
18007
18088
|
referenceType,
|
|
18008
18089
|
reactionName,
|
|
18009
18090
|
});
|
|
18010
|
-
await client.http.delete(`/api/v2/reactions`, {
|
|
18091
|
+
await client.http.delete(`/api/v2/reactions`, {
|
|
18092
|
+
data: { referenceId, referenceType, reactionName },
|
|
18093
|
+
});
|
|
18011
18094
|
const model = await fetchReference(referenceType, referenceId);
|
|
18012
18095
|
dispatchReactable(referenceType, model.data);
|
|
18013
18096
|
return (_b = !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName))) !== null && _b !== void 0 ? _b : false;
|
|
@@ -18026,7 +18109,7 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
|
|
|
18026
18109
|
* @returns The added result.
|
|
18027
18110
|
*
|
|
18028
18111
|
* @category Reaction API
|
|
18029
|
-
|
|
18112
|
+
* */
|
|
18030
18113
|
removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
18031
18114
|
var _a, _b, _c, _d, _e;
|
|
18032
18115
|
const client = getActiveClient();
|
|
@@ -18037,7 +18120,11 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
|
|
|
18037
18120
|
});
|
|
18038
18121
|
if (!client.cache)
|
|
18039
18122
|
return;
|
|
18040
|
-
const model = pullFromCache([
|
|
18123
|
+
const model = pullFromCache([
|
|
18124
|
+
referenceType,
|
|
18125
|
+
'get',
|
|
18126
|
+
referenceId,
|
|
18127
|
+
]);
|
|
18041
18128
|
if (!(model === null || model === void 0 ? void 0 : model.data) || !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
|
|
18042
18129
|
return;
|
|
18043
18130
|
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) }) });
|
|
@@ -18216,6 +18303,7 @@ const onPostReactionAdded = (callback) => {
|
|
|
18216
18303
|
}
|
|
18217
18304
|
else {
|
|
18218
18305
|
preparePayloadForCache('post.addReaction', payload);
|
|
18306
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18219
18307
|
const postPayload = __rest(payload, ["reactor"]);
|
|
18220
18308
|
ingestInCache(postPayload);
|
|
18221
18309
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
@@ -18248,6 +18336,7 @@ const onPostReactionRemoved = (callback) => {
|
|
|
18248
18336
|
}
|
|
18249
18337
|
else {
|
|
18250
18338
|
preparePayloadForCache('post.removeReaction', payload);
|
|
18339
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18251
18340
|
const postPayload = __rest(payload, ["reactor"]);
|
|
18252
18341
|
ingestInCache(postPayload);
|
|
18253
18342
|
const post = pullFromCache(['post', 'get', payload.posts[0].postId]);
|
|
@@ -18267,7 +18356,11 @@ const createCommentEventSubscriber = (event, callback) => {
|
|
|
18267
18356
|
}
|
|
18268
18357
|
else {
|
|
18269
18358
|
ingestInCache(payload);
|
|
18270
|
-
const comment = pullFromCache([
|
|
18359
|
+
const comment = pullFromCache([
|
|
18360
|
+
'comment',
|
|
18361
|
+
'get',
|
|
18362
|
+
payload.comments[0].commentId,
|
|
18363
|
+
]);
|
|
18271
18364
|
if (['comment.created'].includes(event)) {
|
|
18272
18365
|
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; });
|
|
18273
18366
|
queries === null || queries === void 0 ? void 0 : queries.map(({ key, data }) => upsertInCache(key, data, { cachedAt: -1 }));
|
|
@@ -18386,9 +18479,14 @@ const onCommentReactionAdded = (callback) => {
|
|
|
18386
18479
|
}
|
|
18387
18480
|
else {
|
|
18388
18481
|
preparePayloadForCache('comment.addReaction', payload);
|
|
18482
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18389
18483
|
const commentPayload = __rest(payload, ["reactor"]);
|
|
18390
18484
|
ingestInCache(commentPayload);
|
|
18391
|
-
const comment = pullFromCache([
|
|
18485
|
+
const comment = pullFromCache([
|
|
18486
|
+
'comment',
|
|
18487
|
+
'get',
|
|
18488
|
+
payload.comments[0].commentId,
|
|
18489
|
+
]);
|
|
18392
18490
|
callback(comment.data);
|
|
18393
18491
|
}
|
|
18394
18492
|
};
|
|
@@ -18418,9 +18516,14 @@ const onCommentReactionRemoved = (callback) => {
|
|
|
18418
18516
|
}
|
|
18419
18517
|
else {
|
|
18420
18518
|
preparePayloadForCache('comment.removeReaction', payload);
|
|
18519
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18421
18520
|
const commentPayload = __rest(payload, ["reactor"]);
|
|
18422
18521
|
ingestInCache(commentPayload);
|
|
18423
|
-
const comment = pullFromCache([
|
|
18522
|
+
const comment = pullFromCache([
|
|
18523
|
+
'comment',
|
|
18524
|
+
'get',
|
|
18525
|
+
payload.comments[0].commentId,
|
|
18526
|
+
]);
|
|
18424
18527
|
callback(comment.data);
|
|
18425
18528
|
}
|
|
18426
18529
|
};
|
|
@@ -18443,7 +18546,7 @@ const onCommentReactionRemoved = (callback) => {
|
|
|
18443
18546
|
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
18444
18547
|
*
|
|
18445
18548
|
* @category Message Events
|
|
18446
|
-
|
|
18549
|
+
* */
|
|
18447
18550
|
const onReactionRemoved = (referenceType, referenceId, callback) => {
|
|
18448
18551
|
const callbackWrapper = (model) => {
|
|
18449
18552
|
if (getResolver(referenceType)(model) === referenceId) {
|
|
@@ -18454,7 +18557,11 @@ const onReactionRemoved = (referenceType, referenceId, callback) => {
|
|
|
18454
18557
|
const client = getActiveClient();
|
|
18455
18558
|
const filter = (payload) => {
|
|
18456
18559
|
var _a;
|
|
18457
|
-
const cached = pullFromCache([
|
|
18560
|
+
const cached = pullFromCache([
|
|
18561
|
+
'message',
|
|
18562
|
+
'get',
|
|
18563
|
+
payload.messages[0].messageId,
|
|
18564
|
+
]);
|
|
18458
18565
|
const isReactionEvent = ((_a = cached === null || cached === void 0 ? void 0 : cached.data) === null || _a === void 0 ? void 0 : _a.reactionsCount) !== payload.messages[0].reactionsCount;
|
|
18459
18566
|
ingestInCache(payload);
|
|
18460
18567
|
if (isReactionEvent) {
|
|
@@ -18504,12 +18611,12 @@ var REFERENCE_TYPES = {
|
|
|
18504
18611
|
*
|
|
18505
18612
|
* @category Report API
|
|
18506
18613
|
* @async
|
|
18507
|
-
|
|
18614
|
+
* */
|
|
18508
18615
|
const createReport = async (referenceType, referenceId) => {
|
|
18509
18616
|
const client = getActiveClient();
|
|
18510
18617
|
client.log('report/createReport', { referenceType, referenceId });
|
|
18511
18618
|
const { domainName } = REFERENCE_TYPES[referenceType];
|
|
18512
|
-
const { data } = await client.http.post(`/api/v3/${domainName}/${
|
|
18619
|
+
const { data } = await client.http.post(`/api/v3/${domainName}/${encodeURIComponent(referenceId)}/flag`);
|
|
18513
18620
|
if (client.cache)
|
|
18514
18621
|
ingestInCache(data);
|
|
18515
18622
|
const event = referenceType === 'message'
|
|
@@ -18531,7 +18638,7 @@ const createReport = async (referenceType, referenceId) => {
|
|
|
18531
18638
|
*
|
|
18532
18639
|
* @category Report API
|
|
18533
18640
|
* @async
|
|
18534
|
-
|
|
18641
|
+
* */
|
|
18535
18642
|
const deleteReport = async (referenceType, referenceId) => {
|
|
18536
18643
|
const client = getActiveClient();
|
|
18537
18644
|
client.log('report/deleteReport', { referenceType, referenceId });
|
|
@@ -18558,7 +18665,7 @@ const deleteReport = async (referenceType, referenceId) => {
|
|
|
18558
18665
|
*
|
|
18559
18666
|
* @category Report API
|
|
18560
18667
|
* @async
|
|
18561
|
-
|
|
18668
|
+
* */
|
|
18562
18669
|
const isReportedByMe = async (referenceType, referenceId) => {
|
|
18563
18670
|
var _a, _b;
|
|
18564
18671
|
const client = getActiveClient();
|
|
@@ -18593,15 +18700,21 @@ const queryChannels = async (query) => {
|
|
|
18593
18700
|
// API-FIX: parameters should be querystring.
|
|
18594
18701
|
// API-FIX: backend doesnt answer Amity.Response
|
|
18595
18702
|
// const { data } = await client.http.get<Amity.Response<Amity.Paged<ChannelPayload>>>(
|
|
18596
|
-
const { data } = await client.http.get(`/api/v3/channels`, {
|
|
18703
|
+
const { data } = await client.http.get(`/api/v3/channels`, {
|
|
18704
|
+
params: Object.assign(Object.assign({}, params), { keyword: displayName, filter: membership, options: {
|
|
18597
18705
|
token: toToken(page, 'skiplimit'),
|
|
18598
|
-
} })
|
|
18706
|
+
} }),
|
|
18707
|
+
});
|
|
18599
18708
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
18600
18709
|
const { channels } = payload;
|
|
18601
18710
|
const cachedAt = client.cache && Date.now();
|
|
18602
18711
|
if (client.cache) {
|
|
18603
18712
|
ingestInCache(payload, { cachedAt });
|
|
18604
|
-
const cacheKey = [
|
|
18713
|
+
const cacheKey = [
|
|
18714
|
+
'channel',
|
|
18715
|
+
'query',
|
|
18716
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
18717
|
+
];
|
|
18605
18718
|
pushToCache(cacheKey, { channels: channels.map(getResolver('channel')), paging });
|
|
18606
18719
|
}
|
|
18607
18720
|
const nextPage = toPage(paging.next);
|
|
@@ -18646,13 +18759,15 @@ const getChannels = async (channelIds) => {
|
|
|
18646
18759
|
client.log('channel/getChannels', channelIds);
|
|
18647
18760
|
const encodedChannelIds = channelIds.map(channelId => encodeURIComponent(channelId));
|
|
18648
18761
|
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
18649
|
-
const { data } = await client.http.get(`/api/v3/channels/list`, {
|
|
18762
|
+
const { data } = await client.http.get(`/api/v3/channels/list`, {
|
|
18763
|
+
params: { channelIds: encodedChannelIds },
|
|
18764
|
+
});
|
|
18650
18765
|
const cachedAt = client.cache && Date.now();
|
|
18651
18766
|
if (client.cache)
|
|
18652
18767
|
ingestInCache(data, { cachedAt });
|
|
18653
18768
|
return {
|
|
18654
18769
|
data: data.channels,
|
|
18655
|
-
cachedAt
|
|
18770
|
+
cachedAt,
|
|
18656
18771
|
};
|
|
18657
18772
|
};
|
|
18658
18773
|
/**
|
|
@@ -18678,7 +18793,7 @@ getChannels.locally = (channelIds) => {
|
|
|
18678
18793
|
.map(channelId => pullFromCache(['channel', 'get', channelId]))
|
|
18679
18794
|
.filter(Boolean);
|
|
18680
18795
|
const channels = cached.map(({ data }) => data);
|
|
18681
|
-
const oldest = (_a = cached.sort((a, b) => a.cachedAt < b.cachedAt ? -1 : 1)) === null || _a === void 0 ? void 0 : _a[0];
|
|
18796
|
+
const oldest = (_a = cached.sort((a, b) => (a.cachedAt < b.cachedAt ? -1 : 1))) === null || _a === void 0 ? void 0 : _a[0];
|
|
18682
18797
|
if ((cached === null || cached === void 0 ? void 0 : cached.length) < channelIds.length)
|
|
18683
18798
|
return;
|
|
18684
18799
|
return {
|
|
@@ -18850,8 +18965,7 @@ const joinChannel = async (channelId) => {
|
|
|
18850
18965
|
if (client.cache)
|
|
18851
18966
|
ingestInCache(data);
|
|
18852
18967
|
const { channelUsers } = data;
|
|
18853
|
-
return !!channelUsers.find(channelUser =>
|
|
18854
|
-
&& channelUser.membership === 'member'));
|
|
18968
|
+
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership === 'member');
|
|
18855
18969
|
};
|
|
18856
18970
|
|
|
18857
18971
|
/**
|
|
@@ -18875,8 +18989,7 @@ const leaveChannel = async (channelId) => {
|
|
|
18875
18989
|
if (client.cache)
|
|
18876
18990
|
ingestInCache(data);
|
|
18877
18991
|
const { channelUsers } = data;
|
|
18878
|
-
return !!channelUsers.find(channelUser =>
|
|
18879
|
-
&& channelUser.membership !== 'member'));
|
|
18992
|
+
return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership !== 'member');
|
|
18880
18993
|
};
|
|
18881
18994
|
|
|
18882
18995
|
/**
|
|
@@ -18892,7 +19005,7 @@ const leaveChannel = async (channelId) => {
|
|
|
18892
19005
|
*
|
|
18893
19006
|
* @category Channel API
|
|
18894
19007
|
* @async
|
|
18895
|
-
|
|
19008
|
+
* */
|
|
18896
19009
|
const queryChannelMembers = async (query) => {
|
|
18897
19010
|
const client = getActiveClient();
|
|
18898
19011
|
client.log('channel/queryChannelMembers', query);
|
|
@@ -19388,7 +19501,11 @@ const createCommunityEventSubscriber = (event, callback) => {
|
|
|
19388
19501
|
}
|
|
19389
19502
|
else {
|
|
19390
19503
|
ingestInCache(payload);
|
|
19391
|
-
const community = pullFromCache([
|
|
19504
|
+
const community = pullFromCache([
|
|
19505
|
+
'community',
|
|
19506
|
+
'get',
|
|
19507
|
+
payload.communities[0].communityId,
|
|
19508
|
+
]);
|
|
19392
19509
|
callback(community.data);
|
|
19393
19510
|
}
|
|
19394
19511
|
};
|
|
@@ -19398,8 +19515,8 @@ function hasPermission(member, payload, permission) {
|
|
|
19398
19515
|
if (member.permissions.some(x => x === permission)) {
|
|
19399
19516
|
return true;
|
|
19400
19517
|
}
|
|
19401
|
-
return payload
|
|
19402
|
-
.find(user => user.userId === member.userId)
|
|
19518
|
+
return payload
|
|
19519
|
+
.users.find(user => user.userId === member.userId)
|
|
19403
19520
|
.permissions.some(x => x === permission);
|
|
19404
19521
|
}
|
|
19405
19522
|
function getEventRelatedMember(event, payload) {
|
|
@@ -19429,11 +19546,15 @@ const createCommunityMemberEventSubscriber = (event, callback) => {
|
|
|
19429
19546
|
}
|
|
19430
19547
|
else {
|
|
19431
19548
|
ingestInCache(payload);
|
|
19432
|
-
const community = pullFromCache([
|
|
19549
|
+
const community = pullFromCache([
|
|
19550
|
+
'community',
|
|
19551
|
+
'get',
|
|
19552
|
+
payload.communities[0].communityId,
|
|
19553
|
+
]);
|
|
19433
19554
|
const member = pullFromCache([
|
|
19434
19555
|
'communityUsers',
|
|
19435
19556
|
'get',
|
|
19436
|
-
getResolver('communityUsers')(getEventRelatedMember(event, payload))
|
|
19557
|
+
getResolver('communityUsers')(getEventRelatedMember(event, payload)),
|
|
19437
19558
|
]);
|
|
19438
19559
|
callback(community.data, member.data);
|
|
19439
19560
|
}
|
|
@@ -19638,6 +19759,134 @@ const observeCommunity = (communityId, callback) => {
|
|
|
19638
19759
|
};
|
|
19639
19760
|
};
|
|
19640
19761
|
|
|
19762
|
+
/**
|
|
19763
|
+
* ```js
|
|
19764
|
+
* import { queryCategories } from '@amityco/ts-sdk'
|
|
19765
|
+
* const { data: categories, prevPage, nextPage } = await queryCategories()
|
|
19766
|
+
* ```
|
|
19767
|
+
*
|
|
19768
|
+
* Queries a paginable list of {@link Amity.Category} objects
|
|
19769
|
+
*
|
|
19770
|
+
* @param query The query parameters
|
|
19771
|
+
* @returns A page of {@link Amity.Category} objects
|
|
19772
|
+
*
|
|
19773
|
+
* @category Category API
|
|
19774
|
+
* @async
|
|
19775
|
+
* */
|
|
19776
|
+
const queryCategories = async (query) => {
|
|
19777
|
+
const client = getActiveClient();
|
|
19778
|
+
client.log('category/queryCategories', query);
|
|
19779
|
+
const _a = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 } } = _a, params = __rest(_a, ["page"]);
|
|
19780
|
+
const { data } = await client.http.get(`/api/v3/community-categories`, {
|
|
19781
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
19782
|
+
token: toToken(page, 'skiplimit'),
|
|
19783
|
+
} }),
|
|
19784
|
+
});
|
|
19785
|
+
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
19786
|
+
const { categories } = payload;
|
|
19787
|
+
const cachedAt = client.cache && Date.now();
|
|
19788
|
+
if (client.cache) {
|
|
19789
|
+
ingestInCache(payload, { cachedAt });
|
|
19790
|
+
const cacheKey = [
|
|
19791
|
+
'category',
|
|
19792
|
+
'query',
|
|
19793
|
+
Object.assign(Object.assign({}, params), { options: Object.assign({}, page) }),
|
|
19794
|
+
];
|
|
19795
|
+
pushToCache(cacheKey, { categories: categories.map(getResolver('category')), paging });
|
|
19796
|
+
}
|
|
19797
|
+
const nextPage = toPage(paging.next);
|
|
19798
|
+
const prevPage = toPage(paging.previous);
|
|
19799
|
+
return { data: categories, cachedAt, prevPage, nextPage };
|
|
19800
|
+
};
|
|
19801
|
+
/**
|
|
19802
|
+
* ```js
|
|
19803
|
+
* import { queryCategories } from '@amityco/ts-sdk'
|
|
19804
|
+
* const { data: categories, prevPage, nextPage } = queryCategories.locally()
|
|
19805
|
+
* ```
|
|
19806
|
+
*
|
|
19807
|
+
* Queries a paginable list of {@link Amity.Category} objects from cache
|
|
19808
|
+
*
|
|
19809
|
+
* @param query The query parameters
|
|
19810
|
+
* @returns categories
|
|
19811
|
+
*
|
|
19812
|
+
* @category category API
|
|
19813
|
+
*/
|
|
19814
|
+
queryCategories.locally = (query) => {
|
|
19815
|
+
var _a, _b;
|
|
19816
|
+
const client = getActiveClient();
|
|
19817
|
+
client.log('category/queryCategories.locally', query);
|
|
19818
|
+
if (!client.cache)
|
|
19819
|
+
return;
|
|
19820
|
+
const _c = query !== null && query !== void 0 ? query : {}, { page = { limit: 10 } } = _c, params = __rest(_c, ["page"]);
|
|
19821
|
+
const queryKey = ['category', 'query', Object.assign(Object.assign({}, params), { options: Object.assign({}, page) })];
|
|
19822
|
+
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
19823
|
+
if (!(data === null || data === void 0 ? void 0 : data.categories.length))
|
|
19824
|
+
return;
|
|
19825
|
+
const categories = data.categories
|
|
19826
|
+
.map(categoryId => pullFromCache(['category', 'get', categoryId]))
|
|
19827
|
+
.filter(Boolean)
|
|
19828
|
+
.map(({ data }) => data);
|
|
19829
|
+
const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
|
|
19830
|
+
const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
|
|
19831
|
+
return categories.length === ((_b = data === null || data === void 0 ? void 0 : data.categories) === null || _b === void 0 ? void 0 : _b.length)
|
|
19832
|
+
? { data: categories, cachedAt, prevPage, nextPage }
|
|
19833
|
+
: undefined;
|
|
19834
|
+
};
|
|
19835
|
+
|
|
19836
|
+
/**
|
|
19837
|
+
* ```js
|
|
19838
|
+
* import { getCategory } from '@amityco/ts-sdk'
|
|
19839
|
+
* const { data: category } = await getCategory('foo')
|
|
19840
|
+
* ```
|
|
19841
|
+
*
|
|
19842
|
+
* Fetches a {@link Amity.Category} object
|
|
19843
|
+
*
|
|
19844
|
+
* @param categoryId the ID of the {@link Amity.Category} to fetch
|
|
19845
|
+
* @returns the associated {@link Amity.Category} object
|
|
19846
|
+
*
|
|
19847
|
+
* @category Category API
|
|
19848
|
+
* @async
|
|
19849
|
+
*/
|
|
19850
|
+
const getCategory = async (categoryId) => {
|
|
19851
|
+
const client = getActiveClient();
|
|
19852
|
+
client.log('category/getCategory', categoryId);
|
|
19853
|
+
const { data } = await client.http.get(`/api/v3/community-categories/${encodeURIComponent(categoryId)}`);
|
|
19854
|
+
const cachedAt = client.cache && Date.now();
|
|
19855
|
+
if (client.cache)
|
|
19856
|
+
ingestInCache(data, { cachedAt });
|
|
19857
|
+
const { categories } = data;
|
|
19858
|
+
return {
|
|
19859
|
+
data: categories.find(category => category.categoryId === categoryId),
|
|
19860
|
+
cachedAt,
|
|
19861
|
+
};
|
|
19862
|
+
};
|
|
19863
|
+
/**
|
|
19864
|
+
* ```js
|
|
19865
|
+
* import { getCategory } from '@amityco/ts-sdk'
|
|
19866
|
+
* const { data: category } = getCategory.locally('foobar')
|
|
19867
|
+
* ```
|
|
19868
|
+
*
|
|
19869
|
+
* Fetches a {@link Amity.Category} object from cache
|
|
19870
|
+
*
|
|
19871
|
+
* @param categoryId the ID of the {@link Amity.Category} to fetch
|
|
19872
|
+
* @returns the associated {@link Amity.Category} object
|
|
19873
|
+
*
|
|
19874
|
+
* @category Category API
|
|
19875
|
+
*/
|
|
19876
|
+
getCategory.locally = (categoryId) => {
|
|
19877
|
+
const client = getActiveClient();
|
|
19878
|
+
client.log('category/getCategory.locally', categoryId);
|
|
19879
|
+
if (!client.cache)
|
|
19880
|
+
return;
|
|
19881
|
+
const cached = pullFromCache(['category', 'get', categoryId]);
|
|
19882
|
+
if (!cached)
|
|
19883
|
+
return;
|
|
19884
|
+
return {
|
|
19885
|
+
data: cached.data,
|
|
19886
|
+
cachedAt: cached.cachedAt,
|
|
19887
|
+
};
|
|
19888
|
+
};
|
|
19889
|
+
|
|
19641
19890
|
/**
|
|
19642
19891
|
* ```js
|
|
19643
19892
|
* import { queryGlobalFeed } from '@amityco/ts-sdk'
|
|
@@ -19651,20 +19900,26 @@ const observeCommunity = (communityId, callback) => {
|
|
|
19651
19900
|
*
|
|
19652
19901
|
* @category Feed API
|
|
19653
19902
|
* @async
|
|
19654
|
-
|
|
19903
|
+
* */
|
|
19655
19904
|
const queryGlobalFeed = async (query) => {
|
|
19656
19905
|
const client = getActiveClient();
|
|
19657
19906
|
client.log('feed/queryGlobalFeed', query);
|
|
19658
19907
|
const _a = query !== null && query !== void 0 ? query : {}, { useCustomRanking, page } = _a, params = __rest(_a, ["useCustomRanking", "page"]);
|
|
19659
|
-
const { data } = await client.http.get(useCustomRanking ? `/api/v5/me/global-feeds` : `/api/v4/me/global-feeds`, {
|
|
19660
|
-
|
|
19661
|
-
|
|
19908
|
+
const { data } = await client.http.get(useCustomRanking ? `/api/v5/me/global-feeds` : `/api/v4/me/global-feeds`, {
|
|
19909
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
19910
|
+
token: toToken(page, 'skiplimit'),
|
|
19911
|
+
} }),
|
|
19912
|
+
});
|
|
19662
19913
|
const { paging } = data, payload = __rest(data, ["paging"]);
|
|
19663
19914
|
const { posts } = payload;
|
|
19664
19915
|
const cachedAt = client.cache && Date.now();
|
|
19665
19916
|
if (client.cache) {
|
|
19666
19917
|
ingestInCache(payload);
|
|
19667
|
-
const cacheKey = [
|
|
19918
|
+
const cacheKey = [
|
|
19919
|
+
'globalFeed',
|
|
19920
|
+
'query',
|
|
19921
|
+
Object.assign(Object.assign({}, params), { useCustomRanking, options: Object.assign({}, page) }),
|
|
19922
|
+
];
|
|
19668
19923
|
pushToCache(cacheKey, { posts: posts.map(getResolver('post')), paging });
|
|
19669
19924
|
}
|
|
19670
19925
|
const nextPage = toPage(paging.next);
|
|
@@ -19684,7 +19939,7 @@ const queryGlobalFeed = async (query) => {
|
|
|
19684
19939
|
*
|
|
19685
19940
|
* @category Feed API
|
|
19686
19941
|
* @async
|
|
19687
|
-
|
|
19942
|
+
* */
|
|
19688
19943
|
queryGlobalFeed.locally = (query) => {
|
|
19689
19944
|
var _a, _b;
|
|
19690
19945
|
const client = getActiveClient();
|
|
@@ -19692,7 +19947,11 @@ queryGlobalFeed.locally = (query) => {
|
|
|
19692
19947
|
if (!client.cache)
|
|
19693
19948
|
return;
|
|
19694
19949
|
const _c = query !== null && query !== void 0 ? query : {}, { useCustomRanking, page } = _c, params = __rest(_c, ["useCustomRanking", "page"]);
|
|
19695
|
-
const queryKey = [
|
|
19950
|
+
const queryKey = [
|
|
19951
|
+
'globalFeed',
|
|
19952
|
+
'query',
|
|
19953
|
+
Object.assign(Object.assign({}, params), { useCustomRanking, options: Object.assign({}, page) }),
|
|
19954
|
+
];
|
|
19696
19955
|
const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
|
|
19697
19956
|
if (!(data === null || data === void 0 ? void 0 : data.posts.length))
|
|
19698
19957
|
return;
|
|
@@ -19719,7 +19978,11 @@ const queryFollows = async (key, query) => {
|
|
|
19719
19978
|
const cachedAt = client.cache && Date.now();
|
|
19720
19979
|
if (client.cache) {
|
|
19721
19980
|
ingestInCache(payload, { cachedAt });
|
|
19722
|
-
const cacheKey = [
|
|
19981
|
+
const cacheKey = [
|
|
19982
|
+
key,
|
|
19983
|
+
'query',
|
|
19984
|
+
Object.assign(Object.assign({}, params), { userId, options: Object.assign({}, page) }),
|
|
19985
|
+
];
|
|
19723
19986
|
pushToCache(cacheKey, { follows: follows.map(getResolver('follow')), paging });
|
|
19724
19987
|
}
|
|
19725
19988
|
const nextPage = toPage(paging.next);
|
|
@@ -19809,7 +20072,11 @@ const queryFollowings = async (query) => queryFollows('following', query);
|
|
|
19809
20072
|
*/
|
|
19810
20073
|
queryFollowings.locally = (query) => queryFollows.locally('following', query);
|
|
19811
20074
|
|
|
19812
|
-
const getCacheKey = (userId) => [
|
|
20075
|
+
const getCacheKey = (userId) => [
|
|
20076
|
+
'followInfo',
|
|
20077
|
+
'get',
|
|
20078
|
+
`${getActiveClient().userId}#${userId}`,
|
|
20079
|
+
];
|
|
19813
20080
|
/**
|
|
19814
20081
|
* ```js
|
|
19815
20082
|
* import { getFollowInfo } from '@amityco/ts-sdk'
|
|
@@ -19982,8 +20249,8 @@ const createFollowEventSubscriber = (event, callback) => {
|
|
|
19982
20249
|
else {
|
|
19983
20250
|
ingestInCache({ follows: [payload] });
|
|
19984
20251
|
const queries = [
|
|
19985
|
-
...(_a = queryCache(['followers', 'query'])) !== null && _a !== void 0 ? _a : [],
|
|
19986
|
-
...(_b = queryCache(['followings', 'query'])) !== null && _b !== void 0 ? _b : [],
|
|
20252
|
+
...((_a = queryCache(['followers', 'query'])) !== null && _a !== void 0 ? _a : []),
|
|
20253
|
+
...((_b = queryCache(['followings', 'query'])) !== null && _b !== void 0 ? _b : []),
|
|
19987
20254
|
];
|
|
19988
20255
|
queries
|
|
19989
20256
|
// @ts-ignore
|
|
@@ -20131,7 +20398,10 @@ const onFollowRequestDeclined = (callback) => createFollowEventSubscriber('follo
|
|
|
20131
20398
|
*/
|
|
20132
20399
|
const onFollowInfoUpdated = (callback) => {
|
|
20133
20400
|
const handler = async (payload) => {
|
|
20134
|
-
const [{ data: followInfoFrom }, { data: followInfoTo }
|
|
20401
|
+
const [{ data: followInfoFrom }, { data: followInfoTo }] = await Promise.all([
|
|
20402
|
+
getFollowInfo(payload.from),
|
|
20403
|
+
getFollowInfo(payload.to),
|
|
20404
|
+
]);
|
|
20135
20405
|
callback(followInfoFrom);
|
|
20136
20406
|
callback(followInfoTo);
|
|
20137
20407
|
};
|
|
@@ -20297,8 +20567,7 @@ const observePosts = (params, callback) => {
|
|
|
20297
20567
|
const disposers = [];
|
|
20298
20568
|
const router = (post, action) => {
|
|
20299
20569
|
var _a, _b;
|
|
20300
|
-
if (params.targetId !== post.targetId
|
|
20301
|
-
|| params.targetType !== post.targetType)
|
|
20570
|
+
if (params.targetId !== post.targetId || params.targetType !== post.targetType)
|
|
20302
20571
|
return;
|
|
20303
20572
|
if (callback instanceof Function)
|
|
20304
20573
|
return callback(post);
|
|
@@ -20509,9 +20778,11 @@ const queryStreams = async (query) => {
|
|
|
20509
20778
|
const client = getActiveClient();
|
|
20510
20779
|
client.log('stream/queryStreams', query);
|
|
20511
20780
|
const _a = query !== null && query !== void 0 ? query : {}, { page } = _a, params = __rest(_a, ["page"]);
|
|
20512
|
-
const { data } = await client.http.get(`/api/v3/video-streaming`, {
|
|
20781
|
+
const { data } = await client.http.get(`/api/v3/video-streaming`, {
|
|
20782
|
+
params: Object.assign(Object.assign({}, params), { options: {
|
|
20513
20783
|
token: toToken(page, 'skiplimit'),
|
|
20514
|
-
} })
|
|
20784
|
+
} }),
|
|
20785
|
+
});
|
|
20515
20786
|
// API-FIX: backend to response Amity.Response: const { paging, videoStreamings } = unwrapPayload(data)
|
|
20516
20787
|
// API-FIX: seems returned data has a results identifier on top of data, like no other apis, and this is beautiful
|
|
20517
20788
|
const { paging, results: payload } = data;
|
|
@@ -20617,7 +20888,7 @@ const updateStream = async (streamId, patch) => {
|
|
|
20617
20888
|
const deleteStream = async (streamId) => {
|
|
20618
20889
|
const client = getActiveClient();
|
|
20619
20890
|
client.log('stream/deleteStream', streamId);
|
|
20620
|
-
|
|
20891
|
+
const stream = await getStream(streamId);
|
|
20621
20892
|
// API-FIX: it returns { success: boolean } but seems it should be Amity.Response<{ success: boolean }
|
|
20622
20893
|
// API-FIX: swagger docs are wrong!
|
|
20623
20894
|
const { data } = await client.http.delete(`/api/v3/video-streaming/${streamId}`);
|
|
@@ -20734,7 +21005,7 @@ exports.acceptFollower = acceptFollower;
|
|
|
20734
21005
|
exports.addChannelMembers = addChannelMembers;
|
|
20735
21006
|
exports.addChannelMembersRole = addChannelMembersRole;
|
|
20736
21007
|
exports.addCommunityMembers = addCommunityMembers;
|
|
20737
|
-
exports.
|
|
21008
|
+
exports.addCommunityMembersRoles = addCommunityMembersRoles;
|
|
20738
21009
|
exports.addReaction = addReaction;
|
|
20739
21010
|
exports.backupCache = backupCache;
|
|
20740
21011
|
exports.connectClient = connectClient;
|
|
@@ -20748,6 +21019,7 @@ exports.createPost = createPost;
|
|
|
20748
21019
|
exports.createQuery = createQuery;
|
|
20749
21020
|
exports.createReport = createReport;
|
|
20750
21021
|
exports.createStream = createStream;
|
|
21022
|
+
exports.createVideo = createVideo;
|
|
20751
21023
|
exports.declineFollower = declineFollower;
|
|
20752
21024
|
exports.deleteChannel = deleteChannel;
|
|
20753
21025
|
exports.deleteComment = deleteComment;
|
|
@@ -20766,6 +21038,7 @@ exports.fileUrlWithSize = fileUrlWithSize;
|
|
|
20766
21038
|
exports.filterByPropEquality = filterByPropEquality;
|
|
20767
21039
|
exports.follow = follow;
|
|
20768
21040
|
exports.getActiveClient = getActiveClient;
|
|
21041
|
+
exports.getCategory = getCategory;
|
|
20769
21042
|
exports.getChannel = getChannel;
|
|
20770
21043
|
exports.getChannels = getChannels;
|
|
20771
21044
|
exports.getComment = getComment;
|
|
@@ -20876,6 +21149,7 @@ exports.onUserUpdated = onUserUpdated;
|
|
|
20876
21149
|
exports.pullFromCache = pullFromCache;
|
|
20877
21150
|
exports.pushToCache = pushToCache;
|
|
20878
21151
|
exports.queryCache = queryCache;
|
|
21152
|
+
exports.queryCategories = queryCategories;
|
|
20879
21153
|
exports.queryChannelMembers = queryChannelMembers;
|
|
20880
21154
|
exports.queryChannels = queryChannels;
|
|
20881
21155
|
exports.queryComments = queryComments;
|
|
@@ -20893,7 +21167,7 @@ exports.queryUsers = queryUsers;
|
|
|
20893
21167
|
exports.removeChannelMembers = removeChannelMembers;
|
|
20894
21168
|
exports.removeChannelMembersRole = removeChannelMembersRole;
|
|
20895
21169
|
exports.removeCommunityMembers = removeCommunityMembers;
|
|
20896
|
-
exports.
|
|
21170
|
+
exports.removeCommunityMembersRoles = removeCommunityMembersRoles;
|
|
20897
21171
|
exports.removeReaction = removeReaction;
|
|
20898
21172
|
exports.restoreCache = restoreCache;
|
|
20899
21173
|
exports.runQuery = runQuery;
|