Skip to content

Commit 4f6f8ca

Browse files
Add missing types
1 parent bc2023b commit 4f6f8ca

File tree

2 files changed

+219
-46
lines changed

2 files changed

+219
-46
lines changed

src/client.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,8 @@ import {
193193
TokenOrProvider,
194194
TranslateResponse,
195195
UnBanUserOptions,
196-
UpdateChannelOptions,
197-
UpdateChannelResponse,
196+
UpdateChannelTypeRequest,
197+
UpdateChannelTypeResponse,
198198
UpdateCommandOptions,
199199
UpdateCommandResponse,
200200
UpdatedMessage,
@@ -2490,8 +2490,8 @@ export class StreamChat {
24902490
return this.get<GetChannelTypeResponse>(this.baseURL + `/channeltypes/${encodeURIComponent(channelType)}`);
24912491
}
24922492

2493-
updateChannelType(channelType: string, data: UpdateChannelOptions) {
2494-
return this.put<UpdateChannelResponse>(this.baseURL + `/channeltypes/${encodeURIComponent(channelType)}`, data);
2493+
updateChannelType(channelType: string, data: UpdateChannelTypeRequest) {
2494+
return this.put<UpdateChannelTypeResponse>(this.baseURL + `/channeltypes/${encodeURIComponent(channelType)}`, data);
24952495
}
24962496

24972497
deleteChannelType(channelType: string) {

src/types.ts

Lines changed: 215 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -477,14 +477,6 @@ export type FormatMessageResponse = Omit<
477477
updated_at: Date;
478478
};
479479

480-
export type GetChannelTypeResponse = APIResponse &
481-
Omit<CreateChannelOptions, 'client_id' | 'connection_id' | 'commands'> & {
482-
created_at: string;
483-
updated_at: string;
484-
commands?: CommandResponse[];
485-
grants?: Record<string, string[]>;
486-
};
487-
488480
export type GetCommandResponse = APIResponse & CreateCommandOptions & CreatedAtUpdatedAt;
489481

490482
export type GetMessageAPIResponse = SendMessageAPIResponse;
@@ -1004,22 +996,173 @@ export type DeactivateUsersOptions = {
1004996

1005997
export type NewMemberPayload = CustomMemberData & Pick<ChannelMemberResponse, 'user_id' | 'channel_role'>;
1006998

1007-
export type UpdateChannelOptions = {
1008-
accept_invite?: boolean;
1009-
add_members?: string[];
1010-
add_moderators?: string[];
1011-
client_id?: string;
1012-
connection_id?: string;
1013-
data?: Omit<ChannelResponse, 'id' | 'cid'>;
1014-
demote_moderators?: string[];
1015-
invites?: string[];
1016-
message?: MessageResponse;
1017-
reject_invite?: boolean;
1018-
remove_members?: string[];
1019-
user?: UserResponse;
1020-
user_id?: string;
999+
export type Thresholds = Record<'explicit' | 'spam' | 'toxic', { block: number; flag: number }>;
1000+
1001+
export type BlockListOptions = {
1002+
behavior: BlocklistBehavior;
1003+
blocklist: string;
1004+
};
1005+
1006+
export type PolicyRequest = {
1007+
action: 'Deny' | 'Allow' | (string & {});
1008+
/**
1009+
* @description User-friendly policy name
1010+
*/
1011+
name: string;
1012+
/**
1013+
* @description Whether policy applies to resource owner or not
1014+
*/
1015+
owner: boolean;
1016+
priority: number;
1017+
/**
1018+
* @description List of resources to apply policy to
1019+
*/
1020+
resources: string[];
1021+
/**
1022+
* @description List of roles to apply policy to
1023+
*/
1024+
roles: string[];
1025+
};
1026+
1027+
export type Automod = 'disabled' | 'simple' | 'AI' | (string & {});
1028+
export type AutomodBehavior = 'flag' | 'block' | 'shadow_block' | (string & {});
1029+
export type BlocklistBehavior = AutomodBehavior;
1030+
1031+
export type UpdateChannelTypeRequest =
1032+
// these three properties are required in OpenAPI spec but omitted in some QA tests
1033+
Partial<{
1034+
automod: Automod;
1035+
automod_behavior: AutomodBehavior;
1036+
max_message_length: number;
1037+
}> & {
1038+
allowed_flag_reasons?: string[];
1039+
automod_thresholds?: Thresholds;
1040+
blocklist?: string;
1041+
blocklist_behavior?: BlocklistBehavior;
1042+
blocklists?: BlockListOptions[];
1043+
commands?: CommandVariants[];
1044+
connect_events?: boolean;
1045+
custom_events?: boolean;
1046+
grants?: Record<string, string[]>;
1047+
mark_messages_pending?: boolean;
1048+
mutes?: boolean;
1049+
partition_size?: number;
1050+
/**
1051+
* @example 24h
1052+
*/
1053+
partition_ttl?: string | null;
1054+
permissions?: PolicyRequest[];
1055+
polls?: boolean;
1056+
push_notifications?: boolean;
1057+
quotes?: boolean;
1058+
reactions?: boolean;
1059+
read_events?: boolean;
1060+
reminders?: boolean;
1061+
replies?: boolean;
1062+
search?: boolean;
1063+
skip_last_msg_update_for_system_msgs?: boolean;
1064+
typing_events?: boolean;
1065+
uploads?: boolean;
1066+
url_enrichment?: boolean;
1067+
};
1068+
1069+
export type UpdateChannelTypeResponse = {
1070+
automod: Automod;
1071+
automod_behavior: AutomodBehavior;
1072+
commands: CommandVariants[];
1073+
connect_events: boolean;
1074+
created_at: string;
1075+
custom_events: boolean;
1076+
duration: string;
1077+
grants: Record<string, string[]>;
1078+
mark_messages_pending: boolean;
1079+
max_message_length: number;
1080+
mutes: boolean;
1081+
name: string;
1082+
permissions: PolicyRequest[];
1083+
polls: boolean;
1084+
push_notifications: boolean;
1085+
quotes: boolean;
1086+
reactions: boolean;
1087+
read_events: boolean;
1088+
reminders: boolean;
1089+
replies: boolean;
1090+
search: boolean;
1091+
skip_last_msg_update_for_system_msgs: boolean;
1092+
typing_events: boolean;
1093+
updated_at: string;
1094+
uploads: boolean;
1095+
url_enrichment: boolean;
1096+
allowed_flag_reasons?: string[];
1097+
automod_thresholds?: Thresholds;
1098+
blocklist?: string;
1099+
blocklist_behavior?: BlocklistBehavior;
1100+
blocklists?: BlockListOptions[];
1101+
partition_size?: number;
1102+
partition_ttl?: string;
1103+
};
1104+
1105+
export type Command = {
1106+
args: string;
1107+
description: string;
1108+
name: string;
1109+
set: string;
1110+
created_at?: string;
1111+
updated_at?: string;
1112+
};
1113+
1114+
export type GetChannelTypeResponse = {
1115+
automod: Automod;
1116+
automod_behavior: AutomodBehavior;
1117+
commands: Command[];
1118+
connect_events: boolean;
1119+
created_at: string;
1120+
custom_events: boolean;
1121+
duration: string;
1122+
grants: Record<string, string[]>;
1123+
mark_messages_pending: boolean;
1124+
max_message_length: number;
1125+
mutes: boolean;
1126+
name: string;
1127+
permissions: PolicyRequest[];
1128+
polls: boolean;
1129+
push_notifications: boolean;
1130+
quotes: boolean;
1131+
reactions: boolean;
1132+
read_events: boolean;
1133+
reminders: boolean;
1134+
replies: boolean;
1135+
search: boolean;
1136+
skip_last_msg_update_for_system_msgs: boolean;
1137+
typing_events: boolean;
1138+
updated_at: string;
1139+
uploads: boolean;
1140+
url_enrichment: boolean;
1141+
allowed_flag_reasons?: string[];
1142+
automod_thresholds?: Thresholds;
1143+
blocklist?: string;
1144+
blocklist_behavior?: BlocklistBehavior;
1145+
blocklists?: BlockListOptions[];
1146+
partition_size?: number;
1147+
partition_ttl?: string;
10211148
};
10221149

1150+
export type UpdateChannelOptions = Partial<{
1151+
accept_invite: boolean;
1152+
add_members: string[];
1153+
add_moderators: string[];
1154+
client_id: string;
1155+
connection_id: string;
1156+
data: Omit<ChannelResponse, 'id' | 'cid'>;
1157+
demote_moderators: string[];
1158+
invites: string[];
1159+
message: MessageResponse;
1160+
reject_invite: boolean;
1161+
remove_members: string[];
1162+
user: UserResponse;
1163+
user_id: string;
1164+
}>;
1165+
10231166
export type MarkChannelsReadOptions = {
10241167
client_id?: string;
10251168
connection_id?: string;
@@ -1461,25 +1604,30 @@ export type ReactionFilters = QueryFilters<
14611604

14621605
export type ChannelFilters = QueryFilters<
14631606
ContainsOperator<CustomChannelData> & {
1607+
archived?: boolean;
1608+
'member.user.name'?:
1609+
| RequireOnlyOne<{
1610+
$autocomplete?: string;
1611+
$eq?: string;
1612+
}>
1613+
| string;
1614+
14641615
members?:
14651616
| RequireOnlyOne<Pick<QueryFilter<string>, '$in'>>
14661617
| RequireOnlyOne<Pick<QueryFilter<string[]>, '$eq'>>
14671618
| PrimitiveFilter<string[]>;
1468-
} & {
14691619
name?:
14701620
| RequireOnlyOne<
14711621
{
14721622
$autocomplete?: ChannelResponse['name'];
14731623
} & QueryFilter<ChannelResponse['name']>
14741624
>
14751625
| PrimitiveFilter<ChannelResponse['name']>;
1626+
pinned?: boolean;
14761627
} & {
14771628
[Key in keyof Omit<ChannelResponse, 'name' | 'members' | keyof CustomChannelData>]:
14781629
| RequireOnlyOne<QueryFilter<ChannelResponse[Key]>>
14791630
| PrimitiveFilter<ChannelResponse[Key]>;
1480-
} & {
1481-
archived?: boolean;
1482-
pinned?: boolean;
14831631
}
14841632
>;
14851633

@@ -1591,6 +1739,13 @@ export type ContainsOperator<CustomType = {}> = {
15911739

15921740
export type MessageFilters = QueryFilters<
15931741
ContainsOperator<CustomMessageData> & {
1742+
'attachments.type'?:
1743+
| RequireOnlyOne<{
1744+
$eq: PrimitiveFilter<Attachment['type']>;
1745+
$in: PrimitiveFilter<Attachment['type']>[];
1746+
}>
1747+
| PrimitiveFilter<Attachment['type']>;
1748+
'mentioned_users.id'?: RequireOnlyOne<{ $contains: PrimitiveFilter<UserResponse['id']> }>;
15941749
text?:
15951750
| RequireOnlyOne<
15961751
{
@@ -1599,6 +1754,13 @@ export type MessageFilters = QueryFilters<
15991754
} & QueryFilter<MessageResponse['text']>
16001755
>
16011756
| PrimitiveFilter<MessageResponse['text']>;
1757+
'user.id'?:
1758+
| RequireOnlyOne<
1759+
{
1760+
$autocomplete?: UserResponse['id'];
1761+
} & QueryFilter<UserResponse['id']>
1762+
>
1763+
| PrimitiveFilter<UserResponse['id']>;
16021764
} & {
16031765
[Key in keyof Omit<MessageResponse, 'text' | keyof CustomMessageData>]?:
16041766
| RequireOnlyOne<QueryFilter<MessageResponse[Key]>>
@@ -1693,6 +1855,9 @@ export type MemberFilters = QueryFilters<
16931855
}>
16941856
| UserResponse['id'];
16951857
invite?: { $eq?: ChannelMemberResponse['status'] } | ChannelMemberResponse['status'];
1858+
is_moderator?:
1859+
| RequireOnlyOne<{ $eq?: ChannelMemberResponse['is_moderator'] }>
1860+
| ChannelMemberResponse['is_moderator'];
16961861
joined?: { $eq?: boolean } | boolean;
16971862
last_active?:
16981863
| {
@@ -1711,6 +1876,9 @@ export type MemberFilters = QueryFilters<
17111876
$q?: NonNullable<ChannelMemberResponse['user']>['name'];
17121877
}>
17131878
| PrimitiveFilter<NonNullable<ChannelMemberResponse['user']>['name']>;
1879+
notifications_muted?:
1880+
| RequireOnlyOne<{ $eq?: ChannelMemberResponse['notifications_muted'] }>
1881+
| ChannelMemberResponse['notifications_muted'];
17141882
updated_at?:
17151883
| {
17161884
$eq?: ChannelMemberResponse['updated_at'];
@@ -1732,7 +1900,7 @@ export type MemberFilters = QueryFilters<
17321900
$eq?: ChannelMemberResponse['user_id'];
17331901
$in?: ChannelMemberResponse['user_id'][];
17341902
}>
1735-
| PrimitiveFilter<NonNullable<ChannelMemberResponse['user']>['id'][]>;
1903+
| PrimitiveFilter<ChannelMemberResponse['user_id']>;
17361904
} & {
17371905
[Key in keyof ContainsOperator<CustomMemberData>]?:
17381906
| RequireOnlyOne<QueryFilter<ContainsOperator<CustomMemberData>[Key]>>
@@ -1956,6 +2124,7 @@ export type Attachment = CustomAttachmentData & {
19562124
original_height?: number;
19572125
original_width?: number;
19582126
pretext?: string;
2127+
stopped_sharing?: boolean;
19592128
text?: string;
19602129
thumb_url?: string;
19612130
title?: string;
@@ -1990,15 +2159,13 @@ export type ChannelConfig = ChannelConfigFields &
19902159
commands?: CommandVariants[];
19912160
};
19922161

1993-
export type ChannelConfigAutomod = '' | 'AI' | 'disabled' | 'simple';
2162+
export type ChannelConfigAutomod = 'AI' | 'disabled' | 'simple' | (string & {});
19942163

1995-
export type ChannelConfigAutomodBehavior = '' | 'block' | 'flag';
2164+
export type ChannelConfigAutomodBehavior = 'block' | 'flag' | (string & {});
19962165

1997-
export type ChannelConfigAutomodThresholds = null | {
1998-
explicit?: { block?: number; flag?: number };
1999-
spam?: { block?: number; flag?: number };
2000-
toxic?: { block?: number; flag?: number };
2001-
};
2166+
export type ChannelConfigAutomodThresholds = null | Partial<
2167+
Record<'explicit' | 'spam' | 'toxic', { block?: number; flag?: number }>
2168+
>;
20022169

20032170
export type ChannelConfigFields = {
20042171
reminders: boolean;
@@ -2283,13 +2450,15 @@ export type EndpointName =
22832450
| 'ListPushProviders'
22842451
| 'CreatePoll';
22852452

2286-
export type ExportChannelRequest = {
2287-
id: string;
2288-
type: string;
2289-
cid?: string;
2290-
messages_since?: Date;
2291-
messages_until?: Date;
2292-
};
2453+
export type ExportChannelRequest = (
2454+
| {
2455+
id: string;
2456+
type: string;
2457+
}
2458+
| {
2459+
cid: string;
2460+
}
2461+
) & { messages_since?: Date; messages_until?: Date };
22932462

22942463
export type ExportChannelOptions = {
22952464
clear_deleted_message_text?: boolean;
@@ -2628,7 +2797,10 @@ export type ReservedMessageFields =
26282797
| 'updated_at'
26292798
| 'user';
26302799

2631-
export type UpdatedMessage = Omit<MessageResponse, 'mentioned_users'> & { mentioned_users?: string[] };
2800+
export type UpdatedMessage = Omit<MessageResponse, 'mentioned_users' | 'type'> & {
2801+
mentioned_users?: string[];
2802+
type?: MessageLabel;
2803+
};
26322804

26332805
export type User = CustomUserData & {
26342806
id: string;
@@ -2953,6 +3125,7 @@ export type UpdatePollAPIResponse = {
29533125

29543126
export type PollResponse = CustomPollData &
29553127
PollEnrichData & {
3128+
cid: string;
29563129
created_at: string;
29573130
created_by: UserResponse | null;
29583131
created_by_id: string;

0 commit comments

Comments
 (0)