Skip to content

Commit

Permalink
Fixing ts for ChannelFilters
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnarkhede committed Sep 10, 2020
1 parent cf9914d commit 5e840ba
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,8 @@ export type ChannelFilters<
CommandType extends string = LiteralStringForUnion
> = QueryFilters<
ContainsOperator<ChannelType> & {
members?: QueryFilter<string>;
} & {
name?:
| RequireOnlyOne<
{
Expand All @@ -905,7 +907,10 @@ export type ChannelFilters<
>
| PrimitiveFilter<ChannelResponse<ChannelType, UserType, CommandType>['name']>;
} & {
[Key in keyof Omit<ChannelResponse<{}, UserType, CommandType>, 'name'>]:
[Key in keyof Omit<
ChannelResponse<{}, UserType, CommandType>,
'name' | 'members'
>]:
| RequireOnlyOne<QueryFilter<ChannelResponse<{}, UserType, CommandType>[Key]>>
| PrimitiveFilter<ChannelResponse<{}, UserType, CommandType>[Key]>;
}
Expand Down
42 changes: 42 additions & 0 deletions ts-test/unit-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,45 @@ client.updateChannelType('messaging', { permissions }).then(response => {
const permissionName: string = permissions[0].name || '';
const permissionRoles: string[] = permissions[0].roles || [];
});

client.queryChannels({
members: {
$in: ['vishal'],
},
cid: {
$in: ['messaging:channelid'],
},
name: {
$autocomplete: 'chan',
},
});

// TODO: Fix this
// channel.queryMembers({
// $or: [
// { name: { $autocomplete: 'Rob' } }, // rob, rob2
// { banned: true }, // banned
// { is_moderator: true }, // mod
// {
// // invited
// $and: [
// { name: { $q: 'Mar' } },
// { invite: 'accepted' },
// {
// $or: [
// { name: { $autocomplete: 'mar' } },
// { invite: 'rejected' },
// ],
// },
// ],
// },
// {
// // no match
// $nor: [
// {
// $and: [{ name: { $q: 'Car' } }, { invite: 'accepted' }],
// },
// ],
// },
// ],
// });

0 comments on commit 5e840ba

Please sign in to comment.