@amityco/ts-sdk 0.0.1-02f0fa3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +390 -0
- package/README.md +137 -0
- package/dist/@types/core/cache.d.ts +21 -0
- package/dist/@types/core/cache.d.ts.map +1 -0
- package/dist/@types/core/errors.d.ts +32 -0
- package/dist/@types/core/errors.d.ts.map +1 -0
- package/dist/@types/core/events.d.ts +46 -0
- package/dist/@types/core/events.d.ts.map +1 -0
- package/dist/@types/core/model.d.ts +41 -0
- package/dist/@types/core/model.d.ts.map +1 -0
- package/dist/@types/core/payload.d.ts +88 -0
- package/dist/@types/core/payload.d.ts.map +1 -0
- package/dist/@types/core/permissions.d.ts +71 -0
- package/dist/@types/core/permissions.d.ts.map +1 -0
- package/dist/@types/core/query.d.ts +72 -0
- package/dist/@types/core/query.d.ts.map +1 -0
- package/dist/@types/core/store.d.ts +46 -0
- package/dist/@types/core/store.d.ts.map +1 -0
- package/dist/@types/core/transport.d.ts +27 -0
- package/dist/@types/core/transport.d.ts.map +1 -0
- package/dist/@types/domains/category.d.ts +11 -0
- package/dist/@types/domains/category.d.ts.map +1 -0
- package/dist/@types/domains/channel.d.ts +26 -0
- package/dist/@types/domains/channel.d.ts.map +1 -0
- package/dist/@types/domains/client.d.ts +31 -0
- package/dist/@types/domains/client.d.ts.map +1 -0
- package/dist/@types/domains/comment.d.ts +17 -0
- package/dist/@types/domains/comment.d.ts.map +1 -0
- package/dist/@types/domains/community.d.ts +24 -0
- package/dist/@types/domains/community.d.ts.map +1 -0
- package/dist/@types/domains/content.d.ts +26 -0
- package/dist/@types/domains/content.d.ts.map +1 -0
- package/dist/@types/domains/feed.d.ts +14 -0
- package/dist/@types/domains/feed.d.ts.map +1 -0
- package/dist/@types/domains/file.d.ts +29 -0
- package/dist/@types/domains/file.d.ts.map +1 -0
- package/dist/@types/domains/group.d.ts +26 -0
- package/dist/@types/domains/group.d.ts.map +1 -0
- package/dist/@types/domains/message.d.ts +16 -0
- package/dist/@types/domains/message.d.ts.map +1 -0
- package/dist/@types/domains/partials.d.ts +42 -0
- package/dist/@types/domains/partials.d.ts.map +1 -0
- package/dist/@types/domains/post.d.ts +22 -0
- package/dist/@types/domains/post.d.ts.map +1 -0
- package/dist/@types/domains/reaction.d.ts +24 -0
- package/dist/@types/domains/reaction.d.ts.map +1 -0
- package/dist/@types/domains/stream.d.ts +47 -0
- package/dist/@types/domains/stream.d.ts.map +1 -0
- package/dist/@types/domains/user.d.ts +12 -0
- package/dist/@types/domains/user.d.ts.map +1 -0
- package/dist/@types/global.d.ts +13 -0
- package/dist/@types/global.d.ts.map +1 -0
- package/dist/@types/index.d.ts +23 -0
- package/dist/@types/index.d.ts.map +1 -0
- package/dist/category/api/getCategory.d.ts +16 -0
- package/dist/category/api/getCategory.d.ts.map +1 -0
- package/dist/category/api/index.d.ts +3 -0
- package/dist/category/api/index.d.ts.map +1 -0
- package/dist/category/api/queryCategories.d.ts +23 -0
- package/dist/category/api/queryCategories.d.ts.map +1 -0
- package/dist/channel/api/addChannelMembers.d.ts +17 -0
- package/dist/channel/api/addChannelMembers.d.ts.map +1 -0
- package/dist/channel/api/addChannelMembersRole.d.ts +18 -0
- package/dist/channel/api/addChannelMembersRole.d.ts.map +1 -0
- package/dist/channel/api/createChannel.d.ts +19 -0
- package/dist/channel/api/createChannel.d.ts.map +1 -0
- package/dist/channel/api/deleteChannel.d.ts +16 -0
- package/dist/channel/api/deleteChannel.d.ts.map +1 -0
- package/dist/channel/api/getChannel.d.ts +32 -0
- package/dist/channel/api/getChannel.d.ts.map +1 -0
- package/dist/channel/api/getChannels.d.ts +32 -0
- package/dist/channel/api/getChannels.d.ts.map +1 -0
- package/dist/channel/api/index.d.ts +14 -0
- package/dist/channel/api/index.d.ts.map +1 -0
- package/dist/channel/api/joinChannel.d.ts +16 -0
- package/dist/channel/api/joinChannel.d.ts.map +1 -0
- package/dist/channel/api/leaveChannel.d.ts +16 -0
- package/dist/channel/api/leaveChannel.d.ts.map +1 -0
- package/dist/channel/api/queryChannelMembers.d.ts +42 -0
- package/dist/channel/api/queryChannelMembers.d.ts.map +1 -0
- package/dist/channel/api/queryChannels.d.ts +43 -0
- package/dist/channel/api/queryChannels.d.ts.map +1 -0
- package/dist/channel/api/removeChannelMembers.d.ts +17 -0
- package/dist/channel/api/removeChannelMembers.d.ts.map +1 -0
- package/dist/channel/api/removeChannelMembersRole.d.ts +18 -0
- package/dist/channel/api/removeChannelMembersRole.d.ts.map +1 -0
- package/dist/channel/api/updateChannel.d.ts +17 -0
- package/dist/channel/api/updateChannel.d.ts.map +1 -0
- package/dist/channel/events/index.d.ts +7 -0
- package/dist/channel/events/index.d.ts.map +1 -0
- package/dist/channel/events/onChannelCreated.d.ts +17 -0
- package/dist/channel/events/onChannelCreated.d.ts.map +1 -0
- package/dist/channel/events/onChannelDeleted.d.ts +17 -0
- package/dist/channel/events/onChannelDeleted.d.ts.map +1 -0
- package/dist/channel/events/onChannelJoined.d.ts +17 -0
- package/dist/channel/events/onChannelJoined.d.ts.map +1 -0
- package/dist/channel/events/onChannelLeft.d.ts +17 -0
- package/dist/channel/events/onChannelLeft.d.ts.map +1 -0
- package/dist/channel/events/onChannelUpdated.d.ts +17 -0
- package/dist/channel/events/onChannelUpdated.d.ts.map +1 -0
- package/dist/channel/events/onMemberAdded.d.ts +17 -0
- package/dist/channel/events/onMemberAdded.d.ts.map +1 -0
- package/dist/channel/events/onMemberRemoved.d.ts +17 -0
- package/dist/channel/events/onMemberRemoved.d.ts.map +1 -0
- package/dist/channel/observers/index.d.ts +2 -0
- package/dist/channel/observers/index.d.ts.map +1 -0
- package/dist/channel/observers/observeChannel.d.ts +20 -0
- package/dist/channel/observers/observeChannel.d.ts.map +1 -0
- package/dist/client/api/activeClient.d.ts +17 -0
- package/dist/client/api/activeClient.d.ts.map +1 -0
- package/dist/client/api/clearCache.d.ts +15 -0
- package/dist/client/api/clearCache.d.ts.map +1 -0
- package/dist/client/api/connectClient.d.ts +26 -0
- package/dist/client/api/connectClient.d.ts.map +1 -0
- package/dist/client/api/createClient.d.ts +17 -0
- package/dist/client/api/createClient.d.ts.map +1 -0
- package/dist/client/api/disconnectClient.d.ts +16 -0
- package/dist/client/api/disconnectClient.d.ts.map +1 -0
- package/dist/client/api/enableCache.d.ts +15 -0
- package/dist/client/api/enableCache.d.ts.map +1 -0
- package/dist/client/api/getToken.d.ts +19 -0
- package/dist/client/api/getToken.d.ts.map +1 -0
- package/dist/client/api/index.d.ts +8 -0
- package/dist/client/api/index.d.ts.map +1 -0
- package/dist/client/api/isConnected.d.ts +14 -0
- package/dist/client/api/isConnected.d.ts.map +1 -0
- package/dist/client/events/index.d.ts +2 -0
- package/dist/client/events/index.d.ts.map +1 -0
- package/dist/client/events/onClientDisconnected.d.ts +17 -0
- package/dist/client/events/onClientDisconnected.d.ts.map +1 -0
- package/dist/comment/api/createComment.d.ts +16 -0
- package/dist/comment/api/createComment.d.ts.map +1 -0
- package/dist/comment/api/deleteComment.d.ts +16 -0
- package/dist/comment/api/deleteComment.d.ts.map +1 -0
- package/dist/comment/api/getComment.d.ts +32 -0
- package/dist/comment/api/getComment.d.ts.map +1 -0
- package/dist/comment/api/getComments.d.ts +32 -0
- package/dist/comment/api/getComments.d.ts.map +1 -0
- package/dist/comment/api/index.d.ts +7 -0
- package/dist/comment/api/index.d.ts.map +1 -0
- package/dist/comment/api/queryComments.d.ts +53 -0
- package/dist/comment/api/queryComments.d.ts.map +1 -0
- package/dist/comment/api/updateComment.d.ts +19 -0
- package/dist/comment/api/updateComment.d.ts.map +1 -0
- package/dist/comment/events/index.d.ts +4 -0
- package/dist/comment/events/index.d.ts.map +1 -0
- package/dist/comment/events/onCommentCreated.d.ts +17 -0
- package/dist/comment/events/onCommentCreated.d.ts.map +1 -0
- package/dist/comment/events/onCommentDeleted.d.ts +17 -0
- package/dist/comment/events/onCommentDeleted.d.ts.map +1 -0
- package/dist/comment/events/onCommentUpdated.d.ts +17 -0
- package/dist/comment/events/onCommentUpdated.d.ts.map +1 -0
- package/dist/comment/observers/index.d.ts +3 -0
- package/dist/comment/observers/index.d.ts.map +1 -0
- package/dist/comment/observers/observeComment.d.ts +20 -0
- package/dist/comment/observers/observeComment.d.ts.map +1 -0
- package/dist/comment/observers/observeComments.d.ts +22 -0
- package/dist/comment/observers/observeComments.d.ts.map +1 -0
- package/dist/community/api/addCommunityMembers.d.ts +17 -0
- package/dist/community/api/addCommunityMembers.d.ts.map +1 -0
- package/dist/community/api/addCommunityMembersRole.d.ts +18 -0
- package/dist/community/api/addCommunityMembersRole.d.ts.map +1 -0
- package/dist/community/api/createCommunity.d.ts +20 -0
- package/dist/community/api/createCommunity.d.ts.map +1 -0
- package/dist/community/api/deleteCommunity.d.ts +16 -0
- package/dist/community/api/deleteCommunity.d.ts.map +1 -0
- package/dist/community/api/getCommunities.d.ts +32 -0
- package/dist/community/api/getCommunities.d.ts.map +1 -0
- package/dist/community/api/getCommunity.d.ts +32 -0
- package/dist/community/api/getCommunity.d.ts.map +1 -0
- package/dist/community/api/index.d.ts +14 -0
- package/dist/community/api/index.d.ts.map +1 -0
- package/dist/community/api/joinCommunity.d.ts +16 -0
- package/dist/community/api/joinCommunity.d.ts.map +1 -0
- package/dist/community/api/leaveCommunity.d.ts +16 -0
- package/dist/community/api/leaveCommunity.d.ts.map +1 -0
- package/dist/community/api/queryCommunities.d.ts +46 -0
- package/dist/community/api/queryCommunities.d.ts.map +1 -0
- package/dist/community/api/queryCommunityMembers.d.ts +42 -0
- package/dist/community/api/queryCommunityMembers.d.ts.map +1 -0
- package/dist/community/api/removeCommunityMembers.d.ts +17 -0
- package/dist/community/api/removeCommunityMembers.d.ts.map +1 -0
- package/dist/community/api/removeCommunityMembersRole.d.ts +18 -0
- package/dist/community/api/removeCommunityMembersRole.d.ts.map +1 -0
- package/dist/community/api/updateCommunity.d.ts +17 -0
- package/dist/community/api/updateCommunity.d.ts.map +1 -0
- package/dist/community/events/index.d.ts +6 -0
- package/dist/community/events/index.d.ts.map +1 -0
- package/dist/community/events/onCommunityCreated.d.ts +17 -0
- package/dist/community/events/onCommunityCreated.d.ts.map +1 -0
- package/dist/community/events/onCommunityDeleted.d.ts +17 -0
- package/dist/community/events/onCommunityDeleted.d.ts.map +1 -0
- package/dist/community/events/onCommunityJoined.d.ts +17 -0
- package/dist/community/events/onCommunityJoined.d.ts.map +1 -0
- package/dist/community/events/onCommunityLeft.d.ts +17 -0
- package/dist/community/events/onCommunityLeft.d.ts.map +1 -0
- package/dist/community/events/onCommunityUpdated.d.ts +17 -0
- package/dist/community/events/onCommunityUpdated.d.ts.map +1 -0
- package/dist/community/observers/index.d.ts +2 -0
- package/dist/community/observers/index.d.ts.map +1 -0
- package/dist/community/observers/observeCommunity.d.ts +20 -0
- package/dist/community/observers/observeCommunity.d.ts.map +1 -0
- package/dist/core/cache/drop.d.ts +11 -0
- package/dist/core/cache/drop.d.ts.map +1 -0
- package/dist/core/cache/index.d.ts +19 -0
- package/dist/core/cache/index.d.ts.map +1 -0
- package/dist/core/cache/ingest.d.ts +10 -0
- package/dist/core/cache/ingest.d.ts.map +1 -0
- package/dist/core/cache/merge.d.ts +10 -0
- package/dist/core/cache/merge.d.ts.map +1 -0
- package/dist/core/cache/mutate.d.ts +10 -0
- package/dist/core/cache/mutate.d.ts.map +1 -0
- package/dist/core/cache/pull.d.ts +11 -0
- package/dist/core/cache/pull.d.ts.map +1 -0
- package/dist/core/cache/push.d.ts +10 -0
- package/dist/core/cache/push.d.ts.map +1 -0
- package/dist/core/cache/sync.d.ts +10 -0
- package/dist/core/cache/sync.d.ts.map +1 -0
- package/dist/core/debug.d.ts +15 -0
- package/dist/core/debug.d.ts.map +1 -0
- package/dist/core/device.d.ts +7 -0
- package/dist/core/device.d.ts.map +1 -0
- package/dist/core/errors.d.ts +59 -0
- package/dist/core/errors.d.ts.map +1 -0
- package/dist/core/events.d.ts +33 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/model/idResolvers.d.ts +20 -0
- package/dist/core/model/idResolvers.d.ts.map +1 -0
- package/dist/core/model/identifyModel.d.ts +8 -0
- package/dist/core/model/identifyModel.d.ts.map +1 -0
- package/dist/core/model/index.d.ts +4 -0
- package/dist/core/model/index.d.ts.map +1 -0
- package/dist/core/model/toRecord.d.ts +10 -0
- package/dist/core/model/toRecord.d.ts.map +1 -0
- package/dist/core/query/decorate.d.ts +23 -0
- package/dist/core/query/decorate.d.ts.map +1 -0
- package/dist/core/query/filtering.d.ts +12 -0
- package/dist/core/query/filtering.d.ts.map +1 -0
- package/dist/core/query/index.d.ts +6 -0
- package/dist/core/query/index.d.ts.map +1 -0
- package/dist/core/query/paging.d.ts +58 -0
- package/dist/core/query/paging.d.ts.map +1 -0
- package/dist/core/query/query.d.ts +121 -0
- package/dist/core/query/query.d.ts.map +1 -0
- package/dist/core/query/sorting.d.ts +39 -0
- package/dist/core/query/sorting.d.ts.map +1 -0
- package/dist/core/stores/index.d.ts +3 -0
- package/dist/core/stores/index.d.ts.map +1 -0
- package/dist/core/stores/memory.d.ts +30 -0
- package/dist/core/stores/memory.d.ts.map +1 -0
- package/dist/core/stores/persistent.d.ts +13 -0
- package/dist/core/stores/persistent.d.ts.map +1 -0
- package/dist/core/transports.d.ts +49 -0
- package/dist/core/transports.d.ts.map +1 -0
- package/dist/core/uuid.d.ts +2 -0
- package/dist/core/uuid.d.ts.map +1 -0
- package/dist/feed/api/index.d.ts +2 -0
- package/dist/feed/api/index.d.ts.map +1 -0
- package/dist/feed/api/queryGlobalFeed.d.ts +23 -0
- package/dist/feed/api/queryGlobalFeed.d.ts.map +1 -0
- package/dist/file/api/createFile.d.ts +16 -0
- package/dist/file/api/createFile.d.ts.map +1 -0
- package/dist/file/api/deleteFile.d.ts +16 -0
- package/dist/file/api/deleteFile.d.ts.map +1 -0
- package/dist/file/api/fileUrlWithSize.d.ts +9 -0
- package/dist/file/api/fileUrlWithSize.d.ts.map +1 -0
- package/dist/file/api/getFile.d.ts +32 -0
- package/dist/file/api/getFile.d.ts.map +1 -0
- package/dist/file/api/index.d.ts +5 -0
- package/dist/file/api/index.d.ts.map +1 -0
- package/dist/file/observers/index.d.ts +2 -0
- package/dist/file/observers/index.d.ts.map +1 -0
- package/dist/file/observers/observeFile.d.ts +20 -0
- package/dist/file/observers/observeFile.d.ts.map +1 -0
- package/dist/index.cjs.js +4884 -0
- package/dist/index.d.ts +32 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.js +4734 -0
- package/dist/index.umd.js +4880 -0
- package/dist/message/api/createMessage.d.ts +38 -0
- package/dist/message/api/createMessage.d.ts.map +1 -0
- package/dist/message/api/deleteMessage.d.ts +32 -0
- package/dist/message/api/deleteMessage.d.ts.map +1 -0
- package/dist/message/api/getMessage.d.ts +32 -0
- package/dist/message/api/getMessage.d.ts.map +1 -0
- package/dist/message/api/getMessages.d.ts +32 -0
- package/dist/message/api/getMessages.d.ts.map +1 -0
- package/dist/message/api/index.d.ts +7 -0
- package/dist/message/api/index.d.ts.map +1 -0
- package/dist/message/api/queryMessages.d.ts +55 -0
- package/dist/message/api/queryMessages.d.ts.map +1 -0
- package/dist/message/api/updateMessage.d.ts +38 -0
- package/dist/message/api/updateMessage.d.ts.map +1 -0
- package/dist/message/events/index.d.ts +4 -0
- package/dist/message/events/index.d.ts.map +1 -0
- package/dist/message/events/onMessageCreated.d.ts +17 -0
- package/dist/message/events/onMessageCreated.d.ts.map +1 -0
- package/dist/message/events/onMessageDeleted.d.ts +17 -0
- package/dist/message/events/onMessageDeleted.d.ts.map +1 -0
- package/dist/message/events/onMessageUpdated.d.ts +17 -0
- package/dist/message/events/onMessageUpdated.d.ts.map +1 -0
- package/dist/message/observers/index.d.ts +3 -0
- package/dist/message/observers/index.d.ts.map +1 -0
- package/dist/message/observers/observeMessage.d.ts +22 -0
- package/dist/message/observers/observeMessage.d.ts.map +1 -0
- package/dist/message/observers/observeMessages.d.ts +19 -0
- package/dist/message/observers/observeMessages.d.ts.map +1 -0
- package/dist/post/api/createPost.d.ts +21 -0
- package/dist/post/api/createPost.d.ts.map +1 -0
- package/dist/post/api/deletePost.d.ts +16 -0
- package/dist/post/api/deletePost.d.ts.map +1 -0
- package/dist/post/api/getPost.d.ts +32 -0
- package/dist/post/api/getPost.d.ts.map +1 -0
- package/dist/post/api/getPosts.d.ts +32 -0
- package/dist/post/api/getPosts.d.ts.map +1 -0
- package/dist/post/api/index.d.ts +7 -0
- package/dist/post/api/index.d.ts.map +1 -0
- package/dist/post/api/queryPosts.d.ts +45 -0
- package/dist/post/api/queryPosts.d.ts.map +1 -0
- package/dist/post/api/updatePost.d.ts +19 -0
- package/dist/post/api/updatePost.d.ts.map +1 -0
- package/dist/post/events/index.d.ts +4 -0
- package/dist/post/events/index.d.ts.map +1 -0
- package/dist/post/events/onPostCreated.d.ts +17 -0
- package/dist/post/events/onPostCreated.d.ts.map +1 -0
- package/dist/post/events/onPostDeleted.d.ts +17 -0
- package/dist/post/events/onPostDeleted.d.ts.map +1 -0
- package/dist/post/events/onPostUpdated.d.ts +17 -0
- package/dist/post/events/onPostUpdated.d.ts.map +1 -0
- package/dist/post/observers/index.d.ts +3 -0
- package/dist/post/observers/index.d.ts.map +1 -0
- package/dist/post/observers/observePost.d.ts +20 -0
- package/dist/post/observers/observePost.d.ts.map +1 -0
- package/dist/post/observers/observePosts.d.ts +25 -0
- package/dist/post/observers/observePosts.d.ts.map +1 -0
- package/dist/reaction/api/addReaction.d.ts +36 -0
- package/dist/reaction/api/addReaction.d.ts.map +1 -0
- package/dist/reaction/api/index.d.ts +3 -0
- package/dist/reaction/api/index.d.ts.map +1 -0
- package/dist/reaction/api/removeReaction.d.ts +36 -0
- package/dist/reaction/api/removeReaction.d.ts.map +1 -0
- package/dist/reaction/events/index.d.ts +2 -0
- package/dist/reaction/events/index.d.ts.map +1 -0
- package/dist/reaction/events/onReactionAdded.d.ts +17 -0
- package/dist/reaction/events/onReactionAdded.d.ts.map +1 -0
- package/dist/reaction/events/onReactionRemoved.d.ts +17 -0
- package/dist/reaction/events/onReactionRemoved.d.ts.map +1 -0
- package/dist/reaction/utils/dispatchReactable.d.ts +3 -0
- package/dist/reaction/utils/dispatchReactable.d.ts.map +1 -0
- package/dist/reaction/utils/fetchReference.d.ts +3 -0
- package/dist/reaction/utils/fetchReference.d.ts.map +1 -0
- package/dist/reaction/utils/index.d.ts +3 -0
- package/dist/reaction/utils/index.d.ts.map +1 -0
- package/dist/report/api/createReport.d.ts +16 -0
- package/dist/report/api/createReport.d.ts.map +1 -0
- package/dist/report/api/deleteReport.d.ts +16 -0
- package/dist/report/api/deleteReport.d.ts.map +1 -0
- package/dist/report/api/index.d.ts +4 -0
- package/dist/report/api/index.d.ts.map +1 -0
- package/dist/report/api/isReportedByMe.d.ts +16 -0
- package/dist/report/api/isReportedByMe.d.ts.map +1 -0
- package/dist/report/constants/referenceTypes.d.ts +24 -0
- package/dist/report/constants/referenceTypes.d.ts.map +1 -0
- package/dist/role/api/getRole.d.ts +32 -0
- package/dist/role/api/getRole.d.ts.map +1 -0
- package/dist/role/api/index.d.ts +3 -0
- package/dist/role/api/index.d.ts.map +1 -0
- package/dist/role/api/queryRoles.d.ts +42 -0
- package/dist/role/api/queryRoles.d.ts.map +1 -0
- package/dist/stream/api/createStream.d.ts +18 -0
- package/dist/stream/api/createStream.d.ts.map +1 -0
- package/dist/stream/api/deleteStream.d.ts +16 -0
- package/dist/stream/api/deleteStream.d.ts.map +1 -0
- package/dist/stream/api/getStream.d.ts +12 -0
- package/dist/stream/api/getStream.d.ts.map +1 -0
- package/dist/stream/api/index.d.ts +6 -0
- package/dist/stream/api/index.d.ts.map +1 -0
- package/dist/stream/api/queryStreams.d.ts +23 -0
- package/dist/stream/api/queryStreams.d.ts.map +1 -0
- package/dist/stream/api/updateStream.d.ts +17 -0
- package/dist/stream/api/updateStream.d.ts.map +1 -0
- package/dist/stream/events/index.d.ts +4 -0
- package/dist/stream/events/index.d.ts.map +1 -0
- package/dist/stream/events/onStreamRecorded.d.ts +17 -0
- package/dist/stream/events/onStreamRecorded.d.ts.map +1 -0
- package/dist/stream/events/onStreamStarted.d.ts +17 -0
- package/dist/stream/events/onStreamStarted.d.ts.map +1 -0
- package/dist/stream/events/onStreamStopped.d.ts +17 -0
- package/dist/stream/events/onStreamStopped.d.ts.map +1 -0
- package/dist/user/api/getUser.d.ts +32 -0
- package/dist/user/api/getUser.d.ts.map +1 -0
- package/dist/user/api/getUsers.d.ts +32 -0
- package/dist/user/api/getUsers.d.ts.map +1 -0
- package/dist/user/api/index.d.ts +5 -0
- package/dist/user/api/index.d.ts.map +1 -0
- package/dist/user/api/queryUsers.d.ts +43 -0
- package/dist/user/api/queryUsers.d.ts.map +1 -0
- package/dist/user/api/updateUser.d.ts +17 -0
- package/dist/user/api/updateUser.d.ts.map +1 -0
- package/dist/user/events/index.d.ts +2 -0
- package/dist/user/events/index.d.ts.map +1 -0
- package/dist/user/events/onUserUpdated.d.ts +17 -0
- package/dist/user/events/onUserUpdated.d.ts.map +1 -0
- package/dist/user/observers/index.d.ts +2 -0
- package/dist/user/observers/index.d.ts.map +1 -0
- package/dist/user/observers/observeUser.d.ts +19 -0
- package/dist/user/observers/observeUser.d.ts.map +1 -0
- package/package.json +59 -0
- package/rollup.config.js +41 -0
- package/src/@types/core/cache.ts +22 -0
- package/src/@types/core/errors.ts +34 -0
- package/src/@types/core/events.ts +60 -0
- package/src/@types/core/model.ts +51 -0
- package/src/@types/core/payload.ts +102 -0
- package/src/@types/core/permissions.ts +76 -0
- package/src/@types/core/query.ts +95 -0
- package/src/@types/core/store.ts +52 -0
- package/src/@types/core/transport.ts +32 -0
- package/src/@types/domains/category.ts +15 -0
- package/src/@types/domains/channel.ts +38 -0
- package/src/@types/domains/client.ts +36 -0
- package/src/@types/domains/comment.ts +26 -0
- package/src/@types/domains/community.ts +35 -0
- package/src/@types/domains/content.ts +35 -0
- package/src/@types/domains/feed.ts +16 -0
- package/src/@types/domains/file.ts +41 -0
- package/src/@types/domains/group.ts +38 -0
- package/src/@types/domains/message.ts +27 -0
- package/src/@types/domains/partials.ts +52 -0
- package/src/@types/domains/post.ts +31 -0
- package/src/@types/domains/reaction.ts +30 -0
- package/src/@types/domains/stream.ts +57 -0
- package/src/@types/domains/user.ts +18 -0
- package/src/@types/global.ts +25 -0
- package/src/@types/index.ts +31 -0
- package/src/category/api/getCategory.ts +35 -0
- package/src/category/api/index.ts +2 -0
- package/src/category/api/queryCategories.ts +49 -0
- package/src/channel/api/addChannelMembers.ts +45 -0
- package/src/channel/api/addChannelMembersRole.ts +43 -0
- package/src/channel/api/createChannel.ts +37 -0
- package/src/channel/api/deleteChannel.ts +34 -0
- package/src/channel/api/getChannel.ts +59 -0
- package/src/channel/api/getChannels.ts +63 -0
- package/src/channel/api/index.ts +18 -0
- package/src/channel/api/joinChannel.ts +38 -0
- package/src/channel/api/leaveChannel.ts +38 -0
- package/src/channel/api/queryChannelMembers.ts +79 -0
- package/src/channel/api/queryChannels.ts +89 -0
- package/src/channel/api/removeChannelMembers.ts +45 -0
- package/src/channel/api/removeChannelMembersRole.ts +43 -0
- package/src/channel/api/updateChannel.ts +38 -0
- package/src/channel/events/index.ts +6 -0
- package/src/channel/events/onChannelCreated.ts +37 -0
- package/src/channel/events/onChannelDeleted.ts +37 -0
- package/src/channel/events/onChannelJoined.ts +37 -0
- package/src/channel/events/onChannelLeft.ts +37 -0
- package/src/channel/events/onChannelUpdated.ts +37 -0
- package/src/channel/events/onMemberAdded.ts +37 -0
- package/src/channel/events/onMemberRemoved.ts +37 -0
- package/src/channel/observers/index.ts +1 -0
- package/src/channel/observers/observeChannel.ts +80 -0
- package/src/client/api/activeClient.ts +33 -0
- package/src/client/api/clearCache.ts +23 -0
- package/src/client/api/connectClient.ts +63 -0
- package/src/client/api/createClient.ts +56 -0
- package/src/client/api/disconnectClient.ts +31 -0
- package/src/client/api/enableCache.ts +35 -0
- package/src/client/api/getToken.ts +35 -0
- package/src/client/api/index.ts +7 -0
- package/src/client/api/isConnected.ts +24 -0
- package/src/client/events/index.ts +1 -0
- package/src/client/events/onClientDisconnected.ts +29 -0
- package/src/comment/api/createComment.ts +43 -0
- package/src/comment/api/deleteComment.ts +40 -0
- package/src/comment/api/getComment.ts +59 -0
- package/src/comment/api/getComments.ts +63 -0
- package/src/comment/api/index.ts +7 -0
- package/src/comment/api/queryComments.ts +169 -0
- package/src/comment/api/updateComment.ts +41 -0
- package/src/comment/events/index.ts +3 -0
- package/src/comment/events/onCommentCreated.ts +39 -0
- package/src/comment/events/onCommentDeleted.ts +39 -0
- package/src/comment/events/onCommentUpdated.ts +39 -0
- package/src/comment/observers/index.ts +2 -0
- package/src/comment/observers/observeComment.ts +73 -0
- package/src/comment/observers/observeComments.ts +61 -0
- package/src/community/api/addCommunityMembers.ts +46 -0
- package/src/community/api/addCommunityMembersRole.ts +43 -0
- package/src/community/api/createCommunity.ts +43 -0
- package/src/community/api/deleteCommunity.ts +35 -0
- package/src/community/api/getCommunities.ts +63 -0
- package/src/community/api/getCommunity.ts +58 -0
- package/src/community/api/index.ts +17 -0
- package/src/community/api/joinCommunity.ts +41 -0
- package/src/community/api/leaveCommunity.ts +41 -0
- package/src/community/api/queryCommunities.ts +92 -0
- package/src/community/api/queryCommunityMembers.ts +78 -0
- package/src/community/api/removeCommunityMembers.ts +46 -0
- package/src/community/api/removeCommunityMembersRole.ts +43 -0
- package/src/community/api/updateCommunity.ts +40 -0
- package/src/community/events/index.ts +6 -0
- package/src/community/events/onCommunityCreated.ts +37 -0
- package/src/community/events/onCommunityDeleted.ts +37 -0
- package/src/community/events/onCommunityJoined.ts +37 -0
- package/src/community/events/onCommunityLeft.ts +37 -0
- package/src/community/events/onCommunityUpdated.ts +37 -0
- package/src/community/observers/index.ts +1 -0
- package/src/community/observers/observeCommunity.ts +74 -0
- package/src/core/cache/drop.ts +24 -0
- package/src/core/cache/index.ts +24 -0
- package/src/core/cache/ingest.ts +24 -0
- package/src/core/cache/merge.ts +19 -0
- package/src/core/cache/mutate.ts +25 -0
- package/src/core/cache/pull.ts +31 -0
- package/src/core/cache/push.ts +41 -0
- package/src/core/cache/sync.ts +41 -0
- package/src/core/debug.ts +26 -0
- package/src/core/device.ts +38 -0
- package/src/core/errors.ts +85 -0
- package/src/core/events.ts +93 -0
- package/src/core/model/idResolvers.ts +66 -0
- package/src/core/model/identifyModel.ts +32 -0
- package/src/core/model/index.ts +3 -0
- package/src/core/model/toRecord.ts +11 -0
- package/src/core/query/decorate.ts +64 -0
- package/src/core/query/filtering.ts +17 -0
- package/src/core/query/index.ts +5 -0
- package/src/core/query/paging.ts +166 -0
- package/src/core/query/query.ts +300 -0
- package/src/core/query/sorting.ts +50 -0
- package/src/core/stores/index.ts +2 -0
- package/src/core/stores/memory.ts +59 -0
- package/src/core/stores/persistent.ts +63 -0
- package/src/core/transports.ts +157 -0
- package/src/core/uuid.ts +2 -0
- package/src/feed/api/index.ts +1 -0
- package/src/feed/api/queryGlobalFeed.ts +50 -0
- package/src/file/api/createFile.ts +51 -0
- package/src/file/api/deleteFile.ts +35 -0
- package/src/file/api/fileUrlWithSize.ts +13 -0
- package/src/file/api/getFile.ts +60 -0
- package/src/file/api/index.ts +4 -0
- package/src/file/observers/index.ts +1 -0
- package/src/file/observers/observeFile.ts +57 -0
- package/src/index.ts +55 -0
- package/src/message/api/createMessage.ts +90 -0
- package/src/message/api/deleteMessage.ts +75 -0
- package/src/message/api/getMessage.ts +60 -0
- package/src/message/api/getMessages.ts +63 -0
- package/src/message/api/index.ts +6 -0
- package/src/message/api/queryMessages.ts +145 -0
- package/src/message/api/updateMessage.ts +79 -0
- package/src/message/events/index.ts +3 -0
- package/src/message/events/onMessageCreated.ts +39 -0
- package/src/message/events/onMessageDeleted.ts +39 -0
- package/src/message/events/onMessageUpdated.ts +39 -0
- package/src/message/observers/index.ts +2 -0
- package/src/message/observers/observeMessage.ts +76 -0
- package/src/message/observers/observeMessages.ts +60 -0
- package/src/post/api/createPost.ts +45 -0
- package/src/post/api/deletePost.ts +43 -0
- package/src/post/api/getPost.ts +60 -0
- package/src/post/api/getPosts.ts +63 -0
- package/src/post/api/index.ts +7 -0
- package/src/post/api/queryPosts.ts +86 -0
- package/src/post/api/updatePost.ts +42 -0
- package/src/post/events/index.ts +3 -0
- package/src/post/events/onPostCreated.ts +39 -0
- package/src/post/events/onPostDeleted.ts +39 -0
- package/src/post/events/onPostUpdated.ts +39 -0
- package/src/post/observers/index.ts +2 -0
- package/src/post/observers/observePost.ts +72 -0
- package/src/post/observers/observePosts.ts +66 -0
- package/src/reaction/api/addReaction.ts +84 -0
- package/src/reaction/api/index.ts +2 -0
- package/src/reaction/api/removeReaction.ts +84 -0
- package/src/reaction/events/index.ts +1 -0
- package/src/reaction/events/onReactionAdded.ts +43 -0
- package/src/reaction/events/onReactionRemoved.ts +41 -0
- package/src/reaction/utils/dispatchReactable.ts +19 -0
- package/src/reaction/utils/fetchReference.ts +18 -0
- package/src/reaction/utils/index.ts +2 -0
- package/src/report/api/createReport.ts +40 -0
- package/src/report/api/deleteReport.ts +40 -0
- package/src/report/api/index.ts +4 -0
- package/src/report/api/isReportedByMe.ts +37 -0
- package/src/report/constants/referenceTypes.ts +22 -0
- package/src/role/api/getRole.ts +53 -0
- package/src/role/api/index.ts +2 -0
- package/src/role/api/queryRoles.ts +79 -0
- package/src/stream/api/createStream.ts +33 -0
- package/src/stream/api/deleteStream.ts +38 -0
- package/src/stream/api/getStream.ts +29 -0
- package/src/stream/api/index.ts +7 -0
- package/src/stream/api/queryStreams.ts +44 -0
- package/src/stream/api/updateStream.ts +36 -0
- package/src/stream/events/index.ts +3 -0
- package/src/stream/events/onStreamRecorded.ts +39 -0
- package/src/stream/events/onStreamStarted.ts +39 -0
- package/src/stream/events/onStreamStopped.ts +39 -0
- package/src/user/api/getUser.ts +59 -0
- package/src/user/api/getUsers.ts +60 -0
- package/src/user/api/index.ts +5 -0
- package/src/user/api/queryUsers.ts +88 -0
- package/src/user/api/updateUser.ts +44 -0
- package/src/user/events/index.ts +1 -0
- package/src/user/events/onUserUpdated.ts +39 -0
- package/src/user/observers/index.ts +1 -0
- package/src/user/observers/observeUser.ts +64 -0
- package/tsconfig.json +28 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import { decoratePayload } from '~/core/query'
|
|
4
|
+
import { ingestInCache } from '~/core/cache'
|
|
5
|
+
import { fireEvent } from '~/core/events'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { leaveCommunity } from '@amityco/ts-sdk'
|
|
10
|
+
* const isLeft = await leaveCommunity('foobar')
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Leaves a {@link Amity.Community} object
|
|
14
|
+
*
|
|
15
|
+
* @param communityId the {@link Amity.Community} to leave
|
|
16
|
+
* @returns A success boolean if {@link Amity.Community} was left
|
|
17
|
+
*
|
|
18
|
+
* @category Community API
|
|
19
|
+
* @async
|
|
20
|
+
*/
|
|
21
|
+
export const leaveCommunity = async (communityId: Amity.Community['communityId']) => {
|
|
22
|
+
const client = getActiveClient()
|
|
23
|
+
client.log('community/leaveCommunity', communityId)
|
|
24
|
+
|
|
25
|
+
const { data } = await client.http.delete<Amity.CommunityMembershipPayload>(
|
|
26
|
+
`/api/v3/communities/${communityId}/leave`,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
decoratePayload(data)
|
|
30
|
+
ingestInCache(data)
|
|
31
|
+
fireEvent('v3.community.didJoin', {
|
|
32
|
+
communities: data.communities!,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
const { communityUsers } = data
|
|
36
|
+
|
|
37
|
+
return !!communityUsers.find(communityUser => (
|
|
38
|
+
communityUser.communityId === communityId
|
|
39
|
+
&& communityUser.communityMembership !== 'member'
|
|
40
|
+
))
|
|
41
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import { decoratePayload, toPage, toToken } from '~/core/query'
|
|
4
|
+
import { ingestInCache } from '~/core/cache'
|
|
5
|
+
import { toRecord } from '~/core/model'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { queryCommunities } from '@amityco/ts-sdk'
|
|
10
|
+
* const communities = await queryCommunities()
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Queries a paginable list of {@link Amity.Community} objects
|
|
14
|
+
* Search is performed by displayName such as `.startsWith(search)`
|
|
15
|
+
*
|
|
16
|
+
* @param query The query parameters
|
|
17
|
+
* @returns A page of {@link Amity.Community} objects
|
|
18
|
+
*
|
|
19
|
+
* @category Community API
|
|
20
|
+
* @async
|
|
21
|
+
*/
|
|
22
|
+
export const queryCommunities = async (
|
|
23
|
+
query?: {
|
|
24
|
+
displayName?: string
|
|
25
|
+
membership?: 'all' | 'member' | 'notMember'
|
|
26
|
+
categoryId?: Amity.Category['categoryId'],
|
|
27
|
+
isDeleted?: Amity.Community['isDeleted'],
|
|
28
|
+
hasFlag?: boolean,
|
|
29
|
+
tags?: Amity.Taggable['tags'],
|
|
30
|
+
sortBy?: ('displayName' | 'firstCreated' | 'lastCreated')
|
|
31
|
+
page?: Amity.Page
|
|
32
|
+
}
|
|
33
|
+
) => {
|
|
34
|
+
const client = getActiveClient()
|
|
35
|
+
client.log('channel/queryCommunities', query)
|
|
36
|
+
|
|
37
|
+
// safe decapsulation
|
|
38
|
+
const {
|
|
39
|
+
page,
|
|
40
|
+
displayName,
|
|
41
|
+
membership,
|
|
42
|
+
...params
|
|
43
|
+
} = query ?? {}
|
|
44
|
+
|
|
45
|
+
// API-FIX: parameters should be querystring.
|
|
46
|
+
// API-FIX: backend doesnt answer Amity.Response
|
|
47
|
+
// const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<CommunityPayload>>>(
|
|
48
|
+
const { data } = await client.http.get<Amity.CommunityPayload & Amity.Pagination>(
|
|
49
|
+
`/api/v3/communities`, { params: {
|
|
50
|
+
...params,
|
|
51
|
+
keyword: displayName,
|
|
52
|
+
filter: membership,
|
|
53
|
+
options: {
|
|
54
|
+
token: toToken(page, 'skiplimit')
|
|
55
|
+
}
|
|
56
|
+
} }
|
|
57
|
+
)
|
|
58
|
+
|
|
59
|
+
// API-FIX: backend to response Amity.Response: const { paging, communities } = unwrapPayload(data)
|
|
60
|
+
const { paging, ...response } = data
|
|
61
|
+
|
|
62
|
+
decoratePayload(response as unknown as Record<string, object[]>)
|
|
63
|
+
ingestInCache(response as unknown as Record<string, object[]>)
|
|
64
|
+
|
|
65
|
+
const prevPage = toPage(paging?.previous)
|
|
66
|
+
const nextPage = toPage(paging?.next)
|
|
67
|
+
|
|
68
|
+
const { communities } = response
|
|
69
|
+
return { data: toRecord(communities), prevPage, nextPage }
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* ```js
|
|
74
|
+
* import { queryCommunities } from '@amityco/ts-sdk'
|
|
75
|
+
* const communities = queryCommunities.locally()
|
|
76
|
+
* ```
|
|
77
|
+
*
|
|
78
|
+
* Queries a paginable list of {@link Amity.Community} objects from cache
|
|
79
|
+
*
|
|
80
|
+
* @param query The query parameters
|
|
81
|
+
* @returns communities
|
|
82
|
+
*
|
|
83
|
+
* @category Community API
|
|
84
|
+
*/
|
|
85
|
+
queryCommunities.locally = (
|
|
86
|
+
query: Parameters<typeof queryCommunities>[0],
|
|
87
|
+
) => {
|
|
88
|
+
const client = getActiveClient()
|
|
89
|
+
client.log('community/queryCommunities.locally', query)
|
|
90
|
+
|
|
91
|
+
// TODO
|
|
92
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import { decoratePayload, toPage, toToken } from '~/core/query'
|
|
4
|
+
import { ingestInCache } from '~/core/cache'
|
|
5
|
+
|
|
6
|
+
import { toRecord } from '~/core/model'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ```js
|
|
10
|
+
* import { queryCommunityMembers } from '@amityco/ts-sdk'
|
|
11
|
+
* const communityMembers = await queryCommunityMembers({ communityId: 'foo' })
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Queries a paginable list of {@link Amity.CommunityUser} objects
|
|
15
|
+
*
|
|
16
|
+
* @param query The query parameters
|
|
17
|
+
* @returns A page of {@link Amity.CommunityUser} objects
|
|
18
|
+
*
|
|
19
|
+
* @category Community API
|
|
20
|
+
* @async
|
|
21
|
+
**/
|
|
22
|
+
export const queryCommunityMembers = async (query: {
|
|
23
|
+
communityId: string
|
|
24
|
+
membership?: ('banned' | 'member')[]
|
|
25
|
+
roles?: string[]
|
|
26
|
+
sortBy?: 'firstCreated' | 'lastCreated'
|
|
27
|
+
page?: Amity.Page
|
|
28
|
+
}) => {
|
|
29
|
+
const client = getActiveClient()
|
|
30
|
+
client.log('community/queryCommunityMembers', query)
|
|
31
|
+
|
|
32
|
+
const { page, communityId, ...params } = query ?? {}
|
|
33
|
+
|
|
34
|
+
const { data } = await client.http.get<
|
|
35
|
+
Amity.CommunityMembershipPayload & Amity.Pagination
|
|
36
|
+
>(`/api/v3/communities/${communityId}/users`, {
|
|
37
|
+
params: {
|
|
38
|
+
...params,
|
|
39
|
+
options: {
|
|
40
|
+
token: toToken(page, 'skiplimit'),
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
|
|
45
|
+
const { paging, ...response } = data
|
|
46
|
+
|
|
47
|
+
decoratePayload(response as unknown as Record<string, Object[]>)
|
|
48
|
+
ingestInCache(response as unknown as Record<string, Object[]>)
|
|
49
|
+
|
|
50
|
+
const { communityUsers } = response
|
|
51
|
+
|
|
52
|
+
const nextPage = toPage(paging.next)
|
|
53
|
+
const prevPage = toPage(paging.previous)
|
|
54
|
+
|
|
55
|
+
return { data: toRecord(communityUsers), nextPage, prevPage }
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* ```js
|
|
60
|
+
* import { queryCommunityMembers } from '@amityco/ts-sdk'
|
|
61
|
+
* const communityMembers = await queryCommunityMembers(query)
|
|
62
|
+
* ```
|
|
63
|
+
*
|
|
64
|
+
* Queries a paginable list of {@link Amity.Post} objects from cache
|
|
65
|
+
*
|
|
66
|
+
* @param query The query parameters
|
|
67
|
+
* @returns posts
|
|
68
|
+
*
|
|
69
|
+
* @category Post API
|
|
70
|
+
*/
|
|
71
|
+
queryCommunityMembers.locally = (
|
|
72
|
+
query: Parameters<typeof queryCommunityMembers>[0]
|
|
73
|
+
) => {
|
|
74
|
+
const client = getActiveClient()
|
|
75
|
+
client.log('community/queryCommunityMembers', query)
|
|
76
|
+
|
|
77
|
+
// TODO
|
|
78
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import { decoratePayload } from '~/core/query'
|
|
4
|
+
import { ingestInCache } from '~/core/cache'
|
|
5
|
+
import { fireEvent } from '~/core/events'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { removeCommunityMembers } from '@amityco/ts-sdk'
|
|
10
|
+
* const updated = await removeCommunityMembers(communityId, ['foo', 'bar'])
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Removes a list of {@link Amity.User} from a {@link Amity.Channel}
|
|
14
|
+
*
|
|
15
|
+
* @param communityId The ID of the {@link Amity.Community} to edit
|
|
16
|
+
* @param userIds The list of IDs {@link Amity.User} to remove
|
|
17
|
+
* @returns A success boolean if the list of {@link Amity.User} were removed from the {@link Amity.Community}
|
|
18
|
+
*
|
|
19
|
+
* @category Community API
|
|
20
|
+
* @async
|
|
21
|
+
*/
|
|
22
|
+
export const removeCommunityMembers = async (
|
|
23
|
+
communityId: Amity.Community['communityId'],
|
|
24
|
+
userIds: Amity.User['userId'][]
|
|
25
|
+
) => {
|
|
26
|
+
const client = getActiveClient()
|
|
27
|
+
client.log('community/removeCommunityMembers', communityId, userIds)
|
|
28
|
+
|
|
29
|
+
const { data } = await client.http.delete<Amity.CommunityMembershipPayload>(
|
|
30
|
+
`/api/v3/communities/${communityId}/users`,
|
|
31
|
+
{ data: { communityId, userIds } }
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
decoratePayload(data)
|
|
35
|
+
ingestInCache(data)
|
|
36
|
+
fireEvent('v3.community.didRemoveUsers', {
|
|
37
|
+
communities: data.communities!,
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const { communityUsers } = data
|
|
41
|
+
return !!communityUsers.find(
|
|
42
|
+
communityUser =>
|
|
43
|
+
communityUser.communityId === communityId &&
|
|
44
|
+
communityUser.communityMembership !== 'member'
|
|
45
|
+
)
|
|
46
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import { decoratePayload } from '~/core/query'
|
|
4
|
+
import { ingestInCache } from '~/core/cache'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ```js
|
|
8
|
+
* import { removeCommunityMembersRole } from '@amityco/ts-sdk'
|
|
9
|
+
* const updated = await removeCommunityMembersRole(communityId, 'foo', ['bar'])
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Removes an {@link Amity.Role} from a list of {@link Amity.User} on a {@link Amity.Community}
|
|
13
|
+
*
|
|
14
|
+
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
15
|
+
* @param role The ID of the {@link Amity.Role} to apply
|
|
16
|
+
* @param userId Array of IDs of the {@link Amity.User} to perform
|
|
17
|
+
* @returns A success boolean if the {@link Amity.Role} were removed from list of {@link Amity.User} in the {@link Amity.Community}
|
|
18
|
+
*
|
|
19
|
+
* @category Community API
|
|
20
|
+
* @async
|
|
21
|
+
*/
|
|
22
|
+
export const removeCommunityMembersRole = async (
|
|
23
|
+
communityId: Amity.Community['communityId'],
|
|
24
|
+
roleId: Amity.Role['roleId'],
|
|
25
|
+
userIds: Amity.User['userId'][]
|
|
26
|
+
) => {
|
|
27
|
+
const client = getActiveClient()
|
|
28
|
+
client.log('community/removeCommunityMembersRole', communityId, roleId, userIds)
|
|
29
|
+
|
|
30
|
+
const { data } = await client.http.delete<Amity.CommunityMembershipPayload>(
|
|
31
|
+
`/api/v3/communities/${communityId}/users/roles`,
|
|
32
|
+
{ data: { communityId, role: roleId, userIds } }
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
decoratePayload(data)
|
|
36
|
+
ingestInCache(data)
|
|
37
|
+
|
|
38
|
+
const { communityUsers } = data
|
|
39
|
+
return !!communityUsers.find(
|
|
40
|
+
communityUser =>
|
|
41
|
+
communityUser.communityId === communityId && !communityUser.roles.includes(roleId)
|
|
42
|
+
)
|
|
43
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import { decoratePayload } from '~/core/query'
|
|
4
|
+
import { ingestInCache } from '~/core/cache'
|
|
5
|
+
import { fireEvent } from '~/core/events'
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* ```js
|
|
10
|
+
* import { updateCommunity } from '@amityco/ts-sdk'
|
|
11
|
+
* const updated = await updateCommunity(communityId, { displayName: 'foobar' })
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* Updates an {@link Amity.Community}
|
|
15
|
+
*
|
|
16
|
+
* @param communityId The ID of the {@link Amity.Community} to edit
|
|
17
|
+
* @param patch The patch data to apply
|
|
18
|
+
* @returns the updated {@link Amity.Community} object
|
|
19
|
+
*
|
|
20
|
+
* @category Community API
|
|
21
|
+
* @async
|
|
22
|
+
*/
|
|
23
|
+
export const updateCommunity = async (
|
|
24
|
+
communityId: Amity.Community['communityId'],
|
|
25
|
+
patch: Patch<Amity.Community, 'displayName' | 'description' | 'avatarFileId' | 'tags' | 'metadata'>,
|
|
26
|
+
) => {
|
|
27
|
+
const client = getActiveClient()
|
|
28
|
+
client.log('community/updateCommunity', communityId, patch)
|
|
29
|
+
|
|
30
|
+
const { data } = await client.http.put<Amity.CommunityPayload>(
|
|
31
|
+
`/api/v3/communities/${communityId}`, patch,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
decoratePayload(data)
|
|
35
|
+
ingestInCache(data)
|
|
36
|
+
fireEvent('v3.community.didUpdate', data)
|
|
37
|
+
|
|
38
|
+
const { communities } = data
|
|
39
|
+
return communities.find(community => community.communityId === communityId)!
|
|
40
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
import { createEventSubscriber } from '~/core/events'
|
|
3
|
+
|
|
4
|
+
import { decoratePayload } from '~/core/query'
|
|
5
|
+
import { ingestInCache } from '~/core/cache'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { onCommunityCreated } from '@amityco/ts-sdk'
|
|
10
|
+
* const dispose = onCommunityCreated(channel => {
|
|
11
|
+
* // ...
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Fired when any {@link Amity.Community} have been created
|
|
16
|
+
*
|
|
17
|
+
* @param callback The function to call when the event was fired
|
|
18
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19
|
+
*
|
|
20
|
+
* @category Community Events
|
|
21
|
+
*/
|
|
22
|
+
export const onCommunityCreated = (callback: Amity.Listener<Amity.Community>) => {
|
|
23
|
+
const client = getActiveClient()
|
|
24
|
+
|
|
25
|
+
const filter = (payload: Amity.CommunityPayload) => {
|
|
26
|
+
decoratePayload(payload)
|
|
27
|
+
ingestInCache(payload)
|
|
28
|
+
callback(payload.communities[0])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return createEventSubscriber(
|
|
32
|
+
client,
|
|
33
|
+
'onCommunityCreated',
|
|
34
|
+
'v3.community.didCreate',
|
|
35
|
+
filter
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
import { createEventSubscriber } from '~/core/events'
|
|
3
|
+
|
|
4
|
+
import { decoratePayload } from '~/core/query'
|
|
5
|
+
import { ingestInCache } from '~/core/cache'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { onCommunityDeleted } from '@amityco/ts-sdk'
|
|
10
|
+
* const dispose = onCommunityDeleted(channel => {
|
|
11
|
+
* // ...
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Fired when any {@link Amity.Community} have been deleted
|
|
16
|
+
*
|
|
17
|
+
* @param callback The function to call when the event was fired
|
|
18
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19
|
+
*
|
|
20
|
+
* @category Community Events
|
|
21
|
+
*/
|
|
22
|
+
export const onCommunityDeleted = (callback: Amity.Listener<Amity.Community>) => {
|
|
23
|
+
const client = getActiveClient()
|
|
24
|
+
|
|
25
|
+
const filter = (payload: Amity.CommunityPayload) => {
|
|
26
|
+
decoratePayload(payload)
|
|
27
|
+
ingestInCache(payload)
|
|
28
|
+
callback(payload.communities[0])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return createEventSubscriber(
|
|
32
|
+
client,
|
|
33
|
+
'onCommunityDeleted',
|
|
34
|
+
'v3.community.didDelete',
|
|
35
|
+
filter
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
import { createEventSubscriber } from '~/core/events'
|
|
3
|
+
|
|
4
|
+
import { decoratePayload } from '~/core/query'
|
|
5
|
+
import { ingestInCache } from '~/core/cache'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { onCommunityJoined } from '@amityco/ts-sdk'
|
|
10
|
+
* const dispose = onCommunityJoined(channel => {
|
|
11
|
+
* // ...
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Fired when any {@link Amity.Community} was joined
|
|
16
|
+
*
|
|
17
|
+
* @param callback The function to call when the event was fired
|
|
18
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19
|
+
*
|
|
20
|
+
* @category Community Events
|
|
21
|
+
*/
|
|
22
|
+
export const onCommunityJoined = (callback: Amity.Listener<Amity.Community>) => {
|
|
23
|
+
const client = getActiveClient()
|
|
24
|
+
|
|
25
|
+
const filter = (payload: Amity.CommunityPayload) => {
|
|
26
|
+
decoratePayload(payload)
|
|
27
|
+
ingestInCache(payload)
|
|
28
|
+
callback(payload.communities[0])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return createEventSubscriber(
|
|
32
|
+
client,
|
|
33
|
+
'onCommunityJoined',
|
|
34
|
+
'v3.community.didJoin',
|
|
35
|
+
filter
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
import { createEventSubscriber } from '~/core/events'
|
|
3
|
+
|
|
4
|
+
import { decoratePayload } from '~/core/query'
|
|
5
|
+
import { ingestInCache } from '~/core/cache'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { onCommunityLeft } from '@amityco/ts-sdk'
|
|
10
|
+
* const dispose = onCommunityLeft(channel => {
|
|
11
|
+
* // ...
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Fired when any {@link Amity.Community} was left
|
|
16
|
+
*
|
|
17
|
+
* @param callback The function to call when the event was fired
|
|
18
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19
|
+
*
|
|
20
|
+
* @category Community Events
|
|
21
|
+
*/
|
|
22
|
+
export const onCommunityLeft = (callback: Amity.Listener<Amity.Community>) => {
|
|
23
|
+
const client = getActiveClient()
|
|
24
|
+
|
|
25
|
+
const filter = (payload: Amity.CommunityPayload) => {
|
|
26
|
+
decoratePayload(payload)
|
|
27
|
+
ingestInCache(payload)
|
|
28
|
+
callback(payload.communities[0])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return createEventSubscriber(
|
|
32
|
+
client,
|
|
33
|
+
'onCommunityLeft',
|
|
34
|
+
'v3.community.didLeave',
|
|
35
|
+
filter
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
import { createEventSubscriber } from '~/core/events'
|
|
3
|
+
|
|
4
|
+
import { decoratePayload } from '~/core/query'
|
|
5
|
+
import { ingestInCache } from '~/core/cache'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { onCommunityUpdated } from '@amityco/ts-sdk'
|
|
10
|
+
* const dispose = onCommunityUpdated(channel => {
|
|
11
|
+
* // ...
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Fired when any {@link Amity.Community} have been updated
|
|
16
|
+
*
|
|
17
|
+
* @param callback The function to call when the event was fired
|
|
18
|
+
* @returns an {@link Amity.Unsubscriber} function to stop listening
|
|
19
|
+
*
|
|
20
|
+
* @category Community Events
|
|
21
|
+
*/
|
|
22
|
+
export const onCommunityUpdated = (callback: Amity.Listener<Amity.Community>) => {
|
|
23
|
+
const client = getActiveClient()
|
|
24
|
+
|
|
25
|
+
const filter = (payload: Amity.CommunityPayload) => {
|
|
26
|
+
decoratePayload(payload)
|
|
27
|
+
ingestInCache(payload)
|
|
28
|
+
callback(payload.communities[0])
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return createEventSubscriber(
|
|
32
|
+
client,
|
|
33
|
+
'onCommunityUpdated',
|
|
34
|
+
'v3.community.didUpdate',
|
|
35
|
+
filter
|
|
36
|
+
)
|
|
37
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './observeCommunity'
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { createQuery, runQuery } from '~/core/query/query'
|
|
2
|
+
|
|
3
|
+
import { getActiveClient } from '~/client/api'
|
|
4
|
+
|
|
5
|
+
import { getCommunity } from '../api'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
onCommunityUpdated,
|
|
9
|
+
onCommunityDeleted,
|
|
10
|
+
onCommunityJoined,
|
|
11
|
+
onCommunityLeft,
|
|
12
|
+
} from '../events'
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* ```js
|
|
16
|
+
* import { observeCommunity } from '@amityco/ts-sdk'
|
|
17
|
+
*
|
|
18
|
+
* let community = {}
|
|
19
|
+
* const dispose = observeCommunity(communityId, updated => community = updated)
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* Observe all mutation on a given {@link Amity.Community}
|
|
23
|
+
*
|
|
24
|
+
* @param communityId the ID of the community to observe
|
|
25
|
+
* @param callback the function to call when new data are available
|
|
26
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the community
|
|
27
|
+
*
|
|
28
|
+
* @category Community Observer
|
|
29
|
+
*/
|
|
30
|
+
export const observeCommunity = <Events extends ['onFetch', 'onUpdate', 'onDelete', 'onJoin', 'onLeft']>(
|
|
31
|
+
communityId: string,
|
|
32
|
+
callback: Amity.ObjectListener<Amity.QueryResult<Amity.Community>, Events>
|
|
33
|
+
): Amity.Unsubscriber => {
|
|
34
|
+
const { log } = getActiveClient()
|
|
35
|
+
|
|
36
|
+
const timestamp = Date.now()
|
|
37
|
+
log(`observeCommunity(tmpid: ${timestamp}) > listen`)
|
|
38
|
+
|
|
39
|
+
// wrapper function to make sure
|
|
40
|
+
const router = (
|
|
41
|
+
result: Amity.QueryResult<Amity.Community>,
|
|
42
|
+
action: Events[number]
|
|
43
|
+
) => {
|
|
44
|
+
// filter function
|
|
45
|
+
if (result.data?.communityId !== communityId) return
|
|
46
|
+
|
|
47
|
+
if (callback instanceof Function)
|
|
48
|
+
return callback(result)
|
|
49
|
+
|
|
50
|
+
if (action !== 'onFetch')
|
|
51
|
+
callback.onEvent?.(action, result)
|
|
52
|
+
|
|
53
|
+
callback[action]?.(result)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const disposers: Amity.Unsubscriber[] = []
|
|
57
|
+
|
|
58
|
+
disposers.push(
|
|
59
|
+
onCommunityUpdated(data => router({ data }, 'onUpdate')),
|
|
60
|
+
onCommunityDeleted(data => router({ data }, 'onDelete')),
|
|
61
|
+
onCommunityJoined(data => router({ data }, 'onJoin')),
|
|
62
|
+
onCommunityLeft(data => router({ data }, 'onLeft')),
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
runQuery(
|
|
66
|
+
createQuery(getCommunity, communityId),
|
|
67
|
+
result => result.data && router(result, 'onFetch')
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
return () => {
|
|
71
|
+
log(`observeCommunity(tmpid: ${timestamp}) > dispose`)
|
|
72
|
+
disposers.forEach(fn => fn())
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api/activeClient'
|
|
2
|
+
import { getResolver } from '../model/idResolvers'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Pull objects from the cache layer
|
|
6
|
+
*
|
|
7
|
+
* @param name The name of the store to query
|
|
8
|
+
* @param keys A collection of unique keys for the store
|
|
9
|
+
* @returns The collection of objects matching the keys. Keys which don't match object will be omitted
|
|
10
|
+
*
|
|
11
|
+
* @category Cache
|
|
12
|
+
*/
|
|
13
|
+
export const dropFromCache = <T extends Amity.Domain>(name: T, partial: Amity.Minimal[T] & Partial<Amity.Model[T]>) => {
|
|
14
|
+
const { cache } = getActiveClient()
|
|
15
|
+
const store = cache?.[name] as unknown as Amity.Store<Amity.Model[T]>
|
|
16
|
+
|
|
17
|
+
if (!cache || !store) return []
|
|
18
|
+
|
|
19
|
+
const modelId = getResolver(name)(partial)
|
|
20
|
+
const localId = cache.lookup[`${name}#${modelId}`]
|
|
21
|
+
|
|
22
|
+
delete cache.lookup[`${name}#${modelId}`]
|
|
23
|
+
store.erase(localId)
|
|
24
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './pull'
|
|
2
|
+
export * from './push'
|
|
3
|
+
export * from './drop'
|
|
4
|
+
export * from './sync'
|
|
5
|
+
export * from './ingest'
|
|
6
|
+
export * from './mutate'
|
|
7
|
+
export * from './merge'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Creates a cache instance. The cache instance will handle stores
|
|
11
|
+
* given to it as input, and will be used as the first source of cached data
|
|
12
|
+
* in the SDK.
|
|
13
|
+
*
|
|
14
|
+
* @param stores A partial collection of stores
|
|
15
|
+
* @returns A cache instance
|
|
16
|
+
*
|
|
17
|
+
* @category Cache
|
|
18
|
+
*/
|
|
19
|
+
export const createCache = (
|
|
20
|
+
stores: Partial<Amity.StoreCollection<Amity.Domain[]>>
|
|
21
|
+
): Amity.Cache => {
|
|
22
|
+
const lookup: Record<string, string> = {}
|
|
23
|
+
return { lookup, ...stores }
|
|
24
|
+
}
|