stream-chat 9.50.3 → 10.0.0-rc.2

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 (242) hide show
  1. package/dist/cjs/index.browser.js +19798 -14472
  2. package/dist/cjs/index.browser.js.map +4 -4
  3. package/dist/cjs/index.node.js +19817 -14482
  4. package/dist/cjs/index.node.js.map +4 -4
  5. package/dist/esm/index.mjs +19795 -14469
  6. package/dist/esm/index.mjs.map +4 -4
  7. package/dist/types/ChannelManager.d.ts +221 -0
  8. package/dist/types/EventHandlerPipeline.d.ts +104 -0
  9. package/dist/types/api-client.d.ts +26 -0
  10. package/dist/types/campaign.d.ts +0 -44
  11. package/dist/types/channel.d.ts +454 -479
  12. package/dist/types/channel_batch_updater.d.ts +0 -93
  13. package/dist/types/channel_state.d.ts +53 -201
  14. package/dist/types/client.d.ts +451 -1920
  15. package/dist/types/client_state.d.ts +4 -4
  16. package/dist/types/configuration/InstanceConfigurationService.d.ts +26 -0
  17. package/dist/types/configuration/index.d.ts +1 -0
  18. package/dist/types/configuration/types.d.ts +53 -0
  19. package/dist/types/connection.d.ts +49 -41
  20. package/dist/types/connection_fallback.d.ts +6 -4
  21. package/dist/types/constants.d.ts +0 -4
  22. package/dist/types/custom_types.d.ts +2 -0
  23. package/dist/types/entityStore/EntityStore.d.ts +111 -0
  24. package/dist/types/entityStore/StoreBackedItemIndex.d.ts +60 -0
  25. package/dist/types/entityStore/applyReactionLocally.d.ts +26 -0
  26. package/dist/types/entityStore/index.d.ts +2 -0
  27. package/dist/types/errors.d.ts +10 -2
  28. package/dist/types/gen/chat/ChannelApi.d.ts +45 -0
  29. package/dist/types/gen/chat/ChatApi.d.ts +334 -0
  30. package/dist/types/gen/model-decoders/decoders.d.ts +3 -0
  31. package/dist/types/gen/model-decoders/event-decoder-mapping.d.ts +6 -0
  32. package/dist/types/gen/models/index.d.ts +8836 -0
  33. package/dist/types/gen/moderation/ModerationApi.d.ts +50 -0
  34. package/dist/types/gen-imports.d.ts +3 -0
  35. package/dist/types/index.d.ts +8 -7
  36. package/dist/types/insights.d.ts +9 -8
  37. package/dist/types/logger.d.ts +9 -0
  38. package/dist/types/messageComposer/LocationComposer.d.ts +7 -4
  39. package/dist/types/messageComposer/attachmentIdentity.d.ts +2 -2
  40. package/dist/types/messageComposer/attachmentManager.d.ts +8 -4
  41. package/dist/types/messageComposer/configuration/types.d.ts +11 -11
  42. package/dist/types/messageComposer/linkPreviewsManager.d.ts +25 -13
  43. package/dist/types/messageComposer/messageComposer.d.ts +10 -10
  44. package/dist/types/messageComposer/middleware/messageComposer/types.d.ts +3 -3
  45. package/dist/types/messageComposer/middleware/pollComposer/types.d.ts +4 -7
  46. package/dist/types/messageComposer/middleware/textComposer/commandUtils.d.ts +3 -3
  47. package/dist/types/messageComposer/middleware/textComposer/commands.d.ts +7 -7
  48. package/dist/types/messageComposer/middleware/textComposer/mentions.d.ts +218 -4
  49. package/dist/types/messageComposer/middleware/textComposer/types.d.ts +9 -4
  50. package/dist/types/messageComposer/pollComposer.d.ts +5 -4
  51. package/dist/types/messageComposer/textComposer.d.ts +8 -3
  52. package/dist/types/messageComposer/types.d.ts +6 -28
  53. package/dist/types/messageDelivery/MessageDeliveryReporter.d.ts +40 -25
  54. package/dist/types/messageDelivery/MessageReceiptsTracker.d.ts +53 -12
  55. package/dist/types/messageOperations/MessageOperationStatePolicy.d.ts +19 -0
  56. package/dist/types/messageOperations/MessageOperations.d.ts +17 -0
  57. package/dist/types/messageOperations/index.d.ts +3 -0
  58. package/dist/types/messageOperations/types.d.ts +49 -0
  59. package/dist/types/moderation.d.ts +21 -203
  60. package/dist/types/notifications/types.d.ts +8 -7
  61. package/dist/types/offline-support/offline_support_api.d.ts +111 -87
  62. package/dist/types/offline-support/offline_sync_manager.d.ts +0 -7
  63. package/dist/types/offline-support/types.d.ts +19 -23
  64. package/dist/types/offline-support/util.d.ts +4 -2
  65. package/dist/types/pagination/FilterBuilder.d.ts +1 -1
  66. package/dist/types/pagination/ItemIndex.d.ts +25 -0
  67. package/dist/types/pagination/cursorDerivation/createdAtAroundPaginationFlags.d.ts +9 -0
  68. package/dist/types/pagination/cursorDerivation/idAroundPaginationFlags.d.ts +6 -0
  69. package/dist/types/pagination/cursorDerivation/index.d.ts +1 -0
  70. package/dist/types/pagination/cursorDerivation/linearPaginationFlags.d.ts +6 -0
  71. package/dist/types/pagination/filterCompiler.d.ts +7 -0
  72. package/dist/types/pagination/index.d.ts +1 -3
  73. package/dist/types/pagination/paginators/BasePaginator.d.ts +848 -0
  74. package/dist/types/pagination/paginators/ChannelPaginator.d.ts +212 -0
  75. package/dist/types/pagination/paginators/MessageIntervalPaginator.d.ts +282 -0
  76. package/dist/types/pagination/paginators/MessagePaginator.d.ts +208 -0
  77. package/dist/types/pagination/paginators/PinnedMessagePaginator.d.ts +39 -0
  78. package/dist/types/pagination/paginators/ReminderPaginator.d.ts +19 -0
  79. package/dist/types/pagination/paginators/UserGroupPaginator.d.ts +24 -0
  80. package/dist/types/pagination/paginators/index.d.ts +7 -0
  81. package/dist/types/pagination/paginators/stateThrottling.d.ts +2 -0
  82. package/dist/types/pagination/sortCompiler.d.ts +49 -0
  83. package/dist/types/pagination/types.normalization.d.ts +11 -0
  84. package/dist/types/pagination/utility.normalization.d.ts +18 -0
  85. package/dist/types/pagination/utility.queryChannel.d.ts +26 -0
  86. package/dist/types/pagination/utility.search.d.ts +13 -0
  87. package/dist/types/permissions.d.ts +1 -1
  88. package/dist/types/poll.d.ts +29 -32
  89. package/dist/types/poll_manager.d.ts +2 -2
  90. package/dist/types/reminders/Reminder.d.ts +2 -5
  91. package/dist/types/reminders/ReminderManager.d.ts +2 -9
  92. package/dist/types/search/MessageSearchSource.d.ts +4 -4
  93. package/dist/types/search/UserSearchSource.d.ts +1 -1
  94. package/dist/types/search/types.d.ts +3 -3
  95. package/dist/types/segment.d.ts +0 -34
  96. package/dist/types/signing.d.ts +105 -65
  97. package/dist/types/store.d.ts +1 -0
  98. package/dist/types/thread.d.ts +70 -34
  99. package/dist/types/thread_manager.d.ts +3 -3
  100. package/dist/types/token_manager.d.ts +15 -10
  101. package/dist/types/types.d.ts +197 -3404
  102. package/dist/types/utils/FixedSizeQueueCache.d.ts +12 -6
  103. package/dist/types/utils/WithSubscriptions.d.ts +2 -1
  104. package/dist/types/utils/concurrency.d.ts +4 -4
  105. package/dist/types/utils/mergeWith/mergeWith.d.ts +3 -3
  106. package/dist/types/utils/mergeWith/mergeWithCore.d.ts +8 -3
  107. package/dist/types/utils/retryable.d.ts +34 -0
  108. package/dist/types/utils/throttling/throttle.d.ts +36 -0
  109. package/dist/types/utils.d.ts +100 -194
  110. package/package.json +7 -3
  111. package/src/ChannelManager.ts +724 -0
  112. package/src/CooldownTimer.ts +2 -2
  113. package/src/EventHandlerPipeline.ts +228 -0
  114. package/src/LiveLocationManager.ts +12 -11
  115. package/src/api-client.ts +275 -0
  116. package/src/campaign.ts +1 -77
  117. package/src/channel.ts +1344 -1282
  118. package/src/channel_batch_updater.ts +1 -211
  119. package/src/channel_state.ts +144 -1013
  120. package/src/client.ts +936 -3995
  121. package/src/client_state.ts +4 -4
  122. package/src/configuration/InstanceConfigurationService.ts +73 -0
  123. package/src/configuration/index.ts +1 -0
  124. package/src/configuration/types.ts +81 -0
  125. package/src/connection.ts +145 -94
  126. package/src/connection_fallback.ts +29 -27
  127. package/src/constants.ts +1 -5
  128. package/src/custom_types.ts +4 -1
  129. package/src/entityStore/EntityStore.ts +208 -0
  130. package/src/entityStore/StoreBackedItemIndex.ts +115 -0
  131. package/src/entityStore/applyReactionLocally.ts +113 -0
  132. package/src/entityStore/index.ts +2 -0
  133. package/src/errors.ts +14 -2
  134. package/src/gen/chat/ChannelApi.ts +275 -0
  135. package/src/gen/chat/ChatApi.ts +2554 -0
  136. package/src/gen/model-decoders/decoders.ts +2680 -0
  137. package/src/gen/model-decoders/event-decoder-mapping.ts +198 -0
  138. package/src/gen/models/index.ts +12673 -0
  139. package/src/gen/moderation/ModerationApi.ts +607 -0
  140. package/src/gen-imports.ts +3 -0
  141. package/src/index.ts +11 -12
  142. package/src/insights.ts +6 -5
  143. package/src/logger.ts +28 -0
  144. package/src/messageComposer/LocationComposer.ts +9 -5
  145. package/src/messageComposer/MessageComposerEffectHandlers.ts +1 -0
  146. package/src/messageComposer/attachmentIdentity.ts +16 -9
  147. package/src/messageComposer/attachmentManager.ts +13 -8
  148. package/src/messageComposer/configuration/types.ts +11 -11
  149. package/src/messageComposer/linkPreviewsManager.ts +9 -10
  150. package/src/messageComposer/messageComposer.ts +57 -53
  151. package/src/messageComposer/middleware/messageComposer/attachments.ts +1 -2
  152. package/src/messageComposer/middleware/messageComposer/cleanData.ts +1 -1
  153. package/src/messageComposer/middleware/messageComposer/compositionValidation.ts +2 -2
  154. package/src/messageComposer/middleware/messageComposer/messageComposerState.ts +2 -2
  155. package/src/messageComposer/middleware/messageComposer/sharedLocation.ts +4 -3
  156. package/src/messageComposer/middleware/messageComposer/textComposer.ts +2 -2
  157. package/src/messageComposer/middleware/messageComposer/types.ts +3 -4
  158. package/src/messageComposer/middleware/messageComposer/userDataInjection.ts +9 -5
  159. package/src/messageComposer/middleware/pollComposer/state.ts +0 -2
  160. package/src/messageComposer/middleware/pollComposer/types.ts +4 -7
  161. package/src/messageComposer/middleware/textComposer/TextComposerMiddlewareExecutor.ts +10 -1
  162. package/src/messageComposer/middleware/textComposer/commandEffects.ts +4 -4
  163. package/src/messageComposer/middleware/textComposer/commandUtils.ts +3 -6
  164. package/src/messageComposer/middleware/textComposer/commands.ts +3 -3
  165. package/src/messageComposer/middleware/textComposer/mentionUtils.ts +1 -1
  166. package/src/messageComposer/middleware/textComposer/mentions.ts +31 -15
  167. package/src/messageComposer/middleware/textComposer/types.ts +9 -4
  168. package/src/messageComposer/pollComposer.ts +6 -8
  169. package/src/messageComposer/textComposer.ts +27 -2
  170. package/src/messageComposer/types.ts +6 -28
  171. package/src/messageDelivery/MessageDeliveryReporter.ts +101 -45
  172. package/src/messageDelivery/MessageReceiptsTracker.ts +294 -21
  173. package/src/messageOperations/MessageOperationStatePolicy.ts +77 -0
  174. package/src/messageOperations/MessageOperations.ts +212 -0
  175. package/src/messageOperations/index.ts +10 -0
  176. package/src/messageOperations/types.ts +64 -0
  177. package/src/moderation.ts +38 -431
  178. package/src/notifications/types.ts +8 -7
  179. package/src/offline-support/offline_support_api.ts +200 -133
  180. package/src/offline-support/offline_sync_manager.ts +23 -44
  181. package/src/offline-support/types.ts +23 -26
  182. package/src/offline-support/util.ts +5 -4
  183. package/src/pagination/FilterBuilder.ts +4 -1
  184. package/src/pagination/ItemIndex.ts +25 -0
  185. package/src/pagination/cursorDerivation/createdAtAroundPaginationFlags.ts +73 -0
  186. package/src/pagination/cursorDerivation/idAroundPaginationFlags.ts +53 -0
  187. package/src/pagination/cursorDerivation/index.ts +1 -0
  188. package/src/pagination/cursorDerivation/linearPaginationFlags.ts +86 -0
  189. package/src/pagination/filterCompiler.ts +196 -0
  190. package/src/pagination/index.ts +1 -3
  191. package/src/pagination/paginators/BasePaginator.ts +2859 -0
  192. package/src/pagination/paginators/ChannelPaginator.ts +729 -0
  193. package/src/pagination/paginators/MessageIntervalPaginator.ts +1116 -0
  194. package/src/pagination/paginators/MessagePaginator.ts +508 -0
  195. package/src/pagination/paginators/PinnedMessagePaginator.ts +108 -0
  196. package/src/pagination/paginators/ReminderPaginator.ts +107 -0
  197. package/src/pagination/paginators/UserGroupPaginator.ts +127 -0
  198. package/src/pagination/paginators/index.ts +7 -0
  199. package/src/pagination/paginators/stateThrottling.ts +31 -0
  200. package/src/pagination/sortCompiler.ts +193 -0
  201. package/src/pagination/types.normalization.ts +14 -0
  202. package/src/pagination/utility.normalization.ts +106 -0
  203. package/src/pagination/utility.queryChannel.ts +84 -0
  204. package/src/pagination/utility.search.ts +80 -0
  205. package/src/permissions.ts +7 -8
  206. package/src/poll.ts +101 -110
  207. package/src/poll_manager.ts +14 -8
  208. package/src/reminders/Reminder.ts +2 -5
  209. package/src/reminders/ReminderManager.ts +19 -21
  210. package/src/search/BaseSearchSource.ts +0 -3
  211. package/src/search/ChannelMemberSearchSource.ts +7 -1
  212. package/src/search/ChannelSearchSource.ts +10 -3
  213. package/src/search/MessageSearchSource.ts +29 -30
  214. package/src/search/UserSearchSource.ts +12 -8
  215. package/src/search/types.ts +3 -4
  216. package/src/segment.ts +1 -95
  217. package/src/signing.ts +107 -67
  218. package/src/store.ts +2 -1
  219. package/src/thread.ts +562 -238
  220. package/src/thread_manager.ts +37 -16
  221. package/src/token_manager.ts +21 -10
  222. package/src/types.ts +364 -4533
  223. package/src/uploadManager.ts +8 -0
  224. package/src/utils/FixedSizeQueueCache.ts +12 -6
  225. package/src/utils/WithSubscriptions.ts +2 -1
  226. package/src/utils/concurrency.ts +4 -4
  227. package/src/utils/mergeWith/mergeWith.ts +3 -3
  228. package/src/utils/mergeWith/mergeWithCore.ts +140 -164
  229. package/src/utils/mergeWith/mergeWithDiff.ts +3 -3
  230. package/src/utils/retryable.ts +117 -0
  231. package/src/utils/throttling/throttle.ts +130 -0
  232. package/src/utils.ts +208 -754
  233. package/dist/types/channel_manager.d.ts +0 -122
  234. package/dist/types/events.d.ts +0 -72
  235. package/dist/types/pagination/BasePaginator.d.ts +0 -69
  236. package/dist/types/pagination/ReminderPaginator.d.ts +0 -16
  237. package/dist/types/pagination/UserGroupPaginator.d.ts +0 -21
  238. package/src/channel_manager.ts +0 -830
  239. package/src/events.ts +0 -75
  240. package/src/pagination/BasePaginator.ts +0 -184
  241. package/src/pagination/ReminderPaginator.ts +0 -56
  242. package/src/pagination/UserGroupPaginator.ts +0 -93
package/src/moderation.ts CHANGED
@@ -1,464 +1,71 @@
1
- import type {
2
- APIResponse,
3
- CheckResponse,
4
- CustomCheckFlag,
5
- CustomCheckResponse,
6
- GetConfigResponse,
7
- GetUserModerationReportOptions,
8
- GetUserModerationReportResponse,
9
- ModerationConfig,
10
- ModerationFlagOptions,
11
- ModerationMuteOptions,
12
- ModerationRule,
13
- ModerationRuleRequest,
14
- MuteUserResponse,
15
- Pager,
16
- QueryConfigsResponse,
17
- QueryModerationConfigsFilters,
18
- QueryModerationConfigsSort,
19
- QueryModerationRulesFilters,
20
- QueryModerationRulesResponse,
21
- QueryModerationRulesSort,
22
- RequireAtLeastOne,
23
- ReviewQueueFilters,
24
- ReviewQueuePaginationOptions,
25
- ReviewQueueResponse,
26
- ReviewQueueSort,
27
- SubmitActionOptions,
28
- SubmitActionResponse,
29
- UnmuteUserResponse,
30
- UpsertConfigResponse,
31
- UpsertModerationRuleResponse,
32
- } from './types';
1
+ import type { ModerationFlagOptions, UnmuteUserResponse } from './types';
33
2
  import type { StreamChat } from './client';
34
- import { normalizeQuerySort } from './utils';
3
+ import { ModerationApi } from './gen/moderation/ModerationApi';
35
4
 
36
5
  export const MODERATION_ENTITY_TYPES = {
37
6
  user: 'stream:user',
38
7
  message: 'stream:chat:v1:message',
39
- userprofile: 'stream:v1:user_profile',
40
8
  };
41
9
 
42
10
  // Moderation class provides all the endpoints related to moderation v2.
43
- export class Moderation {
11
+ export class Moderation extends ModerationApi {
44
12
  client: StreamChat;
45
13
 
46
14
  constructor(client: StreamChat) {
15
+ super(client.api);
47
16
  this.client = client;
48
17
  }
49
18
 
50
19
  /**
51
- * Flag a user
20
+ * Flags a user.
52
21
  *
53
- * @param {string} flaggedUserID User ID to be flagged
54
- * @param {string} reason Reason for flagging the user
55
- * @param {Object} options Additional options for flagging the user
56
- * @param {string} options.user_id (For server side usage) User ID of the user who is flagging the target user
57
- * @param {Object} options.custom Additional data to be stored with the flag
58
- * @returns
22
+ * @param flaggedUserId - User ID to be flagged.
23
+ * @param reason - Reason for flagging the user.
24
+ * @param options - Additional options for flagging the user (optional, defaults to `{}`).
25
+ * @param options.custom - Additional data to be stored with the flag (optional).
26
+ * @returns The flag response.
59
27
  */
60
- flagUser(flaggedUserID: string, reason: string, options: ModerationFlagOptions = {}) {
61
- return this.flag(MODERATION_ENTITY_TYPES.user, flaggedUserID, '', reason, options);
28
+ flagUser(flaggedUserId: string, reason: string, options: ModerationFlagOptions = {}) {
29
+ return this.flag({
30
+ entity_type: MODERATION_ENTITY_TYPES.user,
31
+ entity_id: flaggedUserId,
32
+ entity_creator_id: '',
33
+ reason,
34
+ ...options,
35
+ });
62
36
  }
63
37
 
64
38
  /**
65
- * Flag a message
39
+ * Flags a message.
66
40
  *
67
- * @param {string} messageID Message ID to be flagged
68
- * @param {string} reason Reason for flagging the message
69
- * @param {Object} options Additional options for flagging the message
70
- * @param {string} options.user_id (For server side usage) User ID of the user who is flagging the target message
71
- * @param {Object} options.custom Additional data to be stored with the flag
72
- * @returns
41
+ * @param messageId - MessageRequest ID to be flagged.
42
+ * @param reason - Reason for flagging the message.
43
+ * @param options - Additional options for flagging the message (optional, defaults to `{}`).
44
+ * @param options.custom - Additional data to be stored with the flag (optional).
45
+ * @returns The flag response.
73
46
  */
74
- flagMessage(messageID: string, reason: string, options: ModerationFlagOptions = {}) {
75
- return this.flag(MODERATION_ENTITY_TYPES.message, messageID, '', reason, options);
47
+ flagMessage(messageId: string, reason: string, options: ModerationFlagOptions = {}) {
48
+ return this.flag({
49
+ entity_type: MODERATION_ENTITY_TYPES.message,
50
+ entity_id: messageId,
51
+ entity_creator_id: '',
52
+ reason,
53
+ ...options,
54
+ });
76
55
  }
77
56
 
78
57
  /**
79
- * Flag a user
58
+ * Unmutes a user.
80
59
  *
81
- * @param {string} entityType Entity type to be flagged
82
- * @param {string} entityId Entity ID to be flagged
83
- * @param {string} entityCreatorID User ID of the entity creator
84
- * @param {string} reason Reason for flagging the entity
85
- * @param {Object} options Additional options for flagging the entity
86
- * @param {string} options.user_id (For server side usage) User ID of the user who is flagging the target entity
87
- * @param {Object} options.moderation_payload Content to be flagged e.g., { texts: ['text1', 'text2'], images: ['image1', 'image2']}
88
- * @param {Object} options.custom Additional data to be stored with the flag
89
- * @returns
60
+ * @param targetId - User ID to be unmuted.
61
+ * @returns The unmute response.
90
62
  */
91
- async flag(
92
- entityType: string,
93
- entityId: string,
94
- entityCreatorID: string,
95
- reason: string,
96
- options: ModerationFlagOptions = {},
97
- ) {
98
- return await this.client.post<{ item_id: string } & APIResponse>(
99
- this.client.baseURL + '/api/v2/moderation/flag',
100
- {
101
- entity_type: entityType,
102
- entity_id: entityId,
103
- entity_creator_id: entityCreatorID,
104
- reason,
105
- ...options,
106
- },
107
- );
108
- }
109
-
110
- /**
111
- * Mute a user
112
- * @param {string} targetID User ID to be muted
113
- * @param {Object} options Additional options for muting the user
114
- * @param {string} options.user_id (For server side usage) User ID of the user who is muting the target user
115
- * @param {number} options.timeout Timeout for the mute in minutes
116
- * @returns
117
- */
118
- async muteUser(targetID: string, options: ModerationMuteOptions = {}) {
119
- return await this.client.post<MuteUserResponse & APIResponse>(
120
- this.client.baseURL + '/api/v2/moderation/mute',
121
- {
122
- target_ids: [targetID],
123
- ...options,
124
- },
125
- );
126
- }
127
-
128
- /**
129
- * Unmute a user
130
- * @param {string} targetID User ID to be unmuted
131
- * @param {Object} options Additional options for unmuting the user
132
- * @param {string} options.user_id (For server side usage) User ID of the user who is unmuting the target user
133
- * @returns
134
- */
135
- async unmuteUser(
136
- targetID: string,
137
- options: {
138
- user_id?: string;
139
- },
140
- ) {
141
- return await this.client.post<UnmuteUserResponse>(
63
+ async unmuteUser(targetId: string) {
64
+ return await this.client.api.post<UnmuteUserResponse>(
142
65
  this.client.baseURL + '/api/v2/moderation/unmute',
143
66
  {
144
- target_ids: [targetID],
145
- ...options,
146
- },
147
- );
148
- }
149
-
150
- /**
151
- * Get moderation report for a user
152
- * @param {string} userID User ID for which moderation report is to be fetched
153
- * @param {Object} options Additional options for fetching the moderation report
154
- * @param {boolean} options.create_user_if_not_exists Create user if not exists
155
- * @param {boolean} options.include_user_blocks Include user blocks
156
- * @param {boolean} options.include_user_mutes Include user mutes
157
- */
158
- async getUserModerationReport(
159
- userID: string,
160
- options: GetUserModerationReportOptions = {},
161
- ) {
162
- return await this.client.get<GetUserModerationReportResponse>(
163
- this.client.baseURL + `/api/v2/moderation/user_report`,
164
- {
165
- user_id: userID,
166
- ...options,
167
- },
168
- );
169
- }
170
-
171
- /**
172
- * Query review queue
173
- * @param {Object} filterConditions Filter conditions for querying review queue
174
- * @param {Object} sort Sort conditions for querying review queue
175
- * @param {Object} options Pagination options for querying review queue
176
- */
177
- async queryReviewQueue(
178
- filterConditions: ReviewQueueFilters = {},
179
- sort: ReviewQueueSort = [],
180
- options: ReviewQueuePaginationOptions = {},
181
- ) {
182
- return await this.client.post<ReviewQueueResponse>(
183
- this.client.baseURL + '/api/v2/moderation/review_queue',
184
- {
185
- filter: filterConditions,
186
- sort: normalizeQuerySort(sort),
187
- ...options,
188
- },
189
- );
190
- }
191
-
192
- /**
193
- * Upsert moderation config
194
- * @param {Object} config Moderation config to be upserted
195
- */
196
- async upsertConfig(config: ModerationConfig) {
197
- return await this.client.post<UpsertConfigResponse>(
198
- this.client.baseURL + '/api/v2/moderation/config',
199
- config,
200
- );
201
- }
202
-
203
- /**
204
- * Get moderation config
205
- * @param {string} key Key for which moderation config is to be fetched
206
- */
207
- async getConfig(key: string, data?: { team?: string }) {
208
- return await this.client.get<GetConfigResponse>(
209
- this.client.baseURL + '/api/v2/moderation/config/' + key,
210
- data,
211
- );
212
- }
213
-
214
- async deleteConfig(key: string, data?: { team?: string }) {
215
- return await this.client.delete<APIResponse>(
216
- this.client.baseURL + '/api/v2/moderation/config/' + key,
217
- data,
218
- );
219
- }
220
-
221
- /**
222
- * Query moderation configs
223
- * @param {Object} filterConditions Filter conditions for querying moderation configs
224
- * @param {Object} sort Sort conditions for querying moderation configs
225
- * @param {Object} options Additional options for querying moderation configs
226
- */
227
- async queryConfigs(
228
- filterConditions: QueryModerationConfigsFilters,
229
- sort: QueryModerationConfigsSort,
230
- options: Pager = {},
231
- ) {
232
- return await this.client.post<QueryConfigsResponse>(
233
- this.client.baseURL + '/api/v2/moderation/configs',
234
- {
235
- filter: filterConditions,
236
- sort,
237
- ...options,
238
- },
239
- );
240
- }
241
-
242
- async submitAction(
243
- actionType: string,
244
- itemID: string,
245
- options: SubmitActionOptions = {},
246
- ) {
247
- return await this.client.post<SubmitActionResponse>(
248
- this.client.baseURL + '/api/v2/moderation/submit_action',
249
- {
250
- action_type: actionType,
251
- item_id: itemID,
252
- ...options,
253
- },
254
- );
255
- }
256
-
257
- /**
258
- *
259
- * @param {string} entityType string Type of entity to be checked E.g., stream:user, stream:chat:v1:message, or any custom string
260
- * @param {string} entityID string ID of the entity to be checked. This is mainly for tracking purposes
261
- * @param {string} entityCreatorID string ID of the entity creator
262
- * @param {object} moderationPayload object Content to be checked for moderation. E.g., { texts: ['text1', 'text2'], images: ['image1', 'image2']}
263
- * @param {Array} moderationPayload.texts array Array of texts to be checked for moderation
264
- * @param {Array} moderationPayload.images array Array of images to be checked for moderation
265
- * @param {Array} moderationPayload.videos array Array of videos to be checked for moderation
266
- * @param configKey
267
- * @param options
268
- * @returns
269
- */
270
- async check(
271
- entityType: string,
272
- entityID: string,
273
- entityCreatorID: string,
274
- moderationPayload: {
275
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
276
- custom?: Record<string, any>;
277
- images?: string[];
278
- texts?: string[];
279
- videos?: string[];
280
- },
281
- configKey: string,
282
- options?: {
283
- force_sync?: boolean;
284
- },
285
- testMode?: boolean,
286
- ) {
287
- return await this.client.post<CheckResponse>(
288
- this.client.baseURL + `/api/v2/moderation/check`,
289
- {
290
- entity_type: entityType,
291
- entity_id: entityID,
292
- entity_creator_id: entityCreatorID,
293
- moderation_payload: moderationPayload,
294
- config_key: configKey,
295
- options,
296
- test_mode: testMode,
297
- },
298
- );
299
- }
300
-
301
- /**
302
- * Experimental: Check user profile
303
- *
304
- * Warning: This is an experimental feature and the API is subject to change.
305
- *
306
- * This function is used to check a user profile for moderation.
307
- * This will not create any review queue items for the user profile.
308
- * You can just use this to check whether to allow a certain user profile to be created or not.
309
- *
310
- * Example:
311
- *
312
- * ```ts
313
- * const res = await client.moderation.checkUserProfile(userId, { username: "fuck_boy_001", image: "https://example.com/profile.jpg" });
314
- * if (res.recommended_action === "remove") {
315
- * // Block the user profile from being created
316
- * } else {
317
- * // Allow the user profile to be created
318
- * }
319
- * ```
320
- *
321
- * @param userId
322
- * @param profile.username
323
- * @param profile.image
324
- * @returns
325
- */
326
- async checkUserProfile(
327
- userId: string,
328
- profile: RequireAtLeastOne<{ image?: string; username?: string }>,
329
- ) {
330
- if (!profile.username && !profile.image) {
331
- throw new Error('Either username or image must be provided');
332
- }
333
-
334
- const moderationPayload: { images?: string[]; texts?: string[] } = {};
335
- if (profile.username) {
336
- moderationPayload.texts = [profile.username];
337
- }
338
- if (profile.image) {
339
- moderationPayload.images = [profile.image];
340
- }
341
-
342
- return await this.check(
343
- MODERATION_ENTITY_TYPES.userprofile,
344
- userId,
345
- userId,
346
- moderationPayload,
347
- 'user_profile:default',
348
- {
349
- force_sync: true,
350
- },
351
- true,
352
- );
353
- }
354
-
355
- /**
356
- *
357
- * @param {string} entityType string Type of entity to be checked E.g., stream:user, stream:chat:v1:message, or any custom string
358
- * @param {string} entityID string ID of the entity to be checked. This is mainly for tracking purposes
359
- * @param {string} entityCreatorID string ID of the entity creator
360
- * @param {object} moderationPayload object Content to be checked for moderation. E.g., { texts: ['text1', 'text2'], images: ['image1', 'image2']}
361
- * @param {Array} moderationPayload.texts array Array of texts to be checked for moderation
362
- * @param {Array} moderationPayload.images array Array of images to be checked for moderation
363
- * @param {Array} moderationPayload.videos array Array of videos to be checked for moderation
364
- * @param {object} moderationPayload.custom object Additional custom data to attach to the moderation review queue item
365
- * @param {Array<CustomCheckFlag>} flags Array of CustomCheckFlag to be passed to flag the entity
366
- * @returns
367
- */
368
- async addCustomFlags(
369
- entityType: string,
370
- entityID: string,
371
- entityCreatorID: string,
372
- moderationPayload: {
373
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
374
- custom?: Record<string, any>;
375
- images?: string[];
376
- texts?: string[];
377
- videos?: string[];
378
- },
379
- flags: CustomCheckFlag[],
380
- ) {
381
- return await this.client.post<CustomCheckResponse>(
382
- this.client.baseURL + `/api/v2/moderation/custom_check`,
383
- {
384
- entity_type: entityType,
385
- entity_id: entityID,
386
- entity_creator_id: entityCreatorID,
387
- moderation_payload: moderationPayload,
388
- flags,
67
+ target_ids: [targetId],
389
68
  },
390
69
  );
391
70
  }
392
-
393
- /**
394
- * Add custom flags to a message
395
- * @param {string} messageID Message ID to be flagged
396
- * @param {Array<CustomCheckFlag>} flags Array of CustomCheckFlag to be passed to flag the message
397
- * @returns
398
- */
399
- async addCustomMessageFlags(messageID: string, flags: CustomCheckFlag[]) {
400
- return await this.addCustomFlags(
401
- MODERATION_ENTITY_TYPES.message,
402
- messageID,
403
- '',
404
- {},
405
- flags,
406
- );
407
- }
408
-
409
- /**
410
- * Create or update a moderation rule
411
- * @param {ModerationRuleRequest} rule Rule configuration to be upserted
412
- * @returns
413
- */
414
- async upsertModerationRule(rule: ModerationRuleRequest) {
415
- return await this.client.post<UpsertModerationRuleResponse>(
416
- this.client.baseURL + '/api/v2/moderation/moderation_rule',
417
- rule,
418
- );
419
- }
420
-
421
- /**
422
- * Query moderation rules
423
- * @param {QueryModerationRulesFilters} filterConditions Filter conditions for querying moderation rules
424
- * @param {QueryModerationRulesSort} sort Sort conditions for querying moderation rules
425
- * @param {Pager} options Pagination options for querying moderation rules
426
- * @returns
427
- */
428
- async queryModerationRules(
429
- filterConditions: QueryModerationRulesFilters = {},
430
- sort: QueryModerationRulesSort = [],
431
- options: Pager = {},
432
- ) {
433
- return await this.client.post<QueryModerationRulesResponse>(
434
- this.client.baseURL + '/api/v2/moderation/moderation_rules',
435
- {
436
- filter: filterConditions,
437
- sort,
438
- ...options,
439
- },
440
- );
441
- }
442
-
443
- /**
444
- * Get a specific moderation rule by ID
445
- * @param {string} id ID of the moderation rule to fetch
446
- * @returns
447
- */
448
- async getModerationRule(id: string) {
449
- return await this.client.get<{ rule: ModerationRule }>(
450
- this.client.baseURL + '/api/v2/moderation/moderation_rule/' + id,
451
- );
452
- }
453
-
454
- /**
455
- * Delete a moderation rule by ID
456
- * @param {string} id ID of the moderation rule to delete
457
- * @returns
458
- */
459
- async deleteModerationRule(id: string) {
460
- return await this.client.delete<APIResponse>(
461
- this.client.baseURL + '/api/v2/moderation/moderation_rule/' + id,
462
- );
463
- }
464
71
  }
@@ -33,7 +33,7 @@ export type Notification = {
33
33
  origin: NotificationOrigin;
34
34
  /** Array of action buttons for the notification */
35
35
  actions?: NotificationAction[];
36
- /** The severity level of the notification. Defaults to undefined unless explicitly provided. */
36
+ /** The severity level of the notification (defaults to `undefined` unless explicitly provided). */
37
37
  severity?: NotificationSeverity;
38
38
  /**
39
39
  * Optional code that can be used to group the notifications of the same type, e.g. attachment-upload-blocked.
@@ -55,9 +55,9 @@ export type Notification = {
55
55
  * 'validation:attachment:size:exceeded' // File size too large
56
56
  * 'validation:attachment:count:exceeded' // Too many attachments
57
57
  *
58
- * Message related errors
59
- * 'api:message:send:failed' // Message send failed
60
- * 'validation:message:content:empty' // Message content validation failed
58
+ * MessageRequest related errors
59
+ * 'api:message:send:failed' // MessageRequest send failed
60
+ * 'validation:message:content:empty' // MessageRequest content validation failed
61
61
  *
62
62
  * Channel related errors
63
63
  * 'api:channel:join:failed' // Channel join failed
@@ -104,11 +104,12 @@ export type NotificationOptions = Partial<
104
104
  };
105
105
 
106
106
  /**
107
- * State shape for the notification store
108
- * @deprcated use NotificationManagerState
107
+ * State shape for the notification store.
108
+ *
109
+ * @deprecated Use {@link NotificationManagerState} instead.
109
110
  */
110
111
  export type NotificationState = {
111
- /** Array of current notification objects */
112
+ /** Array of current notification objects. */
112
113
  notifications: Notification[];
113
114
  };
114
115