Skip to content

Commit

Permalink
Add account deletion feature (#166)
Browse files Browse the repository at this point in the history
Co-authored-by: Youngteac Hong <[email protected]>
  • Loading branch information
chacha912 and hackerwins authored Aug 29, 2024
1 parent fb2b128 commit 92376a5
Show file tree
Hide file tree
Showing 17 changed files with 624 additions and 14 deletions.
3 changes: 2 additions & 1 deletion .prettierrc.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
module.exports = {
const config = {
bracketSpacing: true,
singleQuote: true,
trailingComma: 'all',
printWidth: 120,
tabWidth: 2,
};
export default config;
5 changes: 5 additions & 0 deletions src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,11 @@ export async function signUp(username: string, password: string): Promise<User>
return converter.fromUser(res.user!);
}

// deleteAccount deletes the account.
export async function deleteAccount(username: string, password: string) {
await client.deleteAccount({ username, password });
}

// createProject creates a new project.
export async function createProject(name: string): Promise<Project> {
const res = await client.createProject({ name });
Expand Down
40 changes: 40 additions & 0 deletions src/api/yorkie/v1/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ option java_package = "dev.yorkie.api.v1";
service AdminService {
rpc SignUp(SignUpRequest) returns (SignUpResponse) {}
rpc LogIn(LogInRequest) returns (LogInResponse) {}
rpc DeleteAccount(DeleteAccountRequest) returns (DeleteAccountResponse) {}
rpc ChangePassword(ChangePasswordRequest) returns (ChangePasswordResponse) {}

rpc CreateProject(CreateProjectRequest) returns (CreateProjectResponse) {}
rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse) {}
Expand All @@ -36,11 +38,14 @@ service AdminService {

rpc ListDocuments (ListDocumentsRequest) returns (ListDocumentsResponse) {}
rpc GetDocument (GetDocumentRequest) returns (GetDocumentResponse) {}
rpc GetDocuments (GetDocumentsRequest) returns (GetDocumentsResponse) {}
rpc RemoveDocumentByAdmin (RemoveDocumentByAdminRequest) returns (RemoveDocumentByAdminResponse) {}
rpc GetSnapshotMeta (GetSnapshotMetaRequest) returns (GetSnapshotMetaResponse) {}
rpc SearchDocuments (SearchDocumentsRequest) returns (SearchDocumentsResponse) {}

rpc ListChanges (ListChangesRequest) returns (ListChangesResponse) {}

rpc GetServerVersion (GetServerVersionRequest) returns (GetServerVersionResponse) {}
}

message SignUpRequest {
Expand All @@ -61,6 +66,23 @@ message LogInResponse {
string token = 1;
}

message DeleteAccountRequest {
string username = 1;
string password = 2;
}

message DeleteAccountResponse {
}

message ChangePasswordRequest {
string username = 1;
string current_password = 2;
string new_password = 3;
}

message ChangePasswordResponse {
}

message CreateProjectRequest {
string name = 1;
}
Expand Down Expand Up @@ -113,6 +135,16 @@ message GetDocumentResponse {
DocumentSummary document = 1;
}

message GetDocumentsRequest {
string project_name = 1;
repeated string document_keys = 2;
bool include_snapshot = 3;
}

message GetDocumentsResponse {
repeated DocumentSummary documents = 1;
}

message RemoveDocumentByAdminRequest {
string project_name = 1;
string document_key = 2;
Expand Down Expand Up @@ -154,3 +186,11 @@ message ListChangesRequest {
message ListChangesResponse {
repeated Change changes = 1;
}

message GetServerVersionRequest {}

message GetServerVersionResponse {
string yorkie_version = 1;
string go_version = 2;
string build_date = 3;
}
38 changes: 37 additions & 1 deletion src/api/yorkie/v1/admin_connect.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* eslint-disable */
// @ts-nocheck

import { CreateProjectRequest, CreateProjectResponse, GetDocumentRequest, GetDocumentResponse, GetProjectRequest, GetProjectResponse, GetSnapshotMetaRequest, GetSnapshotMetaResponse, ListChangesRequest, ListChangesResponse, ListDocumentsRequest, ListDocumentsResponse, ListProjectsRequest, ListProjectsResponse, LogInRequest, LogInResponse, RemoveDocumentByAdminRequest, RemoveDocumentByAdminResponse, SearchDocumentsRequest, SearchDocumentsResponse, SignUpRequest, SignUpResponse, UpdateProjectRequest, UpdateProjectResponse } from "./admin_pb.js";
import { ChangePasswordRequest, ChangePasswordResponse, CreateProjectRequest, CreateProjectResponse, DeleteAccountRequest, DeleteAccountResponse, GetDocumentRequest, GetDocumentResponse, GetDocumentsRequest, GetDocumentsResponse, GetProjectRequest, GetProjectResponse, GetServerVersionRequest, GetServerVersionResponse, GetSnapshotMetaRequest, GetSnapshotMetaResponse, ListChangesRequest, ListChangesResponse, ListDocumentsRequest, ListDocumentsResponse, ListProjectsRequest, ListProjectsResponse, LogInRequest, LogInResponse, RemoveDocumentByAdminRequest, RemoveDocumentByAdminResponse, SearchDocumentsRequest, SearchDocumentsResponse, SignUpRequest, SignUpResponse, UpdateProjectRequest, UpdateProjectResponse } from "./admin_pb.js";
import { MethodKind } from "@bufbuild/protobuf";

/**
Expand Down Expand Up @@ -47,6 +47,24 @@ export declare const AdminService: {
readonly O: typeof LogInResponse,
readonly kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.DeleteAccount
*/
readonly deleteAccount: {
readonly name: "DeleteAccount",
readonly I: typeof DeleteAccountRequest,
readonly O: typeof DeleteAccountResponse,
readonly kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.ChangePassword
*/
readonly changePassword: {
readonly name: "ChangePassword",
readonly I: typeof ChangePasswordRequest,
readonly O: typeof ChangePasswordResponse,
readonly kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.CreateProject
*/
Expand Down Expand Up @@ -101,6 +119,15 @@ export declare const AdminService: {
readonly O: typeof GetDocumentResponse,
readonly kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.GetDocuments
*/
readonly getDocuments: {
readonly name: "GetDocuments",
readonly I: typeof GetDocumentsRequest,
readonly O: typeof GetDocumentsResponse,
readonly kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.RemoveDocumentByAdmin
*/
Expand Down Expand Up @@ -137,6 +164,15 @@ export declare const AdminService: {
readonly O: typeof ListChangesResponse,
readonly kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.GetServerVersion
*/
readonly getServerVersion: {
readonly name: "GetServerVersion",
readonly I: typeof GetServerVersionRequest,
readonly O: typeof GetServerVersionResponse,
readonly kind: MethodKind.Unary,
},
}
};

38 changes: 37 additions & 1 deletion src/api/yorkie/v1/admin_connect.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
/* eslint-disable */
// @ts-nocheck

import { CreateProjectRequest, CreateProjectResponse, GetDocumentRequest, GetDocumentResponse, GetProjectRequest, GetProjectResponse, GetSnapshotMetaRequest, GetSnapshotMetaResponse, ListChangesRequest, ListChangesResponse, ListDocumentsRequest, ListDocumentsResponse, ListProjectsRequest, ListProjectsResponse, LogInRequest, LogInResponse, RemoveDocumentByAdminRequest, RemoveDocumentByAdminResponse, SearchDocumentsRequest, SearchDocumentsResponse, SignUpRequest, SignUpResponse, UpdateProjectRequest, UpdateProjectResponse } from "./admin_pb.js";
import { ChangePasswordRequest, ChangePasswordResponse, CreateProjectRequest, CreateProjectResponse, DeleteAccountRequest, DeleteAccountResponse, GetDocumentRequest, GetDocumentResponse, GetDocumentsRequest, GetDocumentsResponse, GetProjectRequest, GetProjectResponse, GetServerVersionRequest, GetServerVersionResponse, GetSnapshotMetaRequest, GetSnapshotMetaResponse, ListChangesRequest, ListChangesResponse, ListDocumentsRequest, ListDocumentsResponse, ListProjectsRequest, ListProjectsResponse, LogInRequest, LogInResponse, RemoveDocumentByAdminRequest, RemoveDocumentByAdminResponse, SearchDocumentsRequest, SearchDocumentsResponse, SignUpRequest, SignUpResponse, UpdateProjectRequest, UpdateProjectResponse } from "./admin_pb.js";
import { MethodKind } from "@bufbuild/protobuf";

/**
Expand Down Expand Up @@ -47,6 +47,24 @@ export const AdminService = {
O: LogInResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.DeleteAccount
*/
deleteAccount: {
name: "DeleteAccount",
I: DeleteAccountRequest,
O: DeleteAccountResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.ChangePassword
*/
changePassword: {
name: "ChangePassword",
I: ChangePasswordRequest,
O: ChangePasswordResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.CreateProject
*/
Expand Down Expand Up @@ -101,6 +119,15 @@ export const AdminService = {
O: GetDocumentResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.GetDocuments
*/
getDocuments: {
name: "GetDocuments",
I: GetDocumentsRequest,
O: GetDocumentsResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.RemoveDocumentByAdmin
*/
Expand Down Expand Up @@ -137,6 +164,15 @@ export const AdminService = {
O: ListChangesResponse,
kind: MethodKind.Unary,
},
/**
* @generated from rpc yorkie.v1.AdminService.GetServerVersion
*/
getServerVersion: {
name: "GetServerVersion",
I: GetServerVersionRequest,
O: GetServerVersionResponse,
kind: MethodKind.Unary,
},
}
};

Loading

0 comments on commit 92376a5

Please sign in to comment.