@amityco/ts-sdk 7.5.3-d6ee46d.0 → 7.5.4-2d34fd5f.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 (75) hide show
  1. package/dist/@types/domains/content.d.ts +11 -2
  2. package/dist/@types/domains/content.d.ts.map +1 -1
  3. package/dist/@types/domains/feed.d.ts +2 -1
  4. package/dist/@types/domains/feed.d.ts.map +1 -1
  5. package/dist/@types/domains/file.d.ts +3 -1
  6. package/dist/@types/domains/file.d.ts.map +1 -1
  7. package/dist/@types/domains/pinnedPost.d.ts +1 -1
  8. package/dist/@types/domains/pinnedPost.d.ts.map +1 -1
  9. package/dist/@types/domains/post.d.ts +21 -1
  10. package/dist/@types/domains/post.d.ts.map +1 -1
  11. package/dist/@types/index.d.ts +2 -0
  12. package/dist/@types/index.d.ts.map +1 -1
  13. package/dist/client/api/enableUnreadCount.d.ts.map +1 -1
  14. package/dist/client/api/login.d.ts.map +1 -1
  15. package/dist/client/utils/markerSyncEngine.d.ts +1 -1
  16. package/dist/client/utils/markerSyncEngine.d.ts.map +1 -1
  17. package/dist/communityRepository/api/deleteCommunity.d.ts.map +1 -1
  18. package/dist/communityRepository/api/getCommunity.d.ts +2 -2
  19. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  20. package/dist/communityRepository/observers/getCommunity.d.ts.map +1 -1
  21. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts.map +1 -1
  22. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +1 -1
  23. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
  24. package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  25. package/dist/fileRepository/api/index.d.ts +1 -0
  26. package/dist/fileRepository/api/index.d.ts.map +1 -1
  27. package/dist/fileRepository/api/uploadClip.d.ts +17 -0
  28. package/dist/fileRepository/api/uploadClip.d.ts.map +1 -0
  29. package/dist/index.cjs.js +433 -432
  30. package/dist/index.esm.js +400 -399
  31. package/dist/index.umd.js +2 -2
  32. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  33. package/dist/postRepository/api/createClipPost.d.ts +32 -0
  34. package/dist/postRepository/api/createClipPost.d.ts.map +1 -0
  35. package/dist/postRepository/api/getPost.d.ts +2 -2
  36. package/dist/postRepository/api/getPost.d.ts.map +1 -1
  37. package/dist/postRepository/api/index.d.ts +1 -0
  38. package/dist/postRepository/api/index.d.ts.map +1 -1
  39. package/dist/userRepository/observers/getBlockedUsers.d.ts +4 -4
  40. package/dist/userRepository/observers/getBlockedUsers.d.ts.map +1 -1
  41. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  42. package/dist/utils/postTypePredicate.d.ts +1 -0
  43. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  44. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  45. package/package.json +1 -1
  46. package/src/@types/domains/content.ts +25 -1
  47. package/src/@types/domains/feed.ts +2 -1
  48. package/src/@types/domains/file.ts +5 -0
  49. package/src/@types/domains/pinnedPost.ts +1 -1
  50. package/src/@types/domains/post.ts +29 -8
  51. package/src/@types/index.ts +2 -0
  52. package/src/client/api/enableUnreadCount.ts +0 -22
  53. package/src/client/api/login.ts +0 -4
  54. package/src/client/utils/markerSyncEngine.ts +3 -24
  55. package/src/commentRepository/api/createComment.ts +1 -1
  56. package/src/commentRepository/api/deleteComment.ts +1 -1
  57. package/src/communityRepository/api/deleteCommunity.ts +2 -1
  58. package/src/communityRepository/api/getCommunity.ts +5 -7
  59. package/src/communityRepository/observers/getCommunity.ts +24 -12
  60. package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts +1 -2
  61. package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +1 -1
  62. package/src/feedRepository/api/queryGlobalFeed.ts +3 -1
  63. package/src/fileRepository/api/index.ts +1 -0
  64. package/src/fileRepository/api/uploadClip.ts +71 -0
  65. package/src/postRepository/api/createClipPost.ts +62 -0
  66. package/src/postRepository/api/getPost.ts +6 -4
  67. package/src/postRepository/api/index.ts +2 -0
  68. package/src/postRepository/api/queryPosts.ts +1 -1
  69. package/src/postRepository/observers/getPost.ts +2 -2
  70. package/src/postRepository/observers/getPosts/PostPaginationController.ts +1 -1
  71. package/src/reactionRepository/api/addReaction.ts +1 -1
  72. package/src/userRepository/observers/getBlockedUsers.ts +4 -4
  73. package/src/utils/linkedObject/postLinkedObject.ts +12 -1
  74. package/src/utils/linkedObject/streamLinkedObject.ts +1 -1
  75. package/src/utils/postTypePredicate.ts +10 -0
package/dist/index.esm.js CHANGED
@@ -18,6 +18,7 @@ const FileType = Object.freeze({
18
18
  FILE: 'file',
19
19
  IMAGE: 'image',
20
20
  VIDEO: 'video',
21
+ CLIP: 'clip',
21
22
  });
22
23
  const VideoResolution = Object.freeze({
23
24
  '1080P': '1080p',
@@ -101,6 +102,7 @@ const PostContentType = Object.freeze({
101
102
  VIDEO: 'video',
102
103
  LIVESTREAM: 'liveStream',
103
104
  POLL: 'poll',
105
+ CLIP: 'clip',
104
106
  });
105
107
 
106
108
  var InvitationTypeEnum;
@@ -136,8 +138,8 @@ var JoinResultStatusEnum;
136
138
 
137
139
  function getVersion() {
138
140
  try {
139
- // the string ''v7.5.2-esm'' should be replaced by actual value by @rollup/plugin-replace
140
- return 'v7.5.2-esm';
141
+ // the string ''v7.5.3-esm'' should be replaced by actual value by @rollup/plugin-replace
142
+ return 'v7.5.3-esm';
141
143
  }
142
144
  catch (error) {
143
145
  return '__dev__';
@@ -22783,6 +22785,13 @@ function isAmityVideoPost(post) {
22783
22785
  'videoFileId' in post.data &&
22784
22786
  'thumbnailFileId' in post.data &&
22785
22787
  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');
22786
22795
  }
22787
22796
 
22788
22797
  const postLinkedObject = (post) => {
@@ -22837,6 +22846,12 @@ const postLinkedObject = (post) => {
22837
22846
  return isAmityFilePost(post)
22838
22847
  ? (_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
22839
22848
  : 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;
22840
22855
  } });
22841
22856
  };
22842
22857
 
@@ -23817,7 +23832,7 @@ class PaginationController {
23817
23832
  */
23818
23833
  class JoinRequestsPaginationController extends PaginationController {
23819
23834
  async getRequest(queryParams, token) {
23820
- const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, communityId } = queryParams, params = __rest(queryParams, ["limit", "communityId"]);
23835
+ const { limit = 20, communityId } = queryParams, params = __rest(queryParams, ["limit", "communityId"]);
23821
23836
  const options = token ? { token } : { limit };
23822
23837
  const { data: queryResponse } = await this.http.get(`/api/v4/communities/${communityId}/join`, {
23823
23838
  params: Object.assign(Object.assign({}, params), { options }),
@@ -25987,6 +26002,266 @@ const removeChannelMarkerCache = (channel) => {
25987
26002
  dropFromCache(['channelMarker', 'get', id], true);
25988
26003
  };
25989
26004
 
26005
+ /* eslint-disable no-param-reassign */
26006
+ /*
26007
+ * declared earlier to accomodate case when logging in with a different user
26008
+ * than the one already connected, in which case the existing subscriptions need
26009
+ * to be cleared
26010
+ */
26011
+ let subscriptions = [];
26012
+ async function runMqtt() {
26013
+ await modifyMqttConnection();
26014
+ }
26015
+ /* begin_public_function
26016
+ id: client.login
26017
+ */
26018
+ /**
26019
+ * ```js
26020
+ * import { login } from '@amityco/ts-sdk/client/api'
26021
+ * const success = await login({
26022
+ * userId: 'XYZ123456789',
26023
+ * })
26024
+ * ```
26025
+ *
26026
+ * Connects an {@link Amity.Client} instance to ASC servers
26027
+ *
26028
+ * @param params the connect parameters
26029
+ * @param params.userId the user ID for the current session
26030
+ * @param params.displayName the user's displayName for the current session
26031
+ * @param params.deviceId Manual override of the user's device id (for device management)
26032
+ * @param params.authToken The authentication token - necessary when network option is set to secure
26033
+ * @returns a success boolean if connected
26034
+ *
26035
+ * @category Client API
26036
+ * @async
26037
+ */
26038
+ const login = async (params, sessionHandler, config) => {
26039
+ var _a;
26040
+ const client = getActiveClient();
26041
+ let unsubWatcher;
26042
+ client.log('client/api/connectClient', Object.assign({ apiKey: client.apiKey, sessionState: client.sessionState }, params));
26043
+ // if connecting to a different userId than the one that is connected currently
26044
+ if (client.userId && client.userId !== params.userId) {
26045
+ await logout();
26046
+ // Remove subscription to ban and delete
26047
+ subscriptions.forEach(fn => fn());
26048
+ subscriptions = [];
26049
+ }
26050
+ // default values
26051
+ const defaultDeviceId = await getDeviceId();
26052
+ try {
26053
+ const { users } = await setClientToken({
26054
+ params: Object.assign(Object.assign({}, params), { displayName: params === null || params === void 0 ? void 0 : params.displayName, deviceId: (params === null || params === void 0 ? void 0 : params.deviceId) || defaultDeviceId }),
26055
+ options: {
26056
+ setAccessTokenCookie: true,
26057
+ },
26058
+ });
26059
+ const user = users.find(u => u.userId === params.userId);
26060
+ if (user == null) {
26061
+ throw new ASCError(`${params.userId} has not been founded`, 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
26062
+ }
26063
+ if (user.isDeleted) {
26064
+ terminateClient("userDeleted" /* Amity.TokenTerminationReason.USER_DELETED */);
26065
+ return false;
26066
+ }
26067
+ if (user.isGlobalBanned) {
26068
+ terminateClient("globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */);
26069
+ return false;
26070
+ }
26071
+ // FIXME: events are duplicated if connectClient is called few times without disconnectClient
26072
+ // wire websocket events to our event emitter
26073
+ proxyWebsocketEvents(client.ws, client.emitter);
26074
+ (_a = client.ws) === null || _a === void 0 ? void 0 : _a.open();
26075
+ client.userId = user.userId;
26076
+ client.sessionHandler = sessionHandler;
26077
+ /*
26078
+ * Cannot push to subscriptions as watcher needs to continue working even if
26079
+ * token expires
26080
+ */
26081
+ unsubWatcher = client.accessTokenExpiryWatcher(sessionHandler);
26082
+ setActiveUser(user);
26083
+ }
26084
+ catch (error) {
26085
+ /*
26086
+ * if getting token failed session state reverts to initial state when app
26087
+ * is first launched
26088
+ */
26089
+ SessionWatcher$1.getInstance().setSessionState("notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */);
26090
+ // pass error down tree so the calling function handle it
26091
+ throw error;
26092
+ }
26093
+ if ((config === null || config === void 0 ? void 0 : config.disableRTE) !== true) {
26094
+ runMqtt();
26095
+ }
26096
+ await initializeMessagePreviewSetting();
26097
+ if (subscriptions.length === 0) {
26098
+ subscriptions.push(
26099
+ // GLOBAL_BAN
26100
+ onClientBanned((_) => {
26101
+ terminateClient("globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */);
26102
+ subscriptions.forEach(fn => fn());
26103
+ unsubWatcher();
26104
+ }), onTokenTerminated(_ => {
26105
+ terminateClient();
26106
+ subscriptions.forEach(fn => fn());
26107
+ unsubWatcher();
26108
+ }), onUserDeleted$2((user) => {
26109
+ if (user.userId === client.userId) {
26110
+ terminateClient("userDeleted" /* Amity.TokenTerminationReason.USER_DELETED */);
26111
+ subscriptions.forEach(fn => fn());
26112
+ unsubWatcher();
26113
+ }
26114
+ }), onTokenExpired(state => {
26115
+ SessionWatcher$1.getInstance().setSessionState(state);
26116
+ logout();
26117
+ subscriptions.forEach(fn => fn());
26118
+ }),
26119
+ // NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
26120
+ // the channel because currently backend can't handle this, so every time a user is banned from
26121
+ // a channel or the channel is deleted the channel's unread count will not be reset to zero
26122
+ onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
26123
+ if (client.useLegacyUnreadCount) {
26124
+ subscriptions.push(readReceiptSyncEngineOnLoginHandler());
26125
+ }
26126
+ else
26127
+ subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
26128
+ }
26129
+ return true;
26130
+ };
26131
+ /* end_public_function */
26132
+
26133
+ /* begin_public_function
26134
+ id: client.renew_access_token
26135
+ */
26136
+ /*
26137
+ * Renewal defintion accepted by SessionHandler interface
26138
+ *
26139
+ * Tech Spec:
26140
+ * https://ekoapp.atlassian.net/wiki/spaces/UP/pages/2082537485/ASC+Core+-+Session+Management+3.0#Session-Handler
26141
+ *
26142
+ * @category private
26143
+ */
26144
+ const renewal = () => {
26145
+ let tokenRenewed = false;
26146
+ let renewTimeoutId;
26147
+ const client = getActiveClient();
26148
+ client.log('initiating access token renewal');
26149
+ /*
26150
+ * Renews a token if it is hasn't been renewed before. Also marks token as
26151
+ * renewed once done
26152
+ * Per instance of Renewal, only one renewal is allowed
26153
+ */
26154
+ const renewToken = async (authToken) => {
26155
+ const { userId, displayName } = getActiveUser();
26156
+ const deviceId = await getDeviceId();
26157
+ const params = { userId, displayName, authToken, deviceId };
26158
+ if (client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */ && client.sessionHandler) {
26159
+ await login(params, client.sessionHandler);
26160
+ }
26161
+ else {
26162
+ // about to expire
26163
+ await setClientToken({
26164
+ params,
26165
+ options: {
26166
+ setAccessTokenCookie: true,
26167
+ },
26168
+ });
26169
+ }
26170
+ tokenRenewed = true;
26171
+ if (renewTimeoutId)
26172
+ clearTimeout(renewTimeoutId);
26173
+ };
26174
+ return {
26175
+ renew: () => {
26176
+ if (tokenRenewed) {
26177
+ console.log("'renew' method can be called only once per renewal instance");
26178
+ return;
26179
+ }
26180
+ renewToken();
26181
+ },
26182
+ renewWithAuthToken: (authToken) => {
26183
+ if (tokenRenewed) {
26184
+ console.log("'renewWithAuthToken' method can be called only once per renewal instance");
26185
+ return;
26186
+ }
26187
+ renewToken(authToken);
26188
+ },
26189
+ unableToRetrieveAuthToken: () => {
26190
+ renewTimeoutId = setTimeout(() => {
26191
+ var _a;
26192
+ (_a = client.sessionHandler) === null || _a === void 0 ? void 0 : _a.sessionWillRenewAccessToken(renewal());
26193
+ }, ACCESS_TOKEN_WATCHER_INTERVAL);
26194
+ },
26195
+ };
26196
+ };
26197
+ /* end_public_function */
26198
+
26199
+ const ABOUT_TO_EXPIRE_THRESHOLD = 80 / 100;
26200
+ const COMPENSATED_DELAY = 5 * MINUTE;
26201
+ /*
26202
+ * a helper function to check if the token has expires
26203
+ *
26204
+ * @param token to be checked
26205
+ * @returns boolean indicating if token expires
26206
+ *
26207
+ * @category private
26208
+ */
26209
+ const isExpired = (expiresAt) => Date.now() > Date.parse(expiresAt) - COMPENSATED_DELAY;
26210
+ /*
26211
+ * a helper function to check if the token is about to expire
26212
+ *
26213
+ * @param token to be checked
26214
+ * @returns boolean indicating if token is aboutToExpire
26215
+ *
26216
+ * @category private
26217
+ */
26218
+ const isAboutToExpire = (params) => {
26219
+ const { expiresAt, issuedAt } = params;
26220
+ const expires = Date.parse(expiresAt);
26221
+ const issued = Date.parse(issuedAt);
26222
+ const now = Date.now();
26223
+ const duration = expires - issued - COMPENSATED_DELAY;
26224
+ const aboutToExpireAt = issued + duration * ABOUT_TO_EXPIRE_THRESHOLD;
26225
+ return now > aboutToExpireAt && now < expires;
26226
+ };
26227
+ /*
26228
+ * Monitors time to expire of token and updates session state to aboutToExpire
26229
+ *
26230
+ * @returns intervalId to be cleared after trigger
26231
+ *
26232
+ * @category private
26233
+ */
26234
+ const accessTokenExpiryWatcher = (sessionHandler) => {
26235
+ const interval = setInterval(() => {
26236
+ const client = getActiveClient();
26237
+ if (!client.token)
26238
+ return;
26239
+ const { issuedAt, expiresAt } = client.token;
26240
+ if (isExpired(expiresAt)) {
26241
+ /*
26242
+ * the event handler will take care of updating session state
26243
+ * Note, this will also clear the interval id, so this event will only be
26244
+ * fired once
26245
+ */
26246
+ fireEvent('tokenExpired', "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */);
26247
+ /*
26248
+ * https://ekoapp.atlassian.net/wiki/spaces/UP/pages/2082537485/ASC+Core+-+Session+Management+3.0#Automatically-initiate-renewal-flow
26249
+ *
26250
+ * Why sechduled task?
26251
+ * Since fireEvent is scheduled, it will be called
26252
+ * after sessionHandler leading to an invalid state change from
26253
+ * establishing to tokenExpired
26254
+ */
26255
+ scheduleTask(() => sessionHandler.sessionWillRenewAccessToken(renewal()));
26256
+ return;
26257
+ }
26258
+ if (isAboutToExpire({ expiresAt, issuedAt })) {
26259
+ sessionHandler.sessionWillRenewAccessToken(renewal());
26260
+ }
26261
+ }, ACCESS_TOKEN_WATCHER_INTERVAL);
26262
+ return () => clearInterval(interval);
26263
+ };
26264
+
25990
26265
  const callbacks$9 = [];
25991
26266
  let mainDisposer$8 = null;
25992
26267
  const dispose$9 = (cb) => {
@@ -26259,33 +26534,6 @@ const onChannelMemberRoleRemoved = (callback) => {
26259
26534
  return () => dispose(callback);
26260
26535
  };
26261
26536
 
26262
- /**
26263
- * ```js
26264
- * import { onUserMarkerSync } from '@amityco/ts-sdk'
26265
- * const dispose = onUserMarkerSync(UserMarker => {
26266
- * // ...
26267
- * })
26268
- * ```
26269
- *
26270
- * Fired when an {@link Amity.UserMarker} has been sync
26271
- *
26272
- * @param callback The function to call when the event was fired
26273
- * @returns an {@link Amity.Unsubscriber} function to stop listening
26274
- *
26275
- * @category UserMarker Events
26276
- */
26277
- const onUserMarkerSync = (callback) => {
26278
- const client = getActiveClient();
26279
- const filter = (payload) => {
26280
- const { userMarkers, userEntityMarkers: userEntityMarkersPayload, userFeedMarkers: userFeedMarkersPayload } = payload, rest = __rest(payload, ["userMarkers", "userEntityMarkers", "userFeedMarkers"]);
26281
- const userEntityMarkers = convertChannelMarkerResponse(userEntityMarkersPayload);
26282
- const userFeedMarker = convertSubChannelMarkerResponse(userFeedMarkersPayload);
26283
- ingestInCache(Object.assign({ userMarkers, userEntityMarkers, userFeedMarker }, rest));
26284
- callback(userMarkers[0]);
26285
- };
26286
- return createEventSubscriber(client, 'UserMarker/onUserMarkerSync', 'marker.user-sync', filter);
26287
- };
26288
-
26289
26537
  /**
26290
26538
  * ```js
26291
26539
  * import { onFeedMarkerUpdated } from '@amityco/ts-sdk'
@@ -26557,52 +26805,11 @@ const markerSync = async (deviceLastSyncAt) => {
26557
26805
  };
26558
26806
  };
26559
26807
 
26560
- const enableUnreadCount = () => {
26561
- const client = getActiveClient();
26562
- client.log('client/api/isUnreadCountEnabled', client.isUnreadCountEnabled);
26563
- if (!client) {
26564
- throw new ASCError('There is no active client', 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "fatal" /* Amity.ErrorLevel.FATAL */);
26565
- }
26566
- if (client.isUnreadCountEnabled)
26567
- return false;
26568
- client.isUnreadCountEnabled = true;
26569
- client.useLegacyUnreadCount = false;
26570
- client.emitter.emit('unreadCountEnabled', true);
26571
- return true;
26572
- };
26573
-
26574
- /**
26575
- * ```js
26576
- * import { onFeedMarkerUpdated } from '@amityco/ts-sdk'
26577
- * const dispose = onFeedMarkerUpdated(feedMarker => {
26578
- * // ...
26579
- * })
26580
- * ```
26581
- *
26582
- * Fired when an {@link Amity.UserFeedMarker} has been updated
26583
- *
26584
- * @param callback The function to call when the event was fired
26585
- * @returns an {@link Amity.Unsubscriber} function to stop listening
26586
- *
26587
- * @category FeedMarker Events
26588
- */
26589
- const onUserFeedMarkerUpdated = (callback) => {
26590
- const client = getActiveClient();
26591
- const filter = (payload) => {
26592
- persistUnreadCountInfo(payload);
26593
- payload.feedMarkers.forEach(feedMarker => {
26594
- callback(feedMarker);
26595
- });
26596
- };
26597
- return createEventSubscriber(client, 'feedMarker/onUserFeedMarkerUpdated', 'marker.userFeed-updated', filter);
26598
- };
26599
-
26600
26808
  const SYNC_TRIGGER_INTERVAL_TIME = 2000;
26601
- const ON_SUB_CHANNEL_DELETE_SYNC_TRIGGER_DELAY = 2000;
26602
26809
  let isSyncRunning = false;
26603
26810
  let disposers$1 = [];
26604
26811
  let isWaitingForResponse = false;
26605
- let isConsistentMode = true;
26812
+ const isConsistentMode = true;
26606
26813
  let deviceLastSyncAt = null;
26607
26814
  const getDeviceLastSyncAt = () => {
26608
26815
  if (deviceLastSyncAt == null) {
@@ -26617,12 +26824,6 @@ const saveDeviceLastSyncAt = (lastSyncAt) => {
26617
26824
  deviceLastSyncAt = lastSyncAt;
26618
26825
  }
26619
26826
  };
26620
- const fetchDeviceLastSyncAt = async () => {
26621
- const { data: userMarker } = await getUserMarker();
26622
- if (userMarker == null)
26623
- return;
26624
- saveDeviceLastSyncAt(new Date(userMarker.lastSyncAt));
26625
- };
26626
26827
  /**
26627
26828
  * list of conditions that make timer still trigger the syncing process.
26628
26829
  * If it's empty, it means sync is stopped.
@@ -26687,43 +26888,11 @@ const markerSyncTrigger = async () => {
26687
26888
  }
26688
26889
  }
26689
26890
  };
26690
- const registerEventListeners = () => {
26691
- if (disposers$1.length > 0) {
26692
- return;
26693
- }
26694
- // based on the tech spec design, we designed a fetch marker in case of these events
26695
- // - new message
26696
- // - create channel
26697
- // - remove channel
26698
- // - app going to online again after offline
26699
- disposers$1.push(onOnline(() => {
26700
- // should add RESUME to the event to trigger marker syncing again
26701
- events.push("resume" /* Amity.MarkerSyncEvent.RESUME */);
26702
- }), onMessageCreatedMqtt(message => {
26703
- // only conversation, community and broadcast types can sync
26704
- const client = getActiveClient();
26705
- if (isUnreadCountSupport$1(message) && message.creatorId !== client.userId)
26706
- events.push("new message" /* Amity.MarkerSyncEvent.NEW_MESSAGE */);
26707
- }), onChannelCreated(() => events.push("subchannel is created" /* Amity.MarkerSyncEvent.CHANNEL_CREATED */)), onChannelDeleted(() => events.push("subchannel is deleted" /* Amity.MarkerSyncEvent.CHANNEL_DELETED */)), onChannelJoined(() => events.push("subchannel is joined" /* Amity.MarkerSyncEvent.CHANNEL_JOINED */)), onChannelLeft(() => events.push("subchannel is left" /* Amity.MarkerSyncEvent.CHANNEL_LEFT */)), onSubChannelCreated(() => events.push("subchannel is created" /* Amity.MarkerSyncEvent.SUB_CHANNEL_CREATED */)), onSubChannelDeleted(() =>
26708
- /*
26709
- workaround: when receiving the event for sub-channel deletion,
26710
- before triggering marker update, the SDK will have to add a 2-second delay.
26711
- so that the unread count is calculated correctly.
26712
- */
26713
- setTimeout(() => events.push("subchannel is deleted" /* Amity.MarkerSyncEvent.SUBCHANNEL_IS_DELETED */), ON_SUB_CHANNEL_DELETE_SYNC_TRIGGER_DELAY)), onFeedMarkerUpdated(() => events.push("feed marker updated" /* Amity.MarkerSyncEvent.MARKER_UPDATED */)), onUserMarkerSync(() => events.push("feed marker updated" /* Amity.MarkerSyncEvent.MARKER_UPDATED */)), onUserFeedMarkerUpdated(() => events.push("feed marker updated" /* Amity.MarkerSyncEvent.MARKER_UPDATED */)));
26714
- };
26715
26891
  const unRegisterEventListeners = () => {
26716
26892
  disposers$1.forEach(fn => fn());
26717
26893
  disposers$1 = [];
26718
26894
  };
26719
- const startMarkerSync = async () => {
26720
- await fetchDeviceLastSyncAt();
26721
- pushMarkerSyncEvent("start syncing" /* Amity.MarkerSyncEvent.START_SYNCING */);
26722
- isConsistentMode = true;
26723
- isSyncRunning = true;
26724
- registerEventListeners();
26725
- return unRegisterEventListeners;
26726
- };
26895
+ const startMarkerSync = async () => Promise.resolve();
26727
26896
  /**
26728
26897
  ```js
26729
26898
  * import { startUnreadSync } from '@amityco/ts-sdk'
@@ -26735,14 +26904,7 @@ const startMarkerSync = async () => {
26735
26904
  *
26736
26905
  * @category Marker API
26737
26906
  */
26738
- const startUnreadSync = async () => {
26739
- await fetchDeviceLastSyncAt();
26740
- pushMarkerSyncEvent("start syncing" /* Amity.MarkerSyncEvent.START_SYNCING */);
26741
- enableUnreadCount();
26742
- isConsistentMode = false;
26743
- isSyncRunning = true;
26744
- registerEventListeners();
26745
- };
26907
+ const startUnreadSync = async () => Promise.resolve();
26746
26908
  /**
26747
26909
  ```js
26748
26910
  * import { stopUnreadSync } from '@amityco/ts-sdk'
@@ -26765,268 +26927,6 @@ setIntervalTask(async () => {
26765
26927
  }, SYNC_TRIGGER_INTERVAL_TIME);
26766
26928
  const getMarkerSyncConsistentMode = () => isConsistentMode;
26767
26929
 
26768
- /* eslint-disable no-param-reassign */
26769
- /*
26770
- * declared earlier to accomodate case when logging in with a different user
26771
- * than the one already connected, in which case the existing subscriptions need
26772
- * to be cleared
26773
- */
26774
- let subscriptions = [];
26775
- async function runMqtt() {
26776
- await modifyMqttConnection();
26777
- }
26778
- /* begin_public_function
26779
- id: client.login
26780
- */
26781
- /**
26782
- * ```js
26783
- * import { login } from '@amityco/ts-sdk/client/api'
26784
- * const success = await login({
26785
- * userId: 'XYZ123456789',
26786
- * })
26787
- * ```
26788
- *
26789
- * Connects an {@link Amity.Client} instance to ASC servers
26790
- *
26791
- * @param params the connect parameters
26792
- * @param params.userId the user ID for the current session
26793
- * @param params.displayName the user's displayName for the current session
26794
- * @param params.deviceId Manual override of the user's device id (for device management)
26795
- * @param params.authToken The authentication token - necessary when network option is set to secure
26796
- * @returns a success boolean if connected
26797
- *
26798
- * @category Client API
26799
- * @async
26800
- */
26801
- const login = async (params, sessionHandler, config) => {
26802
- var _a;
26803
- const client = getActiveClient();
26804
- let unsubWatcher;
26805
- client.log('client/api/connectClient', Object.assign({ apiKey: client.apiKey, sessionState: client.sessionState }, params));
26806
- // if connecting to a different userId than the one that is connected currently
26807
- if (client.userId && client.userId !== params.userId) {
26808
- await logout();
26809
- // Remove subscription to ban and delete
26810
- subscriptions.forEach(fn => fn());
26811
- subscriptions = [];
26812
- }
26813
- // default values
26814
- const defaultDeviceId = await getDeviceId();
26815
- try {
26816
- const { users } = await setClientToken({
26817
- params: Object.assign(Object.assign({}, params), { displayName: params === null || params === void 0 ? void 0 : params.displayName, deviceId: (params === null || params === void 0 ? void 0 : params.deviceId) || defaultDeviceId }),
26818
- options: {
26819
- setAccessTokenCookie: true,
26820
- },
26821
- });
26822
- const user = users.find(u => u.userId === params.userId);
26823
- if (user == null) {
26824
- throw new ASCError(`${params.userId} has not been founded`, 800000 /* Amity.ClientError.UNKNOWN_ERROR */, "error" /* Amity.ErrorLevel.ERROR */);
26825
- }
26826
- if (user.isDeleted) {
26827
- terminateClient("userDeleted" /* Amity.TokenTerminationReason.USER_DELETED */);
26828
- return false;
26829
- }
26830
- if (user.isGlobalBanned) {
26831
- terminateClient("globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */);
26832
- return false;
26833
- }
26834
- // FIXME: events are duplicated if connectClient is called few times without disconnectClient
26835
- // wire websocket events to our event emitter
26836
- proxyWebsocketEvents(client.ws, client.emitter);
26837
- (_a = client.ws) === null || _a === void 0 ? void 0 : _a.open();
26838
- client.userId = user.userId;
26839
- client.sessionHandler = sessionHandler;
26840
- /*
26841
- * Cannot push to subscriptions as watcher needs to continue working even if
26842
- * token expires
26843
- */
26844
- unsubWatcher = client.accessTokenExpiryWatcher(sessionHandler);
26845
- setActiveUser(user);
26846
- }
26847
- catch (error) {
26848
- /*
26849
- * if getting token failed session state reverts to initial state when app
26850
- * is first launched
26851
- */
26852
- SessionWatcher$1.getInstance().setSessionState("notLoggedIn" /* Amity.SessionStates.NOT_LOGGED_IN */);
26853
- // pass error down tree so the calling function handle it
26854
- throw error;
26855
- }
26856
- if ((config === null || config === void 0 ? void 0 : config.disableRTE) !== true) {
26857
- runMqtt();
26858
- }
26859
- await initializeMessagePreviewSetting();
26860
- if (subscriptions.length === 0) {
26861
- subscriptions.push(
26862
- // GLOBAL_BAN
26863
- onClientBanned((_) => {
26864
- terminateClient("globalBan" /* Amity.TokenTerminationReason.GLOBAL_BAN */);
26865
- subscriptions.forEach(fn => fn());
26866
- unsubWatcher();
26867
- }), onTokenTerminated(_ => {
26868
- terminateClient();
26869
- subscriptions.forEach(fn => fn());
26870
- unsubWatcher();
26871
- }), onUserDeleted$2((user) => {
26872
- if (user.userId === client.userId) {
26873
- terminateClient("userDeleted" /* Amity.TokenTerminationReason.USER_DELETED */);
26874
- subscriptions.forEach(fn => fn());
26875
- unsubWatcher();
26876
- }
26877
- }), onTokenExpired(state => {
26878
- SessionWatcher$1.getInstance().setSessionState(state);
26879
- logout();
26880
- subscriptions.forEach(fn => fn());
26881
- }),
26882
- // NOTE: This is a temporary solution to handle the channel marker when the user is forced to leave
26883
- // the channel because currently backend can't handle this, so every time a user is banned from
26884
- // a channel or the channel is deleted the channel's unread count will not be reset to zero
26885
- onChannelDeleted(removeChannelMarkerCache), onChannelMemberBanned(removeChannelMarkerCache), markReadEngineOnLoginHandler(), analyticsEngineOnLoginHandler(), objectResolverEngineOnLoginHandler());
26886
- if (client.useLegacyUnreadCount) {
26887
- subscriptions.push(readReceiptSyncEngineOnLoginHandler());
26888
- }
26889
- else
26890
- subscriptions.push(legacyReadReceiptSyncEngineOnLoginHandler());
26891
- const markerSyncUnsubscriber = await startMarkerSync();
26892
- subscriptions.push(markerSyncUnsubscriber);
26893
- }
26894
- return true;
26895
- };
26896
- /* end_public_function */
26897
-
26898
- /* begin_public_function
26899
- id: client.renew_access_token
26900
- */
26901
- /*
26902
- * Renewal defintion accepted by SessionHandler interface
26903
- *
26904
- * Tech Spec:
26905
- * https://ekoapp.atlassian.net/wiki/spaces/UP/pages/2082537485/ASC+Core+-+Session+Management+3.0#Session-Handler
26906
- *
26907
- * @category private
26908
- */
26909
- const renewal = () => {
26910
- let tokenRenewed = false;
26911
- let renewTimeoutId;
26912
- const client = getActiveClient();
26913
- client.log('initiating access token renewal');
26914
- /*
26915
- * Renews a token if it is hasn't been renewed before. Also marks token as
26916
- * renewed once done
26917
- * Per instance of Renewal, only one renewal is allowed
26918
- */
26919
- const renewToken = async (authToken) => {
26920
- const { userId, displayName } = getActiveUser();
26921
- const deviceId = await getDeviceId();
26922
- const params = { userId, displayName, authToken, deviceId };
26923
- if (client.sessionState === "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */ && client.sessionHandler) {
26924
- await login(params, client.sessionHandler);
26925
- }
26926
- else {
26927
- // about to expire
26928
- await setClientToken({
26929
- params,
26930
- options: {
26931
- setAccessTokenCookie: true,
26932
- },
26933
- });
26934
- }
26935
- tokenRenewed = true;
26936
- if (renewTimeoutId)
26937
- clearTimeout(renewTimeoutId);
26938
- };
26939
- return {
26940
- renew: () => {
26941
- if (tokenRenewed) {
26942
- console.log("'renew' method can be called only once per renewal instance");
26943
- return;
26944
- }
26945
- renewToken();
26946
- },
26947
- renewWithAuthToken: (authToken) => {
26948
- if (tokenRenewed) {
26949
- console.log("'renewWithAuthToken' method can be called only once per renewal instance");
26950
- return;
26951
- }
26952
- renewToken(authToken);
26953
- },
26954
- unableToRetrieveAuthToken: () => {
26955
- renewTimeoutId = setTimeout(() => {
26956
- var _a;
26957
- (_a = client.sessionHandler) === null || _a === void 0 ? void 0 : _a.sessionWillRenewAccessToken(renewal());
26958
- }, ACCESS_TOKEN_WATCHER_INTERVAL);
26959
- },
26960
- };
26961
- };
26962
- /* end_public_function */
26963
-
26964
- const ABOUT_TO_EXPIRE_THRESHOLD = 80 / 100;
26965
- const COMPENSATED_DELAY = 5 * MINUTE;
26966
- /*
26967
- * a helper function to check if the token has expires
26968
- *
26969
- * @param token to be checked
26970
- * @returns boolean indicating if token expires
26971
- *
26972
- * @category private
26973
- */
26974
- const isExpired = (expiresAt) => Date.now() > Date.parse(expiresAt) - COMPENSATED_DELAY;
26975
- /*
26976
- * a helper function to check if the token is about to expire
26977
- *
26978
- * @param token to be checked
26979
- * @returns boolean indicating if token is aboutToExpire
26980
- *
26981
- * @category private
26982
- */
26983
- const isAboutToExpire = (params) => {
26984
- const { expiresAt, issuedAt } = params;
26985
- const expires = Date.parse(expiresAt);
26986
- const issued = Date.parse(issuedAt);
26987
- const now = Date.now();
26988
- const duration = expires - issued - COMPENSATED_DELAY;
26989
- const aboutToExpireAt = issued + duration * ABOUT_TO_EXPIRE_THRESHOLD;
26990
- return now > aboutToExpireAt && now < expires;
26991
- };
26992
- /*
26993
- * Monitors time to expire of token and updates session state to aboutToExpire
26994
- *
26995
- * @returns intervalId to be cleared after trigger
26996
- *
26997
- * @category private
26998
- */
26999
- const accessTokenExpiryWatcher = (sessionHandler) => {
27000
- const interval = setInterval(() => {
27001
- const client = getActiveClient();
27002
- if (!client.token)
27003
- return;
27004
- const { issuedAt, expiresAt } = client.token;
27005
- if (isExpired(expiresAt)) {
27006
- /*
27007
- * the event handler will take care of updating session state
27008
- * Note, this will also clear the interval id, so this event will only be
27009
- * fired once
27010
- */
27011
- fireEvent('tokenExpired', "tokenExpired" /* Amity.SessionStates.TOKEN_EXPIRED */);
27012
- /*
27013
- * https://ekoapp.atlassian.net/wiki/spaces/UP/pages/2082537485/ASC+Core+-+Session+Management+3.0#Automatically-initiate-renewal-flow
27014
- *
27015
- * Why sechduled task?
27016
- * Since fireEvent is scheduled, it will be called
27017
- * after sessionHandler leading to an invalid state change from
27018
- * establishing to tokenExpired
27019
- */
27020
- scheduleTask(() => sessionHandler.sessionWillRenewAccessToken(renewal()));
27021
- return;
27022
- }
27023
- if (isAboutToExpire({ expiresAt, issuedAt })) {
27024
- sessionHandler.sessionWillRenewAccessToken(renewal());
27025
- }
27026
- }, ACCESS_TOKEN_WATCHER_INTERVAL);
27027
- return () => clearInterval(interval);
27028
- };
27029
-
27030
26930
  const DEFAULT_DEBUG_SESSION = 'amity';
27031
26931
  /**
27032
26932
  * ```js
@@ -27172,6 +27072,10 @@ const isConnected = () => {
27172
27072
  isWsConnected);
27173
27073
  };
27174
27074
 
27075
+ const enableUnreadCount = () => {
27076
+ return true;
27077
+ };
27078
+
27175
27079
  var _GlobalFileAccessType_fileAccessType;
27176
27080
  class GlobalFileAccessType {
27177
27081
  constructor() {
@@ -29323,10 +29227,10 @@ class BlockedUserLiveCollectionController extends LiveCollectionController {
29323
29227
  * const unblockedUser = await UserRepository.blockUser('userId')
29324
29228
  * ```
29325
29229
  *
29326
- * Blocks a {@link Amity.InternalUser}
29230
+ * Blocks a {@link Amity.User}
29327
29231
  *
29328
- * @param params The params to get blocked {@link Amity.InternalUser}s
29329
- * @param callback to recieve updates on unblocked {@link Amity.InternalUser}s
29232
+ * @param params The params to get blocked {@link Amity.User}s
29233
+ * @param callback to recieve updates on unblocked {@link Amity.User}s
29330
29234
  * @returns {@link Amity.Unsubscriber} to unsubscribe from collection
29331
29235
  *
29332
29236
  * @category Post API
@@ -29918,6 +29822,57 @@ const updateAltText = async (fileId, altText) => {
29918
29822
  };
29919
29823
  /* end_public_function */
29920
29824
 
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
+
29921
29876
  var index$k = /*#__PURE__*/Object.freeze({
29922
29877
  __proto__: null,
29923
29878
  getFile: getFile,
@@ -29926,7 +29881,8 @@ var index$k = /*#__PURE__*/Object.freeze({
29926
29881
  fileUrlWithSize: fileUrlWithSize,
29927
29882
  uploadVideo: uploadVideo,
29928
29883
  uploadImage: uploadImage,
29929
- updateAltText: updateAltText
29884
+ updateAltText: updateAltText,
29885
+ uploadClip: uploadClip
29930
29886
  });
29931
29887
 
29932
29888
  /**
@@ -30170,7 +30126,7 @@ const getPost$2 = async (postId) => {
30170
30126
  const { posts } = data;
30171
30127
  const result = posts.find(post => post.postId === postId);
30172
30128
  return {
30173
- data: LinkedObject.post(result),
30129
+ data: result,
30174
30130
  cachedAt,
30175
30131
  };
30176
30132
  };
@@ -30196,7 +30152,7 @@ getPost$2.locally = (postId) => {
30196
30152
  if (!cached)
30197
30153
  return;
30198
30154
  return {
30199
- data: LinkedObject.post(cached.data),
30155
+ data: cached.data,
30200
30156
  cachedAt: cached.cachedAt,
30201
30157
  };
30202
30158
  };
@@ -30357,7 +30313,7 @@ const prepareCommentFromFlaggedEvent = (payload) => {
30357
30313
  * @async
30358
30314
  * */
30359
30315
  const addReaction = async (referenceType, referenceId, reactionName) => {
30360
- var _a, _b;
30316
+ var _a, _b, _c;
30361
30317
  const client = getActiveClient();
30362
30318
  client.log('reaction/createReaction', {
30363
30319
  referenceId,
@@ -30378,9 +30334,9 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
30378
30334
  'get',
30379
30335
  referenceId,
30380
30336
  ]);
30381
- if (!model)
30337
+ if (!model || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
30382
30338
  return true;
30383
- const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_a = model.data.myReactions) !== null && _a !== void 0 ? _a : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_b = model.data.reactions[reactionName]) !== null && _b !== void 0 ? _b : 0) + 1 }) });
30339
+ const updatedModel = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }) });
30384
30340
  if (referenceType === 'comment') {
30385
30341
  fireEvent('local.comment.addReaction', {
30386
30342
  comment: updatedModel,
@@ -35811,7 +35767,7 @@ const getCommunity$1 = async (communityId, type, includeDiscoverablePrivateCommu
35811
35767
  }
35812
35768
  const { communities } = data;
35813
35769
  return {
35814
- data: LinkedObject.community(communities.find(community => community.communityId === communityId)),
35770
+ data: communities.find(community => community.communityId === communityId),
35815
35771
  cachedAt,
35816
35772
  };
35817
35773
  };
@@ -35837,7 +35793,7 @@ getCommunity$1.locally = (communityId) => {
35837
35793
  if (!cached)
35838
35794
  return;
35839
35795
  return {
35840
- data: LinkedObject.community(cached.data),
35796
+ data: cached.data,
35841
35797
  cachedAt: cached.cachedAt,
35842
35798
  };
35843
35799
  };
@@ -35873,7 +35829,7 @@ const deleteCommunity = async (communityId) => {
35873
35829
  files: [],
35874
35830
  users: [],
35875
35831
  });
35876
- return deleted.data;
35832
+ return LinkedObject.community(deleted.data);
35877
35833
  };
35878
35834
  /* end_public_function */
35879
35835
 
@@ -37383,7 +37339,11 @@ const getCommunity = (communityId, callback) => {
37383
37339
  onCommunityUserUnbanned,
37384
37340
  onCommunityUserChanged,
37385
37341
  convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
37386
- ]);
37342
+ ], {
37343
+ callbackDataSelector: (data) => {
37344
+ return LinkedObject.community(data);
37345
+ },
37346
+ });
37387
37347
  };
37388
37348
  /* end_public_function */
37389
37349
 
@@ -38522,14 +38482,14 @@ var index$a = /*#__PURE__*/Object.freeze({
38522
38482
  const queryGlobalFeed = async (query) => {
38523
38483
  const client = getActiveClient();
38524
38484
  client.log('feed/queryGlobalFeed', query);
38525
- const _a = query !== null && query !== void 0 ? query : {}, { queryToken } = _a, params = __rest(_a, ["queryToken"]);
38485
+ const _a = query !== null && query !== void 0 ? query : {}, { queryToken, dataTypes, resolveParent } = _a, params = __rest(_a, ["queryToken", "dataTypes", "resolveParent"]);
38526
38486
  const options = (() => {
38527
38487
  if (queryToken)
38528
38488
  return { token: queryToken };
38529
38489
  return undefined;
38530
38490
  })();
38531
38491
  const { data: queryPayload } = await client.http.get(`/api/v4/me/global-feeds`, {
38532
- params: Object.assign(Object.assign({}, params), { options }),
38492
+ params: Object.assign(Object.assign({}, params), { dataTypes, resolveParent: resolveParent !== null && resolveParent !== void 0 ? resolveParent : true, options }),
38533
38493
  });
38534
38494
  const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
38535
38495
  const data = prepareMembershipPayload(payload, 'communityUsers');
@@ -39115,6 +39075,46 @@ const isPostFlaggedByMe = async (postId) => {
39115
39075
  };
39116
39076
  /* end_public_function */
39117
39077
 
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
39118
  /* begin_public_function
39119
39119
  id: comment.get_by_ids
39120
39120
  */
@@ -40163,12 +40163,12 @@ const getPost$1 = (postId, callback) => {
40163
40163
  onPostFlagged,
40164
40164
  (callback) => {
40165
40165
  return onPostReactionAdded((post) => {
40166
- callback(LinkedObject.post(post));
40166
+ callback(post);
40167
40167
  });
40168
40168
  },
40169
40169
  (callback) => {
40170
40170
  return onPostReactionRemoved((post) => {
40171
- callback(LinkedObject.post(post));
40171
+ callback(post);
40172
40172
  });
40173
40173
  },
40174
40174
  onPostUnflagged,
@@ -40203,7 +40203,7 @@ class PostPaginationController extends PaginationController {
40203
40203
  type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
40204
40204
  };
40205
40205
  const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
40206
- const { data: queryResponse } = await this.http.get(`/api/v4/posts`, {
40206
+ const { data: queryResponse } = await this.http.get(`/api/v5/posts`, {
40207
40207
  params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
40208
40208
  /*
40209
40209
  * when creating post like image, file, video BE will create 2 posts
@@ -41015,6 +41015,7 @@ var index$7 = /*#__PURE__*/Object.freeze({
41015
41015
  flagPost: flagPost,
41016
41016
  unflagPost: unflagPost,
41017
41017
  isPostFlaggedByMe: isPostFlaggedByMe,
41018
+ createClipPost: createClipPost,
41018
41019
  onPostCreated: onPostCreated,
41019
41020
  onPostUpdated: onPostUpdated,
41020
41021
  onPostDeleted: onPostDeleted,