@amityco/ts-sdk 7.5.4-2d34fd5f.0 → 7.5.4-54f750e3.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.
Files changed (79) hide show
  1. package/dist/@types/domains/channel.d.ts +1 -0
  2. package/dist/@types/domains/channel.d.ts.map +1 -1
  3. package/dist/@types/domains/content.d.ts +2 -8
  4. package/dist/@types/domains/content.d.ts.map +1 -1
  5. package/dist/@types/domains/feed.d.ts +1 -2
  6. package/dist/@types/domains/feed.d.ts.map +1 -1
  7. package/dist/@types/domains/file.d.ts +1 -3
  8. package/dist/@types/domains/file.d.ts.map +1 -1
  9. package/dist/@types/domains/group.d.ts +2 -0
  10. package/dist/@types/domains/group.d.ts.map +1 -1
  11. package/dist/@types/domains/invitation.d.ts +4 -2
  12. package/dist/@types/domains/invitation.d.ts.map +1 -1
  13. package/dist/@types/domains/post.d.ts +0 -3
  14. package/dist/@types/domains/post.d.ts.map +1 -1
  15. package/dist/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.d.ts.map +1 -1
  16. package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.d.ts.map +1 -1
  17. package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.d.ts +2 -2
  18. package/dist/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.d.ts.map +1 -1
  19. package/dist/client/api/index.d.ts +1 -0
  20. package/dist/client/api/index.d.ts.map +1 -1
  21. package/dist/client/api/resumeSession.d.ts +32 -0
  22. package/dist/client/api/resumeSession.d.ts.map +1 -0
  23. package/dist/client/api/tests/resumeSession.test.d.ts +2 -0
  24. package/dist/client/api/tests/resumeSession.test.d.ts.map +1 -0
  25. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +1 -1
  26. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
  27. package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  28. package/dist/fileRepository/api/index.d.ts +0 -1
  29. package/dist/fileRepository/api/index.d.ts.map +1 -1
  30. package/dist/index.cjs.js +223 -129
  31. package/dist/index.esm.js +222 -129
  32. package/dist/index.umd.js +4 -4
  33. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  34. package/dist/postRepository/api/index.d.ts +0 -1
  35. package/dist/postRepository/api/index.d.ts.map +1 -1
  36. package/dist/utils/linkedObject/channelLinkedObject.d.ts.map +1 -1
  37. package/dist/utils/linkedObject/channelMemberLinkedObject.d.ts +2 -0
  38. package/dist/utils/linkedObject/channelMemberLinkedObject.d.ts.map +1 -0
  39. package/dist/utils/linkedObject/index.d.ts +1 -0
  40. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  41. package/dist/utils/linkedObject/invitationLinkedObject.d.ts.map +1 -1
  42. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  43. package/dist/utils/postTypePredicate.d.ts +0 -1
  44. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  45. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  46. package/dist/utils/tests/dummy/community.d.ts +2 -0
  47. package/dist/utils/tests/dummy/community.d.ts.map +1 -1
  48. package/package.json +2 -1
  49. package/src/@types/domains/channel.ts +1 -0
  50. package/src/@types/domains/content.ts +0 -10
  51. package/src/@types/domains/feed.ts +1 -2
  52. package/src/@types/domains/file.ts +0 -5
  53. package/src/@types/domains/group.ts +2 -0
  54. package/src/@types/domains/invitation.ts +8 -3
  55. package/src/@types/domains/post.ts +0 -4
  56. package/src/channelRepository/channelMembership/observers/getMembers/ChannelMemberLiveCollectionController.ts +3 -1
  57. package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberLiveCollectionController.ts +2 -1
  58. package/src/channelRepository/channelMembership/observers/searchMembers/SearchChannelMemberQueryStreamController.ts +2 -2
  59. package/src/client/api/index.ts +1 -0
  60. package/src/client/api/resumeSession.ts +282 -0
  61. package/src/client/api/tests/resumeSession.test.ts +173 -0
  62. package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +1 -1
  63. package/src/feedRepository/api/queryGlobalFeed.ts +1 -3
  64. package/src/fileRepository/api/index.ts +0 -1
  65. package/src/postRepository/api/index.ts +0 -2
  66. package/src/postRepository/api/queryPosts.ts +1 -1
  67. package/src/postRepository/observers/getPosts/PostPaginationController.ts +1 -1
  68. package/src/utils/linkedObject/channelLinkedObject.ts +19 -0
  69. package/src/utils/linkedObject/channelMemberLinkedObject.ts +20 -0
  70. package/src/utils/linkedObject/index.ts +2 -0
  71. package/src/utils/linkedObject/invitationLinkedObject.ts +4 -2
  72. package/src/utils/linkedObject/postLinkedObject.ts +1 -12
  73. package/src/utils/postTypePredicate.ts +0 -10
  74. package/dist/fileRepository/api/uploadClip.d.ts +0 -17
  75. package/dist/fileRepository/api/uploadClip.d.ts.map +0 -1
  76. package/dist/postRepository/api/createClipPost.d.ts +0 -32
  77. package/dist/postRepository/api/createClipPost.d.ts.map +0 -1
  78. package/src/fileRepository/api/uploadClip.ts +0 -71
  79. package/src/postRepository/api/createClipPost.ts +0 -62
@@ -3,7 +3,7 @@ export declare const getSubChannelMessagePreviewWithUser: (subChannel: Amity.Sub
3
3
  user: Amity.InternalUser | undefined;
4
4
  messagePreviewId: string;
5
5
  subChannelName: string;
6
- data?: string | Amity.ContentDataText | Amity.ContentDataFile | Amity.ContentDataImage | Amity.ContentDataVideo | Amity.ContentDataPoll | Amity.ContentDataStream | Amity.ContentDataClip | Record<string, unknown> | undefined;
6
+ data?: string | Amity.ContentDataText | Amity.ContentDataFile | Amity.ContentDataImage | Amity.ContentDataVideo | Amity.ContentDataPoll | Amity.ContentDataStream | Record<string, unknown> | undefined;
7
7
  dataType?: any;
8
8
  channelId: string;
9
9
  subChannelId: string;
@@ -9,5 +9,4 @@ export * from './declinePost';
9
9
  export * from './flagPost';
10
10
  export * from './unflagPost';
11
11
  export * from './isPostFlaggedByMe';
12
- export * from './createClipPost';
13
12
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAE/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAE3B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AAEpC,cAAc,kBAAkB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAE/B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAE3B,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,kBAAkB,CAAC;AAEjC,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAE9B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"channelLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/channelLinkedObject.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,mBAAmB,YAAa,MAAM,eAAe,KAAG,MAAM,OAI1E,CAAC"}
1
+ {"version":3,"file":"channelLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/channelLinkedObject.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,mBAAmB,YAAa,MAAM,eAAe,KAAG,MAAM,OAqB1E,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare const channelMemberLinkedObject: (channelMember: Amity.Membership<'channel'>) => Amity.Membership<'channel'>;
2
+ //# sourceMappingURL=channelMemberLinkedObject.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channelMemberLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/channelMemberLinkedObject.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,yBAAyB,kBACrB,MAAM,UAAU,CAAC,SAAS,CAAC,KACzC,MAAM,UAAU,CAAC,SAAS,CAc5B,CAAC"}
@@ -15,5 +15,6 @@ export declare const LinkedObject: {
15
15
  community: (community: Amity.InternalCommunity) => Amity.Community;
16
16
  invitation: (invitation: Amity.InternalInvitation) => Amity.Invitation;
17
17
  joinRequest: (joinRequest: Amity.InternalJoinRequest) => Amity.JoinRequest;
18
+ channelMember: (channelMember: Amity.Membership<"channel">) => Amity.Membership<"channel">;
18
19
  };
19
20
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/index.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;CAiBxB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/index.ts"],"names":[],"mappings":"AAkBA,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;CAkBxB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"invitationLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/invitationLinkedObject.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,eAAgB,MAAM,kBAAkB,KAAG,MAAM,UAgCnF,CAAC"}
1
+ {"version":3,"file":"invitationLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/invitationLinkedObject.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,sBAAsB,eAAgB,MAAM,kBAAkB,KAAG,MAAM,UAkCnF,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"postLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/postLinkedObject.ts"],"names":[],"mappings":"AAWA,eAAO,MAAM,gBAAgB,SAAU,MAAM,YAAY,KAAG,MAAM,IAmEjE,CAAC"}
1
+ {"version":3,"file":"postLinkedObject.d.ts","sourceRoot":"","sources":["../../../src/utils/linkedObject/postLinkedObject.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,gBAAgB,SAAU,MAAM,YAAY,KAAG,MAAM,IA6DjE,CAAC"}
@@ -1,5 +1,4 @@
1
1
  export declare function isAmityImagePost(post: Amity.InternalPost): post is Amity.Post<'image'>;
2
2
  export declare function isAmityFilePost(post: Amity.InternalPost): post is Amity.Post<'file'>;
3
3
  export declare function isAmityVideoPost(post: Amity.InternalPost): post is Amity.Post<'video'>;
4
- export declare function isAmityClipPost(post: Amity.InternalPost): post is Amity.Post<'clip'>;
5
4
  //# sourceMappingURL=postTypePredicate.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"postTypePredicate.d.ts","sourceRoot":"","sources":["../../src/utils/postTypePredicate.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAOtF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAOpF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAQtF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAQpF"}
1
+ {"version":3,"file":"postTypePredicate.d.ts","sourceRoot":"","sources":["../../src/utils/postTypePredicate.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAOtF;AAED,wBAAgB,eAAe,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAOpF;AAED,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,KAAK,CAAC,YAAY,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,CAQtF"}
@@ -23,7 +23,7 @@ export declare const generateComment: (params?: Partial<Amity.InternalComment>)
23
23
  referenceType: Amity.CommentReferenceType;
24
24
  dataType?: any;
25
25
  dataTypes?: any[] | undefined;
26
- data?: string | Record<string, unknown> | Amity.ContentDataText | Amity.ContentDataFile | Amity.ContentDataImage | Amity.ContentDataVideo | Amity.ContentDataPoll | Amity.ContentDataStream | Amity.ContentDataClip | undefined;
26
+ data?: string | Record<string, unknown> | Amity.ContentDataText | Amity.ContentDataFile | Amity.ContentDataImage | Amity.ContentDataVideo | Amity.ContentDataPoll | Amity.ContentDataStream | undefined;
27
27
  metadata?: Record<string, any> | undefined;
28
28
  flagCount: number;
29
29
  hashFlag: {
@@ -55,6 +55,8 @@ export declare const communityUserModel: {
55
55
  muteTimeout: string;
56
56
  lastActivity: string;
57
57
  userId: string;
58
+ userInternalId: string;
59
+ userPublicId: string;
58
60
  communityId: string;
59
61
  communityMembership: Amity.GroupMembership;
60
62
  createdAt: string;
@@ -1 +1 @@
1
- {"version":3,"file":"community.d.ts","sourceRoot":"","sources":["../../../../src/utils/tests/dummy/community.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,SAajC,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,SAoB/B,CAAC;AAEF,eAAO,MAAM,WAAW,EAAE,KAAK,CAAC,SAI/B,CAAC;AAEF,e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+ "version": "7.5.4-54f750e3.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",
@@ -63,6 +63,7 @@
63
63
  "debug": "^4.3.4",
64
64
  "hls.js": "^1.4.10",
65
65
  "js-base64": "^3.7.2",
66
+ "jwt-decode": "^3.1.2",
66
67
  "mitt": "^3.0.0",
67
68
  "mqtt": "^4.3.7",
68
69
  "object-hash": "^3.0.0",
@@ -93,6 +93,7 @@ declare global {
93
93
  type Channel<T extends ChannelType = any> = InternalChannel<T> & {
94
94
  messagePreview?: Amity.MessagePreview | null;
95
95
  markAsRead: () => Promise<boolean>;
96
+ previewMembers: Amity.Membership<'channel'>[];
96
97
  };
97
98
 
98
99
  type QueryChannels = {
@@ -32,7 +32,6 @@ declare global {
32
32
  | 'poll'
33
33
  | 'json'
34
34
  | 'liveStream'
35
- | 'clip'
36
35
  | string;
37
36
 
38
37
  type ContentFeedType = ValueOf<typeof ContentFeedType>;
@@ -63,13 +62,6 @@ declare global {
63
62
  };
64
63
  };
65
64
 
66
- type ContentDataClip = {
67
- thumbnailFileId: Amity.File<'image'>['fileId'];
68
- fileId: Amity.File<'clip'>['fileId'];
69
- isMuted?: boolean;
70
- displayMode?: Amity.ClipDisplayMode;
71
- };
72
-
73
65
  type ContentDataPoll = {
74
66
  pollId: Amity.Poll['pollId'];
75
67
  };
@@ -90,8 +82,6 @@ declare global {
90
82
  ? ContentDataPoll
91
83
  : T extends 'liveStream'
92
84
  ? ContentDataStream
93
- : T extends 'clip'
94
- ? ContentDataClip
95
85
  : T extends 'json'
96
86
  ? Record<string, unknown>
97
87
  : T extends string
@@ -11,9 +11,8 @@ declare global {
11
11
  } & Amity.Timestamps;
12
12
 
13
13
  type QueryGlobalFeed = {
14
- dataTypes?: ('video' | 'image' | 'file' | 'liveStream' | 'clip')[];
14
+ dataType?: 'video' | 'image' | 'file' | 'liveStream';
15
15
  queryToken?: string;
16
- resolveParent?: boolean;
17
16
  };
18
17
  }
19
18
  }
@@ -2,7 +2,6 @@ export const FileType = Object.freeze({
2
2
  FILE: 'file',
3
3
  IMAGE: 'image',
4
4
  VIDEO: 'video',
5
- CLIP: 'clip',
6
5
  });
7
6
 
8
7
  export const VideoResolution = Object.freeze({
@@ -56,16 +55,12 @@ declare global {
56
55
 
57
56
  type VideoMetadata = Record<string, never>;
58
57
 
59
- type ClipMetadata = Record<string, never>;
60
-
61
58
  type MetadataFor<T extends FileType> = T extends 'file'
62
59
  ? FileMetadata
63
60
  : T extends 'image'
64
61
  ? ImageMetadata
65
62
  : T extends 'video'
66
63
  ? VideoMetadata
67
- : T extends 'clip'
68
- ? ClipMetadata
69
64
  : never;
70
65
 
71
66
  type File<T extends FileType = any> = Amity.FilePayload<T>;
@@ -15,6 +15,8 @@ declare global {
15
15
 
16
16
  type Member<T extends Amity.GroupType> = {
17
17
  userId: Amity.InternalUser['userId'];
18
+ userInternalId: Amity.InternalUser['userInternalId'];
19
+ userPublicId: Amity.InternalUser['userPublicId'];
18
20
  } & (T extends 'channel'
19
21
  ? {
20
22
  channelId: Amity.Channel['channelId'];
@@ -29,13 +29,15 @@ declare global {
29
29
  community: Amity.InternalCommunity;
30
30
  };
31
31
 
32
- type InvitationTarget<T extends InvitationTargetType> = InvitationTargetMap[T];
33
-
34
32
  type InvitationSortBy = InvitationSortByEnum;
35
33
 
36
34
  type InvitationDomain<T extends Amity.InvitationTargetType = Amity.InvitationTargetType> =
37
35
  T extends 'community' ? { communityId: string } : { communityId?: string };
38
36
 
37
+ type InvitationTarget<T extends InvitationTargetType = InvitationTargetType> = {
38
+ [K in T]?: InvitationTargetMap[K];
39
+ } & Amity.InvitationDomain<T>;
40
+
39
41
  type RawInvitation = {
40
42
  _id: string;
41
43
  networkId: string;
@@ -60,7 +62,10 @@ declare global {
60
62
  createdById: string;
61
63
  };
62
64
 
63
- type Invitation = Omit<Amity.InternalInvitation, 'createdBy'> &
65
+ type Invitation = Omit<
66
+ Amity.InternalInvitation,
67
+ 'createdBy' | keyof Amity.InvitationDomain<Amity.InvitationTargetType>
68
+ > &
64
69
  Amity.InvitationLinkedObject & {
65
70
  user?: Amity.User;
66
71
  createdById: string;
@@ -5,7 +5,6 @@ export const PostContentType = Object.freeze({
5
5
  VIDEO: 'video',
6
6
  LIVESTREAM: 'liveStream',
7
7
  POLL: 'poll',
8
- CLIP: 'clip',
9
8
  });
10
9
 
11
10
  declare global {
@@ -83,13 +82,10 @@ declare global {
83
82
  getVideoInfo: () => Amity.File<'video'> | undefined;
84
83
  getVideoThumbnailInfo: () => Amity.File<'image'> | undefined;
85
84
  getFileInfo: () => Amity.File<'file'> | undefined;
86
- getClipInfo: () => Amity.File<'clip'> | undefined;
87
85
  };
88
86
 
89
87
  type Post<T extends PostContentType = any> = Amity.InternalPost<T> & Amity.PostLinkObject;
90
88
 
91
- type ClipDisplayMode = 'fill' | 'fit';
92
-
93
89
  type QueryPosts = {
94
90
  targetId: string;
95
91
  targetType: Amity.InternalPost['targetType'];
@@ -23,6 +23,7 @@ import {
23
23
  } from '~/core/query';
24
24
  import { prepareChannelPayload } from '~/channelRepository/utils';
25
25
  import { onUserDeleted } from '~/channelRepository/events/onUserDeleted';
26
+ import { LinkedObject } from '~/utils/linkedObject';
26
27
 
27
28
  export class ChannelMemberLiveCollectionController extends LiveCollectionController<
28
29
  'channelUser',
@@ -100,7 +101,8 @@ export class ChannelMemberLiveCollectionController extends LiveCollectionControl
100
101
  collection.data
101
102
  .map(id => pullFromCache<Amity.Membership<'channel'>>(['channelUsers', 'get', id])!)
102
103
  .filter(Boolean)
103
- .map(({ data }) => data) ?? [],
104
+ .map(({ data }) => data)
105
+ .map(LinkedObject.channelMember) ?? [],
104
106
  );
105
107
 
106
108
  if (!this.shouldNotify(data) && origin === 'event') return;
@@ -17,6 +17,7 @@ import {
17
17
  import { filterByPropIntersection, filterBySearchTerm } from '~/core/query';
18
18
  import { prepareChannelPayload } from '~/channelRepository/utils';
19
19
  import { onUserDeleted } from '~/channelRepository/events/onUserDeleted';
20
+ import { LinkedObject } from '~/utils/linkedObject';
20
21
 
21
22
  export class SearchChannelMemberLiveCollectionController extends LiveCollectionController<
22
23
  'channelUser',
@@ -94,7 +95,7 @@ export class SearchChannelMemberLiveCollectionController extends LiveCollectionC
94
95
  collection.data
95
96
  .map(id => pullFromCache<Amity.Membership<'channel'>>(['channelUsers', 'get', id])!)
96
97
  .filter(Boolean)
97
- .map(({ data }) => data) ?? [],
98
+ .map(({ data }) => LinkedObject.channelMember(data) ?? []),
98
99
  );
99
100
 
100
101
  if (!this.shouldNotify(data) && origin === 'event') return;
@@ -72,7 +72,7 @@ export class SearchChannelMemberQueryStreamController extends QueryStreamControl
72
72
  }
73
73
 
74
74
  reactor(action: string) {
75
- return (channel: Amity.InternalChannel, channelMember: Amity.Membership<'channel'>) => {
75
+ return (channel: Amity.StaticInternalChannel, channelMember: Amity.Membership<'channel'>) => {
76
76
  if (this.query.channelId !== channelMember.channelId) return;
77
77
 
78
78
  const collection = pullFromCache<Amity.ChannelMembersLiveCollectionCache>(
@@ -100,7 +100,7 @@ export class SearchChannelMemberQueryStreamController extends QueryStreamControl
100
100
  createSubscriber: {
101
101
  fn: (
102
102
  reactor: (
103
- channel: Amity.InternalChannel,
103
+ channel: Amity.StaticInternalChannel,
104
104
  channelMember: Amity.Membership<'channel'>,
105
105
  ) => void,
106
106
  ) => Amity.Unsubscriber;
@@ -6,6 +6,7 @@ export * from './createClient';
6
6
  export * from './login';
7
7
  export * from './logout';
8
8
  export * from './secureLogout';
9
+ export * from './resumeSession';
9
10
 
10
11
  export * from './isConnected';
11
12
 
@@ -0,0 +1,282 @@
1
+ import jwtDecode from 'jwt-decode';
2
+ /* eslint-disable no-param-reassign */
3
+ import { modifyMqttConnection } from '~/client/utils/modifyMqttConnection';
4
+ /* eslint-disable require-atomic-updates */
5
+ import { proxyWebsocketEvents } from '~/core/events';
6
+ import { onChannelDeleted } from '~/channelRepository/events/onChannelDeleted';
7
+ import { onChannelMemberBanned } from '~/channelRepository/events/onChannelMemberBanned';
8
+
9
+ import { markReadEngineOnLoginHandler } from '~/subChannelRepository/utils/markReadEngine';
10
+ import { onUserDeleted } from '~/userRepository/events/onUserDeleted';
11
+
12
+ import analyticsEngineOnLoginHandler from '~/analytic/utils/analyticsEngineOnLoginHandler';
13
+ import readReceiptSyncEngineOnLoginHandler from '~/client/utils/ReadReceiptSync/readReceiptSyncEngineOnLoginHandler';
14
+ import legacyReadReceiptSyncEngineOnLoginHandler from '~/client/utils/ReadReceiptSync/legacyReadReceiptSyncEngineOnLoginHandler';
15
+ import objectResolverEngineOnLoginHandler from '~/client/utils/ObjectResolver/objectResolverEngineOnLoginHandler';
16
+ import { logout } from './logout';
17
+
18
+ import { getActiveClient } from './activeClient';
19
+ import { terminateClient } from './terminateClient';
20
+ import { setActiveUser } from './activeUser';
21
+ import { setSessionState } from './setSessionState';
22
+
23
+ import { onClientBanned } from '../events';
24
+ import { onTokenExpired } from '../events/onTokenExpired';
25
+ import { onTokenTerminated } from '../events/onTokenTerminated';
26
+
27
+ import { removeChannelMarkerCache } from '../utils/removeChannelMarkerCache';
28
+ import { initializeMessagePreviewSetting } from '../utils/messagePreviewEngine';
29
+ import { ASCError } from '~/core/errors';
30
+ import SessionWatcher from '../utils/SessionWatcher';
31
+
32
+ /*
33
+ * declared earlier to accomodate case when logging in with a different user
34
+ * than the one already connected, in which case the existing subscriptions need
35
+ * to be cleared
36
+ */
37
+ let subscriptions: Amity.Unsubscriber[] = [];
38
+
39
+ async function runMqtt() {
40
+ await modifyMqttConnection();
41
+ }
42
+
43
+ interface Params {
44
+ userId: string;
45
+ token: {
46
+ issuedAt: string;
47
+ expiresAt: string;
48
+ accessToken: string;
49
+ };
50
+ }
51
+
52
+ const isSameUserId = (token: Params['token']['accessToken']) => {
53
+ const client = getActiveClient();
54
+
55
+ const decoded = jwtDecode<{
56
+ user: {
57
+ userId: string;
58
+ publicUserId: string;
59
+ deviceInfo: Amity.Device['deviceInfo'];
60
+ networkId: string;
61
+ displayName: string;
62
+ refreshToken: string;
63
+ };
64
+ }>(token);
65
+
66
+ return decoded?.user?.publicUserId === client.userId;
67
+ };
68
+
69
+ const validateAccessToken = async ({ token, userId }: Params) => {
70
+ const client = getActiveClient();
71
+ // begin establishing session
72
+ setSessionState(Amity.SessionStates.ESTABLISHING);
73
+
74
+ const {
75
+ data: { users },
76
+ } = await client.http.get(`/api/v3/users/${userId}`, {
77
+ headers: {
78
+ Authorization: `Bearer ${token.accessToken}`,
79
+ },
80
+ });
81
+
82
+ const user = users.find((u: Amity.User) => u.userId === userId);
83
+
84
+ client.http.defaults.headers.common.Authorization = `Bearer ${token.accessToken}`;
85
+
86
+ client.http.defaults.metadata = {
87
+ tokenExpiry: token.expiresAt,
88
+ isGlobalBanned: false,
89
+ isUserDeleted: false,
90
+ };
91
+
92
+ client.upload.defaults.headers.common.Authorization = `Bearer ${token.accessToken}`;
93
+
94
+ client.upload.defaults.metadata = {
95
+ tokenExpiry: token.expiresAt,
96
+ isGlobalBanned: false,
97
+ isUserDeleted: false,
98
+ };
99
+
100
+ // manually setup the token for ws transport
101
+ if (client.ws) client.ws.io.opts.query = { token: token.accessToken };
102
+
103
+ client.token = token;
104
+
105
+ setSessionState(Amity.SessionStates.ESTABLISHED);
106
+
107
+ return user;
108
+ };
109
+
110
+ /* begin_public_function
111
+ id: client.resumeSession
112
+ */
113
+ /**
114
+ * ```js
115
+ * import { resumeSession } from '@amityco/ts-sdk/client/api'
116
+ * const success = await resumeSession({
117
+ * userId: 'XYZ123456789',
118
+ * token: { accessToken: 'abc123', issuedAt: '2023-01-01T00:00:00Z', expiresAt: '2023-01-02T00:00:00Z' }
119
+ * })
120
+ * ```
121
+ *
122
+ * Connects an {@link Amity.Client} instance to ASC servers using an existing access token
123
+ *
124
+ * @param params the connect parameters
125
+ * @param params.userId the user ID for the current session
126
+ * @param params.token the existing access token with its metadata
127
+ * @param sessionHandler the session handler for token renewal
128
+ * @param config optional configuration
129
+ * @returns a success boolean if connected
130
+ *
131
+ * @category Client API
132
+ * @async
133
+ */
134
+ export const resumeSession = async (
135
+ params: Params,
136
+ sessionHandler: Amity.SessionHandler,
137
+ config?: Amity.ConnectClientConfig,
138
+ ): Promise<boolean> => {
139
+ const client = getActiveClient();
140
+ let unsubWatcher: Amity.Unsubscriber;
141
+
142
+ client.log('client/api/resumeSession', {
143
+ apiKey: client.apiKey,
144
+ sessionState: client.sessionState,
145
+ ...params,
146
+ });
147
+
148
+ // Handle existing connected user
149
+ if (client.userId) {
150
+ if (client.userId === params.userId && isSameUserId(params.token.accessToken)) {
151
+ // Clear connections and listeners but preserve cache
152
+ if (client.mqtt && client.mqtt.connected) {
153
+ client.mqtt.disconnect();
154
+ }
155
+ if (client.ws && client.ws.connected) {
156
+ client.ws.disconnect();
157
+ }
158
+
159
+ // Clear existing subscriptions
160
+ subscriptions.forEach(fn => fn());
161
+ subscriptions = [];
162
+ } else {
163
+ // Different user - do full logout
164
+ await logout();
165
+
166
+ // Remove subscription to ban and delete
167
+ subscriptions.forEach(fn => fn());
168
+ subscriptions = [];
169
+ }
170
+ }
171
+
172
+ try {
173
+ const user = await validateAccessToken(params);
174
+
175
+ if (user == null) {
176
+ throw new ASCError(
177
+ `${params.userId} has not been found`,
178
+ Amity.ClientError.UNKNOWN_ERROR,
179
+ Amity.ErrorLevel.ERROR,
180
+ );
181
+ }
182
+
183
+ if (user.isDeleted) {
184
+ terminateClient(Amity.TokenTerminationReason.USER_DELETED);
185
+ return false;
186
+ }
187
+
188
+ if (user.isGlobalBanned) {
189
+ terminateClient(Amity.TokenTerminationReason.GLOBAL_BAN);
190
+ return false;
191
+ }
192
+
193
+ // FIXME: events are duplicated if connectClient is called few times without disconnectClient
194
+ // wire websocket events to our event emitter
195
+ proxyWebsocketEvents(client.ws, client.emitter);
196
+
197
+ client.ws?.open();
198
+
199
+ client.userId = user.userId;
200
+
201
+ client.sessionHandler = sessionHandler;
202
+
203
+ /*
204
+ * Cannot push to subscriptions as watcher needs to continue working even if
205
+ * token expires
206
+ */
207
+ unsubWatcher = client.accessTokenExpiryWatcher(sessionHandler);
208
+
209
+ setActiveUser(user);
210
+ } catch (error) {
211
+ /*
212
+ * if getting token failed session state reverts to initial state when app
213
+ * is first launched
214
+ */
215
+ SessionWatcher.getInstance().setSessionState(Amity.SessionStates.NOT_LOGGED_IN);
216
+
217
+ // pass error down tree so the calling function handle it
218
+ throw error;
219
+ }
220
+
221
+ if (config?.disableRTE !== true) {
222
+ runMqtt();
223
+ }
224
+
225
+ await initializeMessagePreviewSetting();
226
+
227
+ if (subscriptions.length === 0) {
228
+ subscriptions.push(
229
+ // GLOBAL_BAN
230
+ onClientBanned((_: Amity.UserPayload) => {
231
+ terminateClient(Amity.TokenTerminationReason.GLOBAL_BAN);
232
+
233
+ subscriptions.forEach(fn => fn());
234
+
235
+ unsubWatcher();
236
+ }),
237
+
238
+ onTokenTerminated(_ => {
239
+ terminateClient();
240
+
241
+ subscriptions.forEach(fn => fn());
242
+
243
+ unsubWatcher();
244
+ }),
245
+
246
+ onUserDeleted((user: Amity.InternalUser) => {
247
+ if (user.userId === client.userId) {
248
+ terminateClient(Amity.TokenTerminationReason.USER_DELETED);
249
+
250
+ subscriptions.forEach(fn => fn());
251
+
252
+ unsubWatcher();
253
+ }
254
+ }),
255
+
256
+ onTokenExpired(state => {
257
+ SessionWatcher.getInstance().setSessionState(state);
258
+
259
+ logout();
260
+
261
+ subscriptions.forEach(fn => fn());
262
+ }),
263
+
264
+ // NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
265
+ // the channel because currently backend can't handle this, so every time a user is banned from
266
+ // a channel or the channel is deleted the channel's unread count will not be reset to zero
267
+ onChannelDeleted(removeChannelMarkerCache),
268
+ onChannelMemberBanned(removeChannelMarkerCache),
269
+
270
+ markReadEngineOnLoginHandler(),
271
+ analyticsEngineOnLoginHandler(),
272
+ objectResolverEngineOnLoginHandler(),
273
+ );
274
+
275
+ if (client.useLegacyUnreadCount) {
276
+ subscriptions.push(readReceiptSyncEngineOnLoginHandler());
277
+ } else subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
278
+ }
279
+
280
+ return true;
281
+ };
282
+ /* end_public_function */