stream-chat 8.42.0 → 8.43.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.
package/src/moderation.ts CHANGED
@@ -15,6 +15,9 @@ import {
15
15
  ModerationMuteOptions,
16
16
  GetUserModerationReportOptions,
17
17
  SubmitActionOptions,
18
+ QueryModerationConfigsFilters,
19
+ QueryModerationConfigsSort,
20
+ Pager,
18
21
  } from './types';
19
22
  import { StreamChat } from './client';
20
23
  import { normalizeQuerySort } from './utils';
@@ -181,6 +184,28 @@ export class Moderation<StreamChatGenerics extends ExtendableGenerics = DefaultG
181
184
  return await this.client.get<GetConfigResponse>(this.client.baseURL + '/api/v2/moderation/config/' + key);
182
185
  }
183
186
 
187
+ async deleteConfig(key: string) {
188
+ return await this.client.delete(this.client.baseURL + '/api/v2/moderation/config/' + key);
189
+ }
190
+
191
+ /**
192
+ * Query moderation configs
193
+ * @param {Object} filterConditions Filter conditions for querying moderation configs
194
+ * @param {Object} sort Sort conditions for querying moderation configs
195
+ * @param {Object} options Additional options for querying moderation configs
196
+ */
197
+ async queryConfigs(
198
+ filterConditions: QueryModerationConfigsFilters,
199
+ sort: QueryModerationConfigsSort,
200
+ options: Pager = {},
201
+ ) {
202
+ return await this.client.post(this.client.baseURL + '/api/v2/moderation/configs', {
203
+ filter: filterConditions,
204
+ sort,
205
+ ...options,
206
+ });
207
+ }
208
+
184
209
  async submitAction(actionType: string, itemID: string, options: SubmitActionOptions = {}) {
185
210
  return await this.client.post<{ item_id: string } & APIResponse>(
186
211
  this.client.baseURL + '/api/v2/moderation/submit_action',
@@ -191,4 +216,43 @@ export class Moderation<StreamChatGenerics extends ExtendableGenerics = DefaultG
191
216
  },
192
217
  );
193
218
  }
219
+
220
+ /**
221
+ *
222
+ * @param {string} entityType string Type of entity to be checked E.g., stream:user, stream:chat:v1:message, or any custom string
223
+ * @param {string} entityID string ID of the entity to be checked. This is mainly for tracking purposes
224
+ * @param {string} entityCreatorID string ID of the entity creator
225
+ * @param {object} moderationPayload object Content to be checked for moderation. E.g., { texts: ['text1', 'text2'], images: ['image1', 'image2']}
226
+ * @param {Array} moderationPayload.texts array Array of texts to be checked for moderation
227
+ * @param {Array} moderationPayload.images array Array of images to be checked for moderation
228
+ * @param {Array} moderationPayload.videos array Array of videos to be checked for moderation
229
+ * @param configKey
230
+ * @param options
231
+ * @returns
232
+ */
233
+ async check(
234
+ entityType: string,
235
+ entityID: string,
236
+ entityCreatorID: string,
237
+ moderationPayload: {
238
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
239
+ custom?: Record<string, any>;
240
+ images?: string[];
241
+ texts?: string[];
242
+ videos?: string[];
243
+ },
244
+ configKey: string,
245
+ options?: {
246
+ force_sync?: boolean;
247
+ },
248
+ ) {
249
+ return await this.client.post(this.client.baseURL + `/api/v2/moderation/check`, {
250
+ entity_type: entityType,
251
+ entity_id: entityID,
252
+ entity_creator_id: entityCreatorID,
253
+ moderation_payload: moderationPayload,
254
+ config_key: configKey,
255
+ options,
256
+ });
257
+ }
194
258
  }
package/src/types.ts CHANGED
@@ -331,7 +331,14 @@ export type ChannelMemberAPIResponse<StreamChatGenerics extends ExtendableGeneri
331
331
  members: ChannelMemberResponse<StreamChatGenerics>[];
332
332
  };
333
333
 
334
+ export type ChannelMemberUpdates = {
335
+ archived?: boolean;
336
+ channel_role?: Role;
337
+ pinned?: boolean;
338
+ };
339
+
334
340
  export type ChannelMemberResponse<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
341
+ archived_at?: string;
335
342
  ban_expires?: string;
336
343
  banned?: boolean;
337
344
  channel_role?: Role;
@@ -341,6 +348,7 @@ export type ChannelMemberResponse<StreamChatGenerics extends ExtendableGenerics
341
348
  invited?: boolean;
342
349
  is_moderator?: boolean;
343
350
  notifications_muted?: boolean;
351
+ pinned_at?: string;
344
352
  role?: string;
345
353
  shadow_banned?: boolean;
346
354
  status?: string;
@@ -349,6 +357,12 @@ export type ChannelMemberResponse<StreamChatGenerics extends ExtendableGenerics
349
357
  user_id?: string;
350
358
  };
351
359
 
360
+ export type PartialUpdateMemberAPIResponse<
361
+ StreamChatGenerics extends ExtendableGenerics = DefaultGenerics
362
+ > = APIResponse & {
363
+ channel_member: ChannelMemberResponse<StreamChatGenerics>;
364
+ };
365
+
352
366
  export type CheckPushResponse = APIResponse & {
353
367
  device_errors?: {
354
368
  [deviceID: string]: {
@@ -1487,6 +1501,9 @@ export type ChannelFilters<StreamChatGenerics extends ExtendableGenerics = Defau
1487
1501
  userType: StreamChatGenerics['userType'];
1488
1502
  }>[Key]
1489
1503
  >;
1504
+ } & {
1505
+ archived?: boolean;
1506
+ pinned?: boolean;
1490
1507
  }
1491
1508
  >;
1492
1509
 
@@ -1800,7 +1817,8 @@ export type ReactionSortBase<StreamChatGenerics extends ExtendableGenerics = Def
1800
1817
 
1801
1818
  export type ChannelSort<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> =
1802
1819
  | ChannelSortBase<StreamChatGenerics>
1803
- | Array<ChannelSortBase<StreamChatGenerics>>;
1820
+ | Array<ChannelSortBase<StreamChatGenerics>>
1821
+ | { pinned_at: AscDesc };
1804
1822
 
1805
1823
  export type ChannelSortBase<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = Sort<
1806
1824
  StreamChatGenerics['channelType']
@@ -2491,9 +2509,9 @@ export type PartialUpdateChannel<StreamChatGenerics extends ExtendableGenerics =
2491
2509
  unset?: Array<keyof ChannelResponse<StreamChatGenerics>>;
2492
2510
  };
2493
2511
 
2494
- export type PartialUpdateMember<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
2495
- set?: Partial<ChannelMemberResponse<StreamChatGenerics>>;
2496
- unset?: Array<keyof ChannelMemberResponse<StreamChatGenerics>>;
2512
+ export type PartialUpdateMember = {
2513
+ set?: ChannelMemberUpdates;
2514
+ unset?: Array<keyof ChannelMemberUpdates>;
2497
2515
  };
2498
2516
 
2499
2517
  export type PartialUserUpdate<StreamChatGenerics extends ExtendableGenerics = DefaultGenerics> = {
@@ -3303,6 +3321,16 @@ export type GetUserModerationReportResponse<StreamChatGenerics extends Extendabl
3303
3321
  user_mutes?: Mute<StreamChatGenerics>[];
3304
3322
  };
3305
3323
 
3324
+ export type QueryModerationConfigsFilters = QueryFilters<
3325
+ {
3326
+ key?: string;
3327
+ } & {
3328
+ created_at?: PrimitiveFilter<string>;
3329
+ } & {
3330
+ updated_at?: PrimitiveFilter<string>;
3331
+ }
3332
+ >;
3333
+
3306
3334
  export type ReviewQueueFilters = QueryFilters<
3307
3335
  {
3308
3336
  assigned_to?:
@@ -3359,6 +3387,8 @@ export type ReviewQueueSort =
3359
3387
  | Sort<Pick<ReviewQueueItem, 'id' | 'created_at' | 'updated_at'>>
3360
3388
  | Array<Sort<Pick<ReviewQueueItem, 'id' | 'created_at' | 'updated_at'>>>;
3361
3389
 
3390
+ export type QueryModerationConfigsSort = Array<Sort<'key' | 'created_at' | 'updated_at'>>;
3391
+
3362
3392
  export type ReviewQueuePaginationOptions = Pager;
3363
3393
 
3364
3394
  export type ReviewQueueResponse = {