
* refresh tree after adding or removing project * Always check if client is defined * fix lint errors * remove extra nodejs versions from pipeline
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
import { window } from "vscode";
|
|
import { Client, Log, User, UsersClient } from "../appwrite";
|
|
import { AppwriteSDK } from "../constants";
|
|
import AppwriteCall from "../utils/AppwriteCall";
|
|
|
|
export class Users {
|
|
private readonly users: UsersClient;
|
|
|
|
constructor(client: Client) {
|
|
this.users = new AppwriteSDK.Users(client);
|
|
}
|
|
public async createNewUser(context: CreateUserContext): Promise<void> {
|
|
await AppwriteCall<User, void>(this.users.create(context.email, context.password, context.name), (user) => {
|
|
window.showInformationMessage(`Created user with id: ${user.$id}`);
|
|
});
|
|
}
|
|
|
|
public async delete(userId: string): Promise<void> {
|
|
await AppwriteCall(this.users.deleteUser(userId), () => {
|
|
window.showInformationMessage(`Deleted user with id: ${userId}.`);
|
|
});
|
|
}
|
|
|
|
public async getLogs(userId: string): Promise<Log[]> {
|
|
return (await AppwriteCall<Log[], Log[]>(this.users.getLogs(userId))) ?? [];
|
|
}
|
|
}
|
|
|
|
type CreateUserContext = {
|
|
email: string;
|
|
password: string;
|
|
name?: string;
|
|
};
|