@amityco/ts-sdk 7.5.4-2d34fd5f.0 → 7.5.4-3506dd3.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 (51) hide show
  1. package/dist/@types/domains/content.d.ts +2 -8
  2. package/dist/@types/domains/content.d.ts.map +1 -1
  3. package/dist/@types/domains/feed.d.ts +1 -2
  4. package/dist/@types/domains/feed.d.ts.map +1 -1
  5. package/dist/@types/domains/file.d.ts +1 -3
  6. package/dist/@types/domains/file.d.ts.map +1 -1
  7. package/dist/@types/domains/post.d.ts +0 -3
  8. package/dist/@types/domains/post.d.ts.map +1 -1
  9. package/dist/communityRepository/api/deleteCommunity.d.ts.map +1 -1
  10. package/dist/communityRepository/api/getCommunity.d.ts +2 -2
  11. package/dist/communityRepository/api/getCommunity.d.ts.map +1 -1
  12. package/dist/communityRepository/observers/getCommunity.d.ts.map +1 -1
  13. package/dist/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.d.ts.map +1 -1
  14. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts +1 -1
  15. package/dist/feedRepository/api/getCustomRankingGlobalFeed.d.ts.map +1 -1
  16. package/dist/feedRepository/api/queryGlobalFeed.d.ts.map +1 -1
  17. package/dist/fileRepository/api/index.d.ts +0 -1
  18. package/dist/fileRepository/api/index.d.ts.map +1 -1
  19. package/dist/index.cjs.js +9 -121
  20. package/dist/index.esm.js +9 -121
  21. package/dist/index.umd.js +2 -2
  22. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  23. package/dist/postRepository/api/index.d.ts +0 -1
  24. package/dist/postRepository/api/index.d.ts.map +1 -1
  25. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  26. package/dist/utils/postTypePredicate.d.ts +0 -1
  27. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  28. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  29. package/package.json +1 -1
  30. package/src/@types/domains/content.ts +0 -10
  31. package/src/@types/domains/feed.ts +1 -2
  32. package/src/@types/domains/file.ts +0 -5
  33. package/src/@types/domains/post.ts +0 -4
  34. package/src/communityRepository/api/deleteCommunity.ts +1 -2
  35. package/src/communityRepository/api/getCommunity.ts +7 -5
  36. package/src/communityRepository/observers/getCommunity.ts +12 -24
  37. package/src/communityRepository/observers/getJoinRequests/JoinRequestsPaginationController.ts +2 -1
  38. package/src/feedRepository/api/getCustomRankingGlobalFeed.ts +1 -1
  39. package/src/feedRepository/api/queryGlobalFeed.ts +1 -3
  40. package/src/fileRepository/api/index.ts +0 -1
  41. package/src/postRepository/api/index.ts +0 -2
  42. package/src/postRepository/api/queryPosts.ts +1 -1
  43. package/src/postRepository/observers/getPosts/PostPaginationController.ts +1 -1
  44. package/src/utils/linkedObject/postLinkedObject.ts +1 -12
  45. package/src/utils/postTypePredicate.ts +0 -10
  46. package/dist/fileRepository/api/uploadClip.d.ts +0 -17
  47. package/dist/fileRepository/api/uploadClip.d.ts.map +0 -1
  48. package/dist/postRepository/api/createClipPost.d.ts +0 -32
  49. package/dist/postRepository/api/createClipPost.d.ts.map +0 -1
  50. package/src/fileRepository/api/uploadClip.ts +0 -71
  51. 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":"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: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amityco/ts-sdk",
3
- "version": "7.5.4-2d34fd5f.0",
3
+ "version": "7.5.4-3506dd3.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",
@@ -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>;
@@ -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'];
@@ -2,7 +2,6 @@ import { getActiveClient } from '~/client/api';
2
2
 
3
3
  import { fireEvent } from '~/core/events';
4
4
  import { getCommunity } from './getCommunity';
5
- import { LinkedObject } from '~/utils/linkedObject';
6
5
 
7
6
  /* begin_public_function
8
7
  id: community.delete
@@ -41,6 +40,6 @@ export const deleteCommunity = async (
41
40
  users: [],
42
41
  });
43
42
 
44
- return LinkedObject.community(deleted.data);
43
+ return deleted.data;
45
44
  };
46
45
  /* end_public_function */
@@ -25,7 +25,7 @@ export const getCommunity = async (
25
25
  communityId: Amity.Community['communityId'],
26
26
  type?: Amity.JoinRequestType,
27
27
  includeDiscoverablePrivateCommunity?: boolean,
28
- ): Promise<Amity.Cached<Amity.InternalCommunity>> => {
28
+ ): Promise<Amity.Cached<Amity.Community>> => {
29
29
  const client = getActiveClient();
30
30
  client.log('community/getCommunity', communityId);
31
31
 
@@ -51,7 +51,9 @@ export const getCommunity = async (
51
51
  const { communities } = data;
52
52
 
53
53
  return {
54
- data: communities.find(community => community.communityId === communityId)!,
54
+ data: LinkedObject.community(
55
+ communities.find(community => community.communityId === communityId)!,
56
+ ),
55
57
  cachedAt,
56
58
  };
57
59
  };
@@ -71,18 +73,18 @@ export const getCommunity = async (
71
73
  */
72
74
  getCommunity.locally = (
73
75
  communityId: Amity.Community['communityId'],
74
- ): Amity.Cached<Amity.InternalCommunity> | undefined => {
76
+ ): Amity.Cached<Amity.Community> | undefined => {
75
77
  const client = getActiveClient();
76
78
  client.log('community/getCommunity.locally', communityId);
77
79
 
78
80
  if (!client.cache) return;
79
81
 
80
- const cached = pullFromCache<Amity.InternalCommunity>(['community', 'get', communityId]);
82
+ const cached = pullFromCache<Amity.Community>(['community', 'get', communityId]);
81
83
 
82
84
  if (!cached) return;
83
85
 
84
86
  return {
85
- data: cached.data,
87
+ data: LinkedObject.community(cached.data),
86
88
  cachedAt: cached.cachedAt,
87
89
  };
88
90
  };
@@ -12,7 +12,6 @@ import {
12
12
  onLocalCommunityJoin,
13
13
  } from '../communityMembership/events';
14
14
  import { convertEventPayload } from '~/utils/event';
15
- import { LinkedObject } from '~/utils/linkedObject';
16
15
 
17
16
  /* begin_public_function
18
17
  id: community.get
@@ -40,28 +39,17 @@ export const getCommunity = (
40
39
  communityId: Amity.Community['communityId'],
41
40
  callback: Amity.LiveObjectCallback<Amity.Community>,
42
41
  ): Amity.Unsubscriber => {
43
- return liveObject(
44
- communityId,
45
- callback,
46
- 'communityId',
47
- _getCommunity,
48
- [
49
- onCommunityUpdated,
50
- onCommunityDeleted,
51
- onCommunityJoined,
52
- onCommunityLeft,
53
- onLocalCommunityJoined,
54
- onLocalCommunityLeft,
55
- onCommunityUserBanned,
56
- onCommunityUserUnbanned,
57
- onCommunityUserChanged,
58
- convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
59
- ],
60
- {
61
- callbackDataSelector: (data: Amity.InternalCommunity) => {
62
- return LinkedObject.community(data);
63
- },
64
- },
65
- );
42
+ return liveObject(communityId, callback, 'communityId', _getCommunity, [
43
+ onCommunityUpdated,
44
+ onCommunityDeleted,
45
+ onCommunityJoined,
46
+ onCommunityLeft,
47
+ onLocalCommunityJoined,
48
+ onLocalCommunityLeft,
49
+ onCommunityUserBanned,
50
+ onCommunityUserUnbanned,
51
+ onCommunityUserChanged,
52
+ convertEventPayload(onLocalCommunityJoin, 'targetId', 'community'),
53
+ ]);
66
54
  };
67
55
  /* end_public_function */
@@ -1,4 +1,5 @@
1
1
  import { PaginationController } from '~/core/liveCollection/PaginationController';
2
+ import { COLLECTION_DEFAULT_PAGINATION_LIMIT } from '~/utils/constants';
2
3
 
3
4
  /**
4
5
  * TODO: handle cache receive cache option, and cache policy
@@ -9,7 +10,7 @@ export class JoinRequestsPaginationController extends PaginationController<
9
10
  Amity.JoinRequestLiveCollection
10
11
  > {
11
12
  async getRequest(queryParams: Amity.JoinRequestLiveCollection, token: string | undefined) {
12
- const { limit = 20, communityId, ...params } = queryParams;
13
+ const { limit = COLLECTION_DEFAULT_PAGINATION_LIMIT, communityId, ...params } = queryParams;
13
14
  const options = token ? { token } : { limit };
14
15
 
15
16
  const { data: queryResponse } = await this.http.get<
@@ -23,7 +23,7 @@ import { LinkedObject } from '~/utils/linkedObject';
23
23
  * @async
24
24
  * */
25
25
  export const getCustomRankingGlobalFeed = async (query?: {
26
- dataTypes?: ('video' | 'image' | 'file' | 'liveStream' | 'clip')[];
26
+ dataTypes?: ('video' | 'image' | 'file' | 'liveStream')[];
27
27
  limit?: number;
28
28
  queryToken?: string;
29
29
  }): Promise<
@@ -32,7 +32,7 @@ export const queryGlobalFeed = async (
32
32
  const client = getActiveClient();
33
33
  client.log('feed/queryGlobalFeed', query);
34
34
 
35
- const { queryToken, dataTypes, resolveParent, ...params } = query ?? {};
35
+ const { queryToken, ...params } = query ?? {};
36
36
 
37
37
  const options = (() => {
38
38
  if (queryToken) return { token: queryToken };
@@ -44,8 +44,6 @@ export const queryGlobalFeed = async (
44
44
  {
45
45
  params: {
46
46
  ...params,
47
- dataTypes,
48
- resolveParent: resolveParent ?? true,
49
47
  options,
50
48
  },
51
49
  },
@@ -5,4 +5,3 @@ export * from './fileUrlWithSize';
5
5
  export * from './uploadVideo';
6
6
  export * from './uploadImage';
7
7
  export * from './updateAltText';
8
- export * from './uploadClip';
@@ -13,5 +13,3 @@ export * from './declinePost';
13
13
  export * from './flagPost';
14
14
  export * from './unflagPost';
15
15
  export * from './isPostFlaggedByMe';
16
-
17
- export * from './createClipPost';
@@ -43,7 +43,7 @@ export const queryPosts = async (
43
43
  // API-FIX: parameters should be querystring. (1)
44
44
  // API-FIX: backend should answer Amity.Response (2)
45
45
  // const { data } = await client.http.get<Amity.Response<Amity.PagedResponse<Amity.PostPayload>>>(
46
- const { data } = await client.http.get<Amity.PostPayload & Amity.Pagination>(`/api/v5/posts`, {
46
+ const { data } = await client.http.get<Amity.PostPayload & Amity.Pagination>(`/api/v4/posts`, {
47
47
  params: {
48
48
  ...params,
49
49
  isDeleted: inferIsDeleted(includeDeleted),
@@ -23,7 +23,7 @@ export class PostPaginationController extends PaginationController<
23
23
  const options = token ? { ...baseOptions, token } : { ...baseOptions, limit };
24
24
 
25
25
  const { data: queryResponse } = await this.http.get<Amity.PostPayload & Amity.Pagination>(
26
- `/api/v5/posts`,
26
+ `/api/v4/posts`,
27
27
  {
28
28
  params: {
29
29
  ...params,
@@ -2,12 +2,7 @@ import { pullFromCache } from '~/cache/api';
2
2
  import { commentLinkedObject } from '~/utils/linkedObject/commentLinkedObject';
3
3
  import AnalyticsEngine from '../../analytic/service/analytic/AnalyticsEngine';
4
4
  import { userLinkedObject } from './userLinkedObject';
5
- import {
6
- isAmityClipPost,
7
- isAmityFilePost,
8
- isAmityImagePost,
9
- isAmityVideoPost,
10
- } from '../postTypePredicate';
5
+ import { isAmityFilePost, isAmityImagePost, isAmityVideoPost } from '../postTypePredicate';
11
6
 
12
7
  export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
13
8
  return {
@@ -69,11 +64,5 @@ export const postLinkedObject = (post: Amity.InternalPost): Amity.Post => {
69
64
  ? pullFromCache<Amity.File<'file'>>(['file', 'get', post?.data?.fileId])?.data
70
65
  : undefined;
71
66
  },
72
-
73
- getClipInfo(): Amity.File<'clip'> | undefined {
74
- return isAmityClipPost(post)
75
- ? pullFromCache<Amity.File<'clip'>>(['file', 'get', post?.data?.fileId])?.data
76
- : undefined;
77
- },
78
67
  };
79
68
  };
@@ -25,13 +25,3 @@ export function isAmityVideoPost(post: Amity.InternalPost): post is Amity.Post<'
25
25
  post.dataType === 'video'
26
26
  );
27
27
  }
28
-
29
- export function isAmityClipPost(post: Amity.InternalPost): post is Amity.Post<'clip'> {
30
- return !!(
31
- post.data &&
32
- typeof post.data !== 'string' &&
33
- 'fileId' in post.data &&
34
- 'thumbnailFileId' in post.data &&
35
- post.dataType === 'clip'
36
- );
37
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * ```js
3
- * import { FileRepository } from '@amityco/ts-sdk'
4
- * const created = await FileRepository.uploadClip(formData)
5
- * ```
6
- *
7
- * Creates an {@link Amity.File}
8
- *
9
- * @param formData The data necessary to create a new {@link Amity.File}
10
- * @param onProgress The callback to track the upload progress
11
- * @returns The newly created {@link Amity.File}
12
- *
13
- * @category File API
14
- * @async
15
- */
16
- export declare const uploadClip: (formData: FormData, feedType?: Amity.ContentFeedType, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File<'clip'>[]>>;
17
- //# sourceMappingURL=uploadClip.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploadClip.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadClip.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,UAAU,aACX,QAAQ,aACP,MAAM,eAAe,0BACT,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,CA2C5C,CAAC"}
@@ -1,32 +0,0 @@
1
- /**
2
- * ```js
3
- * import { PostRepository } from '@amityco/ts-sdk'
4
- * const created = await PostRepository.createClipPost({
5
- * targetType: 'user',
6
- * targetId: 'foobar',
7
- * dataType: 'clip',
8
- * data: { text: 'hello world' },
9
- * attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
10
- * }))
11
- * ```
12
- *
13
- * Creates an {@link Amity.Post}
14
- *
15
- * @param bundle The data necessary to create a new {@link Amity.Post}
16
- * @returns The newly created {@link Amity.Post}
17
- *
18
- * @category Post API
19
- * @async
20
- */
21
- export declare const createClipPost: <T extends string>(bundle: Pick<Amity.Post<T>, "targetType" | "targetId"> & Partial<Pick<Amity.Post<T>, "metadata" | "tags" | "mentionees">> & {
22
- data: {
23
- [k: string]: any;
24
- };
25
- attachments: {
26
- type: T;
27
- fileId: Amity.File['fileId'];
28
- displayMode?: Amity.ClipDisplayMode | undefined;
29
- isMuted?: boolean | undefined;
30
- }[];
31
- }) => Promise<Amity.Cached<Amity.Post>>;
32
- //# sourceMappingURL=createClipPost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createClipPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/createClipPost.ts"],"names":[],"mappings":"AAUA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,cAAc;;;;;;gBAMX,UAAU,CAAC,QAAQ,CAAC;;;;MAKjC,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,CAmBlC,CAAC"}
@@ -1,71 +0,0 @@
1
- import { getActiveClient } from '~/client/api/activeClient';
2
- import { ingestInCache } from '~/cache/api/ingestInCache';
3
- import GlobalFileAccessType from '~/client/utils/GlobalFileAccessType';
4
-
5
- /* begin_public_function
6
- id: file.upload.clip
7
- */
8
- /**
9
- * ```js
10
- * import { FileRepository } from '@amityco/ts-sdk'
11
- * const created = await FileRepository.uploadClip(formData)
12
- * ```
13
- *
14
- * Creates an {@link Amity.File}
15
- *
16
- * @param formData The data necessary to create a new {@link Amity.File}
17
- * @param onProgress The callback to track the upload progress
18
- * @returns The newly created {@link Amity.File}
19
- *
20
- * @category File API
21
- * @async
22
- */
23
- export const uploadClip = async (
24
- formData: FormData,
25
- feedType?: Amity.ContentFeedType,
26
- onProgress?: (percent: number) => void,
27
- ): Promise<Amity.Cached<Amity.File<'clip'>[]>> => {
28
- const client = getActiveClient();
29
- client.log('file/uploadClip', formData);
30
-
31
- const file = formData.get('files');
32
-
33
- if (!file) throw new Error('The formData object must have a `files` key.');
34
-
35
- const accessType = GlobalFileAccessType.getInstance().getFileAccessType();
36
- formData.append('accessType', accessType);
37
-
38
- formData.append('preferredFilename', (file as File).name);
39
-
40
- if (feedType) {
41
- formData.append('feedType', feedType);
42
- }
43
-
44
- const headers =
45
- 'getHeaders' in formData
46
- ? (formData as any).getHeaders()
47
- : { 'content-type': 'multipart/form-data' };
48
-
49
- const { data } = await client.upload.post<Amity.CreateFilePayload<'clip'>>(
50
- '/api/v4/clips',
51
- formData,
52
- {
53
- headers,
54
- onUploadProgress({ loaded, total = 100 }) {
55
- onProgress && onProgress(Math.round((loaded * 100) / total));
56
- },
57
- },
58
- );
59
-
60
- // API-FIX: payload should be serialized properly
61
- // const { files } = data
62
-
63
- const cachedAt = client.cache && Date.now();
64
- if (client.cache) ingestInCache({ files: data }, { cachedAt });
65
-
66
- return {
67
- data,
68
- cachedAt,
69
- };
70
- };
71
- /* end_public_function */
@@ -1,62 +0,0 @@
1
- import { getActiveClient } from '~/client/api/activeClient';
2
-
3
- import { ingestInCache } from '~/cache/api/ingestInCache';
4
- import { fireEvent } from '~/core/events';
5
- import { prepareMembershipPayload } from '~/group/utils';
6
- import { LinkedObject } from '~/utils/linkedObject';
7
-
8
- /* begin_public_function
9
- id: post.create.clip_post
10
- */
11
- /**
12
- * ```js
13
- * import { PostRepository } from '@amityco/ts-sdk'
14
- * const created = await PostRepository.createClipPost({
15
- * targetType: 'user',
16
- * targetId: 'foobar',
17
- * dataType: 'clip',
18
- * data: { text: 'hello world' },
19
- * attachments: [{ type: 'clip', fileId: 'fileId123', displayMode: 'fill', isMuted: false }]
20
- * }))
21
- * ```
22
- *
23
- * Creates an {@link Amity.Post}
24
- *
25
- * @param bundle The data necessary to create a new {@link Amity.Post}
26
- * @returns The newly created {@link Amity.Post}
27
- *
28
- * @category Post API
29
- * @async
30
- */
31
- export const createClipPost = async <T extends Amity.PostContentType | string>(
32
- bundle: Pick<Amity.Post<T>, 'targetType' | 'targetId'> &
33
- Partial<Pick<Amity.Post<T>, 'metadata' | 'mentionees' | 'tags'>> & {
34
- data: { [k: string]: any };
35
- attachments: {
36
- type: T;
37
- fileId: Amity.File['fileId'];
38
- displayMode?: Amity.ClipDisplayMode;
39
- isMuted?: boolean;
40
- }[];
41
- },
42
- ): Promise<Amity.Cached<Amity.Post>> => {
43
- const client = getActiveClient();
44
- client.log('post/createPost', bundle);
45
-
46
- const { data: payload } = await client.http.post<Amity.PostPayload>('/api/v4/posts', bundle);
47
-
48
- fireEvent('post.created', payload);
49
-
50
- const data = prepareMembershipPayload(payload, 'communityUsers');
51
- const cachedAt = client.cache && Date.now();
52
-
53
- if (client.cache) ingestInCache(data, { cachedAt });
54
-
55
- const { posts } = data;
56
-
57
- return {
58
- data: LinkedObject.post(posts[0]),
59
- cachedAt,
60
- };
61
- };
62
- /* end_public_function */