@amityco/ts-sdk 7.5.3-5f273be.0 → 7.5.3-acf2120.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/@types/domains/post.d.ts +1 -18
- package/dist/@types/domains/post.d.ts.map +1 -1
- package/dist/client/api/enableUnreadCount.d.ts.map +1 -1
- package/dist/client/api/login.d.ts.map +1 -1
- package/dist/client/utils/markerSyncEngine.d.ts +1 -1
- package/dist/client/utils/markerSyncEngine.d.ts.map +1 -1
- package/dist/index.cjs.js +326 -437
- package/dist/index.esm.js +326 -437
- package/dist/index.umd.js +1 -1
- package/dist/postRepository/api/getPost.d.ts +2 -2
- package/dist/postRepository/api/getPost.d.ts.map +1 -1
- package/dist/userRepository/observers/getBlockedUsers.d.ts +4 -4
- package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
- package/dist/utils/tests/dummy/comment.d.ts +1 -1
- package/dist/utils/tests/dummy/post.d.ts +3 -3
- package/package.json +1 -1
- package/src/@types/domains/post.ts +8 -25
- package/src/client/api/enableUnreadCount.ts +0 -22
- package/src/client/api/login.ts +0 -4
- package/src/client/utils/markerSyncEngine.ts +3 -24
- package/src/commentRepository/api/createComment.ts +1 -1
- package/src/commentRepository/api/deleteComment.ts +1 -1
- package/src/postRepository/api/getPost.ts +4 -6
- package/src/postRepository/observers/getPost.ts +2 -2
- package/src/reactionRepository/api/addReaction.ts +1 -1
- package/src/userRepository/observers/getBlockedUsers.ts +4 -4
- package/src/utils/linkedObject/streamLinkedObject.ts +1 -1
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
* @async
|
|
14
14
|
*/
|
|
15
15
|
export declare const getPost: {
|
|
16
|
-
(postId: Amity.Post['postId']): Promise<Amity.Cached<Amity.
|
|
16
|
+
(postId: Amity.Post['postId']): Promise<Amity.Cached<Amity.Post>>;
|
|
17
17
|
/**
|
|
18
18
|
* ```js
|
|
19
19
|
* import { getPost } from '@amityco/ts-sdk'
|
|
@@ -27,6 +27,6 @@ export declare const getPost: {
|
|
|
27
27
|
*
|
|
28
28
|
* @category Post API
|
|
29
29
|
*/
|
|
30
|
-
locally(postId: Amity.Post['postId']): Amity.Cached<Amity.
|
|
30
|
+
locally(postId: Amity.Post['postId']): Amity.Cached<Amity.Post> | undefined;
|
|
31
31
|
};
|
|
32
32
|
//# sourceMappingURL=getPost.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/getPost.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO;
|
|
1
|
+
{"version":3,"file":"getPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/getPost.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,OAAO;aAAkB,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,CAAC;IAqC9F;;;;;;;;;;;;OAYG;oBACwB,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS;CAfrF,CAAC"}
|
|
@@ -4,14 +4,14 @@
|
|
|
4
4
|
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
5
5
|
* ```
|
|
6
6
|
*
|
|
7
|
-
* Blocks a {@link Amity.
|
|
7
|
+
* Blocks a {@link Amity.InternalUser}
|
|
8
8
|
*
|
|
9
|
-
* @param params The params to get blocked {@link Amity.
|
|
10
|
-
* @param callback to recieve updates on unblocked {@link Amity.
|
|
9
|
+
* @param params The params to get blocked {@link Amity.InternalUser}s
|
|
10
|
+
* @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
|
|
11
11
|
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
12
12
|
*
|
|
13
13
|
* @category Post API
|
|
14
14
|
* @async
|
|
15
15
|
*/
|
|
16
|
-
export declare const getBlockedUsers: (params: Amity.BlockedUsersLiveCollection, callback: Amity.LiveCollectionCallback<Amity.
|
|
16
|
+
export declare const getBlockedUsers: (params: Amity.BlockedUsersLiveCollection, callback: Amity.LiveCollectionCallback<Amity.InternalUser>, config?: Amity.LiveCollectionConfig) => Amity.Unsubscriber;
|
|
17
17
|
//# sourceMappingURL=getBlockedUsers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getBlockedUsers.d.ts","sourceRoot":"","sources":["../../../src/userRepository/observers/getBlockedUsers.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,0BAA0B,YAC9B,MAAM,sBAAsB,CAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"getBlockedUsers.d.ts","sourceRoot":"","sources":["../../../src/userRepository/observers/getBlockedUsers.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,0BAA0B,YAC9B,MAAM,sBAAsB,CAAC,MAAM,YAAY,CAAC,WACjD,MAAM,oBAAoB,KAClC,MAAM,YAsBR,CAAC"}
|
|
@@ -18,7 +18,7 @@ export declare const generateComment: (params?: Partial<Amity.InternalComment>)
|
|
|
18
18
|
editedAt: string;
|
|
19
19
|
attachments?: Amity.Attachment[] | undefined;
|
|
20
20
|
targetId: string;
|
|
21
|
-
targetType: "
|
|
21
|
+
targetType: "community" | "user" | "content";
|
|
22
22
|
referenceId: string;
|
|
23
23
|
referenceType: Amity.CommentReferenceType;
|
|
24
24
|
dataType?: any;
|
|
@@ -28,21 +28,21 @@ export declare const emptyPostPayload: {
|
|
|
28
28
|
files: never[];
|
|
29
29
|
};
|
|
30
30
|
export declare const postQueryResponse: {
|
|
31
|
-
data: Omit<Amity.PostPayload<any>, "
|
|
31
|
+
data: Omit<Amity.PostPayload<any>, "communityUsers" | "communities" | "posts"> & {
|
|
32
32
|
posts: Amity.InternalPost<any>[];
|
|
33
33
|
communities: Amity.InternalCommunity[];
|
|
34
34
|
communityUsers: Amity.Membership<"community">[];
|
|
35
35
|
} & Amity.Pagination;
|
|
36
36
|
};
|
|
37
37
|
export declare const postQueryResponse2: {
|
|
38
|
-
data: Omit<Amity.PostPayload<any>, "
|
|
38
|
+
data: Omit<Amity.PostPayload<any>, "communityUsers" | "communities" | "posts"> & {
|
|
39
39
|
posts: Amity.InternalPost<any>[];
|
|
40
40
|
communities: Amity.InternalCommunity[];
|
|
41
41
|
communityUsers: Amity.Membership<"community">[];
|
|
42
42
|
} & Amity.Pagination;
|
|
43
43
|
};
|
|
44
44
|
export declare const postQueryResponsePage2: {
|
|
45
|
-
data: Omit<Amity.PostPayload<any>, "
|
|
45
|
+
data: Omit<Amity.PostPayload<any>, "communityUsers" | "communities" | "posts"> & {
|
|
46
46
|
posts: Amity.InternalPost<any>[];
|
|
47
47
|
communities: Amity.InternalCommunity[];
|
|
48
48
|
communityUsers: Amity.Membership<"community">[];
|
package/package.json
CHANGED
|
@@ -40,32 +40,15 @@ declare global {
|
|
|
40
40
|
hasFlaggedChildren: false;
|
|
41
41
|
hasFlaggedComment: false;
|
|
42
42
|
editedAt: Amity.timestamp;
|
|
43
|
-
// Amity.Metadata
|
|
44
|
-
metadata?: Record<string, any>;
|
|
45
|
-
// Amity.Flaggable
|
|
46
|
-
flagCount: number;
|
|
47
|
-
hashFlag: {
|
|
48
|
-
bits: number;
|
|
49
|
-
hashes: number;
|
|
50
|
-
hash: string;
|
|
51
|
-
} | null;
|
|
52
|
-
// Amity.Taggable
|
|
53
|
-
tags?: string[];
|
|
54
|
-
// Amity.Timestamps
|
|
55
|
-
createdAt: Amity.timestamp;
|
|
56
|
-
updatedAt?: Amity.timestamp;
|
|
57
|
-
// Amity.SoftDelete
|
|
58
|
-
isDeleted?: boolean;
|
|
59
|
-
// Amity.Subscribable
|
|
60
|
-
path: string;
|
|
61
|
-
// Amity.AnalyticPostData
|
|
62
|
-
impression: number;
|
|
63
|
-
reach: number;
|
|
64
|
-
// Amity.Reactable
|
|
65
|
-
reactionsCount: number;
|
|
66
|
-
reactions: Record<string, number>;
|
|
67
|
-
myReactions?: string[];
|
|
68
43
|
} & Amity.Content<T> &
|
|
44
|
+
Amity.Metadata &
|
|
45
|
+
Amity.Flaggable &
|
|
46
|
+
Amity.Reactable &
|
|
47
|
+
Amity.Taggable &
|
|
48
|
+
Amity.Timestamps &
|
|
49
|
+
Amity.SoftDelete &
|
|
50
|
+
Amity.Subscribable &
|
|
51
|
+
Amity.AnalyticPostData &
|
|
69
52
|
Amity.Mentionable<'user'>;
|
|
70
53
|
|
|
71
54
|
type InternalPost<T extends PostContentType = any> = RawPost<T> & {
|
|
@@ -1,25 +1,3 @@
|
|
|
1
|
-
import { ASCError } from '~/core/errors';
|
|
2
|
-
import { getActiveClient } from './activeClient';
|
|
3
|
-
|
|
4
1
|
export const enableUnreadCount = () => {
|
|
5
|
-
const client = getActiveClient();
|
|
6
|
-
|
|
7
|
-
client.log('client/api/isUnreadCountEnabled', client.isUnreadCountEnabled);
|
|
8
|
-
|
|
9
|
-
if (!client) {
|
|
10
|
-
throw new ASCError(
|
|
11
|
-
'There is no active client',
|
|
12
|
-
Amity.ClientError.UNKNOWN_ERROR,
|
|
13
|
-
Amity.ErrorLevel.FATAL,
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (client.isUnreadCountEnabled) return false;
|
|
18
|
-
|
|
19
|
-
client.isUnreadCountEnabled = true;
|
|
20
|
-
client.useLegacyUnreadCount = false;
|
|
21
|
-
|
|
22
|
-
client.emitter.emit('unreadCountEnabled', true);
|
|
23
|
-
|
|
24
2
|
return true;
|
|
25
3
|
};
|
package/src/client/api/login.ts
CHANGED
|
@@ -26,7 +26,6 @@ import { onTokenTerminated } from '../events/onTokenTerminated';
|
|
|
26
26
|
import { setClientToken } from '../utils/setClientToken';
|
|
27
27
|
import { removeChannelMarkerCache } from '../utils/removeChannelMarkerCache';
|
|
28
28
|
import { initializeMessagePreviewSetting } from '../utils/messagePreviewEngine';
|
|
29
|
-
import { startMarkerSync } from '../utils/markerSyncEngine';
|
|
30
29
|
import { ASCError } from '~/core/errors';
|
|
31
30
|
import SessionWatcher from '../utils/SessionWatcher';
|
|
32
31
|
|
|
@@ -207,9 +206,6 @@ export const login = async (
|
|
|
207
206
|
if (client.useLegacyUnreadCount) {
|
|
208
207
|
subscriptions.push(readReceiptSyncEngineOnLoginHandler());
|
|
209
208
|
} else subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
|
|
210
|
-
|
|
211
|
-
const markerSyncUnsubscriber = await startMarkerSync();
|
|
212
|
-
subscriptions.push(markerSyncUnsubscriber);
|
|
213
209
|
}
|
|
214
210
|
|
|
215
211
|
return true;
|
|
@@ -14,7 +14,6 @@ import { onSubChannelDeleted } from '~/subChannelRepository/events/onSubChannelD
|
|
|
14
14
|
import { isUnreadCountSupport } from '~/subChannelRepository/utils';
|
|
15
15
|
|
|
16
16
|
import { markerSync } from '../api/markerSync';
|
|
17
|
-
import { enableUnreadCount } from '../api/enableUnreadCount';
|
|
18
17
|
|
|
19
18
|
import { onOnline } from './onOnline';
|
|
20
19
|
import { onUserFeedMarkerUpdated } from '~/marker/events/onUserFeedMarkerUpdated';
|
|
@@ -27,7 +26,7 @@ let isSyncRunning = false;
|
|
|
27
26
|
let disposers: (() => void)[] = [];
|
|
28
27
|
let isWaitingForResponse = false;
|
|
29
28
|
|
|
30
|
-
|
|
29
|
+
const isConsistentMode = true;
|
|
31
30
|
let deviceLastSyncAt: Date | null = null;
|
|
32
31
|
|
|
33
32
|
const getDeviceLastSyncAt = () => {
|
|
@@ -178,17 +177,7 @@ const unRegisterEventListeners = () => {
|
|
|
178
177
|
disposers = [];
|
|
179
178
|
};
|
|
180
179
|
|
|
181
|
-
export const startMarkerSync = async () =>
|
|
182
|
-
await fetchDeviceLastSyncAt();
|
|
183
|
-
pushMarkerSyncEvent(Amity.MarkerSyncEvent.START_SYNCING);
|
|
184
|
-
|
|
185
|
-
isConsistentMode = true;
|
|
186
|
-
isSyncRunning = true;
|
|
187
|
-
|
|
188
|
-
registerEventListeners();
|
|
189
|
-
|
|
190
|
-
return unRegisterEventListeners;
|
|
191
|
-
};
|
|
180
|
+
export const startMarkerSync = async () => Promise.resolve();
|
|
192
181
|
|
|
193
182
|
/**
|
|
194
183
|
```js
|
|
@@ -201,17 +190,7 @@ export const startMarkerSync = async () => {
|
|
|
201
190
|
*
|
|
202
191
|
* @category Marker API
|
|
203
192
|
*/
|
|
204
|
-
export const startUnreadSync = async () =>
|
|
205
|
-
await fetchDeviceLastSyncAt();
|
|
206
|
-
pushMarkerSyncEvent(Amity.MarkerSyncEvent.START_SYNCING);
|
|
207
|
-
|
|
208
|
-
enableUnreadCount();
|
|
209
|
-
|
|
210
|
-
isConsistentMode = false;
|
|
211
|
-
isSyncRunning = true;
|
|
212
|
-
|
|
213
|
-
registerEventListeners();
|
|
214
|
-
};
|
|
193
|
+
export const startUnreadSync = async () => Promise.resolve();
|
|
215
194
|
|
|
216
195
|
/**
|
|
217
196
|
```js
|
|
@@ -51,7 +51,7 @@ export const createComment = async (
|
|
|
51
51
|
if (client.cache) ingestInCache(data, { cachedAt });
|
|
52
52
|
|
|
53
53
|
if (['post', 'content'].includes(bundle.referenceType)) {
|
|
54
|
-
const post = pullFromCache<Amity.
|
|
54
|
+
const post = pullFromCache<Amity.Post>(['post', 'get', bundle.referenceId])?.data;
|
|
55
55
|
|
|
56
56
|
if (post) {
|
|
57
57
|
post.commentsCount += 1;
|
|
@@ -62,7 +62,7 @@ export const deleteComment = async (
|
|
|
62
62
|
users: [],
|
|
63
63
|
});
|
|
64
64
|
} else {
|
|
65
|
-
const post = pullFromCache<Amity.
|
|
65
|
+
const post = pullFromCache<Amity.Post>(['post', 'get', comment.data.referenceId])?.data;
|
|
66
66
|
|
|
67
67
|
if (post) {
|
|
68
68
|
let removeCount: number;
|
|
@@ -22,9 +22,7 @@ import { LinkedObject } from '~/utils/linkedObject';
|
|
|
22
22
|
* @category Post API
|
|
23
23
|
* @async
|
|
24
24
|
*/
|
|
25
|
-
export const getPost = async (
|
|
26
|
-
postId: Amity.Post['postId'],
|
|
27
|
-
): Promise<Amity.Cached<Amity.InternalPost>> => {
|
|
25
|
+
export const getPost = async (postId: Amity.Post['postId']): Promise<Amity.Cached<Amity.Post>> => {
|
|
28
26
|
const client = getActiveClient();
|
|
29
27
|
client.log('post/getPost', postId);
|
|
30
28
|
|
|
@@ -56,7 +54,7 @@ export const getPost = async (
|
|
|
56
54
|
const result = posts.find(post => post.postId === postId)!;
|
|
57
55
|
|
|
58
56
|
return {
|
|
59
|
-
data: result,
|
|
57
|
+
data: LinkedObject.post(result),
|
|
60
58
|
cachedAt,
|
|
61
59
|
};
|
|
62
60
|
};
|
|
@@ -74,7 +72,7 @@ export const getPost = async (
|
|
|
74
72
|
*
|
|
75
73
|
* @category Post API
|
|
76
74
|
*/
|
|
77
|
-
getPost.locally = (postId: Amity.Post['postId']): Amity.Cached<Amity.
|
|
75
|
+
getPost.locally = (postId: Amity.Post['postId']): Amity.Cached<Amity.Post> | undefined => {
|
|
78
76
|
const client = getActiveClient();
|
|
79
77
|
client.log('post/getPost.locally', postId);
|
|
80
78
|
|
|
@@ -85,7 +83,7 @@ getPost.locally = (postId: Amity.Post['postId']): Amity.Cached<Amity.InternalPos
|
|
|
85
83
|
if (!cached) return;
|
|
86
84
|
|
|
87
85
|
return {
|
|
88
|
-
data: cached.data,
|
|
86
|
+
data: LinkedObject.post(cached.data),
|
|
89
87
|
cachedAt: cached.cachedAt,
|
|
90
88
|
};
|
|
91
89
|
};
|
|
@@ -85,12 +85,12 @@ export const getPost = (
|
|
|
85
85
|
onPostFlagged,
|
|
86
86
|
(callback: Amity.Listener<Amity.InternalPost>) => {
|
|
87
87
|
return onPostReactionAdded((post: Amity.InternalPost) => {
|
|
88
|
-
callback(post);
|
|
88
|
+
callback(LinkedObject.post(post));
|
|
89
89
|
});
|
|
90
90
|
},
|
|
91
91
|
(callback: Amity.Listener<Amity.InternalPost>) => {
|
|
92
92
|
return onPostReactionRemoved((post: Amity.InternalPost) => {
|
|
93
|
-
callback(post);
|
|
93
|
+
callback(LinkedObject.post(post));
|
|
94
94
|
});
|
|
95
95
|
},
|
|
96
96
|
onPostUnflagged,
|
|
@@ -12,10 +12,10 @@ import { BlockedUserLiveCollectionController } from './getBlockedUsers/BlockedUs
|
|
|
12
12
|
* const unblockedUser = await UserRepository.blockUser('userId')
|
|
13
13
|
* ```
|
|
14
14
|
*
|
|
15
|
-
* Blocks a {@link Amity.
|
|
15
|
+
* Blocks a {@link Amity.InternalUser}
|
|
16
16
|
*
|
|
17
|
-
* @param params The params to get blocked {@link Amity.
|
|
18
|
-
* @param callback to recieve updates on unblocked {@link Amity.
|
|
17
|
+
* @param params The params to get blocked {@link Amity.InternalUser}s
|
|
18
|
+
* @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
|
|
19
19
|
* @returns {@link Amity.Unsubscriber} to unsubscribe from collection
|
|
20
20
|
*
|
|
21
21
|
* @category Post API
|
|
@@ -23,7 +23,7 @@ import { BlockedUserLiveCollectionController } from './getBlockedUsers/BlockedUs
|
|
|
23
23
|
*/
|
|
24
24
|
export const getBlockedUsers = (
|
|
25
25
|
params: Amity.BlockedUsersLiveCollection,
|
|
26
|
-
callback: Amity.LiveCollectionCallback<Amity.
|
|
26
|
+
callback: Amity.LiveCollectionCallback<Amity.InternalUser>,
|
|
27
27
|
config?: Amity.LiveCollectionConfig,
|
|
28
28
|
): Amity.Unsubscriber => {
|
|
29
29
|
const { log, cache } = getActiveClient();
|
|
@@ -9,7 +9,7 @@ export const streamLinkedObject = (stream: Amity.InternalStream): Amity.Stream =
|
|
|
9
9
|
},
|
|
10
10
|
get post() {
|
|
11
11
|
if (stream.referenceType !== 'post') return;
|
|
12
|
-
return pullFromCache<Amity.
|
|
12
|
+
return pullFromCache<Amity.Post>(['post', 'get', stream.referenceId])?.data;
|
|
13
13
|
},
|
|
14
14
|
get community() {
|
|
15
15
|
if (stream.targetType !== 'community') return;
|