@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
package/dist/index.esm.js CHANGED
@@ -6,6 +6,7 @@ import HttpAgent, { HttpsAgent } from 'agentkeepalive';
6
6
  import io from 'socket.io-client';
7
7
  import uuid$1 from 'react-native-uuid';
8
8
  import hash from 'object-hash';
9
+ import jwtDecode from 'jwt-decode';
9
10
  import Hls from 'hls.js';
10
11
 
11
12
  var MembershipAcceptanceTypeEnum;
@@ -18,7 +19,6 @@ const FileType = Object.freeze({
18
19
  FILE: 'file',
19
20
  IMAGE: 'image',
20
21
  VIDEO: 'video',
21
- CLIP: 'clip',
22
22
  });
23
23
  const VideoResolution = Object.freeze({
24
24
  '1080P': '1080p',
@@ -102,7 +102,6 @@ const PostContentType = Object.freeze({
102
102
  VIDEO: 'video',
103
103
  LIVESTREAM: 'liveStream',
104
104
  POLL: 'poll',
105
- CLIP: 'clip',
106
105
  });
107
106
 
108
107
  var InvitationTypeEnum;
@@ -22785,13 +22784,6 @@ function isAmityVideoPost(post) {
22785
22784
  'videoFileId' in post.data &&
22786
22785
  'thumbnailFileId' in post.data &&
22787
22786
  post.dataType === 'video');
22788
- }
22789
- function isAmityClipPost(post) {
22790
- return !!(post.data &&
22791
- typeof post.data !== 'string' &&
22792
- 'fileId' in post.data &&
22793
- 'thumbnailFileId' in post.data &&
22794
- post.dataType === 'clip');
22795
22787
  }
22796
22788
 
22797
22789
  const postLinkedObject = (post) => {
@@ -22846,12 +22838,6 @@ const postLinkedObject = (post) => {
22846
22838
  return isAmityFilePost(post)
22847
22839
  ? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
22848
22840
  : undefined;
22849
- },
22850
- getClipInfo() {
22851
- var _a, _b;
22852
- return isAmityClipPost(post)
22853
- ? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.fileId])) === null || _b === void 0 ? void 0 : _b.data
22854
- : undefined;
22855
22841
  } });
22856
22842
  };
22857
22843
 
@@ -23401,9 +23387,35 @@ const markAsRead = async (channelId) => {
23401
23387
  return true;
23402
23388
  };
23403
23389
 
23390
+ const channelMemberLinkedObject = (channelMember) => {
23391
+ const getUser = () => {
23392
+ var _a;
23393
+ const cacheKey = ['user', 'get', channelMember.userId];
23394
+ const internalUser = (_a = pullFromCache(cacheKey)) === null || _a === void 0 ? void 0 : _a.data;
23395
+ return internalUser ? userLinkedObject(internalUser) : undefined;
23396
+ };
23397
+ return Object.assign(Object.assign({}, channelMember), { get user() {
23398
+ return getUser();
23399
+ } });
23400
+ };
23401
+
23404
23402
  const channelLinkedObject = (channel) => {
23403
+ var _a;
23404
+ let previewMembers = [];
23405
+ if (channel.type === 'conversation') {
23406
+ const channelUsers = queryCache(['channelUsers', 'get']);
23407
+ if (channelUsers && (channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.length) > 0) {
23408
+ previewMembers = ((_a = channelUsers === null || channelUsers === void 0 ? void 0 : channelUsers.filter(({ data }) => data.channelId === channel.channelId)) !== null && _a !== void 0 ? _a : [])
23409
+ // sort in ascending order by userInternalId
23410
+ .sort((a, b) => a.data.userInternalId.localeCompare(b.data.userInternalId))
23411
+ // Select only first 4 members
23412
+ .slice(0, 4)
23413
+ .map(({ data }) => channelMemberLinkedObject(data));
23414
+ }
23415
+ }
23405
23416
  return shallowClone(channel, {
23406
23417
  markAsRead: () => markAsRead(channel.channelInternalId),
23418
+ previewMembers,
23407
23419
  });
23408
23420
  };
23409
23421
 
@@ -24372,9 +24384,10 @@ const invitationLinkedObject = (invitation) => {
24372
24384
  'get',
24373
24385
  invitation.targetId,
24374
24386
  ]);
24375
- if (cacheData === null || cacheData === void 0 ? void 0 : cacheData.data)
24376
- return cacheData.data;
24377
- return undefined;
24387
+ return {
24388
+ community: cacheData === null || cacheData === void 0 ? void 0 : cacheData.data,
24389
+ communityId: invitation.communityId,
24390
+ };
24378
24391
  }
24379
24392
  return undefined;
24380
24393
  }, accept: async () => {
@@ -24726,6 +24739,7 @@ const LinkedObject = {
24726
24739
  community: communityLinkedObject,
24727
24740
  invitation: invitationLinkedObject,
24728
24741
  joinRequest: joinRequestLinkedObject,
24742
+ channelMember: channelMemberLinkedObject,
24729
24743
  };
24730
24744
 
24731
24745
  const constructChannelObject = (channel) => {
@@ -26008,8 +26022,8 @@ const removeChannelMarkerCache = (channel) => {
26008
26022
  * than the one already connected, in which case the existing subscriptions need
26009
26023
  * to be cleared
26010
26024
  */
26011
- let subscriptions = [];
26012
- async function runMqtt() {
26025
+ let subscriptions$1 = [];
26026
+ async function runMqtt$1() {
26013
26027
  await modifyMqttConnection();
26014
26028
  }
26015
26029
  /* begin_public_function
@@ -26044,8 +26058,8 @@ const login = async (params, sessionHandler, config) => {
26044
26058
  if (client.userId && client.userId !== params.userId) {
26045
26059
  await logout();
26046
26060
  // Remove subscription to ban and delete
26047
- subscriptions.forEach(fn => fn());
26048
- subscriptions = [];
26061
+ subscriptions$1.forEach(fn => fn());
26062
+ subscriptions$1 = [];
26049
26063
  }
26050
26064
  // default values
26051
26065
  const defaultDeviceId = await getDeviceId();
@@ -26091,40 +26105,40 @@ const login = async (params, sessionHandler, config) => {
26091
26105
  throw error;
26092
26106
  }
26093
26107
  if ((config === null || config === void 0 ? void 0 : config.disableRTE) !== true) {
26094
- runMqtt();
26108
+ runMqtt$1();
26095
26109
  }
26096
26110
  await initializeMessagePreviewSetting();
26097
- if (subscriptions.length === 0) {
26098
- subscriptions.push(
26111
+ if (subscriptions$1.length === 0) {
26112
+ subscriptions$1.push(
26099
26113
  // GLOBAL_BAN
26100
26114
  onClientBanned((_) => {
26101
26115
  terminateClient("globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */);
26102
- subscriptions.forEach(fn => fn());
26116
+ subscriptions$1.forEach(fn => fn());
26103
26117
  unsubWatcher();
26104
26118
  }), onTokenTerminated(_ => {
26105
26119
  terminateClient();
26106
- subscriptions.forEach(fn => fn());
26120
+ subscriptions$1.forEach(fn => fn());
26107
26121
  unsubWatcher();
26108
26122
  }), onUserDeleted$2((user) => {
26109
26123
  if (user.userId === client.userId) {
26110
26124
  terminateClient("userDeleted" /* Amity.TokenTerminationReason.USER_DELETED */);
26111
- subscriptions.forEach(fn => fn());
26125
+ subscriptions$1.forEach(fn => fn());
26112
26126
  unsubWatcher();
26113
26127
  }
26114
26128
  }), onTokenExpired(state => {
26115
26129
  SessionWatcher$1.getInstance().setSessionState(state);
26116
26130
  logout();
26117
- subscriptions.forEach(fn => fn());
26131
+ subscriptions$1.forEach(fn => fn());
26118
26132
  }),
26119
26133
  // NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
26120
26134
  // the channel because currently backend can't handle this, so every time a user is banned from
26121
26135
  // a channel or the channel is deleted the channel's unread count will not be reset to zero
26122
26136
  onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
26123
26137
  if (client.useLegacyUnreadCount) {
26124
- subscriptions.push(readReceiptSyncEngineOnLoginHandler());
26138
+ subscriptions$1.push(readReceiptSyncEngineOnLoginHandler());
26125
26139
  }
26126
26140
  else
26127
- subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
26141
+ subscriptions$1.push(legacyReadReceiptSyncEngineOnLoginHandler());
26128
26142
  }
26129
26143
  return true;
26130
26144
  };
@@ -27049,6 +27063,176 @@ const secureLogout = async () => {
27049
27063
  };
27050
27064
  /* end_public_function */
27051
27065
 
27066
+ /*
27067
+ * declared earlier to accomodate case when logging in with a different user
27068
+ * than the one already connected, in which case the existing subscriptions need
27069
+ * to be cleared
27070
+ */
27071
+ let subscriptions = [];
27072
+ async function runMqtt() {
27073
+ await modifyMqttConnection();
27074
+ }
27075
+ const isSameUserId = (token) => {
27076
+ var _a;
27077
+ const client = getActiveClient();
27078
+ const decoded = jwtDecode(token);
27079
+ return ((_a = decoded === null || decoded === void 0 ? void 0 : decoded.user) === null || _a === void 0 ? void 0 : _a.publicUserId) === client.userId;
27080
+ };
27081
+ const validateAccessToken = async ({ token, userId }) => {
27082
+ const client = getActiveClient();
27083
+ // begin establishing session
27084
+ setSessionState("establishing" /* Amity.SessionStates.ESTABLISHING */);
27085
+ const { data: { users }, } = await client.http.get(`/api/v3/users/${userId}`, {
27086
+ headers: {
27087
+ Authorization: `Bearer ${token.accessToken}`,
27088
+ },
27089
+ });
27090
+ const user = users.find((u) => u.userId === userId);
27091
+ client.http.defaults.headers.common.Authorization = `Bearer ${token.accessToken}`;
27092
+ client.http.defaults.metadata = {
27093
+ tokenExpiry: token.expiresAt,
27094
+ isGlobalBanned: false,
27095
+ isUserDeleted: false,
27096
+ };
27097
+ client.upload.defaults.headers.common.Authorization = `Bearer ${token.accessToken}`;
27098
+ client.upload.defaults.metadata = {
27099
+ tokenExpiry: token.expiresAt,
27100
+ isGlobalBanned: false,
27101
+ isUserDeleted: false,
27102
+ };
27103
+ // manually setup the token for ws transport
27104
+ if (client.ws)
27105
+ client.ws.io.opts.query = { token: token.accessToken };
27106
+ client.token = token;
27107
+ setSessionState("established" /* Amity.SessionStates.ESTABLISHED */);
27108
+ return user;
27109
+ };
27110
+ /* begin_public_function
27111
+ id: client.resumeSession
27112
+ */
27113
+ /**
27114
+ * ```js
27115
+ * import { resumeSession } from '@amityco/ts-sdk/client/api'
27116
+ * const success = await resumeSession({
27117
+ * userId: 'XYZ123456789',
27118
+ * token: { accessToken: 'abc123', issuedAt: '2023-01-01T00:00:00Z', expiresAt: '2023-01-02T00:00:00Z' }
27119
+ * })
27120
+ * ```
27121
+ *
27122
+ * Connects an {@link Amity.Client} instance to ASC servers using an existing access token
27123
+ *
27124
+ * @param params the connect parameters
27125
+ * @param params.userId the user ID for the current session
27126
+ * @param params.token the existing access token with its metadata
27127
+ * @param sessionHandler the session handler for token renewal
27128
+ * @param config optional configuration
27129
+ * @returns a success boolean if connected
27130
+ *
27131
+ * @category Client API
27132
+ * @async
27133
+ */
27134
+ const resumeSession = async (params, sessionHandler, config) => {
27135
+ var _a;
27136
+ const client = getActiveClient();
27137
+ let unsubWatcher;
27138
+ client.log('client/api/resumeSession', Object.assign({ apiKey: client.apiKey, sessionState: client.sessionState }, params));
27139
+ // Handle existing connected user
27140
+ if (client.userId) {
27141
+ if (client.userId === params.userId && isSameUserId(params.token.accessToken)) {
27142
+ // Clear connections and listeners but preserve cache
27143
+ if (client.mqtt && client.mqtt.connected) {
27144
+ client.mqtt.disconnect();
27145
+ }
27146
+ if (client.ws && client.ws.connected) {
27147
+ client.ws.disconnect();
27148
+ }
27149
+ // Clear existing subscriptions
27150
+ subscriptions.forEach(fn => fn());
27151
+ subscriptions = [];
27152
+ }
27153
+ else {
27154
+ // Different user - do full logout
27155
+ await logout();
27156
+ // Remove subscription to ban and delete
27157
+ subscriptions.forEach(fn => fn());
27158
+ subscriptions = [];
27159
+ }
27160
+ }
27161
+ try {
27162
+ const user = await validateAccessToken(params);
27163
+ if (user == null) {
27164
+ throw new ASCError(`${params.userId} has not been found`, 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
27165
+ }
27166
+ if (user.isDeleted) {
27167
+ terminateClient("userDeleted" /* Amity.TokenTerminationReason.USER_DELETED */);
27168
+ return false;
27169
+ }
27170
+ if (user.isGlobalBanned) {
27171
+ terminateClient("globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */);
27172
+ return false;
27173
+ }
27174
+ // FIXME: events are duplicated if connectClient is called few times without disconnectClient
27175
+ // wire websocket events to our event emitter
27176
+ proxyWebsocketEvents(client.ws, client.emitter);
27177
+ (_a = client.ws) === null || _a === void 0 ? void 0 : _a.open();
27178
+ client.userId = user.userId;
27179
+ client.sessionHandler = sessionHandler;
27180
+ /*
27181
+ * Cannot push to subscriptions as watcher needs to continue working even if
27182
+ * token expires
27183
+ */
27184
+ unsubWatcher = client.accessTokenExpiryWatcher(sessionHandler);
27185
+ setActiveUser(user);
27186
+ }
27187
+ catch (error) {
27188
+ /*
27189
+ * if getting token failed session state reverts to initial state when app
27190
+ * is first launched
27191
+ */
27192
+ SessionWatcher$1.getInstance().setSessionState("notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */);
27193
+ // pass error down tree so the calling function handle it
27194
+ throw error;
27195
+ }
27196
+ if ((config === null || config === void 0 ? void 0 : config.disableRTE) !== true) {
27197
+ runMqtt();
27198
+ }
27199
+ await initializeMessagePreviewSetting();
27200
+ if (subscriptions.length === 0) {
27201
+ subscriptions.push(
27202
+ // GLOBAL_BAN
27203
+ onClientBanned((_) => {
27204
+ terminateClient("globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */);
27205
+ subscriptions.forEach(fn => fn());
27206
+ unsubWatcher();
27207
+ }), onTokenTerminated(_ => {
27208
+ terminateClient();
27209
+ subscriptions.forEach(fn => fn());
27210
+ unsubWatcher();
27211
+ }), onUserDeleted$2((user) => {
27212
+ if (user.userId === client.userId) {
27213
+ terminateClient("userDeleted" /* Amity.TokenTerminationReason.USER_DELETED */);
27214
+ subscriptions.forEach(fn => fn());
27215
+ unsubWatcher();
27216
+ }
27217
+ }), onTokenExpired(state => {
27218
+ SessionWatcher$1.getInstance().setSessionState(state);
27219
+ logout();
27220
+ subscriptions.forEach(fn => fn());
27221
+ }),
27222
+ // NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
27223
+ // the channel because currently backend can't handle this, so every time a user is banned from
27224
+ // a channel or the channel is deleted the channel's unread count will not be reset to zero
27225
+ onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
27226
+ if (client.useLegacyUnreadCount) {
27227
+ subscriptions.push(readReceiptSyncEngineOnLoginHandler());
27228
+ }
27229
+ else
27230
+ subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
27231
+ }
27232
+ return true;
27233
+ };
27234
+ /* end_public_function */
27235
+
27052
27236
  /**
27053
27237
  * ```js
27054
27238
  * import { isConnected } from '@amityco/ts-sdk'
@@ -27454,6 +27638,7 @@ var index$n = /*#__PURE__*/Object.freeze({
27454
27638
  login: login,
27455
27639
  logout: logout,
27456
27640
  secureLogout: secureLogout,
27641
+ resumeSession: resumeSession,
27457
27642
  isConnected: isConnected,
27458
27643
  getFeedSettings: getFeedSettings,
27459
27644
  renewal: renewal,
@@ -29822,57 +30007,6 @@ const updateAltText = async (fileId, altText) => {
29822
30007
  };
29823
30008
  /* end_public_function */
29824
30009
 
29825
- /* begin_public_function
29826
- id: file.upload.clip
29827
- */
29828
- /**
29829
- * ```js
29830
- * import { FileRepository } from '@amityco/ts-sdk'
29831
- * const created = await FileRepository.uploadClip(formData)
29832
- * ```
29833
- *
29834
- * Creates an {@link Amity.File}
29835
- *
29836
- * @param formData The data necessary to create a new {@link Amity.File}
29837
- * @param onProgress The callback to track the upload progress
29838
- * @returns The newly created {@link Amity.File}
29839
- *
29840
- * @category File API
29841
- * @async
29842
- */
29843
- const uploadClip = async (formData, feedType, onProgress) => {
29844
- const client = getActiveClient();
29845
- client.log('file/uploadClip', formData);
29846
- const file = formData.get('files');
29847
- if (!file)
29848
- throw new Error('The formData object must have a `files` key.');
29849
- const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
29850
- formData.append('accessType', accessType);
29851
- formData.append('preferredFilename', file.name);
29852
- if (feedType) {
29853
- formData.append('feedType', feedType);
29854
- }
29855
- const headers = 'getHeaders' in formData
29856
- ? formData.getHeaders()
29857
- : { 'content-type': 'multipart/form-data' };
29858
- const { data } = await client.upload.post('/api/v4/clips', formData, {
29859
- headers,
29860
- onUploadProgress({ loaded, total = 100 }) {
29861
- onProgress && onProgress(Math.round((loaded * 100) / total));
29862
- },
29863
- });
29864
- // API-FIX: payload should be serialized properly
29865
- // const { files } = data
29866
- const cachedAt = client.cache && Date.now();
29867
- if (client.cache)
29868
- ingestInCache({ files: data }, { cachedAt });
29869
- return {
29870
- data,
29871
- cachedAt,
29872
- };
29873
- };
29874
- /* end_public_function */
29875
-
29876
30010
  var index$k = /*#__PURE__*/Object.freeze({
29877
30011
  __proto__: null,
29878
30012
  getFile: getFile,
@@ -29881,8 +30015,7 @@ var index$k = /*#__PURE__*/Object.freeze({
29881
30015
  fileUrlWithSize: fileUrlWithSize,
29882
30016
  uploadVideo: uploadVideo,
29883
30017
  uploadImage: uploadImage,
29884
- updateAltText: updateAltText,
29885
- uploadClip: uploadClip
30018
+ updateAltText: updateAltText
29886
30019
  });
29887
30020
 
29888
30021
  /**
@@ -35200,7 +35333,8 @@ class ChannelMemberLiveCollectionController extends LiveCollectionController {
35200
35333
  const data = this.applyFilter((_b = collection.data
35201
35334
  .map(id => pullFromCache(['channelUsers', 'get', id]))
35202
35335
  .filter(Boolean)
35203
- .map(({ data }) => data)) !== null && _b !== void 0 ? _b : []);
35336
+ .map(({ data }) => data)
35337
+ .map(LinkedObject.channelMember)) !== null && _b !== void 0 ? _b : []);
35204
35338
  if (!this.shouldNotify(data) && origin === 'event')
35205
35339
  return;
35206
35340
  this.callback({
@@ -38482,14 +38616,14 @@ var index$a = /*#__PURE__*/Object.freeze({
38482
38616
  const queryGlobalFeed = async (query) => {
38483
38617
  const client = getActiveClient();
38484
38618
  client.log('feed/queryGlobalFeed', query);
38485
- const _a = query !== null && query !== void 0 ? query : {}, { queryToken, dataTypes, resolveParent } = _a, params = __rest(_a, ["queryToken", "dataTypes", "resolveParent"]);
38619
+ const _a = query !== null && query !== void 0 ? query : {}, { queryToken } = _a, params = __rest(_a, ["queryToken"]);
38486
38620
  const options = (() => {
38487
38621
  if (queryToken)
38488
38622
  return { token: queryToken };
38489
38623
  return undefined;
38490
38624
  })();
38491
38625
  const { data: queryPayload } = await client.http.get(`/api/v4/me/global-feeds`, {
38492
- params: Object.assign(Object.assign({}, params), { dataTypes, resolveParent: resolveParent !== null && resolveParent !== void 0 ? resolveParent : true, options }),
38626
+ params: Object.assign(Object.assign({}, params), { options }),
38493
38627
  });
38494
38628
  const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
38495
38629
  const data = prepareMembershipPayload(payload, 'communityUsers');
@@ -39075,46 +39209,6 @@ const isPostFlaggedByMe = async (postId) => {
39075
39209
  };
39076
39210
  /* end_public_function */
39077
39211
 
39078
- /* begin_public_function
39079
- id: post.create.clip_post
39080
- */
39081
- /**
39082
- * ```js
39083
- * import { PostRepository } from '@amityco/ts-sdk'
39084
- * const created = await PostRepository.createClipPost({
39085
- * targetType: 'user',
39086
- * targetId: 'foobar',
39087
- * dataType: 'clip',
39088
- * data: { text: 'hello world' },
39089
- * attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
39090
- * }))
39091
- * ```
39092
- *
39093
- * Creates an {@link Amity.Post}
39094
- *
39095
- * @param bundle The data necessary to create a new {@link Amity.Post}
39096
- * @returns The newly created {@link Amity.Post}
39097
- *
39098
- * @category Post API
39099
- * @async
39100
- */
39101
- const createClipPost = async (bundle) => {
39102
- const client = getActiveClient();
39103
- client.log('post/createPost', bundle);
39104
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
39105
- fireEvent('post.created', payload);
39106
- const data = prepareMembershipPayload(payload, 'communityUsers');
39107
- const cachedAt = client.cache && Date.now();
39108
- if (client.cache)
39109
- ingestInCache(data, { cachedAt });
39110
- const { posts } = data;
39111
- return {
39112
- data: LinkedObject.post(posts[0]),
39113
- cachedAt,
39114
- };
39115
- };
39116
- /* end_public_function */
39117
-
39118
39212
  /* begin_public_function
39119
39213
  id: comment.get_by_ids
39120
39214
  */
@@ -40203,7 +40297,7 @@ class PostPaginationController extends PaginationController {
40203
40297
  type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
40204
40298
  };
40205
40299
  const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
40206
- const { data: queryResponse } = await this.http.get(`/api/v5/posts`, {
40300
+ const { data: queryResponse } = await this.http.get(`/api/v4/posts`, {
40207
40301
  params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
40208
40302
  /*
40209
40303
  * when creating post like image, file, video BE will create 2 posts
@@ -41015,7 +41109,6 @@ var index$7 = /*#__PURE__*/Object.freeze({
41015
41109
  flagPost: flagPost,
41016
41110
  unflagPost: unflagPost,
41017
41111
  isPostFlaggedByMe: isPostFlaggedByMe,
41018
- createClipPost: createClipPost,
41019
41112
  onPostCreated: onPostCreated,
41020
41113
  onPostUpdated: onPostUpdated,
41021
41114
  onPostDeleted: onPostDeleted,