@stream-io/node-sdk 0.4.19 → 0.4.20

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.
@@ -1,8 +1,7 @@
1
1
  import { BaseApi } from '../../BaseApi';
2
2
  import { StreamResponse } from '../../types';
3
- import { BanRequest, BanResponse, CheckRequest, CheckResponse, CustomCheckRequest, CustomCheckResponse, DeleteModerationConfigResponse, DeleteModerationTemplateResponse, FlagRequest, FlagResponse, GetConfigResponse, GetModerationAnalyticsRequest, GetModerationAnalyticsResponse, GetReviewQueueItemResponse, GetUserModerationReportResponse, ModeratorStatsResponse, MuteRequest, MuteResponse, QueryFeedModerationTemplatesResponse, QueryModerationConfigsRequest, QueryModerationConfigsResponse, QueryModerationLogsRequest, QueryModerationLogsResponse, QueryReviewQueueRequest, QueryReviewQueueResponse, QueryUsageStatsRequest, QueryUsageStatsResponse, QueueStatsResponse, SubmitActionRequest, SubmitActionResponse, UnbanRequest, UnbanResponse, UnmuteRequest, UnmuteResponse, UpsertConfigRequest, UpsertConfigResponse, UpsertModerationTemplateRequest, UpsertModerationTemplateResponse } from '../models';
3
+ import { BanRequest, BanResponse, CheckRequest, CheckResponse, CustomCheckRequest, CustomCheckResponse, DeleteModerationConfigResponse, DeleteModerationTemplateResponse, FlagRequest, FlagResponse, GetConfigResponse, GetReviewQueueItemResponse, MuteRequest, MuteResponse, QueryFeedModerationTemplatesResponse, QueryModerationConfigsRequest, QueryModerationConfigsResponse, QueryModerationLogsRequest, QueryModerationLogsResponse, QueryReviewQueueRequest, QueryReviewQueueResponse, SubmitActionRequest, SubmitActionResponse, UnbanRequest, UnbanResponse, UnmuteRequest, UnmuteResponse, UpsertConfigRequest, UpsertConfigResponse, UpsertModerationTemplateRequest, UpsertModerationTemplateResponse } from '../models';
4
4
  export declare class ModerationApi extends BaseApi {
5
- getModerationAnalytics: (request?: GetModerationAnalyticsRequest) => Promise<StreamResponse<GetModerationAnalyticsResponse>>;
6
5
  ban: (request: BanRequest) => Promise<StreamResponse<BanResponse>>;
7
6
  check: (request: CheckRequest) => Promise<StreamResponse<CheckResponse>>;
8
7
  upsertConfig: (request: UpsertConfigRequest) => Promise<StreamResponse<UpsertConfigResponse>>;
@@ -21,9 +20,7 @@ export declare class ModerationApi extends BaseApi {
21
20
  v2UpsertTemplate: (request: UpsertModerationTemplateRequest) => Promise<StreamResponse<UpsertModerationTemplateResponse>>;
22
21
  flag: (request: FlagRequest) => Promise<StreamResponse<FlagResponse>>;
23
22
  queryModerationLogs: (request?: QueryModerationLogsRequest) => Promise<StreamResponse<QueryModerationLogsResponse>>;
24
- getModeratorStats: () => Promise<StreamResponse<ModeratorStatsResponse>>;
25
23
  mute: (request: MuteRequest) => Promise<StreamResponse<MuteResponse>>;
26
- getQueueStats: () => Promise<StreamResponse<QueueStatsResponse>>;
27
24
  queryReviewQueue: (request?: QueryReviewQueueRequest) => Promise<StreamResponse<QueryReviewQueueResponse>>;
28
25
  getReviewQueueItem: (request: {
29
26
  id: string;
@@ -35,11 +32,4 @@ export declare class ModerationApi extends BaseApi {
35
32
  created_by?: string;
36
33
  }) => Promise<StreamResponse<UnbanResponse>>;
37
34
  unmute: (request: UnmuteRequest) => Promise<StreamResponse<UnmuteResponse>>;
38
- queryUsageStats: (request?: QueryUsageStatsRequest) => Promise<StreamResponse<QueryUsageStatsResponse>>;
39
- getUserReport: (request: {
40
- user_id: string;
41
- create_user_if_not_exists?: boolean;
42
- include_user_mutes?: boolean;
43
- include_user_blocks?: boolean;
44
- }) => Promise<StreamResponse<GetUserModerationReportResponse>>;
45
35
  }
@@ -1,9 +1,12 @@
1
+ import { Agent } from 'undici';
1
2
  export type OmitTypeId<T> = Omit<T, 'type' | 'id' | 'connection_id'>;
2
3
  export interface ApiConfig {
3
4
  apiKey: string;
4
5
  token: string;
5
6
  baseUrl: string;
7
+ /** The timeout for requests in milliseconds. The default is 3000. */
6
8
  timeout: number;
9
+ agent: Agent;
7
10
  }
8
11
  export interface RequestMetadata {
9
12
  responseHeaders: Headers;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stream-io/node-sdk",
3
- "version": "0.4.19",
3
+ "version": "0.4.20",
4
4
  "description": "",
5
5
  "exports": {
6
6
  ".": {
@@ -73,6 +73,7 @@
73
73
  "@types/jsonwebtoken": "^9.0.3",
74
74
  "@types/node": "^20.11.24",
75
75
  "jsonwebtoken": "^9.0.2",
76
+ "undici": "^5.29.0",
76
77
  "uuid": "^9.0.1"
77
78
  },
78
79
  "peerDependencies": {
package/src/BaseApi.ts CHANGED
@@ -2,9 +2,14 @@ import { v4 as uuidv4 } from 'uuid';
2
2
  import { ApiConfig, RequestMetadata, StreamError } from './types';
3
3
  import { APIError } from './gen/models';
4
4
  import { getRateLimitFromResponseHeader } from './utils/rate-limit';
5
+ import { Agent } from 'undici';
5
6
 
6
7
  export class BaseApi {
7
- constructor(protected readonly apiConfig: ApiConfig) {}
8
+ private readonly dispatcher: Agent;
9
+
10
+ constructor(protected readonly apiConfig: ApiConfig) {
11
+ this.dispatcher = this.apiConfig.agent;
12
+ }
8
13
 
9
14
  protected sendRequest = async <T>(
10
15
  method: string,
@@ -21,6 +26,7 @@ export class BaseApi {
21
26
  url = url.replace(`{${paramName}}`, pathParams[paramName]);
22
27
  });
23
28
  }
29
+
24
30
  url += `?${encodedParams}`;
25
31
  const clientRequestId = uuidv4();
26
32
  const headers = {
@@ -40,6 +46,8 @@ export class BaseApi {
40
46
  method,
41
47
  body: JSON.stringify(body),
42
48
  headers,
49
+ /** @ts-expect-error we get types from DOM here, but we should use node types */
50
+ dispatcher: this.dispatcher,
43
51
  });
44
52
 
45
53
  const responseHeaders = response.headers;
@@ -6,10 +6,15 @@ import { StreamChatClient } from './StreamChatClient';
6
6
  import { CallTokenPayload, UserTokenPayload } from './types';
7
7
  import { QueryBannedUsersPayload, UserRequest } from './gen/models';
8
8
  import { StreamModerationClient } from './StreamModerationClient';
9
+ import { Agent } from 'undici';
9
10
 
10
11
  export interface StreamClientOptions {
11
12
  timeout?: number;
12
13
  basePath?: string;
14
+ /** The max number of clients to create. `null` if no limit. Default is 100. Has no effect if `agent` is provided. */
15
+ maxConnections?: number | null;
16
+ /** The [HTTP Agent](https://undici.nodejs.org/#/docs/api/Agent.md) to use. */
17
+ agent?: Agent;
13
18
  }
14
19
 
15
20
  export class StreamClient extends CommonApi {
@@ -19,6 +24,7 @@ export class StreamClient extends CommonApi {
19
24
  public readonly options: StreamClientOptions = {};
20
25
 
21
26
  private static readonly DEFAULT_TIMEOUT = 3000;
27
+ private static readonly MAX_CONNECTIONS = 100;
22
28
 
23
29
  /**
24
30
  *
@@ -33,9 +39,17 @@ export class StreamClient extends CommonApi {
33
39
  ) {
34
40
  const token = JWTServerToken(secret);
35
41
  const timeout = config?.timeout ?? StreamClient.DEFAULT_TIMEOUT;
42
+ const agent =
43
+ config?.agent ??
44
+ new Agent({
45
+ connections:
46
+ config?.maxConnections === undefined
47
+ ? StreamClient.MAX_CONNECTIONS
48
+ : config.maxConnections,
49
+ });
36
50
  const chatBaseUrl = config?.basePath ?? 'https://chat.stream-io-api.com';
37
51
  const videoBaseUrl = config?.basePath ?? 'https://video.stream-io-api.com';
38
- super({ apiKey, token, timeout, baseUrl: chatBaseUrl });
52
+ super({ apiKey, token, timeout, baseUrl: chatBaseUrl, agent });
39
53
 
40
54
  this.video = new StreamVideoClient({
41
55
  streamClient: this,
@@ -43,18 +57,21 @@ export class StreamClient extends CommonApi {
43
57
  token,
44
58
  timeout,
45
59
  baseUrl: videoBaseUrl,
60
+ agent,
46
61
  });
47
62
  this.chat = new StreamChatClient({
48
63
  apiKey,
49
64
  token,
50
65
  timeout,
51
66
  baseUrl: chatBaseUrl,
67
+ agent,
52
68
  });
53
69
  this.moderation = new StreamModerationClient({
54
70
  apiKey,
55
71
  token,
56
72
  timeout,
57
73
  baseUrl: chatBaseUrl,
74
+ agent,
58
75
  });
59
76
  }
60
77
 
@@ -7,6 +7,7 @@ import {
7
7
  EventResponse,
8
8
  FileUploadRequest,
9
9
  FileUploadResponse,
10
+ GetDraftResponse,
10
11
  GetManyMessagesResponse,
11
12
  HideChannelRequest,
12
13
  HideChannelResponse,
@@ -83,6 +84,34 @@ export class ChannelApi {
83
84
  });
84
85
  };
85
86
 
87
+ deleteDraft = (request?: {
88
+ parent_id?: string;
89
+ user_id?: string;
90
+ }): Promise<StreamResponse<Response>> => {
91
+ if (!this.id) {
92
+ throw new Error(
93
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
94
+ );
95
+ }
96
+ return this.chatApi.deleteDraft({
97
+ id: this.id,
98
+ type: this.type,
99
+ ...request,
100
+ });
101
+ };
102
+
103
+ getDraft = (request?: {
104
+ parent_id?: string;
105
+ user_id?: string;
106
+ }): Promise<StreamResponse<GetDraftResponse>> => {
107
+ if (!this.id) {
108
+ throw new Error(
109
+ `Channel isn't yet created, call getOrCreateDistinctChannel() before this operation`,
110
+ );
111
+ }
112
+ return this.chatApi.getDraft({ id: this.id, type: this.type, ...request });
113
+ };
114
+
86
115
  sendEvent = (
87
116
  request: SendEventRequest,
88
117
  ): Promise<StreamResponse<EventResponse>> => {
@@ -27,6 +27,7 @@ import {
27
27
  GetCampaignResponse,
28
28
  GetChannelTypeResponse,
29
29
  GetCommandResponse,
30
+ GetDraftResponse,
30
31
  GetManyMessagesResponse,
31
32
  GetMessageResponse,
32
33
  GetReactionsResponse,
@@ -58,6 +59,8 @@ import {
58
59
  QueryCampaignsResponse,
59
60
  QueryChannelsRequest,
60
61
  QueryChannelsResponse,
62
+ QueryDraftsRequest,
63
+ QueryDraftsResponse,
61
64
  QueryMembersPayload,
62
65
  QueryMessageFlagsPayload,
63
66
  QueryMessageFlagsResponse,
@@ -129,6 +132,7 @@ export class ChatApi extends BaseApi {
129
132
  limit: request?.limit,
130
133
  next: request?.next,
131
134
  prev: request?.prev,
135
+ user_limit: request?.user_limit,
132
136
  sort: request?.sort,
133
137
  filter: request?.filter,
134
138
  };
@@ -144,14 +148,22 @@ export class ChatApi extends BaseApi {
144
148
 
145
149
  getCampaign = async (request: {
146
150
  id: string;
151
+ prev?: string;
152
+ next?: string;
153
+ limit?: number;
147
154
  }): Promise<StreamResponse<GetCampaignResponse>> => {
155
+ const queryParams = {
156
+ prev: request?.prev,
157
+ next: request?.next,
158
+ limit: request?.limit,
159
+ };
148
160
  const pathParams = {
149
161
  id: request?.id,
150
162
  };
151
163
 
152
164
  const response = await this.sendRequest<
153
165
  StreamResponse<GetCampaignResponse>
154
- >('GET', '/api/v2/chat/campaigns/{id}', pathParams, undefined);
166
+ >('GET', '/api/v2/chat/campaigns/{id}', pathParams, queryParams);
155
167
 
156
168
  decoders.GetCampaignResponse?.(response.body);
157
169
 
@@ -378,6 +390,60 @@ export class ChatApi extends BaseApi {
378
390
  return { ...response.body, metadata: response.metadata };
379
391
  };
380
392
 
393
+ deleteDraft = async (request: {
394
+ type: string;
395
+ id: string;
396
+ parent_id?: string;
397
+ user_id?: string;
398
+ }): Promise<StreamResponse<Response>> => {
399
+ const queryParams = {
400
+ parent_id: request?.parent_id,
401
+ user_id: request?.user_id,
402
+ };
403
+ const pathParams = {
404
+ type: request?.type,
405
+ id: request?.id,
406
+ };
407
+
408
+ const response = await this.sendRequest<StreamResponse<Response>>(
409
+ 'DELETE',
410
+ '/api/v2/chat/channels/{type}/{id}/draft',
411
+ pathParams,
412
+ queryParams,
413
+ );
414
+
415
+ decoders.Response?.(response.body);
416
+
417
+ return { ...response.body, metadata: response.metadata };
418
+ };
419
+
420
+ getDraft = async (request: {
421
+ type: string;
422
+ id: string;
423
+ parent_id?: string;
424
+ user_id?: string;
425
+ }): Promise<StreamResponse<GetDraftResponse>> => {
426
+ const queryParams = {
427
+ parent_id: request?.parent_id,
428
+ user_id: request?.user_id,
429
+ };
430
+ const pathParams = {
431
+ type: request?.type,
432
+ id: request?.id,
433
+ };
434
+
435
+ const response = await this.sendRequest<StreamResponse<GetDraftResponse>>(
436
+ 'GET',
437
+ '/api/v2/chat/channels/{type}/{id}/draft',
438
+ pathParams,
439
+ queryParams,
440
+ );
441
+
442
+ decoders.GetDraftResponse?.(response.body);
443
+
444
+ return { ...response.body, metadata: response.metadata };
445
+ };
446
+
381
447
  sendEvent = async (
382
448
  request: SendEventRequest & { type: string; id: string },
383
449
  ): Promise<StreamResponse<EventResponse>> => {
@@ -991,6 +1057,28 @@ export class ChatApi extends BaseApi {
991
1057
  return { ...response.body, metadata: response.metadata };
992
1058
  };
993
1059
 
1060
+ queryDrafts = async (
1061
+ request?: QueryDraftsRequest,
1062
+ ): Promise<StreamResponse<QueryDraftsResponse>> => {
1063
+ const body = {
1064
+ limit: request?.limit,
1065
+ next: request?.next,
1066
+ prev: request?.prev,
1067
+ user_id: request?.user_id,
1068
+ sort: request?.sort,
1069
+ filter: request?.filter,
1070
+ user: request?.user,
1071
+ };
1072
+
1073
+ const response = await this.sendRequest<
1074
+ StreamResponse<QueryDraftsResponse>
1075
+ >('POST', '/api/v2/chat/drafts/query', undefined, undefined, body);
1076
+
1077
+ decoders.QueryDraftsResponse?.(response.body);
1078
+
1079
+ return { ...response.body, metadata: response.metadata };
1080
+ };
1081
+
994
1082
  exportChannels = async (
995
1083
  request: ExportChannelsRequest,
996
1084
  ): Promise<StreamResponse<ExportChannelsResponse>> => {
@@ -435,6 +435,8 @@ decoders.ChannelStateResponse = (input?: Record<string, any>) => {
435
435
 
436
436
  channel: { type: 'ChannelResponse', isSingle: true },
437
437
 
438
+ draft: { type: 'DraftResponse', isSingle: true },
439
+
438
440
  membership: { type: 'ChannelMember', isSingle: true },
439
441
 
440
442
  push_preferences: { type: 'ChannelPushPreferences', isSingle: true },
@@ -462,6 +464,8 @@ decoders.ChannelStateResponseFields = (input?: Record<string, any>) => {
462
464
 
463
465
  channel: { type: 'ChannelResponse', isSingle: true },
464
466
 
467
+ draft: { type: 'DraftResponse', isSingle: true },
468
+
465
469
  membership: { type: 'ChannelMember', isSingle: true },
466
470
 
467
471
  push_preferences: { type: 'ChannelPushPreferences', isSingle: true },
@@ -616,6 +620,28 @@ decoders.DeviceResponse = (input?: Record<string, any>) => {
616
620
  return decode(typeMappings, input);
617
621
  };
618
622
 
623
+ decoders.DraftPayloadResponse = (input?: Record<string, any>) => {
624
+ const typeMappings: TypeMapping = {
625
+ mentioned_users: { type: 'UserResponse', isSingle: false },
626
+ };
627
+ return decode(typeMappings, input);
628
+ };
629
+
630
+ decoders.DraftResponse = (input?: Record<string, any>) => {
631
+ const typeMappings: TypeMapping = {
632
+ created_at: { type: 'DatetimeType', isSingle: true },
633
+
634
+ message: { type: 'DraftPayloadResponse', isSingle: true },
635
+
636
+ channel: { type: 'ChannelResponse', isSingle: true },
637
+
638
+ parent_message: { type: 'MessageResponse', isSingle: true },
639
+
640
+ quoted_message: { type: 'MessageResponse', isSingle: true },
641
+ };
642
+ return decode(typeMappings, input);
643
+ };
644
+
619
645
  decoders.EgressRTMPResponse = (input?: Record<string, any>) => {
620
646
  const typeMappings: TypeMapping = {
621
647
  started_at: { type: 'DatetimeType', isSingle: true },
@@ -688,7 +714,7 @@ decoders.ExportUserResponse = (input?: Record<string, any>) => {
688
714
  return decode(typeMappings, input);
689
715
  };
690
716
 
691
- decoders.Flag2 = (input?: Record<string, any>) => {
717
+ decoders.Flag = (input?: Record<string, any>) => {
692
718
  const typeMappings: TypeMapping = {
693
719
  created_at: { type: 'DatetimeType', isSingle: true },
694
720
 
@@ -699,17 +725,6 @@ decoders.Flag2 = (input?: Record<string, any>) => {
699
725
  return decode(typeMappings, input);
700
726
  };
701
727
 
702
- decoders.Flag2Response = (input?: Record<string, any>) => {
703
- const typeMappings: TypeMapping = {
704
- created_at: { type: 'DatetimeType', isSingle: true },
705
-
706
- updated_at: { type: 'DatetimeType', isSingle: true },
707
-
708
- user: { type: 'UserResponse', isSingle: true },
709
- };
710
- return decode(typeMappings, input);
711
- };
712
-
713
728
  decoders.FlagDetails = (input?: Record<string, any>) => {
714
729
  const typeMappings: TypeMapping = {
715
730
  automod: { type: 'AutomodDetails', isSingle: true },
@@ -788,13 +803,6 @@ decoders.GetCallTypeResponse = (input?: Record<string, any>) => {
788
803
  return decode(typeMappings, input);
789
804
  };
790
805
 
791
- decoders.GetCampaignResponse = (input?: Record<string, any>) => {
792
- const typeMappings: TypeMapping = {
793
- campaign: { type: 'CampaignResponse', isSingle: true },
794
- };
795
- return decode(typeMappings, input);
796
- };
797
-
798
806
  decoders.GetChannelTypeResponse = (input?: Record<string, any>) => {
799
807
  const typeMappings: TypeMapping = {
800
808
  created_at: { type: 'DatetimeType', isSingle: true },
@@ -822,6 +830,13 @@ decoders.GetConfigResponse = (input?: Record<string, any>) => {
822
830
  return decode(typeMappings, input);
823
831
  };
824
832
 
833
+ decoders.GetDraftResponse = (input?: Record<string, any>) => {
834
+ const typeMappings: TypeMapping = {
835
+ draft: { type: 'DraftResponse', isSingle: true },
836
+ };
837
+ return decode(typeMappings, input);
838
+ };
839
+
825
840
  decoders.GetImportResponse = (input?: Record<string, any>) => {
826
841
  const typeMappings: TypeMapping = {
827
842
  import_task: { type: 'ImportTask', isSingle: true },
@@ -898,17 +913,6 @@ decoders.GetThreadResponse = (input?: Record<string, any>) => {
898
913
  return decode(typeMappings, input);
899
914
  };
900
915
 
901
- decoders.GetUserModerationReportResponse = (input?: Record<string, any>) => {
902
- const typeMappings: TypeMapping = {
903
- user_blocks: { type: 'UserBlock', isSingle: false },
904
-
905
- user_mutes: { type: 'UserMute', isSingle: false },
906
-
907
- user: { type: 'UserResponse', isSingle: true },
908
- };
909
- return decode(typeMappings, input);
910
- };
911
-
912
916
  decoders.GoLiveResponse = (input?: Record<string, any>) => {
913
917
  const typeMappings: TypeMapping = {
914
918
  call: { type: 'CallResponse', isSingle: true },
@@ -1146,6 +1150,8 @@ decoders.MessageResponse = (input?: Record<string, any>) => {
1146
1150
 
1147
1151
  thread_participants: { type: 'UserResponse', isSingle: false },
1148
1152
 
1153
+ draft: { type: 'DraftResponse', isSingle: true },
1154
+
1149
1155
  pinned_by: { type: 'UserResponse', isSingle: true },
1150
1156
 
1151
1157
  poll: { type: 'PollResponseData', isSingle: true },
@@ -1183,6 +1189,8 @@ decoders.MessageWithChannelResponse = (input?: Record<string, any>) => {
1183
1189
 
1184
1190
  thread_participants: { type: 'UserResponse', isSingle: false },
1185
1191
 
1192
+ draft: { type: 'DraftResponse', isSingle: true },
1193
+
1186
1194
  pinned_by: { type: 'UserResponse', isSingle: true },
1187
1195
 
1188
1196
  poll: { type: 'PollResponseData', isSingle: true },
@@ -1194,15 +1202,6 @@ decoders.MessageWithChannelResponse = (input?: Record<string, any>) => {
1194
1202
  return decode(typeMappings, input);
1195
1203
  };
1196
1204
 
1197
- decoders.ModerationUsageStats = (input?: Record<string, any>) => {
1198
- const typeMappings: TypeMapping = {
1199
- reference_date: { type: 'DatetimeType', isSingle: true },
1200
-
1201
- updated_at: { type: 'DatetimeType', isSingle: true },
1202
- };
1203
- return decode(typeMappings, input);
1204
- };
1205
-
1206
1205
  decoders.MuteChannelResponse = (input?: Record<string, any>) => {
1207
1206
  const typeMappings: TypeMapping = {
1208
1207
  channel_mutes: { type: 'ChannelMute', isSingle: false },
@@ -1442,6 +1441,13 @@ decoders.QueryChannelsResponse = (input?: Record<string, any>) => {
1442
1441
  return decode(typeMappings, input);
1443
1442
  };
1444
1443
 
1444
+ decoders.QueryDraftsResponse = (input?: Record<string, any>) => {
1445
+ const typeMappings: TypeMapping = {
1446
+ drafts: { type: 'DraftResponse', isSingle: false },
1447
+ };
1448
+ return decode(typeMappings, input);
1449
+ };
1450
+
1445
1451
  decoders.QueryFeedModerationTemplate = (input?: Record<string, any>) => {
1446
1452
  const typeMappings: TypeMapping = {
1447
1453
  created_at: { type: 'DatetimeType', isSingle: true },
@@ -1530,13 +1536,6 @@ decoders.QueryThreadsResponse = (input?: Record<string, any>) => {
1530
1536
  return decode(typeMappings, input);
1531
1537
  };
1532
1538
 
1533
- decoders.QueryUsageStatsResponse = (input?: Record<string, any>) => {
1534
- const typeMappings: TypeMapping = {
1535
- items: { type: 'ModerationUsageStats', isSingle: false },
1536
- };
1537
- return decode(typeMappings, input);
1538
- };
1539
-
1540
1539
  decoders.QueryUsersResponse = (input?: Record<string, any>) => {
1541
1540
  const typeMappings: TypeMapping = {
1542
1541
  users: { type: 'FullUserResponse', isSingle: false },
@@ -1601,7 +1600,7 @@ decoders.ReviewQueueItem = (input?: Record<string, any>) => {
1601
1600
 
1602
1601
  bans: { type: 'Ban', isSingle: false },
1603
1602
 
1604
- flags: { type: 'Flag2', isSingle: false },
1603
+ flags: { type: 'Flag', isSingle: false },
1605
1604
 
1606
1605
  assigned_to: { type: 'User', isSingle: true },
1607
1606
 
@@ -1626,8 +1625,6 @@ decoders.ReviewQueueItemResponse = (input?: Record<string, any>) => {
1626
1625
 
1627
1626
  bans: { type: 'Ban', isSingle: false },
1628
1627
 
1629
- flags: { type: 'Flag2Response', isSingle: false },
1630
-
1631
1628
  completed_at: { type: 'DatetimeType', isSingle: true },
1632
1629
 
1633
1630
  reviewed_at: { type: 'DatetimeType', isSingle: true },
@@ -1687,6 +1684,8 @@ decoders.SearchResultMessage = (input?: Record<string, any>) => {
1687
1684
 
1688
1685
  channel: { type: 'ChannelResponse', isSingle: true },
1689
1686
 
1687
+ draft: { type: 'DraftResponse', isSingle: true },
1688
+
1690
1689
  pinned_by: { type: 'UserResponse', isSingle: true },
1691
1690
 
1692
1691
  poll: { type: 'PollResponseData', isSingle: true },
@@ -1743,13 +1742,6 @@ decoders.SendReactionResponse = (input?: Record<string, any>) => {
1743
1742
  return decode(typeMappings, input);
1744
1743
  };
1745
1744
 
1746
- decoders.StartCampaignResponse = (input?: Record<string, any>) => {
1747
- const typeMappings: TypeMapping = {
1748
- campaign: { type: 'CampaignResponse', isSingle: true },
1749
- };
1750
- return decode(typeMappings, input);
1751
- };
1752
-
1753
1745
  decoders.StopLiveResponse = (input?: Record<string, any>) => {
1754
1746
  const typeMappings: TypeMapping = {
1755
1747
  call: { type: 'CallResponse', isSingle: true },
@@ -1820,6 +1812,8 @@ decoders.ThreadStateResponse = (input?: Record<string, any>) => {
1820
1812
 
1821
1813
  created_by: { type: 'UserResponse', isSingle: true },
1822
1814
 
1815
+ draft: { type: 'DraftResponse', isSingle: true },
1816
+
1823
1817
  parent_message: { type: 'MessageResponse', isSingle: true },
1824
1818
  };
1825
1819
  return decode(typeMappings, input);
@@ -2018,13 +2012,6 @@ decoders.User = (input?: Record<string, any>) => {
2018
2012
  return decode(typeMappings, input);
2019
2013
  };
2020
2014
 
2021
- decoders.UserBlock = (input?: Record<string, any>) => {
2022
- const typeMappings: TypeMapping = {
2023
- created_at: { type: 'DatetimeType', isSingle: true },
2024
- };
2025
- return decode(typeMappings, input);
2026
- };
2027
-
2028
2015
  decoders.UserMute = (input?: Record<string, any>) => {
2029
2016
  const typeMappings: TypeMapping = {
2030
2017
  created_at: { type: 'DatetimeType', isSingle: true },