@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 { updateComment } from '@amityco/ts-sdk'
|
|
10
|
+
* const updated = await updateComment(commentId, {
|
|
11
|
+
* data: { text: 'hello world' }
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Updates an {@link Amity.Comment}
|
|
16
|
+
*
|
|
17
|
+
* @param commentId The ID of the {@link Amity.Comment} to edit
|
|
18
|
+
* @param patch The patch data to apply
|
|
19
|
+
* @returns the updated {@link Amity.Comment} object
|
|
20
|
+
*
|
|
21
|
+
* @category Comment API
|
|
22
|
+
* @async
|
|
23
|
+
*/
|
|
24
|
+
export const updateComment = async (
|
|
25
|
+
commentId: Amity.Comment['commentId'],
|
|
26
|
+
patch: Patch<Amity.Comment, 'data' | 'metadata'>,
|
|
27
|
+
) => {
|
|
28
|
+
const client = getActiveClient()
|
|
29
|
+
client.log('user/updateComment', patch)
|
|
30
|
+
|
|
31
|
+
const { data } = await client.http.put<Amity.CommentPayload>(
|
|
32
|
+
`/api/v3/comments/${commentId}`, patch,
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
decoratePayload(data)
|
|
36
|
+
ingestInCache(data)
|
|
37
|
+
fireEvent('v3.comment.didUpdate', data)
|
|
38
|
+
|
|
39
|
+
const { comments } = data
|
|
40
|
+
return comments.find(comment => comment.commentId === commentId)!
|
|
41
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { onCommentCreated } from '@amityco/ts-sdk'
|
|
10
|
+
* const dispose = onCommentCreated(comment => {
|
|
11
|
+
* // ...
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Fired when an {@link Amity.Comment} has 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 Comment Events
|
|
21
|
+
*/
|
|
22
|
+
export const onCommentCreated = <T extends Amity.CommentContentType>(
|
|
23
|
+
callback: Amity.Listener<Amity.Comment<T>>
|
|
24
|
+
): Amity.Unsubscriber => {
|
|
25
|
+
const client = getActiveClient()
|
|
26
|
+
|
|
27
|
+
const filter = (payload: Amity.CommentPayload<T>) => {
|
|
28
|
+
decoratePayload(payload)
|
|
29
|
+
ingestInCache(payload)
|
|
30
|
+
callback(payload.comments[0])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return createEventSubscriber(
|
|
34
|
+
client,
|
|
35
|
+
'message/onCommentCreated',
|
|
36
|
+
'v3.comment.didCreate',
|
|
37
|
+
filter
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { onCommentDeleted } from '@amityco/ts-sdk'
|
|
10
|
+
* const dispose = onCommentDeleted(comment => {
|
|
11
|
+
* // ...
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Fired when an {@link Amity.Comment} has 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 Comment Events
|
|
21
|
+
*/
|
|
22
|
+
export const onCommentDeleted = <T extends Amity.CommentContentType>(
|
|
23
|
+
callback: Amity.Listener<Amity.Comment<T>>
|
|
24
|
+
): Amity.Unsubscriber => {
|
|
25
|
+
const client = getActiveClient()
|
|
26
|
+
|
|
27
|
+
const filter = (payload: Amity.CommentPayload<T>) => {
|
|
28
|
+
decoratePayload(payload)
|
|
29
|
+
ingestInCache(payload)
|
|
30
|
+
callback(payload.comments[0])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return createEventSubscriber(
|
|
34
|
+
client,
|
|
35
|
+
'message/onCommentDeleted',
|
|
36
|
+
'v3.comment.didDelete',
|
|
37
|
+
filter
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
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 { onCommentUpdated } from '@amityco/ts-sdk'
|
|
10
|
+
* const dispose = onCommentUpdated(comment => {
|
|
11
|
+
* // ...
|
|
12
|
+
* })
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* Fired when an {@link Amity.Comment} has 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 Comment Events
|
|
21
|
+
*/
|
|
22
|
+
export const onCommentUpdated = <T extends Amity.CommentContentType>(
|
|
23
|
+
callback: Amity.Listener<Amity.Comment<T>>
|
|
24
|
+
): Amity.Unsubscriber => {
|
|
25
|
+
const client = getActiveClient()
|
|
26
|
+
|
|
27
|
+
const filter = (payload: Amity.CommentPayload<T>) => {
|
|
28
|
+
decoratePayload(payload)
|
|
29
|
+
ingestInCache(payload)
|
|
30
|
+
callback(payload.comments[0])
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return createEventSubscriber(
|
|
34
|
+
client,
|
|
35
|
+
'message/onCommentUpdated',
|
|
36
|
+
'v3.comment.didUpdate',
|
|
37
|
+
filter
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import { createQuery, runQuery, queryOptions } from '~/core/query'
|
|
4
|
+
|
|
5
|
+
import { getComment } from '../api'
|
|
6
|
+
|
|
7
|
+
import {
|
|
8
|
+
onCommentUpdated,
|
|
9
|
+
onCommentDeleted,
|
|
10
|
+
} from '../events'
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* ```js
|
|
15
|
+
* import { observeComment } from '@amityco/ts-sdk'
|
|
16
|
+
*
|
|
17
|
+
* let comment = {}
|
|
18
|
+
* const dispose = observeComment(commentId, ({ data }) => comment = data)
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* Observe all mutation on a given {@link Amity.Comment}
|
|
22
|
+
*
|
|
23
|
+
* @param commentId the ID of the comment to observe
|
|
24
|
+
* @param callback the function to call when new data are available
|
|
25
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
|
|
26
|
+
*
|
|
27
|
+
* @category Comment Observer
|
|
28
|
+
*/
|
|
29
|
+
export const observeComment = <Events extends ['onFetch', 'onUpdate', 'onDelete']>(
|
|
30
|
+
commentId: string,
|
|
31
|
+
callback: Amity.ObjectListener<Amity.QueryResult<Amity.Comment>, Events>,
|
|
32
|
+
policy: Amity.QueryPolicy = 'cache_then_server',
|
|
33
|
+
): Amity.Unsubscriber => {
|
|
34
|
+
const { log } = getActiveClient()
|
|
35
|
+
|
|
36
|
+
const timestamp = Date.now()
|
|
37
|
+
log(`observeComment(tmpid: ${timestamp}) > listen`)
|
|
38
|
+
|
|
39
|
+
// wrapper function to make sure
|
|
40
|
+
const router = (
|
|
41
|
+
result: Amity.QueryResult<Amity.Comment>,
|
|
42
|
+
action: Events[number]
|
|
43
|
+
) => {
|
|
44
|
+
// filter function
|
|
45
|
+
if (result.data?.commentId !== commentId) 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
|
+
onCommentUpdated(data => router({ data }, 'onUpdate')),
|
|
60
|
+
onCommentDeleted(data => router({ data }, 'onDelete')),
|
|
61
|
+
)
|
|
62
|
+
|
|
63
|
+
runQuery(
|
|
64
|
+
createQuery(getComment, commentId),
|
|
65
|
+
result => result.data && router(result, 'onFetch'),
|
|
66
|
+
queryOptions(policy)
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
return () => {
|
|
70
|
+
log(`observeComment(tmpid: ${timestamp}) > dispose`)
|
|
71
|
+
disposers.forEach(fn => fn())
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
onCommentCreated,
|
|
5
|
+
onCommentUpdated,
|
|
6
|
+
onCommentDeleted,
|
|
7
|
+
} from '../events'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* ```js
|
|
11
|
+
* import { observeComments } from '@amityco/ts-sdk'
|
|
12
|
+
*
|
|
13
|
+
* let comments = []
|
|
14
|
+
* const unsub = observeComments(postId, comment => merge(comments, comment))
|
|
15
|
+
* ```
|
|
16
|
+
*
|
|
17
|
+
* Observe all mutations on a list of {@link Amity.Comment} for a given {@link Amity.Post} object
|
|
18
|
+
*
|
|
19
|
+
* @param postId the ID of the post where to observe the comments
|
|
20
|
+
* @param callback the function to call when new data are available
|
|
21
|
+
* @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comments
|
|
22
|
+
*
|
|
23
|
+
* @category Comment Observer
|
|
24
|
+
*/
|
|
25
|
+
export const observeComments = (
|
|
26
|
+
postId: Amity.Post['postId'],
|
|
27
|
+
callback: Amity.ObjectListener<
|
|
28
|
+
Amity.Comment,
|
|
29
|
+
['onCreate', 'onUpdate', 'onDelete']
|
|
30
|
+
>
|
|
31
|
+
): Amity.Unsubscriber => {
|
|
32
|
+
const { log } = getActiveClient()
|
|
33
|
+
|
|
34
|
+
const timestamp = Date.now()
|
|
35
|
+
log(`observeComments(tmpid: ${timestamp}) > listen`)
|
|
36
|
+
|
|
37
|
+
const disposers: Amity.Unsubscriber[] = []
|
|
38
|
+
|
|
39
|
+
const router = (
|
|
40
|
+
comment: Amity.Comment,
|
|
41
|
+
action: 'onCreate' | 'onUpdate' | 'onDelete'
|
|
42
|
+
) => {
|
|
43
|
+
if (comment.referenceId !== postId) return
|
|
44
|
+
|
|
45
|
+
if (callback instanceof Function) return callback(comment)
|
|
46
|
+
|
|
47
|
+
callback.onEvent?.(action, comment)
|
|
48
|
+
callback[action]?.(comment)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
disposers.push(
|
|
52
|
+
onCommentCreated(comment => router(comment, 'onCreate')),
|
|
53
|
+
onCommentUpdated(comment => router(comment, 'onUpdate')),
|
|
54
|
+
onCommentDeleted(comment => router(comment, 'onDelete'))
|
|
55
|
+
)
|
|
56
|
+
|
|
57
|
+
return () => {
|
|
58
|
+
log(`observeComments(tmpid: ${timestamp}) > dispose`)
|
|
59
|
+
disposers.forEach(fn => fn())
|
|
60
|
+
}
|
|
61
|
+
}
|
|
@@ -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 { addCommunityMembers } from '@amityco/ts-sdk'
|
|
10
|
+
* const updated = await addCommunityMembers(communityId, ['foo', 'bar'])
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Adds a list of {@link Amity.User} to a {@link Amity.Community} to add users to
|
|
14
|
+
*
|
|
15
|
+
* @param communityId The ID of the {@link Amity.Community} to perform
|
|
16
|
+
* @param userIds The list of IDs {@link Amity.User} to add
|
|
17
|
+
* @returns A success boolean if the {@link Amity.User} were added to the {@link Amity.Community}
|
|
18
|
+
*
|
|
19
|
+
* @category Community API
|
|
20
|
+
* @async
|
|
21
|
+
*/
|
|
22
|
+
export const addCommunityMembers = async (
|
|
23
|
+
communityId: Amity.Community['communityId'],
|
|
24
|
+
userIds: Amity.User['userId'][]
|
|
25
|
+
) => {
|
|
26
|
+
const client = getActiveClient()
|
|
27
|
+
client.log('community/addCommunityMembers', communityId, userIds)
|
|
28
|
+
|
|
29
|
+
const { data } = await client.http.post<Amity.CommunityMembershipPayload>(
|
|
30
|
+
`/api/v3/communities/${communityId}/users`,
|
|
31
|
+
{ communityId, userIds }
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
decoratePayload(data)
|
|
35
|
+
ingestInCache(data)
|
|
36
|
+
fireEvent('v3.community.didAddUsers', {
|
|
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 { addCommunityMembersRole } from '@amityco/ts-sdk'
|
|
9
|
+
* const updated = await addCommunityMembersRole(communityId, 'foo', ['bar'])
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Adds an {@link Amity.Role} to 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 roleId 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 added to list of {@link Amity.User} in the {@link Amity.Community}
|
|
18
|
+
*
|
|
19
|
+
* @category Community API
|
|
20
|
+
* @async
|
|
21
|
+
*/
|
|
22
|
+
export const addCommunityMembersRole = 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/addCommunityMembersRole', communityId, roleId, userIds)
|
|
29
|
+
|
|
30
|
+
const { data } = await client.http.post<Amity.CommunityMembershipPayload>(
|
|
31
|
+
`/api/v3/communities/${communityId}/users/roles`,
|
|
32
|
+
{ 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,43 @@
|
|
|
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 { createCommunity } from '@amityco/ts-sdk'
|
|
10
|
+
* const created = await createCommunity({ communityId: 'foobar', displayName: 'foobar' })
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Creates an {@link Amity.Community}
|
|
14
|
+
*
|
|
15
|
+
* @param bundle The data necessary to create a new {@link Amity.Community}
|
|
16
|
+
* @returns The newly created {@link Amity.Community}
|
|
17
|
+
*
|
|
18
|
+
* @category Community API
|
|
19
|
+
* @async
|
|
20
|
+
*/
|
|
21
|
+
export const createCommunity = async (
|
|
22
|
+
bundle: Pick<
|
|
23
|
+
Amity.Community,
|
|
24
|
+
'displayName' | 'avatarFileId' | 'description' | 'isPublic' | 'isOfficial' | 'onlyAdminCanPost' | 'needApprovalOnPostCreation' | 'tags' | 'metadata'
|
|
25
|
+
> & {
|
|
26
|
+
userIds?: string[]
|
|
27
|
+
categoryIds?: string[]
|
|
28
|
+
isUniqueDisplayName?: boolean
|
|
29
|
+
}) => {
|
|
30
|
+
const client = getActiveClient()
|
|
31
|
+
client.log('user/createCommunity', bundle)
|
|
32
|
+
|
|
33
|
+
const { data } = await client.http.post<Amity.CommunityPayload>(
|
|
34
|
+
'/api/v3/communities/', bundle,
|
|
35
|
+
)
|
|
36
|
+
|
|
37
|
+
decoratePayload(data)
|
|
38
|
+
ingestInCache(data)
|
|
39
|
+
fireEvent('v3.community.didCreate', data)
|
|
40
|
+
|
|
41
|
+
const { communities } = data
|
|
42
|
+
return communities[0]
|
|
43
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import { fireEvent } from '~/core/events'
|
|
4
|
+
import { getCommunity } from './getCommunity'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* ```js
|
|
8
|
+
* import { deleteCommunity } from '@amityco/ts-sdk'
|
|
9
|
+
* const success = await deleteCommunity('foobar')
|
|
10
|
+
* ```
|
|
11
|
+
*
|
|
12
|
+
* Deletes a {@link Amity.Community}
|
|
13
|
+
*
|
|
14
|
+
* @param communityId The {@link Amity.Community} ID to delete
|
|
15
|
+
* @return A success boolean if the {@link Amity.Community} was deleted
|
|
16
|
+
*
|
|
17
|
+
* @category Community API
|
|
18
|
+
* @async
|
|
19
|
+
*/
|
|
20
|
+
export const deleteCommunity = async (
|
|
21
|
+
communityId: Amity.Community['communityId'],
|
|
22
|
+
) => {
|
|
23
|
+
const client = getActiveClient()
|
|
24
|
+
client.log('community/deleteCommunity', communityId)
|
|
25
|
+
|
|
26
|
+
// API-FIX: This endpoint has not been implemented yet.
|
|
27
|
+
await client.http.delete<{ success: boolean }>(
|
|
28
|
+
`/api/v3/communities/${communityId}`,
|
|
29
|
+
)
|
|
30
|
+
|
|
31
|
+
const deleted = await getCommunity(communityId)
|
|
32
|
+
fireEvent('v3.community.didDelete', { communities: [deleted] })
|
|
33
|
+
|
|
34
|
+
return deleted
|
|
35
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
|
|
3
|
+
import { decoratePayload } from '~/core/query'
|
|
4
|
+
import { ingestInCache, pullFromCache } from '~/core/cache'
|
|
5
|
+
import { toRecord } from '~/core/model'
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* ```js
|
|
9
|
+
* import { getCommunities } from '@amityco/ts-sdk'
|
|
10
|
+
* const communities = await getCommunities(['foo', 'bar'])
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Fetches a collection of {@link Amity.Community} objects
|
|
14
|
+
*
|
|
15
|
+
* @param communityIds the IDs of the {@link Amity.Community} to fetch
|
|
16
|
+
* @returns the associated collection of {@link Amity.Community} objects
|
|
17
|
+
*
|
|
18
|
+
* @category Community API
|
|
19
|
+
* @async
|
|
20
|
+
*/
|
|
21
|
+
export const getCommunities = async (
|
|
22
|
+
communityIds: Amity.Community['communityId'][]
|
|
23
|
+
) => {
|
|
24
|
+
const client = getActiveClient()
|
|
25
|
+
client.log('community/getCommunities', communityIds)
|
|
26
|
+
|
|
27
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
28
|
+
const { data } = await client.http.get<Amity.CommunityPayload>(
|
|
29
|
+
`/api/v3/communities/list`,
|
|
30
|
+
{ params: { communityIds } },
|
|
31
|
+
)
|
|
32
|
+
|
|
33
|
+
decoratePayload(data)
|
|
34
|
+
ingestInCache(data)
|
|
35
|
+
|
|
36
|
+
const { communities } = data
|
|
37
|
+
return toRecord(communities)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* ```js
|
|
42
|
+
* import { getCommunities } from '@amityco/ts-sdk'
|
|
43
|
+
* const communities = getCommunities.locally(['foo', 'bar']) ?? []
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* Fetches a collection of {@link Amity.Community} objects from cache
|
|
47
|
+
*
|
|
48
|
+
* @param communityIds the IDs of the {@link Amity.Community} to fetch
|
|
49
|
+
* @returns the associated collection of {@link Amity.Community} objects
|
|
50
|
+
*
|
|
51
|
+
* @category Community API
|
|
52
|
+
*/
|
|
53
|
+
getCommunities.locally = (
|
|
54
|
+
communityIds: Amity.Community['communityId'][]
|
|
55
|
+
) => {
|
|
56
|
+
const client = getActiveClient()
|
|
57
|
+
client.log('community/getCommunities.locally', communityIds)
|
|
58
|
+
|
|
59
|
+
const cached = pullFromCache('community', ...communityIds) ?? []
|
|
60
|
+
|
|
61
|
+
if (cached?.length === communityIds.length)
|
|
62
|
+
return toRecord(cached)
|
|
63
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { getActiveClient } from '~/client/api'
|
|
2
|
+
import { ingestInCache, pullFromCache } from '~/core/cache'
|
|
3
|
+
import { decoratePayload } from '~/core/query'
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* ```js
|
|
7
|
+
* import { getCommunity } from '@amityco/ts-sdk'
|
|
8
|
+
* const community = await getCommunity('foobar')
|
|
9
|
+
* ```
|
|
10
|
+
*
|
|
11
|
+
* Fetches a {@link Amity.Community} object
|
|
12
|
+
*
|
|
13
|
+
* @param communityId the ID of the {@link Amity.Community} to fetch
|
|
14
|
+
* @returns the associated {@link Amity.Community} object
|
|
15
|
+
*
|
|
16
|
+
* @category Community API
|
|
17
|
+
* @async
|
|
18
|
+
*/
|
|
19
|
+
export const getCommunity = async (
|
|
20
|
+
communityId: Amity.Community['communityId']
|
|
21
|
+
) => {
|
|
22
|
+
const client = getActiveClient()
|
|
23
|
+
client.log('community/getCommunity', communityId)
|
|
24
|
+
|
|
25
|
+
// API-FIX: endpoint should not be /list, parameters should be querystring.
|
|
26
|
+
const { data } = await client.http.get<Amity.CommunityPayload>(
|
|
27
|
+
`/api/v3/communities/${communityId}`,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
decoratePayload(data)
|
|
31
|
+
ingestInCache(data)
|
|
32
|
+
|
|
33
|
+
const { communities } = data
|
|
34
|
+
return communities.find(community => community.communityId === communityId)!
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* ```js
|
|
39
|
+
* import { getCommunity } from '@amityco/ts-sdk'
|
|
40
|
+
* const community = getCommunity.locally('foobar')
|
|
41
|
+
* ```
|
|
42
|
+
*
|
|
43
|
+
* Fetches a {@link Amity.Community} object from cache
|
|
44
|
+
*
|
|
45
|
+
* @param communityId the ID of the {@link Amity.Community} to fetch
|
|
46
|
+
* @returns the associated {@link Amity.Community} object
|
|
47
|
+
*
|
|
48
|
+
* @category Community API
|
|
49
|
+
*/
|
|
50
|
+
getCommunity.locally = (
|
|
51
|
+
communityId: Amity.Community['communityId']
|
|
52
|
+
) => {
|
|
53
|
+
const client = getActiveClient()
|
|
54
|
+
client.log('community/getCommunity.locally', communityId)
|
|
55
|
+
|
|
56
|
+
const [community] = pullFromCache('community', communityId) ?? []
|
|
57
|
+
return community
|
|
58
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export * from './queryCommunities'
|
|
2
|
+
export * from './getCommunities'
|
|
3
|
+
export * from './getCommunity'
|
|
4
|
+
|
|
5
|
+
export * from './createCommunity'
|
|
6
|
+
export * from './updateCommunity'
|
|
7
|
+
export * from './deleteCommunity'
|
|
8
|
+
|
|
9
|
+
export * from './joinCommunity'
|
|
10
|
+
export * from './leaveCommunity'
|
|
11
|
+
|
|
12
|
+
export * from './queryCommunityMembers'
|
|
13
|
+
export * from './addCommunityMembers'
|
|
14
|
+
export * from './removeCommunityMembers'
|
|
15
|
+
|
|
16
|
+
export * from './addCommunityMembersRole'
|
|
17
|
+
export * from './removeCommunityMembersRole'
|
|
@@ -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 { joinCommunity } from '@amityco/ts-sdk'
|
|
10
|
+
* const isJoined = await joinCommunity('foobar')
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* Joins a {@link Amity.Community} object
|
|
14
|
+
*
|
|
15
|
+
* @param communityId the {@link Amity.Community} to join
|
|
16
|
+
* @returns A success boolean if the {@link Amity.Community} was joined
|
|
17
|
+
*
|
|
18
|
+
* @category Community API
|
|
19
|
+
* @async
|
|
20
|
+
*/
|
|
21
|
+
export const joinCommunity = async (communityId: Amity.Community['communityId']) => {
|
|
22
|
+
const client = getActiveClient()
|
|
23
|
+
client.log('community/joinCommunity', communityId)
|
|
24
|
+
|
|
25
|
+
const { data } = await client.http.post<Amity.CommunityMembershipPayload>(
|
|
26
|
+
`/api/v3/communities/${communityId}/join`,
|
|
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
|
+
}
|