@amityco/ts-sdk 7.4.1-0e170b02.0 → 7.4.1-18d364a3.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.
@@ -1 +1 @@
1
- {"version":3,"file":"joinRequestLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/joinRequestLinkedObject.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,gBACrB,MAAM,mBAAmB,KACrC,MAAM,WAkBR,CAAC"}
1
+ {"version":3,"file":"joinRequestLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/joinRequestLinkedObject.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB,gBACrB,MAAM,mBAAmB,KACrC,MAAM,WAsBR,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "7.4.1-0e170b02.0",
3
+ "version": "7.4.1-18d364a3.0",
4
4
  "license": "CC-BY-ND-4.0",
5
5
  "author": "amity.co <developers@amity.co> (https://amity.co)",
6
6
  "description": "Amity Social Cloud Typescript SDK",
@@ -35,10 +35,10 @@ declare global {
35
35
  requestorInternalId: string;
36
36
  requestorPublicId: string;
37
37
 
38
- respondedAt: Amity.timestamp;
39
- responderId: string;
40
- responderInternalId: string;
41
- responderPublicId: string;
38
+ respondedAt: Amity.timestamp | null;
39
+ responderId: string | null;
40
+ responderInternalId: string | null;
41
+ responderPublicId: string | null;
42
42
 
43
43
  status: Amity.JoinRequestStatus;
44
44
  targetId: string;
@@ -10,6 +10,7 @@ declare global {
10
10
  POST_REACT = 'reaction_on_post',
11
11
  COMMENT_REACT = 'reaction_on_comment',
12
12
  REPLY_REACT = 'reaction_on_reply',
13
+ RESPONSE_JOIN_REQUEST = 'respond_on_join_request',
13
14
  }
14
15
 
15
16
  const enum TrayAction {
@@ -19,6 +20,7 @@ declare global {
19
20
  REACTION = 'reaction',
20
21
  MENTION = 'mention',
21
22
  REPLY = 'reply',
23
+ JOIN_REQUEST = 'join_request',
22
24
  }
23
25
 
24
26
  type RawNotificationTrayItem = {
@@ -2,7 +2,7 @@ import { getActiveClient } from '~/client/api/activeClient';
2
2
  import { ingestInCache } from '~/cache/api/ingestInCache';
3
3
  import { prepareCommunityJoinRequestPayload } from '~/communityRepository/utils';
4
4
  import { fireEvent } from '~/core/events';
5
- import { JoinResultStatusEnum } from '~/@types/domains/joinRequest';
5
+ import { JoinRequestStatusEnum, JoinResultStatusEnum } from '~/@types/domains/joinRequest';
6
6
  import { joinRequestLinkedObject } from '~/utils/linkedObject/joinRequestLinkedObject';
7
7
 
8
8
  /* begin_public_function
@@ -40,7 +40,9 @@ export const joinRequest = async (
40
40
  fireEvent('local.community.join', data.joinRequests);
41
41
 
42
42
  const status =
43
- data.joinRequests.length === 0 ? JoinResultStatusEnum.Success : JoinResultStatusEnum.Pending;
43
+ data.joinRequests[0].status === JoinRequestStatusEnum.Approved
44
+ ? JoinResultStatusEnum.Success
45
+ : JoinResultStatusEnum.Pending;
44
46
 
45
47
  return status === JoinResultStatusEnum.Success
46
48
  ? { status }
@@ -29,14 +29,10 @@ export const approveJoinRequest = async (
29
29
  const { data } = await client.http.post<{ success: boolean }>(
30
30
  `/api/v4/communities/${joinRequest.targetId}/join/approve`,
31
31
  {
32
- params: {
33
- userId: joinRequest.userId,
34
- },
32
+ userId: joinRequest.requestorInternalId,
35
33
  },
36
34
  );
37
35
 
38
- // TODO : Check cache id
39
-
40
36
  const joinRequestCache = pullFromCache<Amity.InternalJoinRequest>([
41
37
  'joinRequest',
42
38
  'get',
@@ -27,11 +27,6 @@ export const cancelJoinRequest = async (
27
27
 
28
28
  const { data } = await client.http.delete<{ success: boolean }>(
29
29
  `/api/v4/communities/${joinRequest.targetId}/join`,
30
- {
31
- params: {
32
- userId: joinRequest.userId,
33
- },
34
- },
35
30
  );
36
31
 
37
32
  const joinRequestCache = pullFromCache<Amity.InternalJoinRequest>([
@@ -28,6 +28,9 @@ export const rejectJoinRequest = async (
28
28
 
29
29
  const { data } = await client.http.post<{ success: boolean }>(
30
30
  `/api/v4/communities/${joinRequest.targetId}/join/reject`,
31
+ {
32
+ userId: joinRequest.requestorInternalId,
33
+ },
31
34
  );
32
35
 
33
36
  const joinRequestCache = pullFromCache<Amity.InternalJoinRequest>([
@@ -56,6 +56,7 @@ export const PAYLOAD2MODEL: Record<string, Amity.Domain> = {
56
56
  notificationTrayItems: 'notificationTrayItem',
57
57
 
58
58
  invitations: 'invitation',
59
+ joinRequests: 'joinRequest',
59
60
  };
60
61
 
61
62
  /** hidden */
@@ -9,10 +9,14 @@ export const joinRequestLinkedObject = (
9
9
  ): Amity.JoinRequest => {
10
10
  return {
11
11
  ...joinRequest,
12
- get user() {
13
- const cacheData = pullFromCache<Amity.User>(['user', 'get', joinRequest.userId]);
14
- if (cacheData?.data) return userLinkedObject(cacheData.data);
15
- return undefined;
12
+ get user(): Amity.User | undefined {
13
+ const user = pullFromCache<Amity.InternalUser>([
14
+ 'user',
15
+ 'get',
16
+ joinRequest.requestorPublicId,
17
+ ])?.data;
18
+ if (!user) return undefined;
19
+ return userLinkedObject(user);
16
20
  },
17
21
  cancel: async () => {
18
22
  await cancelJoinRequest(joinRequest);