@amityco/ts-sdk 7.9.2-2bad2e47.0 → 7.9.2-5367a1e.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 (77) hide show
  1. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/content.d.ts +2 -11
  2. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/content.d.ts.map +1 -1
  3. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/content.js.map +1 -1
  4. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/file.d.ts +1 -3
  5. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/file.d.ts.map +1 -1
  6. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/file.js +0 -1
  7. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/file.js.map +1 -1
  8. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts +0 -13
  9. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.d.ts.map +1 -1
  10. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.js +0 -9
  11. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/@types/domains/post.js.map +1 -1
  12. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/fileRepository/api/index.d.ts +0 -1
  13. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/fileRepository/api/index.d.ts.map +1 -1
  14. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/fileRepository/api/index.js +0 -1
  15. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/fileRepository/api/index.js.map +1 -1
  16. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  17. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/index.d.ts +0 -2
  18. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/index.d.ts.map +1 -1
  19. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/index.js +0 -2
  20. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/index.js.map +1 -1
  21. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  22. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js +1 -7
  23. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/linkedObject/postLinkedObject.js.map +1 -1
  24. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/postTypePredicate.d.ts +0 -1
  25. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/postTypePredicate.d.ts.map +1 -1
  26. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/postTypePredicate.js +0 -6
  27. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/postTypePredicate.js.map +1 -1
  28. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/utils/tests/dummy/comment.d.ts +1 -1
  29. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/tsconfig.tsbuildinfo +1 -1
  30. package/dist/@types/domains/content.d.ts +2 -11
  31. package/dist/@types/domains/content.d.ts.map +1 -1
  32. package/dist/@types/domains/file.d.ts +1 -3
  33. package/dist/@types/domains/file.d.ts.map +1 -1
  34. package/dist/@types/domains/post.d.ts +0 -13
  35. package/dist/@types/domains/post.d.ts.map +1 -1
  36. package/dist/fileRepository/api/index.d.ts +0 -1
  37. package/dist/fileRepository/api/index.d.ts.map +1 -1
  38. package/dist/index.cjs.js +1 -153
  39. package/dist/index.esm.js +2 -153
  40. package/dist/index.umd.js +3 -3
  41. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  42. package/dist/postRepository/api/index.d.ts +0 -2
  43. package/dist/postRepository/api/index.d.ts.map +1 -1
  44. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  45. package/dist/utils/postTypePredicate.d.ts +0 -1
  46. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  47. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  48. package/package.json +1 -1
  49. package/src/@types/domains/content.ts +0 -11
  50. package/src/@types/domains/file.ts +0 -5
  51. package/src/@types/domains/post.ts +0 -19
  52. package/src/fileRepository/api/index.ts +0 -1
  53. package/src/postRepository/api/index.ts +0 -2
  54. package/src/utils/linkedObject/postLinkedObject.ts +0 -7
  55. package/src/utils/postTypePredicate.ts +0 -9
  56. package/tsconfig.tsbuildinfo +1 -1
  57. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/fileRepository/api/uploadAudio.d.ts +0 -17
  58. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/fileRepository/api/uploadAudio.d.ts.map +0 -1
  59. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/fileRepository/api/uploadAudio.js +0 -47
  60. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/fileRepository/api/uploadAudio.js.map +0 -1
  61. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createAudioPost.d.ts +0 -30
  62. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createAudioPost.d.ts.map +0 -1
  63. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createAudioPost.js +0 -43
  64. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createAudioPost.js.map +0 -1
  65. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createMixedMediaPost.d.ts +0 -35
  66. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createMixedMediaPost.d.ts.map +0 -1
  67. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createMixedMediaPost.js +0 -49
  68. package/.rollup.cache/home/runner/work/AmityTypescriptSDK/AmityTypescriptSDK/packages/sdk/dist/postRepository/api/createMixedMediaPost.js.map +0 -1
  69. package/dist/fileRepository/api/uploadAudio.d.ts +0 -17
  70. package/dist/fileRepository/api/uploadAudio.d.ts.map +0 -1
  71. package/dist/postRepository/api/createAudioPost.d.ts +0 -30
  72. package/dist/postRepository/api/createAudioPost.d.ts.map +0 -1
  73. package/dist/postRepository/api/createMixedMediaPost.d.ts +0 -35
  74. package/dist/postRepository/api/createMixedMediaPost.d.ts.map +0 -1
  75. package/src/fileRepository/api/uploadAudio.ts +0 -61
  76. package/src/postRepository/api/createAudioPost.ts +0 -60
  77. package/src/postRepository/api/createMixedMediaPost.ts +0 -62
@@ -1,17 +0,0 @@
1
- /**
2
- * ```js
3
- * import { FileRepository } from '@amityco/ts-sdk'
4
- * const uploaded = await FileRepository.uploadAudio(formData, onProgress)
5
- * ```
6
- *
7
- * Creates an {@link Amity.File<'audio'>}
8
- *
9
- * @param formData The data necessary to create a new {@link Amity.File<'audio'>}
10
- * @param onProgress The callback to track the upload progress
11
- * @returns The newly created {@link Amity.File<'audio'>}
12
- *
13
- * @category File API
14
- * @async
15
- */
16
- export declare const uploadAudio: (formData: FormData, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File<'audio'>[]>>;
17
- //# sourceMappingURL=uploadAudio.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploadAudio.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadAudio.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,aACZ,QAAQ,0BACK,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAkC7C,CAAC"}
@@ -1,47 +0,0 @@
1
- import { getActiveClient } from '~/client/api/activeClient';
2
- import { ingestInCache } from '~/cache/api/ingestInCache';
3
- import GlobalFileAccessType from '~/client/utils/GlobalFileAccessType';
4
- /* begin_public_function
5
- id: file.upload.audio
6
- */
7
- /**
8
- * ```js
9
- * import { FileRepository } from '@amityco/ts-sdk'
10
- * const uploaded = await FileRepository.uploadAudio(formData, onProgress)
11
- * ```
12
- *
13
- * Creates an {@link Amity.File<'audio'>}
14
- *
15
- * @param formData The data necessary to create a new {@link Amity.File<'audio'>}
16
- * @param onProgress The callback to track the upload progress
17
- * @returns The newly created {@link Amity.File<'audio'>}
18
- *
19
- * @category File API
20
- * @async
21
- */
22
- export const uploadAudio = async (formData, onProgress) => {
23
- const client = getActiveClient();
24
- client.log('file/uploadAudio', formData);
25
- const file = formData.get('file');
26
- if (!file)
27
- throw new Error('The formData object must have a `file` key with audio file.');
28
- const accessType = GlobalFileAccessType.getInstance().getFileAccessType();
29
- formData.append('accessType', accessType);
30
- formData.append('preferredFilename', file.name);
31
- const headers = { 'content-type': 'multipart/form-data' };
32
- const { data } = await client.upload.post('/api/v4/audios', formData, {
33
- headers,
34
- onUploadProgress({ loaded, total = 100 }) {
35
- onProgress === null || onProgress === void 0 ? void 0 : onProgress(Math.round((loaded * 100) / total));
36
- },
37
- });
38
- const cachedAt = client.cache && Date.now();
39
- if (client.cache)
40
- ingestInCache({ files: data }, { cachedAt });
41
- return {
42
- data,
43
- cachedAt,
44
- };
45
- };
46
- /* end_public_function */
47
- //# sourceMappingURL=uploadAudio.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploadAudio.js","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,oBAAoB,MAAM,qCAAqC,CAAC;AAEvE;;EAEE;AACF;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,EAC9B,QAAkB,EAClB,UAAsC,EACQ,EAAE;IAChD,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,MAAM,CAAC,GAAG,CAAC,kBAAkB,EAAE,QAAQ,CAAC,CAAC;IAEzC,MAAM,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC,MAAM,CAAS,CAAC;IAE1C,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,6DAA6D,CAAC,CAAC;IAE1F,MAAM,UAAU,GAAG,oBAAoB,CAAC,WAAW,EAAE,CAAC,iBAAiB,EAAE,CAAC;IAE1E,QAAQ,CAAC,MAAM,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC;IAE1C,QAAQ,CAAC,MAAM,CAAC,mBAAmB,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IAEhD,MAAM,OAAO,GAAG,EAAE,cAAc,EAAE,qBAAqB,EAAE,CAAC;IAE1D,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CACvC,gBAAgB,EAChB,QAAQ,EACR;QACE,OAAO;QACP,gBAAgB,CAAC,EAAE,MAAM,EAAE,KAAK,GAAG,GAAG,EAAE;YACtC,UAAU,aAAV,UAAU,uBAAV,UAAU,CAAG,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,GAAG,CAAC,GAAG,KAAK,CAAC,CAAC,CAAC;QACnD,CAAC;KACF,CACF,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAC5C,IAAI,MAAM,CAAC,KAAK;QAAE,aAAa,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAE/D,OAAO;QACL,IAAI;QACJ,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC;AACF,yBAAyB","sourcesContent":["import { getActiveClient } from '~/client/api/activeClient';\nimport { ingestInCache } from '~/cache/api/ingestInCache';\nimport GlobalFileAccessType from '~/client/utils/GlobalFileAccessType';\n\n/* begin_public_function\n id: file.upload.audio\n*/\n/**\n * ```js\n * import { FileRepository } from '@amityco/ts-sdk'\n * const uploaded = await FileRepository.uploadAudio(formData, onProgress)\n * ```\n *\n * Creates an {@link Amity.File<'audio'>}\n *\n * @param formData The data necessary to create a new {@link Amity.File<'audio'>}\n * @param onProgress The callback to track the upload progress\n * @returns The newly created {@link Amity.File<'audio'>}\n *\n * @category File API\n * @async\n */\nexport const uploadAudio = async (\n formData: FormData,\n onProgress?: (percent: number) => void,\n): Promise<Amity.Cached<Amity.File<'audio'>[]>> => {\n const client = getActiveClient();\n client.log('file/uploadAudio', formData);\n\n const file = formData.get('file') as File;\n\n if (!file) throw new Error('The formData object must have a `file` key with audio file.');\n\n const accessType = GlobalFileAccessType.getInstance().getFileAccessType();\n\n formData.append('accessType', accessType);\n\n formData.append('preferredFilename', file.name);\n\n const headers = { 'content-type': 'multipart/form-data' };\n\n const { data } = await client.upload.post<Amity.CreateFilePayload<'audio'>>(\n '/api/v4/audios',\n formData,\n {\n headers,\n onUploadProgress({ loaded, total = 100 }) {\n onProgress?.(Math.round((loaded * 100) / total));\n },\n },\n );\n\n const cachedAt = client.cache && Date.now();\n if (client.cache) ingestInCache({ files: data }, { cachedAt });\n\n return {\n data,\n cachedAt,\n };\n};\n/* end_public_function */\n"]}
@@ -1,30 +0,0 @@
1
- /**
2
- * ```js
3
- * import { PostRepository } from '@amityco/ts-sdk'
4
- * const created = await PostRepository.createAudioPost({
5
- * targetType: 'user',
6
- * targetId: 'foobar',
7
- * data: { text: 'Audio Post', title: 'Audio Post Title' },
8
- * attachments: [{ type: 'audio', fileId: 'fileId123'}]
9
- * }))
10
- * ```
11
- *
12
- * Creates an {@link Amity.Post}
13
- *
14
- * @param bundle The data necessary to create a new {@link Amity.Post}
15
- * @returns The newly created {@link Amity.Post}
16
- *
17
- * @category Post API
18
- * @async
19
- */
20
- export declare const createAudioPost: <T extends string = "audio">(bundle: Pick<Amity.Post<T>, "targetId" | "targetType"> & Partial<Pick<Amity.Post<T>, "tags" | "metadata" | "mentionees" | "hashtags">> & {
21
- data?: {
22
- text?: string | undefined;
23
- title?: string | undefined;
24
- } | undefined;
25
- attachments: {
26
- type: T;
27
- fileId: Amity.File['fileId'];
28
- }[];
29
- }) => Promise<Amity.Cached<Amity.Post>>;
30
- //# sourceMappingURL=createAudioPost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createAudioPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/createAudioPost.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe;;;;;;;gBASZ,UAAU,CAAC,QAAQ,CAAC;;MAGjC,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,CAkBlC,CAAC"}
@@ -1,43 +0,0 @@
1
- import { fireEvent } from '~/core/events';
2
- import { postLinkedObject } from '~/utils/linkedObject/postLinkedObject';
3
- import { getActiveClient } from '~/client/api/activeClient';
4
- import { ingestInCache } from '~/cache/api/ingestInCache';
5
- import { preparePostPayload } from '../utils/payload';
6
- /* begin_public_function
7
- id: post.create.audio_post
8
- */
9
- /**
10
- * ```js
11
- * import { PostRepository } from '@amityco/ts-sdk'
12
- * const created = await PostRepository.createAudioPost({
13
- * targetType: 'user',
14
- * targetId: 'foobar',
15
- * data: { text: 'Audio Post', title: 'Audio Post Title' },
16
- * attachments: [{ type: 'audio', fileId: 'fileId123'}]
17
- * }))
18
- * ```
19
- *
20
- * Creates an {@link Amity.Post}
21
- *
22
- * @param bundle The data necessary to create a new {@link Amity.Post}
23
- * @returns The newly created {@link Amity.Post}
24
- *
25
- * @category Post API
26
- * @async
27
- */
28
- export const createAudioPost = async (bundle) => {
29
- const client = getActiveClient();
30
- client.log('post/createAudioPost', bundle);
31
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
32
- fireEvent('post.created', payload);
33
- const data = preparePostPayload(payload);
34
- const cachedAt = client.cache && Date.now();
35
- if (client.cache)
36
- ingestInCache(data, { cachedAt });
37
- return {
38
- data: postLinkedObject(data === null || data === void 0 ? void 0 : data.posts[0]),
39
- cachedAt,
40
- };
41
- };
42
- /* end_public_function */
43
- //# sourceMappingURL=createAudioPost.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createAudioPost.js","sourceRoot":"","sources":["../../../src/postRepository/api/createAudioPost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD;;EAEE;AACF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,MAUG,EACgC,EAAE;IACrC,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,MAAM,CAAC,GAAG,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;IAE3C,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAoB,eAAe,EAAE,MAAM,CAAC,CAAC;IAE7F,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnC,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAE5C,IAAI,MAAM,CAAC,KAAK;QAAE,aAAa,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEpD,OAAO;QACL,IAAI,EAAE,gBAAgB,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,CAAC,CAAC,CAAC;QACtC,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC;AACF,yBAAyB","sourcesContent":["import { fireEvent } from '~/core/events';\nimport { postLinkedObject } from '~/utils/linkedObject/postLinkedObject';\nimport { getActiveClient } from '~/client/api/activeClient';\nimport { ingestInCache } from '~/cache/api/ingestInCache';\nimport { preparePostPayload } from '../utils/payload';\n\n/* begin_public_function\n id: post.create.audio_post\n*/\n/**\n * ```js\n * import { PostRepository } from '@amityco/ts-sdk'\n * const created = await PostRepository.createAudioPost({\n * targetType: 'user',\n * targetId: 'foobar',\n * data: { text: 'Audio Post', title: 'Audio Post Title' },\n * attachments: [{ type: 'audio', fileId: 'fileId123'}]\n * }))\n * ```\n *\n * Creates an {@link Amity.Post}\n *\n * @param bundle The data necessary to create a new {@link Amity.Post}\n * @returns The newly created {@link Amity.Post}\n *\n * @category Post API\n * @async\n */\nexport const createAudioPost = async <T extends Amity.PostContentType = 'audio'>(\n bundle: Pick<Amity.Post<T>, 'targetType' | 'targetId'> &\n Partial<Pick<Amity.Post<T>, 'metadata' | 'mentionees' | 'tags' | 'hashtags'>> & {\n data?: {\n text?: string;\n title?: string;\n };\n attachments: {\n type: T;\n fileId: Amity.File['fileId'];\n }[];\n },\n): Promise<Amity.Cached<Amity.Post>> => {\n const client = getActiveClient();\n client.log('post/createAudioPost', bundle);\n\n const { data: payload } = await client.http.post<Amity.PostPayload>('/api/v4/posts', bundle);\n\n fireEvent('post.created', payload);\n\n const data = preparePostPayload(payload);\n\n const cachedAt = client.cache && Date.now();\n\n if (client.cache) ingestInCache(data, { cachedAt });\n\n return {\n data: postLinkedObject(data?.posts[0]),\n cachedAt,\n };\n};\n/* end_public_function */\n"]}
@@ -1,35 +0,0 @@
1
- /**
2
- * ```js
3
- * import { PostRepository } from '@amityco/ts-sdk'
4
- * const { data } = await PostRepository.createMixedMediaPost({
5
- * targetType: 'community',
6
- * targetId: 'community123',
7
- * data: { text: 'Check out my mixed media post!', title: 'Mixed Media Post' },
8
- * attachments: [
9
- * { fileId: "file1", type: "image" },
10
- * { fileId: "file2", type: "video" },
11
- * { fileId: "file3", type: "audio" },
12
- * { fileId: "file4", type: "file" }
13
- * ],
14
- * })
15
- * ```
16
- *
17
- * Creates an {@link Amity.Post}
18
- *
19
- * @param bundle The data necessary to create a new {@link Amity.Post}
20
- * @returns The newly created {@link Amity.Post}
21
- *
22
- * @category Post API
23
- * @async
24
- */
25
- export declare const createMixedMediaPost: <T extends Amity.MixedMediaPostContentType>(bundle: Pick<Amity.Post<T>, "targetId" | "targetType"> & Partial<Pick<Amity.Post<T>, "tags" | "metadata" | "mentionees" | "hashtags">> & {
26
- data?: {
27
- text?: string | undefined;
28
- title?: string | undefined;
29
- } | undefined;
30
- attachments: {
31
- type: T;
32
- fileId: Amity.File['fileId'];
33
- }[];
34
- }) => Promise<Amity.Cached<Amity.Post>>;
35
- //# sourceMappingURL=createMixedMediaPost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createMixedMediaPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/createMixedMediaPost.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,oBAAoB;;;;;;;gBAOK,UAAU,CAAC,QAAQ,CAAC;;MAEvD,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,CAkBlC,CAAC"}
@@ -1,49 +0,0 @@
1
- import { fireEvent } from '~/core/events';
2
- import { preparePostPayload } from '../utils/payload';
3
- import { ingestInCache } from '~/cache/api/ingestInCache';
4
- import { getActiveClient } from '~/client/api/activeClient';
5
- import { postLinkedObject } from '~/utils/linkedObject/postLinkedObject';
6
- /* begin_public_function
7
- id: post.create.mixed_media_post
8
- */
9
- /**
10
- * ```js
11
- * import { PostRepository } from '@amityco/ts-sdk'
12
- * const { data } = await PostRepository.createMixedMediaPost({
13
- * targetType: 'community',
14
- * targetId: 'community123',
15
- * data: { text: 'Check out my mixed media post!', title: 'Mixed Media Post' },
16
- * attachments: [
17
- * { fileId: "file1", type: "image" },
18
- * { fileId: "file2", type: "video" },
19
- * { fileId: "file3", type: "audio" },
20
- * { fileId: "file4", type: "file" }
21
- * ],
22
- * })
23
- * ```
24
- *
25
- * Creates an {@link Amity.Post}
26
- *
27
- * @param bundle The data necessary to create a new {@link Amity.Post}
28
- * @returns The newly created {@link Amity.Post}
29
- *
30
- * @category Post API
31
- * @async
32
- */
33
- export const createMixedMediaPost = async (bundle) => {
34
- var _a;
35
- const client = getActiveClient();
36
- client.log('post/createMixedMediaPost', bundle);
37
- const { data: payload } = await client.http.post('/api/v4/posts', bundle);
38
- fireEvent('post.created', payload);
39
- const data = preparePostPayload(payload);
40
- const cachedAt = client.cache && Date.now();
41
- if (client.cache)
42
- ingestInCache(data, { cachedAt });
43
- return {
44
- data: postLinkedObject((_a = data === null || data === void 0 ? void 0 : data.posts) === null || _a === void 0 ? void 0 : _a[0]),
45
- cachedAt,
46
- };
47
- };
48
- /* end_public_function */
49
- //# sourceMappingURL=createMixedMediaPost.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createMixedMediaPost.js","sourceRoot":"","sources":["../../../src/postRepository/api/createMixedMediaPost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AAEzE;;EAEE;AACF;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,EACvC,MAOG,EACgC,EAAE;;IACrC,MAAM,MAAM,GAAG,eAAe,EAAE,CAAC;IACjC,MAAM,CAAC,GAAG,CAAC,2BAA2B,EAAE,MAAM,CAAC,CAAC;IAEhD,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,IAAI,CAAC,IAAI,CAAoB,eAAe,EAAE,MAAM,CAAC,CAAC;IAE7F,SAAS,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnC,MAAM,IAAI,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAEzC,MAAM,QAAQ,GAAG,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAE5C,IAAI,MAAM,CAAC,KAAK;QAAE,aAAa,CAAC,IAAI,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IAEpD,OAAO;QACL,IAAI,EAAE,gBAAgB,CAAC,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,0CAAG,CAAC,CAAC,CAAC;QACxC,QAAQ;KACT,CAAC;AACJ,CAAC,CAAC;AACF,yBAAyB","sourcesContent":["import { fireEvent } from '~/core/events';\nimport { preparePostPayload } from '../utils/payload';\nimport { ingestInCache } from '~/cache/api/ingestInCache';\nimport { getActiveClient } from '~/client/api/activeClient';\nimport { postLinkedObject } from '~/utils/linkedObject/postLinkedObject';\n\n/* begin_public_function\n id: post.create.mixed_media_post\n*/\n/**\n * ```js\n * import { PostRepository } from '@amityco/ts-sdk'\n * const { data } = await PostRepository.createMixedMediaPost({\n * targetType: 'community',\n * targetId: 'community123',\n * data: { text: 'Check out my mixed media post!', title: 'Mixed Media Post' },\n * attachments: [\n * { fileId: \"file1\", type: \"image\" },\n * { fileId: \"file2\", type: \"video\" },\n * { fileId: \"file3\", type: \"audio\" },\n * { fileId: \"file4\", type: \"file\" }\n * ],\n * })\n * ```\n *\n * Creates an {@link Amity.Post}\n *\n * @param bundle The data necessary to create a new {@link Amity.Post}\n * @returns The newly created {@link Amity.Post}\n *\n * @category Post API\n * @async\n */\nexport const createMixedMediaPost = async <T extends Amity.MixedMediaPostContentType>(\n bundle: Pick<Amity.Post<T>, 'targetType' | 'targetId'> &\n Partial<Pick<Amity.Post<T>, 'metadata' | 'mentionees' | 'tags' | 'hashtags'>> & {\n data?: {\n text?: string;\n title?: string;\n };\n attachments: { type: T; fileId: Amity.File['fileId'] }[];\n },\n): Promise<Amity.Cached<Amity.Post>> => {\n const client = getActiveClient();\n client.log('post/createMixedMediaPost', bundle);\n\n const { data: payload } = await client.http.post<Amity.PostPayload>('/api/v4/posts', bundle);\n\n fireEvent('post.created', payload);\n\n const data = preparePostPayload(payload);\n\n const cachedAt = client.cache && Date.now();\n\n if (client.cache) ingestInCache(data, { cachedAt });\n\n return {\n data: postLinkedObject(data?.posts?.[0]),\n cachedAt,\n };\n};\n/* end_public_function */\n"]}
@@ -1,17 +0,0 @@
1
- /**
2
- * ```js
3
- * import { FileRepository } from '@amityco/ts-sdk'
4
- * const uploaded = await FileRepository.uploadAudio(formData, onProgress)
5
- * ```
6
- *
7
- * Creates an {@link Amity.File<'audio'>}
8
- *
9
- * @param formData The data necessary to create a new {@link Amity.File<'audio'>}
10
- * @param onProgress The callback to track the upload progress
11
- * @returns The newly created {@link Amity.File<'audio'>}
12
- *
13
- * @category File API
14
- * @async
15
- */
16
- export declare const uploadAudio: (formData: FormData, onProgress?: ((percent: number) => void) | undefined) => Promise<Amity.Cached<Amity.File<'audio'>[]>>;
17
- //# sourceMappingURL=uploadAudio.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"uploadAudio.d.ts","sourceRoot":"","sources":["../../../src/fileRepository/api/uploadAudio.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,WAAW,aACZ,QAAQ,0BACK,MAAM,KAAK,IAAI,kBACrC,QAAQ,MAAM,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAkC7C,CAAC"}
@@ -1,30 +0,0 @@
1
- /**
2
- * ```js
3
- * import { PostRepository } from '@amityco/ts-sdk'
4
- * const created = await PostRepository.createAudioPost({
5
- * targetType: 'user',
6
- * targetId: 'foobar',
7
- * data: { text: 'Audio Post', title: 'Audio Post Title' },
8
- * attachments: [{ type: 'audio', fileId: 'fileId123'}]
9
- * }))
10
- * ```
11
- *
12
- * Creates an {@link Amity.Post}
13
- *
14
- * @param bundle The data necessary to create a new {@link Amity.Post}
15
- * @returns The newly created {@link Amity.Post}
16
- *
17
- * @category Post API
18
- * @async
19
- */
20
- export declare const createAudioPost: <T extends string = "audio">(bundle: Pick<Amity.Post<T>, "targetId" | "targetType"> & Partial<Pick<Amity.Post<T>, "tags" | "metadata" | "mentionees" | "hashtags">> & {
21
- data?: {
22
- text?: string | undefined;
23
- title?: string | undefined;
24
- } | undefined;
25
- attachments: {
26
- type: T;
27
- fileId: Amity.File['fileId'];
28
- }[];
29
- }) => Promise<Amity.Cached<Amity.Post>>;
30
- //# sourceMappingURL=createAudioPost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createAudioPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/createAudioPost.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,eAAe;;;;;;;gBASZ,UAAU,CAAC,QAAQ,CAAC;;MAGjC,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,CAkBlC,CAAC"}
@@ -1,35 +0,0 @@
1
- /**
2
- * ```js
3
- * import { PostRepository } from '@amityco/ts-sdk'
4
- * const { data } = await PostRepository.createMixedMediaPost({
5
- * targetType: 'community',
6
- * targetId: 'community123',
7
- * data: { text: 'Check out my mixed media post!', title: 'Mixed Media Post' },
8
- * attachments: [
9
- * { fileId: "file1", type: "image" },
10
- * { fileId: "file2", type: "video" },
11
- * { fileId: "file3", type: "audio" },
12
- * { fileId: "file4", type: "file" }
13
- * ],
14
- * })
15
- * ```
16
- *
17
- * Creates an {@link Amity.Post}
18
- *
19
- * @param bundle The data necessary to create a new {@link Amity.Post}
20
- * @returns The newly created {@link Amity.Post}
21
- *
22
- * @category Post API
23
- * @async
24
- */
25
- export declare const createMixedMediaPost: <T extends Amity.MixedMediaPostContentType>(bundle: Pick<Amity.Post<T>, "targetId" | "targetType"> & Partial<Pick<Amity.Post<T>, "tags" | "metadata" | "mentionees" | "hashtags">> & {
26
- data?: {
27
- text?: string | undefined;
28
- title?: string | undefined;
29
- } | undefined;
30
- attachments: {
31
- type: T;
32
- fileId: Amity.File['fileId'];
33
- }[];
34
- }) => Promise<Amity.Cached<Amity.Post>>;
35
- //# sourceMappingURL=createMixedMediaPost.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"createMixedMediaPost.d.ts","sourceRoot":"","sources":["../../../src/postRepository/api/createMixedMediaPost.ts"],"names":[],"mappings":"AASA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,oBAAoB;;;;;;;gBAOK,UAAU,CAAC,QAAQ,CAAC;;MAEvD,QAAQ,MAAM,MAAM,CAAC,MAAM,IAAI,CAAC,CAkBlC,CAAC"}
@@ -1,61 +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.audio
7
- */
8
- /**
9
- * ```js
10
- * import { FileRepository } from '@amityco/ts-sdk'
11
- * const uploaded = await FileRepository.uploadAudio(formData, onProgress)
12
- * ```
13
- *
14
- * Creates an {@link Amity.File<'audio'>}
15
- *
16
- * @param formData The data necessary to create a new {@link Amity.File<'audio'>}
17
- * @param onProgress The callback to track the upload progress
18
- * @returns The newly created {@link Amity.File<'audio'>}
19
- *
20
- * @category File API
21
- * @async
22
- */
23
- export const uploadAudio = async (
24
- formData: FormData,
25
- onProgress?: (percent: number) => void,
26
- ): Promise<Amity.Cached<Amity.File<'audio'>[]>> => {
27
- const client = getActiveClient();
28
- client.log('file/uploadAudio', formData);
29
-
30
- const file = formData.get('file') as File;
31
-
32
- if (!file) throw new Error('The formData object must have a `file` key with audio file.');
33
-
34
- const accessType = GlobalFileAccessType.getInstance().getFileAccessType();
35
-
36
- formData.append('accessType', accessType);
37
-
38
- formData.append('preferredFilename', file.name);
39
-
40
- const headers = { 'content-type': 'multipart/form-data' };
41
-
42
- const { data } = await client.upload.post<Amity.CreateFilePayload<'audio'>>(
43
- '/api/v4/audios',
44
- formData,
45
- {
46
- headers,
47
- onUploadProgress({ loaded, total = 100 }) {
48
- onProgress?.(Math.round((loaded * 100) / total));
49
- },
50
- },
51
- );
52
-
53
- const cachedAt = client.cache && Date.now();
54
- if (client.cache) ingestInCache({ files: data }, { cachedAt });
55
-
56
- return {
57
- data,
58
- cachedAt,
59
- };
60
- };
61
- /* end_public_function */
@@ -1,60 +0,0 @@
1
- import { fireEvent } from '~/core/events';
2
- import { postLinkedObject } from '~/utils/linkedObject/postLinkedObject';
3
- import { getActiveClient } from '~/client/api/activeClient';
4
- import { ingestInCache } from '~/cache/api/ingestInCache';
5
- import { preparePostPayload } from '../utils/payload';
6
-
7
- /* begin_public_function
8
- id: post.create.audio_post
9
- */
10
- /**
11
- * ```js
12
- * import { PostRepository } from '@amityco/ts-sdk'
13
- * const created = await PostRepository.createAudioPost({
14
- * targetType: 'user',
15
- * targetId: 'foobar',
16
- * data: { text: 'Audio Post', title: 'Audio Post Title' },
17
- * attachments: [{ type: 'audio', fileId: 'fileId123'}]
18
- * }))
19
- * ```
20
- *
21
- * Creates an {@link Amity.Post}
22
- *
23
- * @param bundle The data necessary to create a new {@link Amity.Post}
24
- * @returns The newly created {@link Amity.Post}
25
- *
26
- * @category Post API
27
- * @async
28
- */
29
- export const createAudioPost = async <T extends Amity.PostContentType = 'audio'>(
30
- bundle: Pick<Amity.Post<T>, 'targetType' | 'targetId'> &
31
- Partial<Pick<Amity.Post<T>, 'metadata' | 'mentionees' | 'tags' | 'hashtags'>> & {
32
- data?: {
33
- text?: string;
34
- title?: string;
35
- };
36
- attachments: {
37
- type: T;
38
- fileId: Amity.File['fileId'];
39
- }[];
40
- },
41
- ): Promise<Amity.Cached<Amity.Post>> => {
42
- const client = getActiveClient();
43
- client.log('post/createAudioPost', bundle);
44
-
45
- const { data: payload } = await client.http.post<Amity.PostPayload>('/api/v4/posts', bundle);
46
-
47
- fireEvent('post.created', payload);
48
-
49
- const data = preparePostPayload(payload);
50
-
51
- const cachedAt = client.cache && Date.now();
52
-
53
- if (client.cache) ingestInCache(data, { cachedAt });
54
-
55
- return {
56
- data: postLinkedObject(data?.posts[0]),
57
- cachedAt,
58
- };
59
- };
60
- /* end_public_function */
@@ -1,62 +0,0 @@
1
- import { fireEvent } from '~/core/events';
2
- import { preparePostPayload } from '../utils/payload';
3
- import { ingestInCache } from '~/cache/api/ingestInCache';
4
- import { getActiveClient } from '~/client/api/activeClient';
5
- import { postLinkedObject } from '~/utils/linkedObject/postLinkedObject';
6
-
7
- /* begin_public_function
8
- id: post.create.mixed_media_post
9
- */
10
- /**
11
- * ```js
12
- * import { PostRepository } from '@amityco/ts-sdk'
13
- * const { data } = await PostRepository.createMixedMediaPost({
14
- * targetType: 'community',
15
- * targetId: 'community123',
16
- * data: { text: 'Check out my mixed media post!', title: 'Mixed Media Post' },
17
- * attachments: [
18
- * { fileId: "file1", type: "image" },
19
- * { fileId: "file2", type: "video" },
20
- * { fileId: "file3", type: "audio" },
21
- * { fileId: "file4", type: "file" }
22
- * ],
23
- * })
24
- * ```
25
- *
26
- * Creates an {@link Amity.Post}
27
- *
28
- * @param bundle The data necessary to create a new {@link Amity.Post}
29
- * @returns The newly created {@link Amity.Post}
30
- *
31
- * @category Post API
32
- * @async
33
- */
34
- export const createMixedMediaPost = async <T extends Amity.MixedMediaPostContentType>(
35
- bundle: Pick<Amity.Post<T>, 'targetType' | 'targetId'> &
36
- Partial<Pick<Amity.Post<T>, 'metadata' | 'mentionees' | 'tags' | 'hashtags'>> & {
37
- data?: {
38
- text?: string;
39
- title?: string;
40
- };
41
- attachments: { type: T; fileId: Amity.File['fileId'] }[];
42
- },
43
- ): Promise<Amity.Cached<Amity.Post>> => {
44
- const client = getActiveClient();
45
- client.log('post/createMixedMediaPost', bundle);
46
-
47
- const { data: payload } = await client.http.post<Amity.PostPayload>('/api/v4/posts', bundle);
48
-
49
- fireEvent('post.created', payload);
50
-
51
- const data = preparePostPayload(payload);
52
-
53
- const cachedAt = client.cache && Date.now();
54
-
55
- if (client.cache) ingestInCache(data, { cachedAt });
56
-
57
- return {
58
- data: postLinkedObject(data?.posts?.[0]),
59
- cachedAt,
60
- };
61
- };
62
- /* end_public_function */