Skip to content

Commit

Permalink
Implement to fetch document data when the DocumentDetail component is…
Browse files Browse the repository at this point in the history
… mounted.

Before, the snapshot data only passed when users clicked the link.
Implement to fetch data when the DocumentDetail component is mounted
to show the document data when entering the URL directly.

This commit also adds some codes by pasting the grpc protocol.
(to keep a single source of truth)
- Add project list command
- Remove collection from document
- Rename agent to server 
- Rename `db` package to `database`

Co-authored-by: Youngteac Hong <youngteac.hong@navercorp.com>
  • Loading branch information
chacha912 and hackerwins committed May 5, 2022
1 parent b34e8db commit 6a3b875
Show file tree
Hide file tree
Showing 16 changed files with 2,327 additions and 391 deletions.
33 changes: 33 additions & 0 deletions src/api/admin.proto
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,34 @@ import "resources.proto";

// Admin is a service that provides a API for Admin.
service Admin {
rpc CreateProject(CreateProjectRequest) returns (CreateProjectResponse) {}
rpc ListProjects(ListProjectsRequest) returns (ListProjectsResponse) {}
rpc UpdateProject(UpdateProjectRequest) returns (UpdateProjectResponse) {}

rpc ListDocuments (ListDocumentsRequest) returns (ListDocumentsResponse) {}
rpc GetDocument (GetDocumentRequest) returns (GetDocumentResponse) {}
}

message CreateProjectRequest {
string name = 1;
}

message CreateProjectResponse {
Project project = 1;
}

message ListProjectsRequest {}

message ListProjectsResponse {
repeated Project projects = 1;
}

message UpdateProjectRequest {
Project project = 1;
}

message UpdateProjectResponse {}

message ListDocumentsRequest {
string previous_id = 1;
int32 page_size = 2;
Expand All @@ -33,3 +58,11 @@ message ListDocumentsRequest {
message ListDocumentsResponse {
repeated DocumentSummary documents = 1;
}

message GetDocumentRequest {
string id = 1;
}

message GetDocumentResponse {
DocumentSummary document = 1;
}
48 changes: 48 additions & 0 deletions src/api/admin_grpc_web_pb.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,72 @@ export class AdminClient {
credentials?: null | { [index: string]: string; },
options?: null | { [index: string]: any; });

createProject(
request: admin_pb.CreateProjectRequest,
metadata: grpcWeb.Metadata | undefined,
callback: (err: grpcWeb.RpcError,
response: admin_pb.CreateProjectResponse) => void
): grpcWeb.ClientReadableStream<admin_pb.CreateProjectResponse>;

listProjects(
request: admin_pb.ListProjectsRequest,
metadata: grpcWeb.Metadata | undefined,
callback: (err: grpcWeb.RpcError,
response: admin_pb.ListProjectsResponse) => void
): grpcWeb.ClientReadableStream<admin_pb.ListProjectsResponse>;

updateProject(
request: admin_pb.UpdateProjectRequest,
metadata: grpcWeb.Metadata | undefined,
callback: (err: grpcWeb.RpcError,
response: admin_pb.UpdateProjectResponse) => void
): grpcWeb.ClientReadableStream<admin_pb.UpdateProjectResponse>;

listDocuments(
request: admin_pb.ListDocumentsRequest,
metadata: grpcWeb.Metadata | undefined,
callback: (err: grpcWeb.RpcError,
response: admin_pb.ListDocumentsResponse) => void
): grpcWeb.ClientReadableStream<admin_pb.ListDocumentsResponse>;

getDocument(
request: admin_pb.GetDocumentRequest,
metadata: grpcWeb.Metadata | undefined,
callback: (err: grpcWeb.RpcError,
response: admin_pb.GetDocumentResponse) => void
): grpcWeb.ClientReadableStream<admin_pb.GetDocumentResponse>;

}

export class AdminPromiseClient {
constructor (hostname: string,
credentials?: null | { [index: string]: string; },
options?: null | { [index: string]: any; });

createProject(
request: admin_pb.CreateProjectRequest,
metadata?: grpcWeb.Metadata
): Promise<admin_pb.CreateProjectResponse>;

listProjects(
request: admin_pb.ListProjectsRequest,
metadata?: grpcWeb.Metadata
): Promise<admin_pb.ListProjectsResponse>;

updateProject(
request: admin_pb.UpdateProjectRequest,
metadata?: grpcWeb.Metadata
): Promise<admin_pb.UpdateProjectResponse>;

listDocuments(
request: admin_pb.ListDocumentsRequest,
metadata?: grpcWeb.Metadata
): Promise<admin_pb.ListDocumentsResponse>;

getDocument(
request: admin_pb.GetDocumentRequest,
metadata?: grpcWeb.Metadata
): Promise<admin_pb.GetDocumentResponse>;

}

244 changes: 244 additions & 0 deletions src/api/admin_grpc_web_pb.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,189 @@ proto.api.AdminPromiseClient =
};


/**
* @const
* @type {!grpc.web.MethodDescriptor<
* !proto.api.CreateProjectRequest,
* !proto.api.CreateProjectResponse>}
*/
const methodDescriptor_Admin_CreateProject = new grpc.web.MethodDescriptor(
'/api.Admin/CreateProject',
grpc.web.MethodType.UNARY,
proto.api.CreateProjectRequest,
proto.api.CreateProjectResponse,
/**
* @param {!proto.api.CreateProjectRequest} request
* @return {!Uint8Array}
*/
function(request) {
return request.serializeBinary();
},
proto.api.CreateProjectResponse.deserializeBinary
);


/**
* @param {!proto.api.CreateProjectRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* call metadata
* @param {function(?grpc.web.RpcError, ?proto.api.CreateProjectResponse)}
* callback The callback function(error, response)
* @return {!grpc.web.ClientReadableStream<!proto.api.CreateProjectResponse>|undefined}
* The XHR Node Readable Stream
*/
proto.api.AdminClient.prototype.createProject =
function(request, metadata, callback) {
return this.client_.rpcCall(this.hostname_ +
'/api.Admin/CreateProject',
request,
metadata || {},
methodDescriptor_Admin_CreateProject,
callback);
};


/**
* @param {!proto.api.CreateProjectRequest} request The
* request proto
* @param {?Object<string, string>=} metadata User defined
* call metadata
* @return {!Promise<!proto.api.CreateProjectResponse>}
* Promise that resolves to the response
*/
proto.api.AdminPromiseClient.prototype.createProject =
function(request, metadata) {
return this.client_.unaryCall(this.hostname_ +
'/api.Admin/CreateProject',
request,
metadata || {},
methodDescriptor_Admin_CreateProject);
};


/**
* @const
* @type {!grpc.web.MethodDescriptor<
* !proto.api.ListProjectsRequest,
* !proto.api.ListProjectsResponse>}
*/
const methodDescriptor_Admin_ListProjects = new grpc.web.MethodDescriptor(
'/api.Admin/ListProjects',
grpc.web.MethodType.UNARY,
proto.api.ListProjectsRequest,
proto.api.ListProjectsResponse,
/**
* @param {!proto.api.ListProjectsRequest} request
* @return {!Uint8Array}
*/
function(request) {
return request.serializeBinary();
},
proto.api.ListProjectsResponse.deserializeBinary
);


/**
* @param {!proto.api.ListProjectsRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* call metadata
* @param {function(?grpc.web.RpcError, ?proto.api.ListProjectsResponse)}
* callback The callback function(error, response)
* @return {!grpc.web.ClientReadableStream<!proto.api.ListProjectsResponse>|undefined}
* The XHR Node Readable Stream
*/
proto.api.AdminClient.prototype.listProjects =
function(request, metadata, callback) {
return this.client_.rpcCall(this.hostname_ +
'/api.Admin/ListProjects',
request,
metadata || {},
methodDescriptor_Admin_ListProjects,
callback);
};


/**
* @param {!proto.api.ListProjectsRequest} request The
* request proto
* @param {?Object<string, string>=} metadata User defined
* call metadata
* @return {!Promise<!proto.api.ListProjectsResponse>}
* Promise that resolves to the response
*/
proto.api.AdminPromiseClient.prototype.listProjects =
function(request, metadata) {
return this.client_.unaryCall(this.hostname_ +
'/api.Admin/ListProjects',
request,
metadata || {},
methodDescriptor_Admin_ListProjects);
};


/**
* @const
* @type {!grpc.web.MethodDescriptor<
* !proto.api.UpdateProjectRequest,
* !proto.api.UpdateProjectResponse>}
*/
const methodDescriptor_Admin_UpdateProject = new grpc.web.MethodDescriptor(
'/api.Admin/UpdateProject',
grpc.web.MethodType.UNARY,
proto.api.UpdateProjectRequest,
proto.api.UpdateProjectResponse,
/**
* @param {!proto.api.UpdateProjectRequest} request
* @return {!Uint8Array}
*/
function(request) {
return request.serializeBinary();
},
proto.api.UpdateProjectResponse.deserializeBinary
);


/**
* @param {!proto.api.UpdateProjectRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* call metadata
* @param {function(?grpc.web.RpcError, ?proto.api.UpdateProjectResponse)}
* callback The callback function(error, response)
* @return {!grpc.web.ClientReadableStream<!proto.api.UpdateProjectResponse>|undefined}
* The XHR Node Readable Stream
*/
proto.api.AdminClient.prototype.updateProject =
function(request, metadata, callback) {
return this.client_.rpcCall(this.hostname_ +
'/api.Admin/UpdateProject',
request,
metadata || {},
methodDescriptor_Admin_UpdateProject,
callback);
};


/**
* @param {!proto.api.UpdateProjectRequest} request The
* request proto
* @param {?Object<string, string>=} metadata User defined
* call metadata
* @return {!Promise<!proto.api.UpdateProjectResponse>}
* Promise that resolves to the response
*/
proto.api.AdminPromiseClient.prototype.updateProject =
function(request, metadata) {
return this.client_.unaryCall(this.hostname_ +
'/api.Admin/UpdateProject',
request,
metadata || {},
methodDescriptor_Admin_UpdateProject);
};


/**
* @const
* @type {!grpc.web.MethodDescriptor<
Expand Down Expand Up @@ -133,5 +316,66 @@ proto.api.AdminPromiseClient.prototype.listDocuments =
};


/**
* @const
* @type {!grpc.web.MethodDescriptor<
* !proto.api.GetDocumentRequest,
* !proto.api.GetDocumentResponse>}
*/
const methodDescriptor_Admin_GetDocument = new grpc.web.MethodDescriptor(
'/api.Admin/GetDocument',
grpc.web.MethodType.UNARY,
proto.api.GetDocumentRequest,
proto.api.GetDocumentResponse,
/**
* @param {!proto.api.GetDocumentRequest} request
* @return {!Uint8Array}
*/
function(request) {
return request.serializeBinary();
},
proto.api.GetDocumentResponse.deserializeBinary
);


/**
* @param {!proto.api.GetDocumentRequest} request The
* request proto
* @param {?Object<string, string>} metadata User defined
* call metadata
* @param {function(?grpc.web.RpcError, ?proto.api.GetDocumentResponse)}
* callback The callback function(error, response)
* @return {!grpc.web.ClientReadableStream<!proto.api.GetDocumentResponse>|undefined}
* The XHR Node Readable Stream
*/
proto.api.AdminClient.prototype.getDocument =
function(request, metadata, callback) {
return this.client_.rpcCall(this.hostname_ +
'/api.Admin/GetDocument',
request,
metadata || {},
methodDescriptor_Admin_GetDocument,
callback);
};


/**
* @param {!proto.api.GetDocumentRequest} request The
* request proto
* @param {?Object<string, string>=} metadata User defined
* call metadata
* @return {!Promise<!proto.api.GetDocumentResponse>}
* Promise that resolves to the response
*/
proto.api.AdminPromiseClient.prototype.getDocument =
function(request, metadata) {
return this.client_.unaryCall(this.hostname_ +
'/api.Admin/GetDocument',
request,
metadata || {},
methodDescriptor_Admin_GetDocument);
};


module.exports = proto.api;

Loading

0 comments on commit 6a3b875

Please sign in to comment.