@amityco/ts-sdk 6.19.0 → 6.19.1-8eb4382.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/.env +26 -26
- package/dist/@types/domains/client.d.ts +1 -2
- package/dist/@types/domains/client.d.ts.map +1 -1
- package/dist/@types/domains/story.d.ts +1 -1
- package/dist/@types/domains/story.d.ts.map +1 -1
- package/dist/client/utils/setClientToken.d.ts +0 -1
- package/dist/client/utils/setClientToken.d.ts.map +1 -1
- package/dist/communityRepository/utils/payload.d.ts.map +1 -1
- package/dist/index.cjs.js +40 -33
- package/dist/index.esm.js +40 -33
- package/dist/index.umd.js +2 -2
- package/dist/reactionRepository/utils/prepareReactionPayloadFormEvent.d.ts.map +1 -1
- package/dist/utils/tests/client.d.ts.map +1 -1
- package/dist/utils/tests/dummy/token.d.ts +0 -1
- package/dist/utils/tests/dummy/token.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/@types/domains/client.ts +1 -2
- package/src/@types/domains/story.ts +1 -1
- package/src/client/api/getToken.ts +1 -1
- package/src/client/api/tests/getToken.test.ts +2 -2
- package/src/client/api/tests/renewal.test.ts +0 -1
- package/src/client/utils/setClientToken.ts +2 -2
- package/src/communityRepository/utils/payload.ts +4 -1
- package/src/core/transports/http.ts +1 -1
- package/src/core/transports/tests/http.test.ts +2 -2
- package/src/external/api/createUserToken.ts +1 -1
- package/src/external/api/tests/createUserToken.test.ts +0 -1
- package/src/reactionRepository/utils/prepareReactionPayloadFormEvent.ts +8 -1
- package/src/utils/tests/client.ts +0 -1
- package/src/utils/tests/dummy/token.ts +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prepareReactionPayloadFormEvent.d.ts","sourceRoot":"","sources":["../../../src/reactionRepository/utils/prepareReactionPayloadFormEvent.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/utils/tests/client.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,YAAS,CAAC;AAYjC,eAAO,MAAM,MAAM,cAA4B,CAAC;AAMhD,eAAO,MAAM,aAAa,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/utils/tests/client.ts"],"names":[],"mappings":"AAUA,eAAO,MAAM,UAAU,YAAS,CAAC;AAYjC,eAAO,MAAM,MAAM,cAA4B,CAAC;AAMhD,eAAO,MAAM,aAAa,qBAuBzB,CAAC;AAEF,eAAO,MAAM,gBAAgB,qBAE5B,CAAC;;AAEF,wBAAkB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/token.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe
|
|
1
|
+
{"version":3,"file":"token.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/token.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;CAQ3B,CAAC"}
|
package/package.json
CHANGED
|
@@ -52,7 +52,7 @@ declare global {
|
|
|
52
52
|
apiKey?: string;
|
|
53
53
|
userId?: string;
|
|
54
54
|
|
|
55
|
-
token?:
|
|
55
|
+
token?: Amity.Tokens;
|
|
56
56
|
|
|
57
57
|
isUnreadCountEnabled: boolean;
|
|
58
58
|
|
|
@@ -78,7 +78,6 @@ declare global {
|
|
|
78
78
|
|
|
79
79
|
type Tokens = {
|
|
80
80
|
accessToken: string;
|
|
81
|
-
refreshToken: string;
|
|
82
81
|
// issuedAt, expiresAt is in iso Date format
|
|
83
82
|
issuedAt: string;
|
|
84
83
|
expiresAt: string;
|
|
@@ -8,8 +8,8 @@ describe('getToken', () => {
|
|
|
8
8
|
const deviceId = 'test-deviceId';
|
|
9
9
|
const params = { userId, displayName, deviceId };
|
|
10
10
|
|
|
11
|
-
test('it should call
|
|
12
|
-
const expected = '/api/
|
|
11
|
+
test('it should call v5/sessions api', async () => {
|
|
12
|
+
const expected = '/api/v5/sessions';
|
|
13
13
|
const mockApi = jest.fn().mockResolvedValue(sessionResponse);
|
|
14
14
|
client.http.post = mockApi;
|
|
15
15
|
|
|
@@ -19,7 +19,7 @@ export const setClientToken = async (params: Parameters<typeof getToken>[0]) =>
|
|
|
19
19
|
// begin establishing session
|
|
20
20
|
setSessionState(Amity.SessionStates.ESTABLISHING);
|
|
21
21
|
|
|
22
|
-
const { accessToken, users, expiresAt, issuedAt
|
|
22
|
+
const { accessToken, users, expiresAt, issuedAt } = await getToken(params);
|
|
23
23
|
|
|
24
24
|
// manually setup the token for http transport
|
|
25
25
|
client.http.defaults.headers.common.Authorization = `Bearer ${accessToken}`;
|
|
@@ -37,5 +37,5 @@ export const setClientToken = async (params: Parameters<typeof getToken>[0]) =>
|
|
|
37
37
|
|
|
38
38
|
setSessionState(Amity.SessionStates.ESTABLISHED);
|
|
39
39
|
|
|
40
|
-
return { accessToken, users
|
|
40
|
+
return { accessToken, users };
|
|
41
41
|
};
|
|
@@ -53,6 +53,9 @@ export const prepareCommunityRequest = <
|
|
|
53
53
|
// Repack community payload by mapping postSetting to the actual value.
|
|
54
54
|
...(postSetting ? CommunityPostSettingMaps[postSetting] : undefined),
|
|
55
55
|
// Convert story setting to the actual value. (Allow by default)
|
|
56
|
-
allowCommentInStory:
|
|
56
|
+
allowCommentInStory:
|
|
57
|
+
typeof storySetting?.enableComment === 'boolean'
|
|
58
|
+
? storySetting?.enableComment !== false
|
|
59
|
+
: true,
|
|
57
60
|
};
|
|
58
61
|
};
|
|
@@ -101,7 +101,7 @@ export const createHttpTransport = (endpoint: string) => {
|
|
|
101
101
|
|
|
102
102
|
instance.interceptors.request.use(config => {
|
|
103
103
|
// do not check expiration for token creation url
|
|
104
|
-
if (config.url === '/api/
|
|
104
|
+
if (config.url === '/api/v5/sessions') {
|
|
105
105
|
return config;
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -72,7 +72,7 @@ describe('core/transports', () => {
|
|
|
72
72
|
|
|
73
73
|
test('should not check token expiration for token creation url', async () => {
|
|
74
74
|
const expectedResolveValue = { foo: 'bar' };
|
|
75
|
-
nock(baseUrl).get('/api/
|
|
75
|
+
nock(baseUrl).get('/api/v5/sessions').reply(200, expectedResolveValue);
|
|
76
76
|
|
|
77
77
|
const instance = createHttpTransport(baseUrl);
|
|
78
78
|
instance.defaults.metadata = {
|
|
@@ -82,7 +82,7 @@ describe('core/transports', () => {
|
|
|
82
82
|
};
|
|
83
83
|
|
|
84
84
|
const expected = expect.objectContaining({ data: expectedResolveValue });
|
|
85
|
-
await expect(instance.get('/api/
|
|
85
|
+
await expect(instance.get('/api/v5/sessions')).resolves.toEqual(expected);
|
|
86
86
|
});
|
|
87
87
|
|
|
88
88
|
test('it should throw error is user is global banned', async () => {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { pullFromCache } from '~/cache/api';
|
|
2
2
|
import { getActiveClient } from '~/client/api';
|
|
3
|
+
import { updateMembershipStatus } from '~/communityRepository/utils/communityWithMembership';
|
|
3
4
|
|
|
4
5
|
const getMyReactionsInCache = <
|
|
5
6
|
T extends Amity.PostPayload | Amity.CommentPayload | Amity.StoryPayload,
|
|
@@ -113,5 +114,11 @@ export const prepareStoryReactionPayloadFormEvent = <
|
|
|
113
114
|
);
|
|
114
115
|
}
|
|
115
116
|
|
|
116
|
-
|
|
117
|
+
// Rebuild the payload with the new myReactions
|
|
118
|
+
const newPayload = rebuildPayload(payload, 'stories', myReactions);
|
|
119
|
+
|
|
120
|
+
if (!payload?.communities || !payload?.communityUsers) return newPayload;
|
|
121
|
+
|
|
122
|
+
const communities = updateMembershipStatus(payload.communities, payload.communityUsers);
|
|
123
|
+
return { ...newPayload, communities };
|
|
117
124
|
};
|
|
@@ -36,7 +36,6 @@ export const connectClient = async () => {
|
|
|
36
36
|
client.http.post = jest.fn().mockReturnValueOnce({
|
|
37
37
|
data: {
|
|
38
38
|
accessToken: 'accessToken',
|
|
39
|
-
refreshToken: 'refreshToken',
|
|
40
39
|
users: [activeUser],
|
|
41
40
|
expiresAt: nextMonth.toISOString(),
|
|
42
41
|
issuedAt: now.toISOString(),
|