@amityco/ts-sdk 0.0.1-beta.31 → 0.0.1-beta.33

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 (110) hide show
  1. package/dist/cache/api/backupCache.d.ts.map +1 -1
  2. package/dist/cache/api/ingestInCache.d.ts +1 -1
  3. package/dist/cache/api/tests/ingestInCache.test.d.ts +2 -0
  4. package/dist/cache/api/tests/ingestInCache.test.d.ts.map +1 -0
  5. package/dist/cache/api/tests/pushToCache.test.d.ts +2 -0
  6. package/dist/cache/api/tests/pushToCache.test.d.ts.map +1 -0
  7. package/dist/channel/api/addChannelMembers.d.ts.map +1 -1
  8. package/dist/channel/api/getChannel.d.ts.map +1 -1
  9. package/dist/channel/api/tests/addChannelMembers.test.d.ts +2 -0
  10. package/dist/channel/api/tests/addChannelMembers.test.d.ts.map +1 -0
  11. package/dist/channel/api/tests/getChannel.test.d.ts +2 -0
  12. package/dist/channel/api/tests/getChannel.test.d.ts.map +1 -0
  13. package/dist/channel/events/onChannelMemberAdded.d.ts.map +1 -1
  14. package/dist/core/events.d.ts +1 -1
  15. package/dist/core/events.d.ts.map +1 -1
  16. package/dist/core/model/idResolvers.d.ts.map +1 -1
  17. package/dist/core/transports/http.d.ts +5 -0
  18. package/dist/core/transports/http.d.ts.map +1 -1
  19. package/dist/core/transports/test/http.test.d.ts +2 -0
  20. package/dist/core/transports/test/http.test.d.ts.map +1 -0
  21. package/dist/index.cjs.js +61 -51
  22. package/dist/index.esm.js +60 -51
  23. package/dist/index.umd.js +4 -4
  24. package/dist/message/api/deleteMessage.d.ts.map +1 -1
  25. package/dist/message/api/tests/deleteMessage.test.d.ts +2 -0
  26. package/dist/message/api/tests/deleteMessage.test.d.ts.map +1 -0
  27. package/dist/message/{tests/api → api/tests}/getMessage.test.d.ts +0 -0
  28. package/dist/message/api/tests/getMessage.test.d.ts.map +1 -0
  29. package/dist/message/api/tests/getMessages.test.d.ts +2 -0
  30. package/dist/message/api/tests/getMessages.test.d.ts.map +1 -0
  31. package/dist/message/api/tests/queryMessages.test.d.ts +2 -0
  32. package/dist/message/api/tests/queryMessages.test.d.ts.map +1 -0
  33. package/dist/message/api/tests/updateMessage.test.d.ts +2 -0
  34. package/dist/message/api/tests/updateMessage.test.d.ts.map +1 -0
  35. package/dist/reaction/api/addReaction.d.ts.map +1 -1
  36. package/dist/reaction/api/removeReaction.d.ts.map +1 -1
  37. package/dist/reaction/api/tests/addReaction.test.d.ts +2 -0
  38. package/dist/reaction/api/tests/addReaction.test.d.ts.map +1 -0
  39. package/dist/reaction/api/tests/removeReaction.test.d.ts +2 -0
  40. package/dist/reaction/api/tests/removeReaction.test.d.ts.map +1 -0
  41. package/dist/user/api/getUser.d.ts.map +1 -1
  42. package/dist/user/api/queryUsers.d.ts.map +1 -1
  43. package/dist/user/api/tests/queryUsers.test.d.ts +2 -0
  44. package/dist/user/api/tests/queryUsers.test.d.ts.map +1 -0
  45. package/dist/utils/tests/dummy/channel.d.ts +6 -0
  46. package/dist/utils/tests/dummy/channel.d.ts.map +1 -1
  47. package/dist/utils/tests/dummy/community.d.ts +4 -0
  48. package/dist/utils/tests/dummy/community.d.ts.map +1 -0
  49. package/dist/utils/tests/dummy/file.d.ts +2 -0
  50. package/dist/utils/tests/dummy/file.d.ts.map +1 -0
  51. package/dist/utils/tests/dummy/follow.d.ts +1 -0
  52. package/dist/utils/tests/dummy/follow.d.ts.map +1 -1
  53. package/dist/utils/tests/dummy/index.d.ts +5 -0
  54. package/dist/utils/tests/dummy/index.d.ts.map +1 -1
  55. package/dist/utils/tests/dummy/message.d.ts +5 -0
  56. package/dist/utils/tests/dummy/message.d.ts.map +1 -1
  57. package/dist/utils/tests/dummy/poll.d.ts +3 -0
  58. package/dist/utils/tests/dummy/poll.d.ts.map +1 -0
  59. package/dist/utils/tests/dummy/post.d.ts +15 -1
  60. package/dist/utils/tests/dummy/post.d.ts.map +1 -1
  61. package/dist/utils/tests/dummy/reaction.d.ts +4 -0
  62. package/dist/utils/tests/dummy/reaction.d.ts.map +1 -0
  63. package/dist/utils/tests/dummy/role.d.ts +4 -0
  64. package/dist/utils/tests/dummy/role.d.ts.map +1 -0
  65. package/dist/utils/tests/dummy/user.d.ts +1 -0
  66. package/dist/utils/tests/dummy/user.d.ts.map +1 -1
  67. package/package.json +2 -1
  68. package/src/cache/api/backupCache.ts +0 -1
  69. package/src/cache/api/ingestInCache.ts +2 -2
  70. package/src/cache/api/tests/ingestInCache.test.ts +87 -0
  71. package/src/cache/api/tests/pushToCache.test.ts +57 -0
  72. package/src/channel/api/addChannelMembers.ts +9 -1
  73. package/src/channel/api/getChannel.ts +20 -5
  74. package/src/channel/api/tests/addChannelMembers.test.ts +95 -0
  75. package/src/channel/api/tests/getChannel.test.ts +108 -0
  76. package/src/channel/api/tests/queryChannels.test.ts +20 -0
  77. package/src/channel/events/onChannelMemberAdded.ts +1 -1
  78. package/src/channel/observers/tests/liveChannels.test.ts +0 -1
  79. package/src/core/events.ts +1 -1
  80. package/src/core/model/idResolvers.ts +1 -1
  81. package/src/core/transports/http.ts +3 -17
  82. package/src/core/transports/test/http.test.ts +83 -0
  83. package/src/message/api/deleteMessage.ts +2 -3
  84. package/src/message/api/tests/createMessage.test.ts +74 -51
  85. package/src/message/api/tests/deleteMessage.test.ts +110 -0
  86. package/src/message/api/tests/getMessage.test.ts +121 -0
  87. package/src/message/api/tests/getMessages.test.ts +108 -0
  88. package/src/message/api/tests/queryMessages.test.ts +115 -0
  89. package/src/message/api/tests/updateMessage.test.ts +100 -0
  90. package/src/post/tests/api/queryPosts.test.ts +117 -18
  91. package/src/reaction/api/addReaction.ts +17 -6
  92. package/src/reaction/api/removeReaction.ts +17 -6
  93. package/src/reaction/api/tests/addReaction.test.ts +73 -0
  94. package/src/reaction/api/tests/removeReaction.test.ts +79 -0
  95. package/src/user/api/getUser.ts +1 -2
  96. package/src/user/api/queryUsers.ts +24 -5
  97. package/src/user/api/tests/queryUsers.test.ts +124 -0
  98. package/src/utils/tests/dummy/channel.ts +9 -1
  99. package/src/utils/tests/dummy/community.ts +44 -0
  100. package/src/utils/tests/dummy/file.ts +20 -0
  101. package/src/utils/tests/dummy/follow.ts +6 -0
  102. package/src/utils/tests/dummy/index.ts +9 -0
  103. package/src/utils/tests/dummy/message.ts +8 -1
  104. package/src/utils/tests/dummy/poll.ts +43 -0
  105. package/src/utils/tests/dummy/post.ts +65 -4
  106. package/src/utils/tests/dummy/reaction.ts +22 -0
  107. package/src/utils/tests/dummy/role.ts +21 -0
  108. package/src/utils/tests/dummy/user.ts +7 -1
  109. package/dist/message/tests/api/getMessage.test.d.ts.map +0 -1
  110. package/src/message/tests/api/getMessage.test.ts +0 -96
@@ -1 +1 @@
1
- {"version":3,"file":"backupCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/backupCache.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,4CAEF,MAAM,UAAU,6BACnC,QAAQ,OAAO,CAkBjB,CAAC"}
1
+ {"version":3,"file":"backupCache.d.ts","sourceRoot":"","sources":["../../../src/cache/api/backupCache.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,WAAW,4CAEF,MAAM,UAAU,6BACnC,QAAQ,OAAO,CAkBjB,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * Ingest a payload (v3) into the cache
3
3
  *
4
4
  * @param payload a "backend v3" payload object
5
- * @param order the order of the keys to process (in case of need)
5
+ * @param options caching options like cachedAt or offline
6
6
  *
7
7
  * @category Cache
8
8
  * @hidden
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ingestInCache.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ingestInCache.test.d.ts","sourceRoot":"","sources":["../../../../src/cache/api/tests/ingestInCache.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=pushToCache.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pushToCache.test.d.ts","sourceRoot":"","sources":["../../../../src/cache/api/tests/pushToCache.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"addChannelMembers.d.ts","sourceRoot":"","sources":["../../../src/channel/api/addChannelMembers.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,cACjB,MAAM,OAAO,CAAC,WAAW,CAAC,WAC5B,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,KAC9B,QAAQ,OAAO,CAmBjB,CAAC"}
1
+ {"version":3,"file":"addChannelMembers.d.ts","sourceRoot":"","sources":["../../../src/channel/api/addChannelMembers.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,iBAAiB,cACjB,MAAM,OAAO,CAAC,WAAW,CAAC,WAC5B,MAAM,IAAI,CAAC,QAAQ,CAAC,EAAE,KAC9B,QAAQ,OAAO,CA2BjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"getChannel.d.ts","sourceRoot":"","sources":["../../../src/channel/api/getChannel.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU;gBACV,MAAM,OAAO,CAAC,WAAW,CAAC,GACpC,QAAQ,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,CAAC;IAsBvC;;;;;;;;;;;;OAYG;uBAEU,MAAM,OAAO,CAAC,WAAW,CAAC,GACpC,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS;CAjBzC,CAAC"}
1
+ {"version":3,"file":"getChannel.d.ts","sourceRoot":"","sources":["../../../src/channel/api/getChannel.ts"],"names":[],"mappings":"AAWA;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,UAAU;gBACV,MAAM,OAAO,CAAC,WAAW,CAAC,GACpC,QAAQ,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,CAAC;IAiCvC;;;;;;;;;;;;OAYG;uBAEU,MAAM,OAAO,CAAC,WAAW,CAAC,GACpC,MAAM,MAAM,CAAC,MAAM,OAAO,CAAC,GAAG,SAAS;CAjBzC,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=addChannelMembers.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"addChannelMembers.test.d.ts","sourceRoot":"","sources":["../../../../src/channel/api/tests/addChannelMembers.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=getChannel.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getChannel.test.d.ts","sourceRoot":"","sources":["../../../../src/channel/api/tests/getChannel.test.ts"],"names":[],"mappings":""}
@@ -1 +1 @@
1
- {"version":3,"file":"onChannelMemberAdded.d.ts","sourceRoot":"","sources":["../../../src/channel/events/onChannelMemberAdded.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,uBACX,MAAM,OAAO,UAAU,MAAM,UAAU,CAAC,SAAS,CAAC,KAAK,IAAI,uBAYhF,CAAC"}
1
+ {"version":3,"file":"onChannelMemberAdded.d.ts","sourceRoot":"","sources":["../../../src/channel/events/onChannelMemberAdded.ts"],"names":[],"mappings":"AAOA;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,oBAAoB,uBACX,MAAM,OAAO,UAAU,MAAM,UAAU,CAAC,SAAS,CAAC,KAAK,IAAI,KAC9E,MAAM,YAWR,CAAC"}
@@ -25,7 +25,7 @@ export declare const proxyMqttEvents: (mqttClient: Amity.Client['mqtt'], emitter
25
25
  * @hidden
26
26
  */
27
27
  export declare const createEventSubscriber: <T extends "disconnected" | "error" | "connect_error" | "reconnect_error" | "reconnect_failed" | "v3.channel.didCreate" | "v3.channel.didUpdate" | "v3.channel.didDelete" | "v3.channel.didJoin" | "v3.channel.didLeave" | "v3.channel.didAddUsers" | "v3.channel.didRemoveUsers" | "v3.channel.didBan" | "v3.channel.didUnban" | "v3.message.didFetch" | "v3.message.didCreate" | "v3.message.didUpdate" | "v3.message.didDelete" | "connect" | "message" | "disconnect" | "close" | "end" | "reconnect" | "video-streaming.didRecord" | "video-streaming.didStart" | "video-streaming.didStop" | "community.created" | "community.updated" | "community.deleted" | "community.joined" | "community.left" | "community.userAdded" | "community.userRemoved" | "community.userBanned" | "community.userUnbanned" | "post.created" | "post.updated" | "post.deleted" | "post.approved" | "post.declined" | "post.flagged" | "post.unflagged" | "post.addReaction" | "post.removeReaction" | "comment.created" | "comment.updated" | "comment.deleted" | "comment.flagged" | "comment.unflagged" | "comment.addReaction" | "comment.removeReaction" | "user.fetched" | "user.updated" | "user.deleted" | "user.flagged" | "user.unflagged" | "user.flagCleared" | "follow.created" | "follow.requested" | "follow.accepted" | "follow.unfollowed" | "follow.requestCanceled" | "follow.requestDeclined" | "follow.followerDeleted" | "poll.updated" | "poll.deleted">(client: Amity.Client, namespace: string, event: T, fn: Amity.Listener<Amity.Events[T]>) => Amity.Unsubscriber;
28
- export declare const createMqttMessageSubscriber: <T extends "disconnected" | "error" | "connect_error" | "reconnect_error" | "reconnect_failed" | "v3.channel.didCreate" | "v3.channel.didUpdate" | "v3.channel.didDelete" | "v3.channel.didJoin" | "v3.channel.didLeave" | "v3.channel.didAddUsers" | "v3.channel.didRemoveUsers" | "v3.channel.didBan" | "v3.channel.didUnban" | "v3.message.didFetch" | "v3.message.didCreate" | "v3.message.didUpdate" | "v3.message.didDelete" | "connect" | "message" | "disconnect" | "close" | "end" | "reconnect" | "video-streaming.didRecord" | "video-streaming.didStart" | "video-streaming.didStop" | "community.created" | "community.updated" | "community.deleted" | "community.joined" | "community.left" | "community.userAdded" | "community.userRemoved" | "community.userBanned" | "community.userUnbanned" | "post.created" | "post.updated" | "post.deleted" | "post.approved" | "post.declined" | "post.flagged" | "post.unflagged" | "post.addReaction" | "post.removeReaction" | "comment.created" | "comment.updated" | "comment.deleted" | "comment.flagged" | "comment.unflagged" | "comment.addReaction" | "comment.removeReaction" | "user.fetched" | "user.updated" | "user.deleted" | "user.flagged" | "user.unflagged" | "user.flagCleared" | "follow.created" | "follow.requested" | "follow.accepted" | "follow.unfollowed" | "follow.requestCanceled" | "follow.requestDeclined" | "follow.followerDeleted" | "poll.updated" | "poll.deleted">(client: Amity.Client, namespace: string, event: string, fn: (params: Record<string, unknown>) => void) => Amity.Unsubscriber;
28
+ export declare const createMqttMessageSubscriber: <T extends "disconnected" | "error" | "connect_error" | "reconnect_error" | "reconnect_failed" | "v3.channel.didCreate" | "v3.channel.didUpdate" | "v3.channel.didDelete" | "v3.channel.didJoin" | "v3.channel.didLeave" | "v3.channel.didAddUsers" | "v3.channel.didRemoveUsers" | "v3.channel.didBan" | "v3.channel.didUnban" | "v3.message.didFetch" | "v3.message.didCreate" | "v3.message.didUpdate" | "v3.message.didDelete" | "connect" | "message" | "disconnect" | "close" | "end" | "reconnect" | "video-streaming.didRecord" | "video-streaming.didStart" | "video-streaming.didStop" | "community.created" | "community.updated" | "community.deleted" | "community.joined" | "community.left" | "community.userAdded" | "community.userRemoved" | "community.userBanned" | "community.userUnbanned" | "post.created" | "post.updated" | "post.deleted" | "post.approved" | "post.declined" | "post.flagged" | "post.unflagged" | "post.addReaction" | "post.removeReaction" | "comment.created" | "comment.updated" | "comment.deleted" | "comment.flagged" | "comment.unflagged" | "comment.addReaction" | "comment.removeReaction" | "user.fetched" | "user.updated" | "user.deleted" | "user.flagged" | "user.unflagged" | "user.flagCleared" | "follow.created" | "follow.requested" | "follow.accepted" | "follow.unfollowed" | "follow.requestCanceled" | "follow.requestDeclined" | "follow.followerDeleted" | "poll.updated" | "poll.deleted">(client: Amity.Client, namespace: string, event: T, fn: (params: Record<string, unknown>) => void) => Amity.Unsubscriber;
29
29
  /**
30
30
  * Wrapper around dispatch event
31
31
  *
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/core/events.ts"],"names":[],"mappings":"AAyCA,cAAc;AACd,eAAO,MAAM,kBAAkB,4CAE9B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,OAAQ,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,MAAM,MAAM,CAAC,SAAS,CAAC,SAI5F,CAAC;AAEF,eAAO,MAAM,eAAe,eACd,MAAM,MAAM,CAAC,MAAM,CAAC,WACvB,MAAM,MAAM,CAAC,SAAS,CAAC,SAcjC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,84CACxB,MAAM,MAAM,aACT,MAAM,oDAGhB,MAAM,YAiBR,CAAC;AAEF,eAAO,MAAM,2BAA2B,84CAC9B,MAAM,MAAM,aACT,MAAM,SACV,MAAM,eACA,OAAO,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,KAC5C,MAAM,YAQR,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,i7CAKrB,CAAC"}
1
+ {"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../../src/core/events.ts"],"names":[],"mappings":"AAyCA,cAAc;AACd,eAAO,MAAM,kBAAkB,4CAE9B,CAAC;AAEF;;;;;;;;;GASG;AACH,eAAO,MAAM,oBAAoB,OAAQ,MAAM,MAAM,CAAC,IAAI,CAAC,WAAW,MAAM,MAAM,CAAC,SAAS,CAAC,SAI5F,CAAC;AAEF,eAAO,MAAM,eAAe,eACd,MAAM,MAAM,CAAC,MAAM,CAAC,WACvB,MAAM,MAAM,CAAC,SAAS,CAAC,SAcjC,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,qBAAqB,84CACxB,MAAM,MAAM,aACT,MAAM,oDAGhB,MAAM,YAiBR,CAAC;AAEF,eAAO,MAAM,2BAA2B,84CAC9B,MAAM,MAAM,aACT,MAAM,yBAEJ,OAAO,MAAM,EAAE,OAAO,CAAC,KAAK,IAAI,KAC5C,MAAM,YAQR,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,SAAS,i7CAKrB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"idResolvers.d.ts","sourceRoot":"","sources":["../../../src/core/model/idResolvers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,aAAK,SAAS,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI;KACzD,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM;CACtD,CAAC;AA0BF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,+EAAyD,CAAC"}
1
+ {"version":3,"file":"idResolvers.d.ts","sourceRoot":"","sources":["../../../src/core/model/idResolvers.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,aAAK,SAAS,CAAC,CAAC,SAAS,KAAK,CAAC,MAAM,EAAE,GAAG,KAAK,CAAC,MAAM,EAAE,IAAI;KACzD,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,MAAM;CACtD,CAAC;AA0BF;;;;;GAKG;AACH,eAAO,MAAM,WAAW,+EAAuE,CAAC"}
@@ -1,3 +1,8 @@
1
+ /**
2
+ * Axios param serializer (for querystring)
3
+ * @hidden
4
+ */
5
+ export declare const stringify: (params: Record<string, unknown>) => string;
1
6
  /**
2
7
  * Creates a pre-configured axios instance
3
8
  *
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/core/transports/http.ts"],"names":[],"mappings":"AA4BA;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,aAAc,MAAM,kCA2BnD,CAAC"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../../src/core/transports/http.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,eAAO,MAAM,SAAS,WAAY,OAAO,MAAM,EAAE,OAAO,CAAC,KAAG,MAE3D,CAAC;AAEF;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,aAAc,MAAM,kCA2BnD,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=http.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"http.test.d.ts","sourceRoot":"","sources":["../../../../src/core/transports/test/http.test.ts"],"names":[],"mappings":""}
package/dist/index.cjs.js CHANGED
@@ -7,6 +7,7 @@ var AsyncStorage = require('@react-native-async-storage/async-storage');
7
7
  var mitt = require('mitt');
8
8
  var debug = require('debug');
9
9
  var axios = require('axios');
10
+ var qs = require('qs');
10
11
  var HttpAgent = require('agentkeepalive');
11
12
  var io = require('socket.io-client');
12
13
  var nativeIdGenerator = require('react-native-uuid');
@@ -17,6 +18,7 @@ var AsyncStorage__default = /*#__PURE__*/_interopDefaultLegacy(AsyncStorage);
17
18
  var mitt__default = /*#__PURE__*/_interopDefaultLegacy(mitt);
18
19
  var debug__default = /*#__PURE__*/_interopDefaultLegacy(debug);
19
20
  var axios__default = /*#__PURE__*/_interopDefaultLegacy(axios);
21
+ var qs__default = /*#__PURE__*/_interopDefaultLegacy(qs);
20
22
  var HttpAgent__default = /*#__PURE__*/_interopDefaultLegacy(HttpAgent);
21
23
  var io__default = /*#__PURE__*/_interopDefaultLegacy(io);
22
24
  var nativeIdGenerator__default = /*#__PURE__*/_interopDefaultLegacy(nativeIdGenerator);
@@ -809,7 +811,6 @@ const restoreCache = async (storageKey = 'amitySdk') => {
809
811
  return true;
810
812
  };
811
813
 
812
- /* eslint-disable @typescript-eslint/no-unused-vars */
813
814
  /**
814
815
  * ```js
815
816
  * import { backupCache } from '@amityco/ts-sdk'
@@ -1396,21 +1397,8 @@ const unwrapPayload = (response) => {
1396
1397
  * Axios param serializer (for querystring)
1397
1398
  * @hidden
1398
1399
  */
1399
- const stringify = (params, prefix) => {
1400
- return Object.entries(params)
1401
- .filter(([, value]) => value !== undefined)
1402
- .map(([name, value]) => {
1403
- const key = prefix ? `${prefix}[${name}]` : name;
1404
- if (Array.isArray(value)) {
1405
- return value.map(item => `${key}[]=${item}`).join('&');
1406
- }
1407
- if (typeof value !== 'object') {
1408
- return `${key}=${value}`;
1409
- }
1410
- // @ts-ignore
1411
- return stringify(value, prefix !== null && prefix !== void 0 ? prefix : name);
1412
- })
1413
- .join('&');
1400
+ const stringify = (params) => {
1401
+ return qs__default["default"].stringify(params, { arrayFormat: 'brackets' });
1414
1402
  };
1415
1403
  /**
1416
1404
  * Creates a pre-configured axios instance
@@ -20422,7 +20410,7 @@ const getDeviceInfo = () => {
20422
20410
  * Ingest a payload (v3) into the cache
20423
20411
  *
20424
20412
  * @param payload a "backend v3" payload object
20425
- * @param order the order of the keys to process (in case of need)
20413
+ * @param options caching options like cachedAt or offline
20426
20414
  *
20427
20415
  * @category Cache
20428
20416
  * @hidden
@@ -20434,9 +20422,7 @@ const ingestInCache = (payload = {}, options) => {
20434
20422
  return;
20435
20423
  const resolver = getResolver(type);
20436
20424
  models.forEach(model => {
20437
- upsertInCache(
20438
- // eslint-disable @typescript-eslint no-explicit-any
20439
- [type, 'get', resolver(model)], // this 'any' cannot be avoided, sorry.
20425
+ upsertInCache([type, 'get', resolver(model)], // this 'any' cannot be avoided, sorry.
20440
20426
  model, options);
20441
20427
  });
20442
20428
  });
@@ -20728,7 +20714,6 @@ const getUser = async (userId, isLive = false) => {
20728
20714
  isInTombstone('user', userId);
20729
20715
  let data;
20730
20716
  try {
20731
- // API-FIX: endpoint should not be /list, parameters should be querystring.
20732
20717
  const response = await client.http.get(`/api/v3/users/${encodeURIComponent(userId)}`);
20733
20718
  data = response.data;
20734
20719
  }
@@ -20875,8 +20860,7 @@ function __rest(s, e) {
20875
20860
  const queryUsers = async (query = {}) => {
20876
20861
  const client = getActiveClient();
20877
20862
  client.log('user/queryUsers', query);
20878
- const { page, displayName, filter = 'all', sortBy = 'displayName' } = query, params = __rest(query, ["page", "displayName", "filter", "sortBy"]);
20879
- // API-FIX: parameters should be querystring.
20863
+ const { page = { limit: 10 }, displayName, filter = 'all', sortBy = 'displayName' } = query, params = __rest(query, ["page", "displayName", "filter", "sortBy"]);
20880
20864
  const { data } = await client.http.get(`/api/v3/users`, {
20881
20865
  params: Object.assign(Object.assign({}, params), { keyword: displayName, filter,
20882
20866
  sortBy, options: {
@@ -20889,7 +20873,11 @@ const queryUsers = async (query = {}) => {
20889
20873
  const cachedAt = client.cache && Date.now();
20890
20874
  if (client.cache) {
20891
20875
  ingestInCache(payload, { cachedAt });
20892
- const cacheKey = ['user', 'query', query];
20876
+ /*
20877
+ * using query as cache key over params because if the keyword, filter, sort
20878
+ * change the API will NOT cache results, when it should
20879
+ */
20880
+ const cacheKey = ['user', 'query', Object.assign(Object.assign({}, query), { options: Object.assign({}, page) })];
20893
20881
  pushToCache(cacheKey, { users: users.map(getResolver('user')), paging });
20894
20882
  }
20895
20883
  fireEvent('user.fetched', data);
@@ -20917,8 +20905,13 @@ queryUsers.locally = (query = {}) => {
20917
20905
  client.log('user/queryUsers.locally', query);
20918
20906
  if (!client.cache)
20919
20907
  return;
20920
- const queryKey = ['user', 'query', query];
20921
- const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
20908
+ const { page = { limit: 10 } } = query !== null && query !== void 0 ? query : {};
20909
+ const cacheKey = [
20910
+ 'user',
20911
+ 'query',
20912
+ Object.assign(Object.assign({}, query), { options: Object.assign({}, page) }),
20913
+ ];
20914
+ const { data, cachedAt } = (_a = pullFromCache(cacheKey)) !== null && _a !== void 0 ? _a : {};
20922
20915
  const users = (_b = data === null || data === void 0 ? void 0 : data.users.map(userId => pullFromCache(['user', 'get', userId])).filter(Boolean).map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
20923
20916
  const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
20924
20917
  const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
@@ -23274,17 +23267,6 @@ const deleteComment = async (commentId, permanent = false) => {
23274
23267
  return deleted;
23275
23268
  };
23276
23269
 
23277
- /** @hidden */
23278
- const fetchReference = async (referenceType, referenceId) => {
23279
- if (referenceType === 'message')
23280
- return getMessage(referenceId);
23281
- if (referenceType === 'post')
23282
- return getPost(referenceId);
23283
- if (referenceType === 'comment')
23284
- return getComment(referenceId);
23285
- throw new Error(`Incorrect referenceType: ${referenceType}`);
23286
- };
23287
-
23288
23270
  /** @hidden */
23289
23271
  const preparePayloadForCache = (event, payload) => {
23290
23272
  var _a, _b;
@@ -23372,7 +23354,6 @@ const prepareMessagePayloadForCache = (payload) => {
23372
23354
  * @async
23373
23355
  * */
23374
23356
  const addReaction = async (referenceType, referenceId, reactionName) => {
23375
- var _a, _b;
23376
23357
  const client = getActiveClient();
23377
23358
  client.log('reaction/createReaction', {
23378
23359
  referenceId,
@@ -23384,9 +23365,16 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
23384
23365
  referenceType,
23385
23366
  reactionName,
23386
23367
  });
23387
- const model = await fetchReference(referenceType, referenceId);
23388
- dispatchReactable(referenceType, model.data);
23389
- return (_b = (_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)) !== null && _b !== void 0 ? _b : false;
23368
+ if (client.cache) {
23369
+ const model = pullFromCache([
23370
+ referenceType,
23371
+ 'get',
23372
+ referenceId,
23373
+ ]);
23374
+ (model === null || model === void 0 ? void 0 : model.data) &&
23375
+ pushToCache([referenceType, 'get', referenceId], model.data, { cachedAt: Date.now() });
23376
+ }
23377
+ return true;
23390
23378
  };
23391
23379
  /**
23392
23380
  * ```js
@@ -23421,7 +23409,9 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
23421
23409
  if (!(model === null || model === void 0 ? void 0 : model.data) || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
23422
23410
  return;
23423
23411
  const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }) });
23424
- upsertInCache([referenceType, 'get', referenceId], reaction, { cachedAt: -1 });
23412
+ upsertInCache([referenceType, 'get', referenceId], reaction, {
23413
+ cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
23414
+ });
23425
23415
  dispatchReactable(referenceType, reaction);
23426
23416
  return (_e = (_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName)) !== null && _e !== void 0 ? _e : false;
23427
23417
  };
@@ -23443,7 +23433,6 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
23443
23433
  * @async
23444
23434
  * */
23445
23435
  const removeReaction = async (referenceType, referenceId, reactionName) => {
23446
- var _a, _b;
23447
23436
  const client = getActiveClient();
23448
23437
  client.log('reaction/removeReaction', {
23449
23438
  referenceId,
@@ -23453,9 +23442,16 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
23453
23442
  await client.http.delete(`/api/v2/reactions`, {
23454
23443
  data: { referenceId, referenceType, reactionName },
23455
23444
  });
23456
- const model = await fetchReference(referenceType, referenceId);
23457
- dispatchReactable(referenceType, model.data);
23458
- return (_b = !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName))) !== null && _b !== void 0 ? _b : false;
23445
+ if (client.cache) {
23446
+ const model = pullFromCache([
23447
+ referenceType,
23448
+ 'get',
23449
+ referenceId,
23450
+ ]);
23451
+ (model === null || model === void 0 ? void 0 : model.data) &&
23452
+ pushToCache([referenceType, 'get', referenceId], model.data, { cachedAt: Date.now() });
23453
+ }
23454
+ return true;
23459
23455
  };
23460
23456
  /**
23461
23457
  * ```js
@@ -23490,7 +23486,9 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
23490
23486
  if (!(model === null || model === void 0 ? void 0 : model.data) || !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
23491
23487
  return;
23492
23488
  const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) - 1) }) });
23493
- upsertInCache([referenceType, 'get', referenceId], reaction, { cachedAt: -1 });
23489
+ upsertInCache([referenceType, 'get', referenceId], reaction, {
23490
+ cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
23491
+ });
23494
23492
  dispatchReactable(referenceType, reaction);
23495
23493
  return (_e = !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName))) !== null && _e !== void 0 ? _e : false;
23496
23494
  };
@@ -24508,9 +24506,18 @@ getChannels.locally = (channelIds) => {
24508
24506
  const getChannel = async (channelId) => {
24509
24507
  const client = getActiveClient();
24510
24508
  client.log('channel/getChannel', channelId);
24511
- // API-FIX: endpoint should not be /list, parameters should be querystring.
24512
- const { data: payload } = await client.http.get(`/api/v3/channels/${encodeURIComponent(channelId)}`);
24513
- const data = prepareChannelPayload(payload);
24509
+ isInTombstone('channel', channelId);
24510
+ let data;
24511
+ try {
24512
+ const { data: payload } = await client.http.get(`/api/v3/channels/${encodeURIComponent(channelId)}`);
24513
+ data = prepareChannelPayload(payload);
24514
+ }
24515
+ catch (error) {
24516
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
24517
+ pushToTombstone('channel', channelId);
24518
+ }
24519
+ throw error;
24520
+ }
24514
24521
  const cachedAt = client.cache && Date.now();
24515
24522
  if (client.cache)
24516
24523
  ingestInCache(data, { cachedAt });
@@ -24790,7 +24797,10 @@ const addChannelMembers = async (channelId, userIds) => {
24790
24797
  const data = prepareChannelPayload(payload);
24791
24798
  if (client.cache)
24792
24799
  ingestInCache(data);
24793
- fireEvent('v3.channel.didAddUsers', data);
24800
+ /*
24801
+ * should fire event for each user that was added
24802
+ */
24803
+ userIds.forEach(id => fireEvent('v3.channel.didAddUsers', Object.assign(Object.assign({}, data), { channelUsers: data.channelUsers.filter(u => u.userId === id) })));
24794
24804
  const { channelUsers } = data;
24795
24805
  return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership === 'member');
24796
24806
  };
package/dist/index.esm.js CHANGED
@@ -3,6 +3,7 @@ import AsyncStorage from '@react-native-async-storage/async-storage';
3
3
  import mitt from 'mitt';
4
4
  import debug from 'debug';
5
5
  import axios from 'axios';
6
+ import qs from 'qs';
6
7
  import HttpAgent, { HttpsAgent } from 'agentkeepalive';
7
8
  import io from 'socket.io-client';
8
9
  import nativeIdGenerator from 'react-native-uuid';
@@ -795,7 +796,6 @@ const restoreCache = async (storageKey = 'amitySdk') => {
795
796
  return true;
796
797
  };
797
798
 
798
- /* eslint-disable @typescript-eslint/no-unused-vars */
799
799
  /**
800
800
  * ```js
801
801
  * import { backupCache } from '@amityco/ts-sdk'
@@ -1382,21 +1382,8 @@ const unwrapPayload = (response) => {
1382
1382
  * Axios param serializer (for querystring)
1383
1383
  * @hidden
1384
1384
  */
1385
- const stringify = (params, prefix) => {
1386
- return Object.entries(params)
1387
- .filter(([, value]) => value !== undefined)
1388
- .map(([name, value]) => {
1389
- const key = prefix ? `${prefix}[${name}]` : name;
1390
- if (Array.isArray(value)) {
1391
- return value.map(item => `${key}[]=${item}`).join('&');
1392
- }
1393
- if (typeof value !== 'object') {
1394
- return `${key}=${value}`;
1395
- }
1396
- // @ts-ignore
1397
- return stringify(value, prefix !== null && prefix !== void 0 ? prefix : name);
1398
- })
1399
- .join('&');
1385
+ const stringify = (params) => {
1386
+ return qs.stringify(params, { arrayFormat: 'brackets' });
1400
1387
  };
1401
1388
  /**
1402
1389
  * Creates a pre-configured axios instance
@@ -20408,7 +20395,7 @@ const getDeviceInfo = () => {
20408
20395
  * Ingest a payload (v3) into the cache
20409
20396
  *
20410
20397
  * @param payload a "backend v3" payload object
20411
- * @param order the order of the keys to process (in case of need)
20398
+ * @param options caching options like cachedAt or offline
20412
20399
  *
20413
20400
  * @category Cache
20414
20401
  * @hidden
@@ -20420,9 +20407,7 @@ const ingestInCache = (payload = {}, options) => {
20420
20407
  return;
20421
20408
  const resolver = getResolver(type);
20422
20409
  models.forEach(model => {
20423
- upsertInCache(
20424
- // eslint-disable @typescript-eslint no-explicit-any
20425
- [type, 'get', resolver(model)], // this 'any' cannot be avoided, sorry.
20410
+ upsertInCache([type, 'get', resolver(model)], // this 'any' cannot be avoided, sorry.
20426
20411
  model, options);
20427
20412
  });
20428
20413
  });
@@ -20714,7 +20699,6 @@ const getUser = async (userId, isLive = false) => {
20714
20699
  isInTombstone('user', userId);
20715
20700
  let data;
20716
20701
  try {
20717
- // API-FIX: endpoint should not be /list, parameters should be querystring.
20718
20702
  const response = await client.http.get(`/api/v3/users/${encodeURIComponent(userId)}`);
20719
20703
  data = response.data;
20720
20704
  }
@@ -20861,8 +20845,7 @@ function __rest(s, e) {
20861
20845
  const queryUsers = async (query = {}) => {
20862
20846
  const client = getActiveClient();
20863
20847
  client.log('user/queryUsers', query);
20864
- const { page, displayName, filter = 'all', sortBy = 'displayName' } = query, params = __rest(query, ["page", "displayName", "filter", "sortBy"]);
20865
- // API-FIX: parameters should be querystring.
20848
+ const { page = { limit: 10 }, displayName, filter = 'all', sortBy = 'displayName' } = query, params = __rest(query, ["page", "displayName", "filter", "sortBy"]);
20866
20849
  const { data } = await client.http.get(`/api/v3/users`, {
20867
20850
  params: Object.assign(Object.assign({}, params), { keyword: displayName, filter,
20868
20851
  sortBy, options: {
@@ -20875,7 +20858,11 @@ const queryUsers = async (query = {}) => {
20875
20858
  const cachedAt = client.cache && Date.now();
20876
20859
  if (client.cache) {
20877
20860
  ingestInCache(payload, { cachedAt });
20878
- const cacheKey = ['user', 'query', query];
20861
+ /*
20862
+ * using query as cache key over params because if the keyword, filter, sort
20863
+ * change the API will NOT cache results, when it should
20864
+ */
20865
+ const cacheKey = ['user', 'query', Object.assign(Object.assign({}, query), { options: Object.assign({}, page) })];
20879
20866
  pushToCache(cacheKey, { users: users.map(getResolver('user')), paging });
20880
20867
  }
20881
20868
  fireEvent('user.fetched', data);
@@ -20903,8 +20890,13 @@ queryUsers.locally = (query = {}) => {
20903
20890
  client.log('user/queryUsers.locally', query);
20904
20891
  if (!client.cache)
20905
20892
  return;
20906
- const queryKey = ['user', 'query', query];
20907
- const { data, cachedAt } = (_a = pullFromCache(queryKey)) !== null && _a !== void 0 ? _a : {};
20893
+ const { page = { limit: 10 } } = query !== null && query !== void 0 ? query : {};
20894
+ const cacheKey = [
20895
+ 'user',
20896
+ 'query',
20897
+ Object.assign(Object.assign({}, query), { options: Object.assign({}, page) }),
20898
+ ];
20899
+ const { data, cachedAt } = (_a = pullFromCache(cacheKey)) !== null && _a !== void 0 ? _a : {};
20908
20900
  const users = (_b = data === null || data === void 0 ? void 0 : data.users.map(userId => pullFromCache(['user', 'get', userId])).filter(Boolean).map(({ data }) => data)) !== null && _b !== void 0 ? _b : [];
20909
20901
  const prevPage = toPage(data === null || data === void 0 ? void 0 : data.paging.previous);
20910
20902
  const nextPage = toPage(data === null || data === void 0 ? void 0 : data.paging.next);
@@ -23260,17 +23252,6 @@ const deleteComment = async (commentId, permanent = false) => {
23260
23252
  return deleted;
23261
23253
  };
23262
23254
 
23263
- /** @hidden */
23264
- const fetchReference = async (referenceType, referenceId) => {
23265
- if (referenceType === 'message')
23266
- return getMessage(referenceId);
23267
- if (referenceType === 'post')
23268
- return getPost(referenceId);
23269
- if (referenceType === 'comment')
23270
- return getComment(referenceId);
23271
- throw new Error(`Incorrect referenceType: ${referenceType}`);
23272
- };
23273
-
23274
23255
  /** @hidden */
23275
23256
  const preparePayloadForCache = (event, payload) => {
23276
23257
  var _a, _b;
@@ -23358,7 +23339,6 @@ const prepareMessagePayloadForCache = (payload) => {
23358
23339
  * @async
23359
23340
  * */
23360
23341
  const addReaction = async (referenceType, referenceId, reactionName) => {
23361
- var _a, _b;
23362
23342
  const client = getActiveClient();
23363
23343
  client.log('reaction/createReaction', {
23364
23344
  referenceId,
@@ -23370,9 +23350,16 @@ const addReaction = async (referenceType, referenceId, reactionName) => {
23370
23350
  referenceType,
23371
23351
  reactionName,
23372
23352
  });
23373
- const model = await fetchReference(referenceType, referenceId);
23374
- dispatchReactable(referenceType, model.data);
23375
- return (_b = (_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)) !== null && _b !== void 0 ? _b : false;
23353
+ if (client.cache) {
23354
+ const model = pullFromCache([
23355
+ referenceType,
23356
+ 'get',
23357
+ referenceId,
23358
+ ]);
23359
+ (model === null || model === void 0 ? void 0 : model.data) &&
23360
+ pushToCache([referenceType, 'get', referenceId], model.data, { cachedAt: Date.now() });
23361
+ }
23362
+ return true;
23376
23363
  };
23377
23364
  /**
23378
23365
  * ```js
@@ -23407,7 +23394,9 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
23407
23394
  if (!(model === null || model === void 0 ? void 0 : model.data) || ((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
23408
23395
  return;
23409
23396
  const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: model.data.reactionsCount + 1, myReactions: [...((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []), reactionName], reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) + 1 }) });
23410
- upsertInCache([referenceType, 'get', referenceId], reaction, { cachedAt: -1 });
23397
+ upsertInCache([referenceType, 'get', referenceId], reaction, {
23398
+ cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
23399
+ });
23411
23400
  dispatchReactable(referenceType, reaction);
23412
23401
  return (_e = (_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName)) !== null && _e !== void 0 ? _e : false;
23413
23402
  };
@@ -23429,7 +23418,6 @@ addReaction.optimistically = (referenceType, referenceId, reactionName) => {
23429
23418
  * @async
23430
23419
  * */
23431
23420
  const removeReaction = async (referenceType, referenceId, reactionName) => {
23432
- var _a, _b;
23433
23421
  const client = getActiveClient();
23434
23422
  client.log('reaction/removeReaction', {
23435
23423
  referenceId,
@@ -23439,9 +23427,16 @@ const removeReaction = async (referenceType, referenceId, reactionName) => {
23439
23427
  await client.http.delete(`/api/v2/reactions`, {
23440
23428
  data: { referenceId, referenceType, reactionName },
23441
23429
  });
23442
- const model = await fetchReference(referenceType, referenceId);
23443
- dispatchReactable(referenceType, model.data);
23444
- return (_b = !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName))) !== null && _b !== void 0 ? _b : false;
23430
+ if (client.cache) {
23431
+ const model = pullFromCache([
23432
+ referenceType,
23433
+ 'get',
23434
+ referenceId,
23435
+ ]);
23436
+ (model === null || model === void 0 ? void 0 : model.data) &&
23437
+ pushToCache([referenceType, 'get', referenceId], model.data, { cachedAt: Date.now() });
23438
+ }
23439
+ return true;
23445
23440
  };
23446
23441
  /**
23447
23442
  * ```js
@@ -23476,7 +23471,9 @@ removeReaction.optimistically = (referenceType, referenceId, reactionName) => {
23476
23471
  if (!(model === null || model === void 0 ? void 0 : model.data) || !((_a = model.data.myReactions) === null || _a === void 0 ? void 0 : _a.includes(reactionName)))
23477
23472
  return;
23478
23473
  const reaction = Object.assign(Object.assign({}, model.data), { reactionsCount: Math.max(0, model.data.reactionsCount - 1), myReactions: ((_b = model.data.myReactions) !== null && _b !== void 0 ? _b : []).filter(item => item !== reactionName), reactions: Object.assign(Object.assign({}, model.data.reactions), { [reactionName]: Math.max(0, ((_c = model.data.reactions[reactionName]) !== null && _c !== void 0 ? _c : 0) - 1) }) });
23479
- upsertInCache([referenceType, 'get', referenceId], reaction, { cachedAt: -1 });
23474
+ upsertInCache([referenceType, 'get', referenceId], reaction, {
23475
+ cachedAt: UNSYNCED_OBJECT_CACHED_AT_VALUE,
23476
+ });
23480
23477
  dispatchReactable(referenceType, reaction);
23481
23478
  return (_e = !((_d = reaction === null || reaction === void 0 ? void 0 : reaction.myReactions) === null || _d === void 0 ? void 0 : _d.includes(reactionName))) !== null && _e !== void 0 ? _e : false;
23482
23479
  };
@@ -24494,9 +24491,18 @@ getChannels.locally = (channelIds) => {
24494
24491
  const getChannel = async (channelId) => {
24495
24492
  const client = getActiveClient();
24496
24493
  client.log('channel/getChannel', channelId);
24497
- // API-FIX: endpoint should not be /list, parameters should be querystring.
24498
- const { data: payload } = await client.http.get(`/api/v3/channels/${encodeURIComponent(channelId)}`);
24499
- const data = prepareChannelPayload(payload);
24494
+ isInTombstone('channel', channelId);
24495
+ let data;
24496
+ try {
24497
+ const { data: payload } = await client.http.get(`/api/v3/channels/${encodeURIComponent(channelId)}`);
24498
+ data = prepareChannelPayload(payload);
24499
+ }
24500
+ catch (error) {
24501
+ if (checkIfShouldGoesToTombstone(error === null || error === void 0 ? void 0 : error.code)) {
24502
+ pushToTombstone('channel', channelId);
24503
+ }
24504
+ throw error;
24505
+ }
24500
24506
  const cachedAt = client.cache && Date.now();
24501
24507
  if (client.cache)
24502
24508
  ingestInCache(data, { cachedAt });
@@ -24776,7 +24782,10 @@ const addChannelMembers = async (channelId, userIds) => {
24776
24782
  const data = prepareChannelPayload(payload);
24777
24783
  if (client.cache)
24778
24784
  ingestInCache(data);
24779
- fireEvent('v3.channel.didAddUsers', data);
24785
+ /*
24786
+ * should fire event for each user that was added
24787
+ */
24788
+ userIds.forEach(id => fireEvent('v3.channel.didAddUsers', Object.assign(Object.assign({}, data), { channelUsers: data.channelUsers.filter(u => u.userId === id) })));
24780
24789
  const { channelUsers } = data;
24781
24790
  return !!channelUsers.find(channelUser => channelUser.channelId === channelId && channelUser.membership === 'member');
24782
24791
  };