Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding missing types #296

Merged
merged 2 commits into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export * from './client_state';
export { logChatPromiseExecution } from './utils';
export * from './channel';
export * from './channel_state';
export * from './connection';
export * from './permissions';
export * from './events';
export * from './signing';
Expand Down
6 changes: 6 additions & 0 deletions types/stream-chat/api-response-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const executables = [
{ f: rg.partialUpdateUser, type: 'UpdateUsersAPIResponse' },
{ f: rg.partialUpdateUsers, type: 'UpdateUsersAPIResponse' },
{ f: rg.banUsers, type: 'BanUserAPIResponse' },
{ f: rg.deleteUser, type: 'DeleteUserAPIResponse' },
{ f: rg.reactivateUser, type: 'ReactivateUserAPIResponse' },
{ f: rg.deactivateUser, type: 'DeactiveUserAPIResponse' },
{ f: rg.exportUser, type: 'ExportUserAPIResponse' },
{ f: rg.unbanUsers, type: 'UnbanUserAPIResponse' },
{ f: rg.muteUser, type: 'MuteAPIResponse' },
{ f: rg.unmuteUser, type: 'UnmuteAPIResponse' },
Expand Down Expand Up @@ -42,6 +46,8 @@ const executables = [
{ f: rg.getReactions, type: 'GetReactionsAPIResponse' },
{ f: rg.updateChannel, type: 'UpdateChannelAPIResponse' },
{ f: rg.deleteChannel, type: 'DeleteChannelAPIResponse' },
/** Keeping truncate quite for now. Needs some fixes on backend regardind commands array in response */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

typo and could you explain what is needed to be fixed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screenshot 2020-04-09 at 18 03 12

commands is different in truncateChannel response. It should be array of objects :)

Marcelo has fixed it. It will be deployed by tomorrow

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I saw the discussion with Mike and it's good to have a reference. I think this comment is enough, no need write in source since it will be updated soon.

// { f: rg.truncateChannel, type: 'TruncateChannelAPIResponse' },
{ f: rg.acceptInvite, type: 'AcceptInviteAPIResponse' },
{ f: rg.rejectInvite, type: 'RejectInviteAPIResponse' },
{ f: rg.addMembers, type: 'AddMembersAPIResponse' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,16 @@ async function deleteChannel() {
return await channel.delete();
}

async function truncateChannel() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but generator is added ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah thats fine. Once backend fix is ready, we will use it anyways!

const authClient = await utils.getTestClientForUser(johnID, {});
const id = uuidv4();
const channel = authClient.channel('messaging', id);
await channel.create();
await channel.watch();

return await channel.truncate();
}

async function acceptInvite() {
const c = await createTestInviteChannel();
const nickC = await utils.getTestClientForUser('nick');
Expand Down Expand Up @@ -141,6 +151,7 @@ module.exports = {
stopWatching,
updateChannel,
deleteChannel,
truncateChannel,
acceptInvite,
rejectInvite,
addMembers,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,66 @@ async function partialUpdateUsers() {
]);
}

async function deactivateUser() {
const client = utils.getServerTestClient();
const userID = uuid4();
await client.upsertUser({
id: userID,
name: 'Vishal',
});

return await client.deactivateUser(userID);
}

async function reactivateUser() {
const client = utils.getServerTestClient();
const userID = uuid4();
await client.upsertUser({
id: userID,
name: 'Vishal',
});

await client.deactivateUser(userID);

return await client.reactivateUser(userID);
}

async function deleteUser() {
const client = utils.getServerTestClient();
const userID = uuid4();
await client.upsertUser({
id: userID,
name: 'Vishal',
});

return client.deleteUser(userID);
}

async function exportUser() {
const client = utils.getServerTestClient();
const userID = uuid4();
await client.upsertUser({
id: userID,
name: 'Vishal',
});

const id = uuid4();
const channel = client.channel('messaging', id, { created_by_id: userID });
await channel.create();
const { message } = await channel.sendMessage({
text: 'this is great',
user_id: userID,
});
await channel.sendReaction(message.id, { type: 'love', user_id: userID });

return client.exportUser(userID);
}

module.exports = {
deactivateUser,
reactivateUser,
deleteUser,
exportUser,
updateUsers,
partialUpdateUser,
partialUpdateUsers,
Expand Down
40 changes: 40 additions & 0 deletions types/stream-chat/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,15 @@ export class StreamChat {
user: OwnUserResponse;
browser: boolean;
wsConnection: StableWSConnection;

testPushSettings(userID: string, data: object): Promise<APIResponse>;

deleteUser(userID: string, params: object): Promise<DeleteUserAPIResponse>;
reactivateUser(userID: string, options: object): Promise<ReactivateUserAPIResponse>;
deactivateUser(userID: string, options: object): Promise<DeactiveUserAPIResponse>;
exportUser(userID: string, options: object): Promise<ExportUserAPIResponse>;
markAllRead(data: object): Promise<void>;

devToken(userID: string): string;
createToken(userID: string, exp?: number): string;
getAuthType(): string;
Expand Down Expand Up @@ -312,6 +321,16 @@ export class Channel {
disconnected: boolean;
state: ChannelState;

getClient(): StreamChat;
truncate(): Promise<TruncateChannelAPIResponse>;
muteStatus(): {
muted: boolean;
createdAt?: string | null;
expiredAt?: string | null;
};
lastRead(): string | null;
countUnreadMentions(): number;

getConfig(): {
created_at: string;
updated_at: string;
Expand Down Expand Up @@ -437,6 +456,9 @@ export class ChannelState {
}>;
membership: SeamlessImmutable.Immutable<ChannelMembership>;
last_message_at: string;
addReaction(reaction: Reaction, message: MessageResponse): void;
removeReaction(reaction: Reaction, message: MessageResponse): void;
clearMessages(): void;
addMessageSorted(newMessage: Message): void;
addMessagesSorted(newMessages: Message[]): void;
messageToImmutable(message: Message): SeamlessImmutable.Immutable<Message>;
Expand Down Expand Up @@ -544,6 +566,21 @@ export interface UsersAPIResponse extends APIResponse {
users: UserResponse[];
}

export interface DeleteUserAPIResponse extends APIResponse {
user: UserResponse;
}
export interface ReactivateUserAPIResponse extends APIResponse {
user: UserResponse;
}
export interface DeactiveUserAPIResponse extends APIResponse {
user: UserResponse;
}
export interface ExportUserAPIResponse extends APIResponse {
user: UserResponse;
messages?: MessageResponse[];
reactions?: ReactionResponse[];
}

export interface SearchAPIResponse extends APIResponse {
results: Array<{
message: MessageResponse;
Expand Down Expand Up @@ -627,6 +664,9 @@ export interface UpdateChannelAPIResponse extends APIResponse {
export interface DeleteChannelAPIResponse extends APIResponse {
channel: ChannelResponse;
}
export interface TruncateChannelAPIResponse extends APIResponse {
channel: ChannelResponse;
}

export interface AcceptInviteAPIResponse extends UpdateChannelAPIResponse {}
export interface RejectInviteAPIResponse extends UpdateChannelAPIResponse {}
Expand Down