@amityco/ts-sdk 6.21.1-dafa2c1.0 → 6.21.1
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/.env +26 -26
- package/dist/client/api/index.d.ts +0 -1
- package/dist/client/api/index.d.ts.map +1 -1
- package/dist/client/api/logout.d.ts +2 -2
- package/dist/commentRepository/events/onCommentReactionRemoved.d.ts.map +1 -1
- package/dist/index.cjs.js +23 -43
- package/dist/index.esm.js +23 -43
- package/dist/index.umd.js +4 -4
- package/dist/postRepository/observers/getPost.d.ts.map +1 -1
- package/dist/reactionRepository/utils/index.d.ts +1 -1
- package/dist/reactionRepository/utils/{prepareReactionPayloadFormEvent.d.ts → prepareReactionPayloadFromEvent.d.ts} +2 -2
- package/dist/reactionRepository/utils/prepareReactionPayloadFromEvent.d.ts.map +1 -0
- package/package.json +1 -1
- package/src/client/api/index.ts +0 -1
- package/src/client/api/logout.ts +2 -2
- package/src/commentRepository/events/onCommentReactionAdded.ts +2 -2
- package/src/commentRepository/events/onCommentReactionRemoved.ts +3 -2
- package/src/commentRepository/events/utils.ts +1 -1
- package/src/postRepository/events/onPostReactionAdded.ts +2 -2
- package/src/postRepository/events/onPostReactionRemoved.ts +2 -2
- package/src/postRepository/observers/getPost.ts +12 -2
- package/src/reactionRepository/utils/index.ts +1 -1
- package/src/reactionRepository/utils/{prepareReactionPayloadFormEvent.ts → prepareReactionPayloadFromEvent.ts} +1 -1
- package/src/subChannelRepository/observers/getSubChannel.ts +1 -1
- package/src/utils/linkedObject/postLinkedObject.ts +2 -2
- package/dist/client/api/secureLogout.d.ts +0 -15
- package/dist/client/api/secureLogout.d.ts.map +0 -1
- package/dist/reactionRepository/utils/prepareReactionPayloadFormEvent.d.ts.map +0 -1
- package/src/client/api/secureLogout.ts +0 -33
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/observers/getPost.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/observers/getPost.ts"],"names":[],"mappings":"AAmBA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,OAAO,WACV,MAAM,IAAI,CAAC,QAAQ,CAAC,YAClB,MAAM,kBAAkB,CAAC,MAAM,IAAI,CAAC,KAC7C,MAAM,YA0CR,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @hidden */
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const prepareReactionPayloadFromEvent: <T extends "post.addReaction" | "post.removeReaction" | "comment.addReaction" | "comment.removeReaction", P extends Amity.Events[T]>(event: T, payload: P) => P;
|
|
3
3
|
export declare const prepareStoryReactionPayloadFormEvent: <T extends "story.reactionAdded" | "story.reactionRemoved", P extends Amity.Events[T]>(event: T, payload: P) => P;
|
|
4
4
|
export declare const prepareCommentFromFlaggedEvent: (payload: Amity.CommentPayload) => Amity.CommentPayload<any> & {
|
|
5
5
|
[x: string]: any[];
|
|
6
6
|
};
|
|
7
|
-
//# sourceMappingURL=
|
|
7
|
+
//# sourceMappingURL=prepareReactionPayloadFromEvent.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareReactionPayloadFromEvent.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/utils/prepareReactionPayloadFromEvent.ts"],"names":[],"mappings":"AAsEA,cAAc;AACd,eAAO,MAAM,+BAA+B,iKAuB3C,CAAC;AAEF,eAAO,MAAM,oCAAoC,mHA2BhD,CAAC;AAEF,eAAO,MAAM,8BAA8B,YAAa,MAAM,cAAc;;CAG3E,CAAC"}
|
package/package.json
CHANGED
package/src/client/api/index.ts
CHANGED
package/src/client/api/logout.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { setSessionState } from './setSessionState';
|
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
8
8
|
* ```js
|
|
9
|
-
* import {
|
|
10
|
-
* const success = await
|
|
9
|
+
* import { disconnectClient } from '@amityco/ts-sdk'
|
|
10
|
+
* const success = await disconnectClient()
|
|
11
11
|
* ```
|
|
12
12
|
*
|
|
13
13
|
* Disconnects an {@link Amity.Client} instance from ASC servers
|
|
@@ -2,7 +2,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
2
2
|
import { pullFromCache } from '~/cache/api';
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { createEventSubscriber } from '~/core/events';
|
|
5
|
-
import {
|
|
5
|
+
import { prepareReactionPayloadFromEvent } from '~/reactionRepository/utils';
|
|
6
6
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -29,7 +29,7 @@ export const onCommentReactionAdded = (
|
|
|
29
29
|
if (!client.cache) {
|
|
30
30
|
callback(LinkedObject.comment(payload.comments[0]));
|
|
31
31
|
} else {
|
|
32
|
-
const processed =
|
|
32
|
+
const processed = prepareReactionPayloadFromEvent('comment.addReaction', payload);
|
|
33
33
|
const { reactor, ...commentPayload } = processed;
|
|
34
34
|
|
|
35
35
|
ingestInCache(commentPayload as Amity.CommentPayload);
|
|
@@ -2,8 +2,9 @@ import { getActiveClient } from '~/client/api';
|
|
|
2
2
|
import { pullFromCache } from '~/cache/api';
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { createEventSubscriber } from '~/core/events';
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
7
|
+
import { prepareReactionPayloadFromEvent } from '~/reactionRepository/utils';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* ```js
|
|
@@ -29,7 +30,7 @@ export const onCommentReactionRemoved = (
|
|
|
29
30
|
if (!client.cache) {
|
|
30
31
|
callback(LinkedObject.comment(payload.comments[0]));
|
|
31
32
|
} else {
|
|
32
|
-
const processed =
|
|
33
|
+
const processed = prepareReactionPayloadFromEvent('comment.removeReaction', payload);
|
|
33
34
|
const { reactor, ...commentPayload } = processed;
|
|
34
35
|
|
|
35
36
|
ingestInCache(commentPayload as Amity.CommentPayload);
|
|
@@ -3,7 +3,7 @@ import { createEventSubscriber } from '~/core/events';
|
|
|
3
3
|
import { pullFromCache, pushToCache, queryCache, upsertInCache } from '~/cache/api';
|
|
4
4
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
5
5
|
import { LinkedObject } from '~/utils/linkedObject';
|
|
6
|
-
import { prepareCommentFromFlaggedEvent } from '~/reactionRepository/utils/
|
|
6
|
+
import { prepareCommentFromFlaggedEvent } from '~/reactionRepository/utils/prepareReactionPayloadFromEvent';
|
|
7
7
|
|
|
8
8
|
export const createCommentEventSubscriber = (
|
|
9
9
|
event: keyof Amity.MqttCommentEvents,
|
|
@@ -2,7 +2,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
2
2
|
import { pullFromCache } from '~/cache/api';
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { createEventSubscriber } from '~/core/events';
|
|
5
|
-
import {
|
|
5
|
+
import { prepareReactionPayloadFromEvent } from '~/reactionRepository/utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* ```js
|
|
@@ -28,7 +28,7 @@ export const onPostReactionAdded = (
|
|
|
28
28
|
if (!client.cache) {
|
|
29
29
|
callback(payload.posts[0]);
|
|
30
30
|
} else {
|
|
31
|
-
const processed =
|
|
31
|
+
const processed = prepareReactionPayloadFromEvent('post.addReaction', payload);
|
|
32
32
|
const { reactor, ...postPayload } = processed;
|
|
33
33
|
|
|
34
34
|
ingestInCache(postPayload as Amity.ProcessedPostPayload);
|
|
@@ -2,7 +2,7 @@ import { getActiveClient } from '~/client/api';
|
|
|
2
2
|
import { pullFromCache } from '~/cache/api';
|
|
3
3
|
import { ingestInCache } from '~/cache/api/ingestInCache';
|
|
4
4
|
import { createEventSubscriber } from '~/core/events';
|
|
5
|
-
import {
|
|
5
|
+
import { prepareReactionPayloadFromEvent } from '~/reactionRepository/utils';
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* ```js
|
|
@@ -28,7 +28,7 @@ export const onPostReactionRemoved = (
|
|
|
28
28
|
if (!client.cache) {
|
|
29
29
|
callback(payload.posts[0]);
|
|
30
30
|
} else {
|
|
31
|
-
const processed =
|
|
31
|
+
const processed = prepareReactionPayloadFromEvent('post.removeReaction', payload);
|
|
32
32
|
const { reactor, ...postPayload } = processed;
|
|
33
33
|
|
|
34
34
|
ingestInCache(postPayload as Amity.ProcessedPostPayload);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { on } from 'events';
|
|
1
2
|
import { liveObject } from '~/utils/liveObject';
|
|
2
3
|
import { getPost as _getPost } from '../api/getPost';
|
|
3
4
|
import {
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
onPostUpdated,
|
|
12
13
|
} from '../events';
|
|
13
14
|
import { pullFromCache, pushToCache } from '~/cache/api';
|
|
15
|
+
import { LinkedObject } from '~/utils/linkedObject';
|
|
14
16
|
|
|
15
17
|
/* begin_public_function
|
|
16
18
|
id: post.get
|
|
@@ -66,8 +68,16 @@ export const getPost = (
|
|
|
66
68
|
});
|
|
67
69
|
},
|
|
68
70
|
onPostFlagged,
|
|
69
|
-
|
|
70
|
-
|
|
71
|
+
(callback: Amity.Listener<Amity.InternalPost>) => {
|
|
72
|
+
return onPostReactionAdded((post: Amity.InternalPost) => {
|
|
73
|
+
callback(LinkedObject.post(post));
|
|
74
|
+
});
|
|
75
|
+
},
|
|
76
|
+
(callback: Amity.Listener<Amity.InternalPost>) => {
|
|
77
|
+
return onPostReactionRemoved((post: Amity.InternalPost) => {
|
|
78
|
+
callback(LinkedObject.post(post));
|
|
79
|
+
});
|
|
80
|
+
},
|
|
71
81
|
onPostUnflagged,
|
|
72
82
|
onPostUpdated,
|
|
73
83
|
]);
|
|
@@ -4,7 +4,7 @@ import { liveObject } from '~/utils/liveObject';
|
|
|
4
4
|
import { getSubChannel as _getSubChannel } from '../api/getSubChannel';
|
|
5
5
|
import { onSubChannelDeleted, onSubChannelUpdated } from '../events';
|
|
6
6
|
import { onSubChannelFetched } from '../events/onSubChannelFetched';
|
|
7
|
-
import { pullFromCache
|
|
7
|
+
import { pullFromCache } from '~/cache/api';
|
|
8
8
|
import {
|
|
9
9
|
onMessageCreatedLocal,
|
|
10
10
|
onMessageCreatedMqtt,
|
|
@@ -32,8 +32,8 @@ export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
|
|
|
32
32
|
},
|
|
33
33
|
get creator(): Amity.User | undefined {
|
|
34
34
|
const cacheData = pullFromCache<Amity.User>(['user', 'get', post.postedUserId]);
|
|
35
|
-
if (cacheData?.data) return
|
|
36
|
-
return
|
|
35
|
+
if (!cacheData?.data) return;
|
|
36
|
+
return userLinkedObject(cacheData.data);
|
|
37
37
|
},
|
|
38
38
|
};
|
|
39
39
|
};
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* ```js
|
|
3
|
-
* import { Client } from '@amityco/ts-sdk'
|
|
4
|
-
* const success = await Client.secureLogout()
|
|
5
|
-
* ```
|
|
6
|
-
*
|
|
7
|
-
* Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
|
|
8
|
-
*
|
|
9
|
-
* @returns a success boolean if disconnected
|
|
10
|
-
*
|
|
11
|
-
* @category Client API
|
|
12
|
-
* @async
|
|
13
|
-
*/
|
|
14
|
-
export declare const secureLogout: () => Promise<boolean>;
|
|
15
|
-
//# sourceMappingURL=secureLogout.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"secureLogout.d.ts","sourceRoot":"","sources":["../../../src/client/api/secureLogout.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,YAAY,QAAa,QAAQ,OAAO,CAYpD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"prepareReactionPayloadFormEvent.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/utils/prepareReactionPayloadFormEvent.ts"],"names":[],"mappings":"AAsEA,cAAc;AACd,eAAO,MAAM,+BAA+B,iKAuB3C,CAAC;AAEF,eAAO,MAAM,oCAAoC,mHA2BhD,CAAC;AAEF,eAAO,MAAM,8BAA8B,YAAa,MAAM,cAAc;;CAG3E,CAAC"}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { getActiveClient } from '~/client/api/activeClient';
|
|
2
|
-
import { logout } from './logout';
|
|
3
|
-
|
|
4
|
-
/* begin_public_function
|
|
5
|
-
id: client.secureLogout
|
|
6
|
-
*/
|
|
7
|
-
/**
|
|
8
|
-
* ```js
|
|
9
|
-
* import { Client } from '@amityco/ts-sdk'
|
|
10
|
-
* const success = await Client.secureLogout()
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Revoke access token for current user and disconnects an {@link Amity.Client} instance from ASC servers
|
|
14
|
-
*
|
|
15
|
-
* @returns a success boolean if disconnected
|
|
16
|
-
*
|
|
17
|
-
* @category Client API
|
|
18
|
-
* @async
|
|
19
|
-
*/
|
|
20
|
-
export const secureLogout = async (): Promise<boolean> => {
|
|
21
|
-
const client = getActiveClient();
|
|
22
|
-
const {
|
|
23
|
-
data: { success },
|
|
24
|
-
} = await client.http.delete<{ success: boolean }>('/api/v4/sessions');
|
|
25
|
-
|
|
26
|
-
if (!success) {
|
|
27
|
-
throw new Error('Failed to logout');
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const result = await logout();
|
|
31
|
-
return result;
|
|
32
|
-
};
|
|
33
|
-
/* end_public_function */
|