@amityco/ts-sdk 7.25.0 → 7.25.1-42fb4ac5.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 (30) hide show
  1. package/dist/@types/core/payload.d.ts +9 -1
  2. package/dist/@types/core/payload.d.ts.map +1 -1
  3. package/dist/@types/domains/content.d.ts +6 -1
  4. package/dist/@types/domains/content.d.ts.map +1 -1
  5. package/dist/@types/domains/post.d.ts +3 -0
  6. package/dist/@types/domains/post.d.ts.map +1 -1
  7. package/dist/fileRepository/api/getFile.d.ts.map +1 -1
  8. package/dist/fileRepository/api/uploadImage.d.ts.map +1 -1
  9. package/dist/fileRepository/api/uploadVideo.d.ts.map +1 -1
  10. package/dist/index.cjs.js +126 -8
  11. package/dist/index.esm.js +126 -8
  12. package/dist/index.umd.js +2 -2
  13. package/dist/messagePreview/utils/getSubChannelMessagePreviewWithUser.d.ts +1 -1
  14. package/dist/postRepository/api/createEventPost.d.ts +36 -0
  15. package/dist/postRepository/api/createEventPost.d.ts.map +1 -0
  16. package/dist/postRepository/api/index.d.ts +1 -0
  17. package/dist/postRepository/api/index.d.ts.map +1 -1
  18. package/dist/postRepository/api/tests/integration/setup.d.ts +1 -0
  19. package/dist/postRepository/api/tests/integration/setup.d.ts.map +1 -1
  20. package/dist/utils/linkedObject/fileLinkedObject.d.ts +2 -0
  21. package/dist/utils/linkedObject/fileLinkedObject.d.ts.map +1 -0
  22. package/dist/utils/linkedObject/index.d.ts +1 -0
  23. package/dist/utils/linkedObject/index.d.ts.map +1 -1
  24. package/dist/utils/linkedObject/postLinkedObject.d.ts.map +1 -1
  25. package/dist/utils/postTypePredicate.d.ts +1 -0
  26. package/dist/utils/postTypePredicate.d.ts.map +1 -1
  27. package/dist/utils/tests/dummy/comment.d.ts +1 -1
  28. package/dist/utils/tests/dummy/file.d.ts.map +1 -1
  29. package/dist/utils/tests/dummy/post.d.ts.map +1 -1
  30. package/package.json +1 -1
package/dist/index.esm.js CHANGED
@@ -146,6 +146,7 @@ const PostContentType = Object.freeze({
146
146
  CLIP: 'clip',
147
147
  AUDIO: 'audio',
148
148
  ROOM: 'room',
149
+ EVENT: 'event',
149
150
  });
150
151
  const PostStructureType = Object.freeze({
151
152
  TEXT: 'text',
@@ -154,6 +155,7 @@ const PostStructureType = Object.freeze({
154
155
  FILE: 'file',
155
156
  AUDIO: 'audio',
156
157
  MIXED: 'mixed',
158
+ EVENT: 'event',
157
159
  });
158
160
 
159
161
  var InvitationTypeEnum;
@@ -12361,6 +12363,9 @@ function isAmityRoomPost(post) {
12361
12363
  'roomId' in post.data &&
12362
12364
  post.dataType === 'room');
12363
12365
  }
12366
+ function isAmityEventPost(post) {
12367
+ return post.dataType === 'event' || post.structureType === 'event';
12368
+ }
12364
12369
 
12365
12370
  /**
12366
12371
  * ```js
@@ -12472,7 +12477,7 @@ const getWatchSessionStorage = () => {
12472
12477
  return storageInstance;
12473
12478
  };
12474
12479
 
12475
- const privateKey = "-----BEGIN PRIVATE KEY-----\nMIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQDHo80SecH7FuF2\nhFYnb+l26/VN8UMLXAQFLnxciNTEwkGVFMpdezlH8rU2HtUJL4RETogbAOLVY0XM\njs6sPn8G1nALmh9qeDpUtVqFOVtBHxEZ910TLOtQiunjqJKO5nWdqZ71EC3OFluR\niGQkO84BiIFbv37ub7xl3S8XarbtKoLcyVpkDHi+1wx1pgCAn6gtBUgckPL5NR8j\nLseabl3HAXQfhTCKo4tmOFM2Dxwl1IUMmIJrJg/aIU/U0tj/1Eoo7mG0JcNWX19l\nW3EecCbi0ncCJOrkUdwlBrcjaMayaX/ubEwyUeTGiLdyc4L3GRLHjyK8xgVNXRMH\nbZWJ2a5NAgMBAAECggEASxuE+35zTFO/XydKgmvIGcWL9FbgMlXb7Vcf0nBoG945\nbiz0NVc2paraIhJXc608xbYF3qLmtAE1MVBI0ORyRdBHNxY024l/6H6SH60Ed+uI\nM4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Tg/g/3Zk/rAxAEGkfOLGoenaJMD41fH4wUq3FRYwkvnaMb9Hd6f/TlBHslIRa2NN58bSBGJCyBP2b59+2+EcCgYEAixDVRXvV37GlYUOa/XVdosk5Zoe6oDGRuQm0xbNdoUBoZvDHDvme7ONWEiQha/8qtVsD+CyQ7awcPfb8kK9c0bBt+bTS6d4BkTcxkEkMgtrkBVR8Nqfu5jXsLH4VCv4G61zbMhZw8+ut+az5YX2yCN7Frj9sFlxapMRPQmzMEe0CgYEAumsAzM8ZqNv4mAK65Mnr0rhLj1cbxcKRdUYACOgtEFQpzxN/HZnTeFAe5nx3pI3uFlRHq3DFEYnT6dHMWaJQmAULYpVIwMi9L6gtyJ9fzoI6uqMtxRDMUqKdaSsTGOY/kJ6KhQ/unXi1K3XXjR+yd1+C0q+HUm1+CYxvrZYLfskCgYEArsEy+IQOiqniJ0NE2vVUF+UK/IRZaic9YKcpov5Ot7Vvzm/MnnW4N1ljVskocETBWMmPUvNSExVjPebi+rxd8fa5kY8BJScPTzMFbunZn/wjtGdcM10qdlVQ9doG61A/9P3ezFKCfS4AvF/H/59LcSx2Bh28fp3/efiVIOpVd4Y=";
12476
12481
  /*
12477
12482
  * The crypto algorithm used for importing key and signing string
12478
12483
  */
@@ -12900,6 +12905,21 @@ const productTagLinkedObject = (productTag) => {
12900
12905
  return Object.assign(Object.assign({}, productTag), { product: internalProduct ? productLinkedObject(internalProduct) : undefined });
12901
12906
  };
12902
12907
 
12908
+ const fileLinkedObject = (file) => {
12909
+ var _a, _b, _c, _d, _e, _f, _g, _h;
12910
+ if (!file)
12911
+ return file;
12912
+ if (file.type === 'video') {
12913
+ const video = (_b = (_a = file.attributes) === null || _a === void 0 ? void 0 : _a.metadata) === null || _b === void 0 ? void 0 : _b.video;
12914
+ return Object.assign(Object.assign({}, file), { width: (_c = video === null || video === void 0 ? void 0 : video.width) !== null && _c !== void 0 ? _c : 0, height: (_d = video === null || video === void 0 ? void 0 : video.height) !== null && _d !== void 0 ? _d : 0, rotation: (_e = video === null || video === void 0 ? void 0 : video.rotation) !== null && _e !== void 0 ? _e : 0 });
12915
+ }
12916
+ if (file.type === 'image') {
12917
+ const metadata = (_f = file.attributes) === null || _f === void 0 ? void 0 : _f.metadata;
12918
+ return Object.assign(Object.assign({}, file), { width: (_g = metadata === null || metadata === void 0 ? void 0 : metadata.width) !== null && _g !== void 0 ? _g : 0, height: (_h = metadata === null || metadata === void 0 ? void 0 : metadata.height) !== null && _h !== void 0 ? _h : 0 });
12919
+ }
12920
+ return file;
12921
+ };
12922
+
12903
12923
  const postLinkedObject = (post) => {
12904
12924
  return shallowClone(post, {
12905
12925
  childrenPosts: post.children
@@ -12957,19 +12977,19 @@ const postLinkedObject = (post) => {
12957
12977
  getImageInfo() {
12958
12978
  var _a, _b;
12959
12979
  return isAmityImagePost(post)
12960
- ? (_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
12980
+ ? fileLinkedObject((_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)
12961
12981
  : undefined;
12962
12982
  },
12963
12983
  getVideoInfo() {
12964
12984
  var _a, _b, _c;
12965
12985
  return isAmityVideoPost(post)
12966
- ? (_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data
12986
+ ? fileLinkedObject((_c = pullFromCache(['file', 'get', (_b = (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.videoFileId) === null || _b === void 0 ? void 0 : _b.original])) === null || _c === void 0 ? void 0 : _c.data)
12967
12987
  : undefined;
12968
12988
  },
12969
12989
  getVideoThumbnailInfo() {
12970
12990
  var _a, _b;
12971
12991
  return isAmityVideoPost(post)
12972
- ? (_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data
12992
+ ? fileLinkedObject((_b = pullFromCache(['file', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.thumbnailFileId])) === null || _b === void 0 ? void 0 : _b.data)
12973
12993
  : undefined;
12974
12994
  },
12975
12995
  getFileInfo() {
@@ -13019,6 +13039,57 @@ const postLinkedObject = (post) => {
13019
13039
  const room = (_b = pullFromCache(['room', 'get', (_a = post === null || post === void 0 ? void 0 : post.data) === null || _a === void 0 ? void 0 : _a.roomId])) === null || _b === void 0 ? void 0 : _b.data;
13020
13040
  return room ? roomLinkedObject(room) : undefined;
13021
13041
  },
13042
+ getEventInfo() {
13043
+ var _a, _b;
13044
+ if (!isAmityEventPost(post))
13045
+ return;
13046
+ const readEventId = (data) => {
13047
+ if (data && typeof data === 'object' && 'eventId' in data) {
13048
+ const value = data.eventId;
13049
+ return typeof value === 'string' ? value : undefined;
13050
+ }
13051
+ return undefined;
13052
+ };
13053
+ const parentEventId = readEventId(post.data);
13054
+ const eventId = parentEventId !== null && parentEventId !== void 0 ? parentEventId : (_a = post.children) === null || _a === void 0 ? void 0 : _a.map(childId => { var _a; return (_a = pullFromCache(['post', 'get', childId])) === null || _a === void 0 ? void 0 : _a.data; }).map(child => readEventId(child === null || child === void 0 ? void 0 : child.data)).find(Boolean);
13055
+ if (!eventId)
13056
+ return;
13057
+ const event = (_b = pullFromCache(['event', 'get', eventId])) === null || _b === void 0 ? void 0 : _b.data;
13058
+ if (!event)
13059
+ return;
13060
+ // Inlined event linked-object construction. Calling eventLinkedObject()
13061
+ // here would create a static import cycle (eventLinkObject already
13062
+ // imports postLinkedObject for its `event.post` getter). Snapshot
13063
+ // consumers get the raw event fields plus the getters they need for the
13064
+ // in-post event card (creator, targetCommunity, coverImage, room). The
13065
+ // full linked-object surface — including RSVP methods and `event.post` —
13066
+ // is available via EventRepository.getEvent(eventId).
13067
+ return Object.assign(Object.assign({}, event), { get creator() {
13068
+ const cacheData = pullFromCache(['user', 'get', event.userId]);
13069
+ if (!(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data))
13070
+ return undefined;
13071
+ return userLinkedObject(cacheData.data);
13072
+ },
13073
+ get targetCommunity() {
13074
+ var _a;
13075
+ if (!event.originId)
13076
+ return undefined;
13077
+ const cacheData = (_a = pullFromCache([
13078
+ 'community',
13079
+ 'get',
13080
+ event.originId,
13081
+ ])) === null || _a === void 0 ? void 0 : _a.data;
13082
+ if (!cacheData)
13083
+ return undefined;
13084
+ return communityLinkedObject(cacheData);
13085
+ },
13086
+ get coverImage() {
13087
+ var _a;
13088
+ if (!event.coverImageFileId)
13089
+ return undefined;
13090
+ return (_a = pullFromCache(['file', 'get', event.coverImageFileId])) === null || _a === void 0 ? void 0 : _a.data;
13091
+ } });
13092
+ },
13022
13093
  });
13023
13094
  };
13024
13095
 
@@ -13909,6 +13980,7 @@ const eventLinkedObject = (event) => {
13909
13980
  };
13910
13981
 
13911
13982
  const LinkedObject = {
13983
+ file: fileLinkedObject,
13912
13984
  ad: adLinkedObject,
13913
13985
  comment: commentLinkedObject,
13914
13986
  post: postLinkedObject,
@@ -15256,7 +15328,7 @@ const getFile = async (fileId) => {
15256
15328
  if (client.cache)
15257
15329
  ingestInCache({ files: [data] }, { cachedAt });
15258
15330
  return {
15259
- data,
15331
+ data: fileLinkedObject(data),
15260
15332
  cachedAt,
15261
15333
  };
15262
15334
  };
@@ -15283,7 +15355,7 @@ getFile.locally = (fileId) => {
15283
15355
  if (!cached)
15284
15356
  return;
15285
15357
  return {
15286
- data: cached.data,
15358
+ data: fileLinkedObject(cached.data),
15287
15359
  cachedAt: cached.cachedAt,
15288
15360
  };
15289
15361
  };
@@ -15420,7 +15492,7 @@ const uploadVideo = async (formData, feedType, onProgress) => {
15420
15492
  if (client.cache)
15421
15493
  ingestInCache({ files: data }, { cachedAt });
15422
15494
  return {
15423
- data,
15495
+ data: data.map(file => fileLinkedObject(file)),
15424
15496
  cachedAt,
15425
15497
  };
15426
15498
  };
@@ -15481,7 +15553,7 @@ const uploadImage = async (formData, onProgress, altText) => {
15481
15553
  if (client.cache)
15482
15554
  ingestInCache({ files: data }, { cachedAt });
15483
15555
  return {
15484
- data,
15556
+ data: data.map(file => fileLinkedObject(file)),
15485
15557
  cachedAt,
15486
15558
  };
15487
15559
  };
@@ -28331,6 +28403,51 @@ const createRoomPost = async (bundle) => {
28331
28403
  };
28332
28404
  /* end_public_function */
28333
28405
 
28406
+ /* begin_public_function
28407
+ id: post.create.event_post
28408
+ */
28409
+ /**
28410
+ * ```js
28411
+ * import { PostRepository } from '@amityco/ts-sdk'
28412
+ * const created = await PostRepository.createEventPost({
28413
+ * targetType: 'community',
28414
+ * targetId: 'communityId',
28415
+ * data: { eventId: 'eventId123', title: 'Summer Meetup', text: 'Come say hi' }
28416
+ * })
28417
+ * ```
28418
+ *
28419
+ * Creates an event {@link Amity.Post} — a post whose content is an event.
28420
+ * The parent post carries the author's caption; the referenced event is
28421
+ * resolved via `post.getEventInfo()`.
28422
+ *
28423
+ * `data.eventId` is REQUIRED; `title` and `text` are OPTIONAL — both blank is
28424
+ * valid and yields a bare event card.
28425
+ *
28426
+ * Media attachments and product tags are rejected by the backend with 400.
28427
+ *
28428
+ * @param bundle The data necessary to create a new event {@link Amity.Post}
28429
+ * @returns The newly created {@link Amity.Post}
28430
+ *
28431
+ * @category Post API
28432
+ * @async
28433
+ */
28434
+ const createEventPost = async (bundle) => {
28435
+ const client = getActiveClient();
28436
+ client.log('post/createEventPost', bundle);
28437
+ const { data: payload } = await client.http.post('/api/v4/posts', Object.assign(Object.assign({}, bundle), { dataType: 'event' }));
28438
+ fireEvent('post.created', payload);
28439
+ const data = preparePostPayload(payload);
28440
+ const cachedAt = client.cache && Date.now();
28441
+ if (client.cache)
28442
+ ingestInCache(data, { cachedAt });
28443
+ const { posts } = data;
28444
+ return {
28445
+ data: LinkedObject.post(posts[0]),
28446
+ cachedAt,
28447
+ };
28448
+ };
28449
+ /* end_public_function */
28450
+
28334
28451
  /* begin_public_function
28335
28452
  id: post.pin_product
28336
28453
  */
@@ -31062,6 +31179,7 @@ var index$b = /*#__PURE__*/Object.freeze({
31062
31179
  createAudioPost: createAudioPost,
31063
31180
  createMixedMediaPost: createMixedMediaPost,
31064
31181
  createRoomPost: createRoomPost,
31182
+ createEventPost: createEventPost,
31065
31183
  pinProduct: pinProduct,
31066
31184
  unpinProduct: unpinProduct,
31067
31185
  updateProductTags: updateProductTags,