@amityco/ts-sdk-react-native 7.6.0 → 7.7.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 (48) hide show
  1. package/dist/@types/core/payload.d.ts +1 -1
  2. package/dist/@types/core/payload.d.ts.map +1 -1
  3. package/dist/@types/domains/content.d.ts +8 -2
  4. package/dist/@types/domains/content.d.ts.map +1 -1
  5. package/dist/@types/domains/feed.d.ts +2 -1
  6. package/dist/@types/domains/feed.d.ts.map +1 -1
  7. package/dist/@types/domains/file.d.ts +3 -1
  8. package/dist/@types/domains/file.d.ts.map +1 -1
  9. package/dist/@types/domains/post.d.ts +3 -0
  10. package/dist/@types/domains/post.d.ts.map +1 -1
  11. package/dist/communityRepository/api/getCommunity.d.ts +1 -1
  12. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  13. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +1 -1
  14. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
  15. package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  16. package/dist/fileRepository/api/index.d.ts +1 -0
  17. package/dist/fileRepository/api/index.d.ts.map +1 -1
  18. package/dist/fileRepository/api/uploadClip.d.ts +17 -0
  19. package/dist/fileRepository/api/uploadClip.d.ts.map +1 -0
  20. package/dist/index.cjs.js +115 -13
  21. package/dist/index.esm.js +115 -13
  22. package/dist/index.umd.js +2 -2
  23. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  24. package/dist/postRepository/api/createClipPost.d.ts +32 -0
  25. package/dist/postRepository/api/createClipPost.d.ts.map +1 -0
  26. package/dist/postRepository/api/index.d.ts +1 -0
  27. package/dist/postRepository/api/index.d.ts.map +1 -1
  28. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  29. package/dist/utils/postTypePredicate.d.ts +1 -0
  30. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  31. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/src/@types/core/payload.ts +1 -1
  34. package/src/@types/domains/content.ts +10 -0
  35. package/src/@types/domains/feed.ts +2 -1
  36. package/src/@types/domains/file.ts +5 -0
  37. package/src/@types/domains/post.ts +4 -0
  38. package/src/communityRepository/api/getCommunity.ts +0 -9
  39. package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +1 -1
  40. package/src/feedRepository/api/queryGlobalFeed.ts +3 -1
  41. package/src/fileRepository/api/index.ts +1 -0
  42. package/src/fileRepository/api/uploadClip.ts +71 -0
  43. package/src/postRepository/api/createClipPost.ts +62 -0
  44. package/src/postRepository/api/index.ts +2 -0
  45. package/src/postRepository/api/queryPosts.ts +1 -1
  46. package/src/postRepository/observers/getPosts/PostPaginationController.ts +1 -1
  47. package/src/utils/linkedObject/postLinkedObject.ts +12 -1
  48. package/src/utils/postTypePredicate.ts +9 -0
package/dist/index.esm.js CHANGED
@@ -21,6 +21,7 @@ const FileType = Object.freeze({
21
21
  FILE: 'file',
22
22
  IMAGE: 'image',
23
23
  VIDEO: 'video',
24
+ CLIP: 'clip',
24
25
  });
25
26
  const VideoResolution = Object.freeze({
26
27
  '1080P': '1080p',
@@ -104,6 +105,7 @@ const PostContentType = Object.freeze({
104
105
  VIDEO: 'video',
105
106
  LIVESTREAM: 'liveStream',
106
107
  POLL: 'poll',
108
+ CLIP: 'clip',
107
109
  });
108
110
 
109
111
  var InvitationTypeEnum;
@@ -139,8 +141,8 @@ var JoinResultStatusEnum;
139
141
 
140
142
  function getVersion() {
141
143
  try {
142
- // the string ''v7.6.0-esm'' should be replaced by actual value by @rollup/plugin-replace
143
- return 'v7.6.0-esm';
144
+ // the string ''v7.7.0-esm'' should be replaced by actual value by @rollup/plugin-replace
145
+ return 'v7.7.0-esm';
144
146
  }
145
147
  catch (error) {
146
148
  return '__dev__';
@@ -22841,6 +22843,12 @@ function isAmityVideoPost(post) {
22841
22843
  'videoFileId' in post.data &&
22842
22844
  'thumbnailFileId' in post.data &&
22843
22845
  post.dataType === 'video');
22846
+ }
22847
+ function isAmityClipPost(post) {
22848
+ return !!(post.data &&
22849
+ typeof post.data !== 'string' &&
22850
+ 'fileId' in post.data &&
22851
+ post.dataType === 'clip');
22844
22852
  }
22845
22853
 
22846
22854
  const postLinkedObject = (post) => {
@@ -22895,6 +22903,12 @@ const postLinkedObject = (post) => {
22895
22903
  return isAmityFilePost(post)
22896
22904
  ? (_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
22897
22905
  : undefined;
22906
+ },
22907
+ getClipInfo() {
22908
+ var _a, _b;
22909
+ return isAmityClipPost(post)
22910
+ ? (_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
22911
+ : undefined;
22898
22912
  } });
22899
22913
  };
22900
22914
 
@@ -30154,6 +30168,57 @@ const updateAltText = async (fileId, altText) => {
30154
30168
  };
30155
30169
  /* end_public_function */
30156
30170
 
30171
+ /* begin_public_function
30172
+ id: file.upload.clip
30173
+ */
30174
+ /**
30175
+ * ```js
30176
+ * import { FileRepository } from '@amityco/ts-sdk'
30177
+ * const created = await FileRepository.uploadClip(formData)
30178
+ * ```
30179
+ *
30180
+ * Creates an {@link Amity.File}
30181
+ *
30182
+ * @param formData The data necessary to create a new {@link Amity.File}
30183
+ * @param onProgress The callback to track the upload progress
30184
+ * @returns The newly created {@link Amity.File}
30185
+ *
30186
+ * @category File API
30187
+ * @async
30188
+ */
30189
+ const uploadClip = async (formData, feedType, onProgress) => {
30190
+ const client = getActiveClient();
30191
+ client.log('file/uploadClip', formData);
30192
+ const file = formData.get('files');
30193
+ if (!file)
30194
+ throw new Error('The formData object must have a `files` key.');
30195
+ const accessType = GlobalFileAccessType$1.getInstance().getFileAccessType();
30196
+ formData.append('accessType', accessType);
30197
+ formData.append('preferredFilename', file.name);
30198
+ if (feedType) {
30199
+ formData.append('feedType', feedType);
30200
+ }
30201
+ const headers = 'getHeaders' in formData
30202
+ ? formData.getHeaders()
30203
+ : { 'content-type': 'multipart/form-data' };
30204
+ const { data } = await client.upload.post('/api/v4/clips', formData, {
30205
+ headers,
30206
+ onUploadProgress({ loaded, total = 100 }) {
30207
+ onProgress && onProgress(Math.round((loaded * 100) / total));
30208
+ },
30209
+ });
30210
+ // API-FIX: payload should be serialized properly
30211
+ // const { files } = data
30212
+ const cachedAt = client.cache && Date.now();
30213
+ if (client.cache)
30214
+ ingestInCache({ files: data }, { cachedAt });
30215
+ return {
30216
+ data,
30217
+ cachedAt,
30218
+ };
30219
+ };
30220
+ /* end_public_function */
30221
+
30157
30222
  var index$k = /*#__PURE__*/Object.freeze({
30158
30223
  __proto__: null,
30159
30224
  getFile: getFile,
@@ -30162,7 +30227,8 @@ var index$k = /*#__PURE__*/Object.freeze({
30162
30227
  fileUrlWithSize: fileUrlWithSize,
30163
30228
  uploadVideo: uploadVideo,
30164
30229
  uploadImage: uploadImage,
30165
- updateAltText: updateAltText
30230
+ updateAltText: updateAltText,
30231
+ uploadClip: uploadClip
30166
30232
  });
30167
30233
 
30168
30234
  /**
@@ -36030,16 +36096,11 @@ const updateCommunity = async (communityId, patch) => {
36030
36096
  * @category Community API
36031
36097
  * @async
36032
36098
  */
36033
- const getCommunity$1 = async (communityId, type, includeDiscoverablePrivateCommunity) => {
36099
+ const getCommunity$1 = async (communityId) => {
36034
36100
  const client = getActiveClient();
36035
36101
  client.log('community/getCommunity', communityId);
36036
36102
  // API-FIX: endpoint should not be /list, parameters should be querystring.
36037
- const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}`, {
36038
- params: {
36039
- type: 'communityJoinRequest',
36040
- includeDiscoverablePrivateCommunity: includeDiscoverablePrivateCommunity !== null && includeDiscoverablePrivateCommunity !== void 0 ? includeDiscoverablePrivateCommunity : true,
36041
- },
36042
- });
36103
+ const { data: payload } = await client.http.get(`/api/v3/communities/${communityId}`);
36043
36104
  const data = prepareCommunityPayload(payload);
36044
36105
  const cachedAt = client.cache && Date.now();
36045
36106
  if (client.cache) {
@@ -38763,14 +38824,14 @@ var index$a = /*#__PURE__*/Object.freeze({
38763
38824
  const queryGlobalFeed = async (query) => {
38764
38825
  const client = getActiveClient();
38765
38826
  client.log('feed/queryGlobalFeed', query);
38766
- const _a = query !== null && query !== void 0 ? query : {}, { queryToken } = _a, params = __rest(_a, ["queryToken"]);
38827
+ const _a = query !== null && query !== void 0 ? query : {}, { queryToken, dataTypes, resolveParent } = _a, params = __rest(_a, ["queryToken", "dataTypes", "resolveParent"]);
38767
38828
  const options = (() => {
38768
38829
  if (queryToken)
38769
38830
  return { token: queryToken };
38770
38831
  return undefined;
38771
38832
  })();
38772
38833
  const { data: queryPayload } = await client.http.get(`/api/v4/me/global-feeds`, {
38773
- params: Object.assign(Object.assign({}, params), { options }),
38834
+ params: Object.assign(Object.assign({}, params), { dataTypes, resolveParent: resolveParent !== null && resolveParent !== void 0 ? resolveParent : true, options }),
38774
38835
  });
38775
38836
  const { paging } = queryPayload, payload = __rest(queryPayload, ["paging"]);
38776
38837
  const data = prepareMembershipPayload(payload, 'communityUsers');
@@ -39356,6 +39417,46 @@ const isPostFlaggedByMe = async (postId) => {
39356
39417
  };
39357
39418
  /* end_public_function */
39358
39419
 
39420
+ /* begin_public_function
39421
+ id: post.create.clip_post
39422
+ */
39423
+ /**
39424
+ * ```js
39425
+ * import { PostRepository } from '@amityco/ts-sdk'
39426
+ * const created = await PostRepository.createClipPost({
39427
+ * targetType: 'user',
39428
+ * targetId: 'foobar',
39429
+ * dataType: 'clip',
39430
+ * data: { text: 'hello world' },
39431
+ * attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
39432
+ * }))
39433
+ * ```
39434
+ *
39435
+ * Creates an {@link Amity.Post}
39436
+ *
39437
+ * @param bundle The data necessary to create a new {@link Amity.Post}
39438
+ * @returns The newly created {@link Amity.Post}
39439
+ *
39440
+ * @category Post API
39441
+ * @async
39442
+ */
39443
+ const createClipPost = async (bundle) => {
39444
+ const client = getActiveClient();
39445
+ client.log('post/createPost', bundle);
39446
+ const { data: payload } = await client.http.post('/api/v4/posts', bundle);
39447
+ fireEvent('post.created', payload);
39448
+ const data = prepareMembershipPayload(payload, 'communityUsers');
39449
+ const cachedAt = client.cache && Date.now();
39450
+ if (client.cache)
39451
+ ingestInCache(data, { cachedAt });
39452
+ const { posts } = data;
39453
+ return {
39454
+ data: LinkedObject.post(posts[0]),
39455
+ cachedAt,
39456
+ };
39457
+ };
39458
+ /* end_public_function */
39459
+
39359
39460
  /* begin_public_function
39360
39461
  id: comment.get_by_ids
39361
39462
  */
@@ -40444,7 +40545,7 @@ class PostPaginationController extends PaginationController {
40444
40545
  type: params.sortBy || queryParams.limit ? 'pagination' : undefined,
40445
40546
  };
40446
40547
  const options = token ? Object.assign(Object.assign({}, baseOptions), { token }) : Object.assign(Object.assign({}, baseOptions), { limit });
40447
- const { data: queryResponse } = await this.http.get(`/api/v4/posts`, {
40548
+ const { data: queryResponse } = await this.http.get(`/api/v5/posts`, {
40448
40549
  params: Object.assign(Object.assign({}, params), { isDeleted: inferIsDeleted(includeDeleted),
40449
40550
  /*
40450
40551
  * when creating post like image, file, video BE will create 2 posts
@@ -41256,6 +41357,7 @@ var index$7 = /*#__PURE__*/Object.freeze({
41256
41357
  flagPost: flagPost,
41257
41358
  unflagPost: unflagPost,
41258
41359
  isPostFlaggedByMe: isPostFlaggedByMe,
41360
+ createClipPost: createClipPost,
41259
41361
  onPostCreated: onPostCreated,
41260
41362
  onPostUpdated: onPostUpdated,
41261
41363
  onPostDeleted: onPostDeleted,