@amityco/ts-sdk 6.7.2-c5c263a.0 → 6.7.3-cbeeb97.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 (108) hide show
  1. package/dist/@types/core/model.d.ts +2 -2
  2. package/dist/@types/core/model.d.ts.map +1 -1
  3. package/dist/@types/core/payload.d.ts +4 -3
  4. package/dist/@types/core/payload.d.ts.map +1 -1
  5. package/dist/@types/domains/comment.d.ts +20 -8
  6. package/dist/@types/domains/comment.d.ts.map +1 -1
  7. package/dist/@types/domains/post.d.ts +1 -1
  8. package/dist/@types/domains/post.d.ts.map +1 -1
  9. package/dist/commentRepository/api/createComment.d.ts +4 -4
  10. package/dist/commentRepository/api/createComment.d.ts.map +1 -1
  11. package/dist/commentRepository/api/deleteComment.d.ts +4 -4
  12. package/dist/commentRepository/api/deleteComment.d.ts.map +1 -1
  13. package/dist/commentRepository/api/flagComment.d.ts +1 -1
  14. package/dist/commentRepository/api/flagComment.d.ts.map +1 -1
  15. package/dist/commentRepository/api/getComment.d.ts +8 -8
  16. package/dist/commentRepository/api/getComment.d.ts.map +1 -1
  17. package/dist/commentRepository/api/getCommentByIds.d.ts +8 -8
  18. package/dist/commentRepository/api/getCommentByIds.d.ts.map +1 -1
  19. package/dist/commentRepository/api/hardDeleteComment.d.ts +4 -4
  20. package/dist/commentRepository/api/hardDeleteComment.d.ts.map +1 -1
  21. package/dist/commentRepository/api/isCommentFlaggedByMe.d.ts +1 -1
  22. package/dist/commentRepository/api/isCommentFlaggedByMe.d.ts.map +1 -1
  23. package/dist/commentRepository/api/queryComments.d.ts +3 -3
  24. package/dist/commentRepository/api/queryComments.d.ts.map +1 -1
  25. package/dist/commentRepository/api/softDeleteComment.d.ts +4 -4
  26. package/dist/commentRepository/api/softDeleteComment.d.ts.map +1 -1
  27. package/dist/commentRepository/api/unflagComment.d.ts +1 -1
  28. package/dist/commentRepository/api/unflagComment.d.ts.map +1 -1
  29. package/dist/commentRepository/api/updateComment.d.ts +4 -4
  30. package/dist/commentRepository/api/updateComment.d.ts.map +1 -1
  31. package/dist/commentRepository/events/onCommentCreated.d.ts +3 -3
  32. package/dist/commentRepository/events/onCommentCreated.d.ts.map +1 -1
  33. package/dist/commentRepository/events/onCommentDeleted.d.ts +3 -3
  34. package/dist/commentRepository/events/onCommentDeleted.d.ts.map +1 -1
  35. package/dist/commentRepository/events/onCommentFlagged.d.ts +3 -3
  36. package/dist/commentRepository/events/onCommentFlagged.d.ts.map +1 -1
  37. package/dist/commentRepository/events/onCommentReactionAdded.d.ts +3 -3
  38. package/dist/commentRepository/events/onCommentReactionAdded.d.ts.map +1 -1
  39. package/dist/commentRepository/events/onCommentReactionRemoved.d.ts +3 -3
  40. package/dist/commentRepository/events/onCommentReactionRemoved.d.ts.map +1 -1
  41. package/dist/commentRepository/events/onCommentUnflagged.d.ts +3 -3
  42. package/dist/commentRepository/events/onCommentUnflagged.d.ts.map +1 -1
  43. package/dist/commentRepository/events/onCommentUpdated.d.ts +3 -3
  44. package/dist/commentRepository/events/onCommentUpdated.d.ts.map +1 -1
  45. package/dist/commentRepository/events/utils.d.ts +1 -1
  46. package/dist/commentRepository/events/utils.d.ts.map +1 -1
  47. package/dist/commentRepository/observers/getComment.d.ts +3 -3
  48. package/dist/commentRepository/observers/getComment.d.ts.map +1 -1
  49. package/dist/commentRepository/observers/getComments.d.ts +4 -4
  50. package/dist/commentRepository/observers/getComments.d.ts.map +1 -1
  51. package/dist/commentRepository/observers/observeComment.d.ts +3 -3
  52. package/dist/commentRepository/observers/observeComment.d.ts.map +1 -1
  53. package/dist/commentRepository/observers/observeComments.d.ts +3 -3
  54. package/dist/commentRepository/observers/observeComments.d.ts.map +1 -1
  55. package/dist/index.cjs.js +126 -74
  56. package/dist/index.esm.js +126 -74
  57. package/dist/index.umd.js +2 -2
  58. package/dist/marker/events/onMessageMarked.d.ts.map +1 -1
  59. package/dist/reactionRepository/events/onReactionAdded.d.ts +1 -1
  60. package/dist/reactionRepository/events/onReactionAdded.d.ts.map +1 -1
  61. package/dist/reactionRepository/events/onReactionRemoved.d.ts +1 -1
  62. package/dist/reactionRepository/events/onReactionRemoved.d.ts.map +1 -1
  63. package/dist/reactionRepository/utils/fetchReference.d.ts +1 -1
  64. package/dist/reactionRepository/utils/fetchReference.d.ts.map +1 -1
  65. package/dist/utils/linkedObject/commentLinkedObject.d.ts +2 -0
  66. package/dist/utils/linkedObject/commentLinkedObject.d.ts.map +1 -0
  67. package/dist/utils/linkedObject/index.d.ts +4 -0
  68. package/dist/utils/linkedObject/index.d.ts.map +1 -0
  69. package/dist/utils/object.d.ts +1 -1
  70. package/dist/utils/object.d.ts.map +1 -1
  71. package/dist/utils/tests/dummy/comment.d.ts +20 -14
  72. package/dist/utils/tests/dummy/comment.d.ts.map +1 -1
  73. package/package.json +1 -1
  74. package/src/@types/core/model.ts +2 -2
  75. package/src/@types/core/payload.ts +4 -3
  76. package/src/@types/domains/comment.ts +20 -8
  77. package/src/@types/domains/post.ts +1 -1
  78. package/src/commentRepository/api/createComment.ts +5 -5
  79. package/src/commentRepository/api/deleteComment.ts +6 -5
  80. package/src/commentRepository/api/flagComment.ts +3 -1
  81. package/src/commentRepository/api/getComment.ts +13 -12
  82. package/src/commentRepository/api/getCommentByIds.ts +11 -11
  83. package/src/commentRepository/api/hardDeleteComment.ts +5 -5
  84. package/src/commentRepository/api/isCommentFlaggedByMe.ts +1 -1
  85. package/src/commentRepository/api/queryComments.ts +4 -4
  86. package/src/commentRepository/api/softDeleteComment.ts +5 -5
  87. package/src/commentRepository/api/tests/queryComments.test.ts +9 -9
  88. package/src/commentRepository/api/unflagComment.ts +3 -1
  89. package/src/commentRepository/api/updateComment.ts +6 -6
  90. package/src/commentRepository/events/onCommentCreated.ts +5 -4
  91. package/src/commentRepository/events/onCommentDeleted.ts +5 -4
  92. package/src/commentRepository/events/onCommentFlagged.ts +5 -4
  93. package/src/commentRepository/events/onCommentReactionAdded.ts +4 -4
  94. package/src/commentRepository/events/onCommentReactionRemoved.ts +4 -4
  95. package/src/commentRepository/events/onCommentUnflagged.ts +5 -4
  96. package/src/commentRepository/events/onCommentUpdated.ts +5 -4
  97. package/src/commentRepository/events/utils.ts +3 -3
  98. package/src/commentRepository/observers/getComment.ts +4 -4
  99. package/src/commentRepository/observers/getComments.ts +9 -8
  100. package/src/commentRepository/observers/observeComment.ts +14 -8
  101. package/src/commentRepository/observers/observeComments.ts +9 -6
  102. package/src/commentRepository/observers/tests/getComment.test.ts +3 -1
  103. package/src/marker/events/onMessageMarked.ts +30 -0
  104. package/src/reactionRepository/utils/prepareReactionPayloadFormEvent.ts +1 -1
  105. package/src/utils/linkedObject/commentLinkedObject.ts +44 -0
  106. package/src/utils/linkedObject/index.ts +5 -0
  107. package/src/utils/object.ts +3 -2
  108. package/src/utils/tests/dummy/comment.ts +25 -8
@@ -1 +1 @@
1
- {"version":3,"file":"onCommentUnflagged.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/events/onCommentUnflagged.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,aAAc,MAAM,QAAQ,CAAC,aAAa,CAAC,KAAG,MAAM,YACtB,CAAC"}
1
+ {"version":3,"file":"onCommentUnflagged.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/events/onCommentUnflagged.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,kBAAkB,aACnB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,YAA2E,CAAC"}
@@ -6,12 +6,12 @@
6
6
  * })
7
7
  * ```
8
8
  *
9
- * Fired when a {@link Amity.Comment} has been updated
9
+ * Fired when a {@link Amity.InternalComment} has been updated
10
10
  *
11
11
  * @param callback The function to call when the event was fired
12
12
  * @returns an {@link Amity.Unsubscriber} function to stop listening
13
13
  *
14
- * @category Comment Events
14
+ * @category InternalComment Events
15
15
  */
16
- export declare const onCommentUpdated: (callback: Amity.Listener<Amity.Comment>) => Amity.Unsubscriber;
16
+ export declare const onCommentUpdated: (callback: Amity.Listener<Amity.InternalComment>) => Amity.Unsubscriber;
17
17
  //# sourceMappingURL=onCommentUpdated.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"onCommentUpdated.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/events/onCommentUpdated.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,aAAc,MAAM,QAAQ,CAAC,aAAa,CAAC,KAAG,MAAM,YACtB,CAAC"}
1
+ {"version":3,"file":"onCommentUpdated.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/events/onCommentUpdated.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,gBAAgB,aACjB,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,KAC9C,MAAM,YAAyE,CAAC"}
@@ -1,2 +1,2 @@
1
- export declare const createCommentEventSubscriber: (event: keyof Amity.MqttCommentEvents, callback: Amity.Listener<Amity.Comment>) => Amity.Unsubscriber;
1
+ export declare const createCommentEventSubscriber: (event: keyof Amity.MqttCommentEvents, callback: Amity.Listener<Amity.InternalComment>) => Amity.Unsubscriber;
2
2
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/events/utils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,4BAA4B,UAChC,MAAM,MAAM,iBAAiB,YAC1B,MAAM,QAAQ,CAAC,aAAa,CAAC,uBA8BxC,CAAC"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/events/utils.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,4BAA4B,UAChC,MAAM,MAAM,iBAAiB,YAC1B,MAAM,QAAQ,CAAC,MAAM,eAAe,CAAC,uBA8BhD,CAAC"}
@@ -9,13 +9,13 @@
9
9
  * });
10
10
  * ```
11
11
  *
12
- * Observe all mutation on a given {@link Amity.Comment}
12
+ * Observe all mutation on a given {@link Amity.InternalComment}
13
13
  *
14
14
  * @param commentId the ID of the comment to observe
15
15
  * @param callback the function to call when new data are available
16
16
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
17
17
  *
18
- * @category Comment Live Object
18
+ * @category InternalComment Live Object
19
19
  */
20
- export declare const getComment: (commentId: Amity.Comment['commentId'], callback: Amity.LiveObjectCallback<Amity.Comment>) => Amity.Unsubscriber;
20
+ export declare const getComment: (commentId: Amity.InternalComment['commentId'], callback: Amity.LiveObjectCallback<Amity.InternalComment>) => Amity.Unsubscriber;
21
21
  //# sourceMappingURL=getComment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/observers/getComment.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,cACV,aAAa,CAAC,WAAW,CAAC,YAC3B,MAAM,kBAAkB,CAAC,aAAa,CAAC,KAChD,MAAM,YASR,CAAC"}
1
+ {"version":3,"file":"getComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/observers/getComment.ts"],"names":[],"mappings":"AAcA;;;;;;;;;;;;;;;;;;GAkBG;AACH,eAAO,MAAM,UAAU,cACV,MAAM,eAAe,CAAC,WAAW,CAAC,YACnC,MAAM,kBAAkB,CAAC,MAAM,eAAe,CAAC,KACxD,MAAM,YASR,CAAC"}
@@ -4,12 +4,12 @@
4
4
  *
5
5
  * let comments = []
6
6
  * const unsub = getComments({
7
- * referenceType: Amity.Comment['referenceType'];
8
- * referenceId: Amity.Comment['referenceId'];
7
+ * referenceType: Amity.InternalComment['referenceType'];
8
+ * referenceId: Amity.InternalComment['referenceId'];
9
9
  * }, response => merge(comments, response.data))
10
10
  * ```
11
11
  *
12
- * Observe all mutations on a list of {@link Amity.Comment} for a given target object
12
+ * Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
13
13
  *
14
14
  * @param referenceType the type of the target
15
15
  * @param referenceId the ID of the target
@@ -18,5 +18,5 @@
18
18
  *
19
19
  * @category Comments Live Collection
20
20
  */
21
- export declare const getComments: (params: Amity.CommentLiveCollection, callback: Amity.LiveCollectionCallback<Amity.Comment>, config?: Amity.LiveCollectionConfig) => Amity.Unsubscriber;
21
+ export declare const getComments: (params: Amity.CommentLiveCollection, callback: Amity.LiveCollectionCallback<Amity.InternalComment>, config?: Amity.LiveCollectionConfig) => Amity.Unsubscriber;
22
22
  //# sourceMappingURL=getComments.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getComments.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/observers/getComments.ts"],"names":[],"mappings":"AAkCA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,WAAW,WACd,MAAM,qBAAqB,YACzB,MAAM,sBAAsB,CAAC,aAAa,CAAC,WAC5C,MAAM,oBAAoB,KAClC,MAAM,YAyHR,CAAC"}
1
+ {"version":3,"file":"getComments.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/observers/getComments.ts"],"names":[],"mappings":"AAmCA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,eAAO,MAAM,WAAW,WACd,MAAM,qBAAqB,YACzB,MAAM,sBAAsB,CAAC,MAAM,eAAe,CAAC,WACpD,MAAM,oBAAoB,KAClC,MAAM,YAyHR,CAAC"}
@@ -6,13 +6,13 @@
6
6
  * const dispose = observeComment(commentId, ({ data }) => comment = data)
7
7
  * ```
8
8
  *
9
- * Observe all mutation on a given {@link Amity.Comment}
9
+ * Observe all mutation on a given {@link Amity.InternalComment}
10
10
  *
11
11
  * @param commentId the ID of the comment to observe
12
12
  * @param callback the function to call when new data are available
13
13
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
14
14
  *
15
- * @category Comment Observer
15
+ * @category InternalComment Observer
16
16
  */
17
- export declare const observeComment: <Events extends ["onFetch", "onUpdate", "onDelete", "onFlagged", "onUnflagged", "onReactionAdded", "onReactionRemoved"]>(commentId: string, callback: Amity.ObjectListener<Amity.Snapshot<Amity.Comment<any> | undefined>, Events>, policy?: Amity.QueryPolicy) => Amity.Unsubscriber;
17
+ export declare const observeComment: <Events extends ["onFetch", "onUpdate", "onDelete", "onFlagged", "onUnflagged", "onReactionAdded", "onReactionRemoved"]>(commentId: string, callback: Amity.ObjectListener<Amity.Snapshot<Amity.InternalComment<any> | undefined>, Events>, policy?: Amity.QueryPolicy) => Amity.Unsubscriber;
18
18
  //# sourceMappingURL=observeComment.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"observeComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/observers/observeComment.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,sIAWd,MAAM,mGAET,MAAM,WAAW,KACxB,MAAM,YAkDR,CAAC"}
1
+ {"version":3,"file":"observeComment.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/observers/observeComment.ts"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,cAAc,sIAWd,MAAM,2GAET,MAAM,WAAW,KACxB,MAAM,YAwDR,CAAC"}
@@ -6,15 +6,15 @@
6
6
  * const unsub = observeComments(postId, comment => merge(comments, comment))
7
7
  * ```
8
8
  *
9
- * Observe all mutations on a list of {@link Amity.Comment} for a given {@link Amity.Post} object
9
+ * Observe all mutations on a list of {@link Amity.InternalComment} for a given {@link Amity.Post} object
10
10
  *
11
11
  * @param postId the ID of the post where to observe the comments
12
12
  * @param callback the function to call when new data are available
13
13
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comments
14
14
  *
15
- * @category Comment Observer
15
+ * @category InternalComment Observer
16
16
  */
17
- export declare const observeComments: (postId: Amity.Post['postId'], callback: Amity.ObjectListener<Amity.Comment, [
17
+ export declare const observeComments: (postId: Amity.Post['postId'], callback: Amity.ObjectListener<Amity.InternalComment, [
18
18
  'onCreate',
19
19
  'onUpdate',
20
20
  'onDelete',
@@ -1 +1 @@
1
- {"version":3,"file":"observeComments.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/observers/observeComments.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,IAAI,CAAC,QAAQ,CAAC,YAClB,MAAM,cAAc,CAC5B,aAAa,EACb;IACE,UAAU;IACV,UAAU;IACV,UAAU;IACV,WAAW;IACX,aAAa;IACb,iBAAiB;IACjB,mBAAmB;CACpB,CACF,KACA,MAAM,YA+BR,CAAC"}
1
+ {"version":3,"file":"observeComments.d.ts","sourceRoot":"","sources":["../../../src/commentRepository/observers/observeComments.ts"],"names":[],"mappings":"AAYA;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,eAAe,WAClB,MAAM,IAAI,CAAC,QAAQ,CAAC,YAClB,MAAM,cAAc,CAC5B,MAAM,eAAe,EACrB;IACE,UAAU;IACV,UAAU;IACV,UAAU;IACV,WAAW;IACX,aAAa;IACb,iBAAiB;IACjB,mBAAmB;CACpB,CACF,KACA,MAAM,YAkCR,CAAC"}
package/dist/index.cjs.js CHANGED
@@ -96,8 +96,8 @@ const PostContentType = Object.freeze({
96
96
 
97
97
  function getVersion() {
98
98
  try {
99
- // the string ''v6.7.1-cjs'' should be replaced by actual value by @rollup/plugin-replace
100
- return 'v6.7.1-cjs';
99
+ // the string ''v6.7.2-cjs'' should be replaced by actual value by @rollup/plugin-replace
100
+ return 'v6.7.2-cjs';
101
101
  }
102
102
  catch (error) {
103
103
  return '__dev__';
@@ -6387,6 +6387,26 @@ const onMessageMarkerFetched = (callback) => {
6387
6387
  return createEventSubscriber(client, 'messageMarker/onMessageMarkerFetched', 'local.messageMarker.fetched', filter);
6388
6388
  };
6389
6389
 
6390
+ function isObject(value) {
6391
+ return typeof value === 'object' && value !== null;
6392
+ }
6393
+ /**
6394
+ * convert all object getter property to static value
6395
+ */
6396
+ const convertGetterPropsToStatic = (obj) => {
6397
+ if (!isObject(obj)) {
6398
+ return obj;
6399
+ }
6400
+ const entries = Object.entries(obj).map(([key, value]) => {
6401
+ const descriptor = Object.getOwnPropertyDescriptor(obj, key);
6402
+ if (typeof (descriptor === null || descriptor === void 0 ? void 0 : descriptor.get) === 'function') {
6403
+ return [key, descriptor.get.call(obj)];
6404
+ }
6405
+ return [key, value];
6406
+ });
6407
+ return Object.fromEntries(entries);
6408
+ };
6409
+
6390
6410
  /**
6391
6411
  * ```js
6392
6412
  * import { onMessageMarked } from '@amityco/ts-sdk'
@@ -6406,29 +6426,31 @@ const onMessageMarked = (callback) => {
6406
6426
  const client = getActiveClient();
6407
6427
  const filter = (payload) => {
6408
6428
  ingestInCache(payload);
6429
+ const cacheCollection = queryCache(['message', 'collection']);
6430
+ if (cacheCollection) {
6431
+ const currentMessageCollection = cacheCollection.filter(currentMessage => {
6432
+ if (!isObject(currentMessage.key[2]))
6433
+ return false;
6434
+ return currentMessage.key[2].subChannelId === payload.contentMarkers[0].feedId;
6435
+ });
6436
+ if (currentMessageCollection) {
6437
+ const currentMessages = currentMessageCollection[0].data.data.map(messageId => {
6438
+ return pullFromCache(['message', 'get', messageId]);
6439
+ });
6440
+ currentMessages.forEach(message => {
6441
+ const isSameSubChannelId = payload.contentMarkers[0].feedId === (message === null || message === void 0 ? void 0 : message.data.subChannelId);
6442
+ const isReadCountLatest = payload.contentMarkers[0].readCount > (message === null || message === void 0 ? void 0 : message.data.readCount);
6443
+ if (isSameSubChannelId && isReadCountLatest) {
6444
+ pushToCache(['message', 'get', message.data.messageId], Object.assign(Object.assign({}, message.data), { readCount: payload.contentMarkers[0].readCount }));
6445
+ }
6446
+ });
6447
+ }
6448
+ }
6409
6449
  callback(payload.contentMarkers[0]);
6410
6450
  };
6411
6451
  return createEventSubscriber(client, 'messageMarker/onMessageMarked', 'marker.marked-message', filter);
6412
6452
  };
6413
6453
 
6414
- const isObject = (value) => typeof value === 'object' && value !== null;
6415
- /**
6416
- * convert all object getter property to static value
6417
- */
6418
- const convertGetterPropsToStatic = (obj) => {
6419
- if (!isObject(obj)) {
6420
- return obj;
6421
- }
6422
- const entries = Object.entries(obj).map(([key, value]) => {
6423
- const descriptor = Object.getOwnPropertyDescriptor(obj, key);
6424
- if (typeof (descriptor === null || descriptor === void 0 ? void 0 : descriptor.get) === 'function') {
6425
- return [key, descriptor.get.call(obj)];
6426
- }
6427
- return [key, value];
6428
- });
6429
- return Object.fromEntries(entries);
6430
- };
6431
-
6432
6454
  /**
6433
6455
  * ```js
6434
6456
  * import { isEqual } from '~/utils/isEqual'
@@ -11009,16 +11031,45 @@ getPost$1.locally = (postId) => {
11009
11031
  };
11010
11032
  };
11011
11033
 
11034
+ const commentLinkedObject = (comment) => {
11035
+ return Object.assign(Object.assign({}, comment), { get target() {
11036
+ const commentTypes = {
11037
+ type: comment.targetType,
11038
+ };
11039
+ if (comment.targetType === 'user') {
11040
+ return Object.assign(Object.assign({}, commentTypes), { userId: comment.targetId });
11041
+ }
11042
+ if (commentTypes.type === 'content') {
11043
+ return Object.assign(Object.assign({}, commentTypes), { contentId: comment.targetId });
11044
+ }
11045
+ if (commentTypes.type === 'community') {
11046
+ const cacheData = pullFromCache([
11047
+ 'communityUsers',
11048
+ 'get',
11049
+ `${comment.targetId}#${comment.userId}`,
11050
+ ]);
11051
+ return Object.assign(Object.assign({}, commentTypes), { communityId: comment.targetId, creatorMember: cacheData === null || cacheData === void 0 ? void 0 : cacheData.data });
11052
+ }
11053
+ return {
11054
+ type: 'unknown',
11055
+ };
11056
+ } });
11057
+ };
11058
+
11059
+ const LinkedObject = {
11060
+ comment: commentLinkedObject,
11061
+ };
11062
+
11012
11063
  /**
11013
11064
  * ```js
11014
11065
  * import { CommentRepository } from '@amityco/ts-sdk'
11015
11066
  * const comment = await CommentRepository.getComment('foobar')
11016
11067
  * ```
11017
11068
  *
11018
- * Fetches a {@link Amity.Comment} object
11069
+ * Fetches a {@link Amity.InternalComment} object
11019
11070
  *
11020
- * @param commentId the ID of the {@link Amity.Comment} to fetch
11021
- * @returns the associated {@link Amity.Comment} object
11071
+ * @param commentId the ID of the {@link Amity.InternalComment} to fetch
11072
+ * @returns the associated {@link Amity.InternalComment} object
11022
11073
  *
11023
11074
  * @category Comment API
11024
11075
  * @async
@@ -11044,7 +11095,7 @@ const getComment$1 = async (commentId) => {
11044
11095
  ingestInCache(data, { cachedAt });
11045
11096
  const { comments } = data;
11046
11097
  return {
11047
- data: comments.find(comment => comment.commentId === commentId),
11098
+ data: LinkedObject.comment(comments.find(comment => comment.commentId === commentId)),
11048
11099
  cachedAt,
11049
11100
  };
11050
11101
  };
@@ -11054,10 +11105,10 @@ const getComment$1 = async (commentId) => {
11054
11105
  * const comment = getComment.locally('foobar')
11055
11106
  * ```
11056
11107
  *
11057
- * Fetches a {@link Amity.Comment} object
11108
+ * Fetches a {@link Amity.InternalComment} object
11058
11109
  *
11059
- * @param commentId the ID of the {@link Amity.Comment} to fetch
11060
- * @returns the associated {@link Amity.Comment} object
11110
+ * @param commentId the ID of the {@link Amity.InternalComment} to fetch
11111
+ * @returns the associated {@link Amity.InternalComment} object
11061
11112
  *
11062
11113
  * @category Comment API
11063
11114
  */
@@ -11558,12 +11609,12 @@ const createCommentEventSubscriber = (event, callback) => {
11558
11609
  * })
11559
11610
  * ```
11560
11611
  *
11561
- * Fired when a {@link Amity.Comment} has been created
11612
+ * Fired when a {@link Amity.InternalComment} has been created
11562
11613
  *
11563
11614
  * @param callback The function to call when the event was fired
11564
11615
  * @returns an {@link Amity.Unsubscriber} function to stop listening
11565
11616
  *
11566
- * @category Comment Events
11617
+ * @category InternalComment Events
11567
11618
  */
11568
11619
  const onCommentCreated = (callback) => createCommentEventSubscriber('comment.created', callback);
11569
11620
 
@@ -11575,12 +11626,12 @@ const onCommentCreated = (callback) => createCommentEventSubscriber('comment.cre
11575
11626
  * })
11576
11627
  * ```
11577
11628
  *
11578
- * Fired when a {@link Amity.Comment} has been updated
11629
+ * Fired when a {@link Amity.InternalComment} has been updated
11579
11630
  *
11580
11631
  * @param callback The function to call when the event was fired
11581
11632
  * @returns an {@link Amity.Unsubscriber} function to stop listening
11582
11633
  *
11583
- * @category Comment Events
11634
+ * @category InternalComment Events
11584
11635
  */
11585
11636
  const onCommentUpdated = (callback) => createCommentEventSubscriber('comment.updated', callback);
11586
11637
 
@@ -11592,12 +11643,12 @@ const onCommentUpdated = (callback) => createCommentEventSubscriber('comment.upd
11592
11643
  * })
11593
11644
  * ```
11594
11645
  *
11595
- * Fired when a {@link Amity.Comment} has been deleted
11646
+ * Fired when a {@link Amity.InternalComment} has been deleted
11596
11647
  *
11597
11648
  * @param callback The function to call when the event was fired
11598
11649
  * @returns an {@link Amity.Unsubscriber} function to stop listening
11599
11650
  *
11600
- * @category Comment Events
11651
+ * @category InternalComment Events
11601
11652
  */
11602
11653
  const onCommentDeleted = (callback) => createCommentEventSubscriber('comment.deleted', callback);
11603
11654
 
@@ -11609,12 +11660,12 @@ const onCommentDeleted = (callback) => createCommentEventSubscriber('comment.del
11609
11660
  * })
11610
11661
  * ```
11611
11662
  *
11612
- * Fired when a {@link Amity.Comment} has been flagged
11663
+ * Fired when a {@link Amity.InternalComment} has been flagged
11613
11664
  *
11614
11665
  * @param callback The function to call when the event was fired
11615
11666
  * @returns an {@link Amity.Unsubscriber} function to stop listening
11616
11667
  *
11617
- * @category Comment Events
11668
+ * @category InternalComment Events
11618
11669
  */
11619
11670
  const onCommentFlagged = (callback) => createCommentEventSubscriber('comment.flagged', callback);
11620
11671
 
@@ -11626,12 +11677,12 @@ const onCommentFlagged = (callback) => createCommentEventSubscriber('comment.fla
11626
11677
  * })
11627
11678
  * ```
11628
11679
  *
11629
- * Fired when a flag has been removed from a {@link Amity.Comment}
11680
+ * Fired when a flag has been removed from a {@link Amity.InternalComment}
11630
11681
  *
11631
11682
  * @param callback The function to call when the event was fired
11632
11683
  * @returns an {@link Amity.Unsubscriber} function to stop listening
11633
11684
  *
11634
- * @category Comment Events
11685
+ * @category InternalComment Events
11635
11686
  */
11636
11687
  const onCommentUnflagged = (callback) => createCommentEventSubscriber('comment.unflagged', callback);
11637
11688
 
@@ -11643,12 +11694,12 @@ const onCommentUnflagged = (callback) => createCommentEventSubscriber('comment.u
11643
11694
  * })
11644
11695
  * ```
11645
11696
  *
11646
- * Fired when a {@link Amity.Comment} has been reacted
11697
+ * Fired when a {@link Amity.InternalComment} has been reacted
11647
11698
  *
11648
11699
  * @param callback The function to call when the event was fired
11649
11700
  * @returns an {@link Amity.Unsubscriber} function to stop listening
11650
11701
  *
11651
- * @category Comment Events
11702
+ * @category InternalComment Events
11652
11703
  */
11653
11704
  const onCommentReactionAdded = (callback) => {
11654
11705
  const client = getActiveClient();
@@ -11679,12 +11730,12 @@ const onCommentReactionAdded = (callback) => {
11679
11730
  * })
11680
11731
  * ```
11681
11732
  *
11682
- * Fired when a reaction has been removed from a {@link Amity.Comment}
11733
+ * Fired when a reaction has been removed from a {@link Amity.InternalComment}
11683
11734
  *
11684
11735
  * @param callback The function to call when the event was fired
11685
11736
  * @returns an {@link Amity.Unsubscriber} function to stop listening
11686
11737
  *
11687
- * @category Comment Events
11738
+ * @category InternalComment Events
11688
11739
  */
11689
11740
  const onCommentReactionRemoved = (callback) => {
11690
11741
  const client = getActiveClient();
@@ -16538,10 +16589,10 @@ var index$3 = /*#__PURE__*/Object.freeze({
16538
16589
  * const comments = await CommentRepository.getCommentByIds(['foo', 'bar'])
16539
16590
  * ```
16540
16591
  *
16541
- * Fetches a collection of {@link Amity.Comment} objects
16592
+ * Fetches a collection of {@link Amity.InternalComment} objects
16542
16593
  *
16543
- * @param commentIds the IDs of the {@link Amity.Comment} to fetch
16544
- * @returns the associated collection of {@link Amity.Comment} objects
16594
+ * @param commentIds the IDs of the {@link Amity.InternalComment} to fetch
16595
+ * @returns the associated collection of {@link Amity.InternalComment} objects
16545
16596
  *
16546
16597
  * @category Comment API
16547
16598
  * @async
@@ -16581,10 +16632,10 @@ const getCommentByIds = async (commentIds) => {
16581
16632
  * const comments = getCommentByIds.locally(['foo', 'bar'])
16582
16633
  * ```
16583
16634
  *
16584
- * Fetches a collection of {@link Amity.Comment} objects from cache
16635
+ * Fetches a collection of {@link Amity.InternalComment} objects from cache
16585
16636
  *
16586
- * @param commentIds the IDs of the {@link Amity.Comment} to fetch
16587
- * @returns the associated collection of {@link Amity.Comment} objects
16637
+ * @param commentIds the IDs of the {@link Amity.InternalComment} to fetch
16638
+ * @returns the associated collection of {@link Amity.InternalComment} objects
16588
16639
  *
16589
16640
  * @category Comment API
16590
16641
  */
@@ -16616,10 +16667,10 @@ getCommentByIds.locally = (commentIds) => {
16616
16667
  * const newComment = await CommentRepository.createComment(bundle)
16617
16668
  * ```
16618
16669
  *
16619
- * Creates an {@link Amity.Comment}
16670
+ * Creates an {@link Amity.InternalComment}
16620
16671
  *
16621
- * @param bundle The data necessary to create a new {@link Amity.Comment}
16622
- * @returns The newly created {@link Amity.Comment}
16672
+ * @param bundle The data necessary to create a new {@link Amity.InternalComment}
16673
+ * @returns The newly created {@link Amity.InternalComment}
16623
16674
  *
16624
16675
  * @category Comment API
16625
16676
  * @async
@@ -16663,11 +16714,11 @@ const createComment = async (bundle) => {
16663
16714
  * })
16664
16715
  * ```
16665
16716
  *
16666
- * Updates an {@link Amity.Comment}
16717
+ * Updates an {@link Amity.InternalComment}
16667
16718
  *
16668
- * @param commentId The ID of the {@link Amity.Comment} to edit
16719
+ * @param commentId The ID of the {@link Amity.InternalComment} to edit
16669
16720
  * @param patch The patch data to apply
16670
- * @returns the updated {@link Amity.Comment} object
16721
+ * @returns the updated {@link Amity.InternalComment} object
16671
16722
  *
16672
16723
  * @category Comment API
16673
16724
  * @async
@@ -16697,10 +16748,10 @@ const updateComment = async (commentId, patch) => {
16697
16748
  * const success = await CommentRepository.deleteComment('foobar')
16698
16749
  * ```
16699
16750
  *
16700
- * Deletes a {@link Amity.Comment}
16751
+ * Deletes a {@link Amity.InternalComment}
16701
16752
  *
16702
- * @param commentId The {@link Amity.Comment} ID to delete
16703
- * @return A success boolean if the {@link Amity.Comment} was deleted
16753
+ * @param commentId The {@link Amity.InternalComment} ID to delete
16754
+ * @return A success boolean if the {@link Amity.InternalComment} was deleted
16704
16755
  *
16705
16756
  * @category Comment API
16706
16757
  * @async
@@ -16734,6 +16785,7 @@ const deleteComment = async (commentId, permanent = false) => {
16734
16785
  commentChildren: [],
16735
16786
  files: [],
16736
16787
  users: [],
16788
+ communityUsers: [],
16737
16789
  });
16738
16790
  if (permanent) {
16739
16791
  scheduleTask(() => pushToTombstone('comment', commentId));
@@ -16754,10 +16806,10 @@ const deleteComment = async (commentId, permanent = false) => {
16754
16806
  * const success = await CommentRepository.softDeleteComment('foobar')
16755
16807
  * ```
16756
16808
  *
16757
- * Deletes a {@link Amity.Comment}
16809
+ * Deletes a {@link Amity.InternalComment}
16758
16810
  *
16759
- * @param commentId The {@link Amity.Comment} ID to delete
16760
- * @return A success boolean if the {@link Amity.Comment} was deleted
16811
+ * @param commentId The {@link Amity.InternalComment} ID to delete
16812
+ * @return A success boolean if the {@link Amity.InternalComment} was deleted
16761
16813
  *
16762
16814
  * @category Comment API
16763
16815
  * @async
@@ -16779,10 +16831,10 @@ const softDeleteComment = async (commentId) => {
16779
16831
  * const success = await CommentRepository.hardDeleteComment('foobar')
16780
16832
  * ```
16781
16833
  *
16782
- * Deletes a {@link Amity.Comment}
16834
+ * Deletes a {@link Amity.InternalComment}
16783
16835
  *
16784
- * @param commentId The {@link Amity.Comment} ID to delete
16785
- * @return A success boolean if the {@link Amity.Comment} was deleted
16836
+ * @param commentId The {@link Amity.InternalComment} ID to delete
16837
+ * @return A success boolean if the {@link Amity.InternalComment} was deleted
16786
16838
  *
16787
16839
  * @category Comment API
16788
16840
  * @async
@@ -16883,13 +16935,13 @@ const isCommentFlaggedByMe = async (commentId) => {
16883
16935
  * const unsub = observeComments(postId, comment => merge(comments, comment))
16884
16936
  * ```
16885
16937
  *
16886
- * Observe all mutations on a list of {@link Amity.Comment} for a given {@link Amity.Post} object
16938
+ * Observe all mutations on a list of {@link Amity.InternalComment} for a given {@link Amity.Post} object
16887
16939
  *
16888
16940
  * @param postId the ID of the post where to observe the comments
16889
16941
  * @param callback the function to call when new data are available
16890
16942
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comments
16891
16943
  *
16892
- * @category Comment Observer
16944
+ * @category InternalComment Observer
16893
16945
  */
16894
16946
  const observeComments = (postId, callback) => {
16895
16947
  const { log } = getActiveClient();
@@ -16920,13 +16972,13 @@ const observeComments = (postId, callback) => {
16920
16972
  * const dispose = observeComment(commentId, ({ data }) => comment = data)
16921
16973
  * ```
16922
16974
  *
16923
- * Observe all mutation on a given {@link Amity.Comment}
16975
+ * Observe all mutation on a given {@link Amity.InternalComment}
16924
16976
  *
16925
16977
  * @param commentId the ID of the comment to observe
16926
16978
  * @param callback the function to call when new data are available
16927
16979
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
16928
16980
  *
16929
- * @category Comment Observer
16981
+ * @category InternalComment Observer
16930
16982
  */
16931
16983
  const observeComment = (commentId, callback, policy = 'cache_then_server') => {
16932
16984
  const { log } = getActiveClient();
@@ -16970,13 +17022,13 @@ const observeComment = (commentId, callback, policy = 'cache_then_server') => {
16970
17022
  * });
16971
17023
  * ```
16972
17024
  *
16973
- * Observe all mutation on a given {@link Amity.Comment}
17025
+ * Observe all mutation on a given {@link Amity.InternalComment}
16974
17026
  *
16975
17027
  * @param commentId the ID of the comment to observe
16976
17028
  * @param callback the function to call when new data are available
16977
17029
  * @returns An {@link Amity.Unsubscriber} function to run when willing to stop observing the comment
16978
17030
  *
16979
- * @category Comment Live Object
17031
+ * @category InternalComment Live Object
16980
17032
  */
16981
17033
  const getComment = (commentId, callback) => {
16982
17034
  return liveObject(commentId, callback, 'commentId', getComment$1, [
@@ -16996,10 +17048,10 @@ const getComment = (commentId, callback) => {
16996
17048
  * const comments = await CommentRepository.queryComments({ referenceType: 'post', referenceId: 'foo' })
16997
17049
  * ```
16998
17050
  *
16999
- * Queries a paginable list of {@link Amity.Comment} objects
17051
+ * Queries a paginable list of {@link Amity.InternalComment} objects
17000
17052
  *
17001
17053
  * @param query The query parameters
17002
- * @returns A page of {@link Amity.Comment} objects
17054
+ * @returns A page of {@link Amity.InternalComment} objects
17003
17055
  *
17004
17056
  * @category Comment API
17005
17057
  * @async
@@ -17049,12 +17101,12 @@ const queryComments = async (query) => {
17049
17101
  *
17050
17102
  * let comments = []
17051
17103
  * const unsub = getComments({
17052
- * referenceType: Amity.Comment['referenceType'];
17053
- * referenceId: Amity.Comment['referenceId'];
17104
+ * referenceType: Amity.InternalComment['referenceType'];
17105
+ * referenceId: Amity.InternalComment['referenceId'];
17054
17106
  * }, response => merge(comments, response.data))
17055
17107
  * ```
17056
17108
  *
17057
- * Observe all mutations on a list of {@link Amity.Comment} for a given target object
17109
+ * Observe all mutations on a list of {@link Amity.InternalComment} for a given target object
17058
17110
  *
17059
17111
  * @param referenceType the type of the target
17060
17112
  * @param referenceId the ID of the target
@@ -17084,7 +17136,7 @@ const getComments = (params, callback, config) => {
17084
17136
  let comments = (_a = data.data
17085
17137
  .map(commentId => pullFromCache(['comment', 'get', commentId]))
17086
17138
  .filter(Boolean)
17087
- .map(({ data }) => data)) !== null && _a !== void 0 ? _a : [];
17139
+ .map(({ data }) => LinkedObject.comment(data))) !== null && _a !== void 0 ? _a : [];
17088
17140
  if (!params.includeDeleted) {
17089
17141
  comments = filterByPropEquality(comments, 'isDeleted', false);
17090
17142
  }