add gen proto

This commit is contained in:
2026-07-14 23:20:53 +07:00
parent 945114c952
commit 083a856111
12 changed files with 2988 additions and 17 deletions
@@ -0,0 +1,754 @@
// Code generated by protoc-gen-typescript-http. DO NOT EDIT.
/* eslint-disable camelcase */
// @ts-nocheck
export type PingReq = {
};
export type PingRsp = {
};
export type EchoReq = {
text: string | undefined;
};
export type EchoRsp = {
text: string | undefined;
};
export type SignupReq = {
username: string | undefined;
email: string | undefined;
};
export type SignupRsp = {
error: string | undefined;
};
export type RefreshPasswordReq = {
email: string | undefined;
};
export type RefreshPasswordRsp = {
error: string | undefined;
};
export type LoginReq = {
email: string | undefined;
password: string | undefined;
};
export type LoginRsp = {
error: string | undefined;
accessToken: string | undefined;
refreshToken: string | undefined;
};
export type RefreshReq = {
refreshToken: string | undefined;
};
export type RefreshRsp = {
error: string | undefined;
accessToken: string | undefined;
refreshToken: string | undefined;
};
export type GetUsersReq = {
};
export type GetUsersRsp = {
error: string | undefined;
users: User[] | undefined;
};
export type User = {
id: number | undefined;
username: string | undefined;
email: string | undefined;
roles: string[] | undefined;
isActive: boolean | undefined;
createdAt: wellKnownTimestamp | undefined;
};
// Encoded using RFC 3339, where generated output will always be Z-normalized
// and uses 0, 3, 6 or 9 fractional digits.
// Offsets other than "Z" are also accepted.
type wellKnownTimestamp = string;
export type GetUserByIdReq = {
id: number | undefined;
};
export type GetUserByIdRsp = {
error: string | undefined;
user: User | undefined;
};
export type GetMeReq = {
};
export type GetMeRsp = {
error: string | undefined;
user: User | undefined;
};
export type AddUserRoleReq = {
id: number | undefined;
role: string | undefined;
};
export type AddUserRoleRsp = {
error: string | undefined;
};
export type DeleteUserRoleReq = {
id: number | undefined;
role: string | undefined;
};
export type DeleteUserRoleRsp = {
error: string | undefined;
};
export type GetPermissionsReq = {
};
export type GetPermissionsRsp = {
error: string | undefined;
permissions: string[] | undefined;
};
export type UploadFileReq = {
filename: string | undefined;
data: string | undefined;
};
export type UploadFileRsp = {
error: string | undefined;
filename: string | undefined;
};
export type DownloadFileReq = {
filename: string | undefined;
};
export type AddScenarioReq = {
name: string | undefined;
};
export type AddScenarioRsp = {
error: string | undefined;
id: number | undefined;
};
export type GetMyScenariosReq = {
};
export type GetMyScenariosRsp = {
error: string | undefined;
scenarios: Scenario[] | undefined;
};
export type Scenario = {
id: number | undefined;
name: string | undefined;
description?: string;
image?: string;
story: Story | undefined;
author: User | undefined;
updatedAt: wellKnownTimestamp | undefined;
createdAt: wellKnownTimestamp | undefined;
publishedAt: wellKnownTimestamp | undefined;
};
export type Story = {
places: Place[] | undefined;
};
export type Place = {
code: string | undefined;
name: string | undefined;
text: string | undefined;
image: string | undefined;
hidden: boolean | undefined;
applications: Application[] | undefined;
doors: Door[] | undefined;
keys: Key[] | undefined;
};
export type Application = {
name: string | undefined;
image: string | undefined;
};
export type Door = {
code: string | undefined;
name: string | undefined;
keys: Key[] | undefined;
};
export type Key = {
name: string | undefined;
};
export type GetScenarioReq = {
id: number | undefined;
};
export type GetScenarioRsp = {
error: string | undefined;
scenario: Scenario | undefined;
};
export type UpdateScenarioReq = {
id: number | undefined;
name: string | undefined;
description: string | undefined;
image: string | undefined;
};
export type UpdateScenarioRsp = {
error: string | undefined;
};
export type DeleteScenarioReq = {
id: number | undefined;
};
export type DeleteScenarioRsp = {
error: string | undefined;
};
export type AddScenarioPlaceReq = {
id: number | undefined;
place: Place | undefined;
};
export type AddScenarioPlaceRsp = {
error: string | undefined;
};
export type UpdateScenarioPlaceReq = {
id: number | undefined;
code: string | undefined;
place: Place | undefined;
};
export type UpdateScenarioPlaceRsp = {
error: string | undefined;
};
export type DeleteScenarioPlaceReq = {
id: number | undefined;
code: string | undefined;
};
export type DeleteScenarioPlaceRsp = {
error: string | undefined;
};
export interface EveningDetectiveServer {
Ping(request: PingReq): Promise<PingRsp>;
Echo(request: EchoReq): Promise<EchoRsp>;
Signup(request: SignupReq): Promise<SignupRsp>;
RefreshPassword(request: RefreshPasswordReq): Promise<RefreshPasswordRsp>;
Login(request: LoginReq): Promise<LoginRsp>;
Refresh(request: RefreshReq): Promise<RefreshRsp>;
GetUsers(request: GetUsersReq): Promise<GetUsersRsp>;
GetUserById(request: GetUserByIdReq): Promise<GetUserByIdRsp>;
GetMe(request: GetMeReq): Promise<GetMeRsp>;
AddUserRole(request: AddUserRoleReq): Promise<AddUserRoleRsp>;
DeleteUserRole(request: DeleteUserRoleReq): Promise<DeleteUserRoleRsp>;
GetPermissions(request: GetPermissionsReq): Promise<GetPermissionsRsp>;
UploadFile(request: UploadFileReq): Promise<UploadFileRsp>;
DownloadFile(request: DownloadFileReq): Promise<googleapi_HttpBody>;
AddScenario(request: AddScenarioReq): Promise<AddScenarioRsp>;
GetMyScenarios(request: GetMyScenariosReq): Promise<GetMyScenariosRsp>;
GetScenario(request: GetScenarioReq): Promise<GetScenarioRsp>;
UpdateScenario(request: UpdateScenarioReq): Promise<UpdateScenarioRsp>;
DeleteScenario(request: DeleteScenarioReq): Promise<DeleteScenarioRsp>;
AddScenarioPlace(request: AddScenarioPlaceReq): Promise<AddScenarioPlaceRsp>;
UpdateScenarioPlace(request: UpdateScenarioPlaceReq): Promise<UpdateScenarioPlaceRsp>;
DeleteScenarioPlace(request: DeleteScenarioPlaceReq): Promise<DeleteScenarioPlaceRsp>;
}
type RequestType = {
path: string;
method: string;
body: string | null;
};
type RequestHandler = (request: RequestType, meta: { service: string, method: string }) => Promise<unknown>;
export function createEveningDetectiveServerClient(
handler: RequestHandler
): EveningDetectiveServer {
return {
Ping(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/test/ping`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "EveningDetectiveServer",
method: "Ping",
}) as Promise<PingRsp>;
},
Echo(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/test/echo`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
if (request.text) {
queryParams.push(`text=${encodeURIComponent(request.text.toString())}`)
}
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "Echo",
}) as Promise<EchoRsp>;
},
Signup(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/auth/signup`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "Signup",
}) as Promise<SignupRsp>;
},
RefreshPassword(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/auth/refresh-password`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "RefreshPassword",
}) as Promise<RefreshPasswordRsp>;
},
Login(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/auth/login`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "Login",
}) as Promise<LoginRsp>;
},
Refresh(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/auth/refresh`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "Refresh",
}) as Promise<RefreshRsp>;
},
GetUsers(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/users`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "EveningDetectiveServer",
method: "GetUsers",
}) as Promise<GetUsersRsp>;
},
GetUserById(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/users/${request.id}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "EveningDetectiveServer",
method: "GetUserById",
}) as Promise<GetUserByIdRsp>;
},
GetMe(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/users/me`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "EveningDetectiveServer",
method: "GetMe",
}) as Promise<GetMeRsp>;
},
AddUserRole(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/users/${request.id}/role/add`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "AddUserRole",
}) as Promise<AddUserRoleRsp>;
},
DeleteUserRole(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/users/${request.id}/role/delete`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "DeleteUserRole",
}) as Promise<DeleteUserRoleRsp>;
},
GetPermissions(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/ui/permissions`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "EveningDetectiveServer",
method: "GetPermissions",
}) as Promise<GetPermissionsRsp>;
},
UploadFile(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/files/upload`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "UploadFile",
}) as Promise<UploadFileRsp>;
},
DownloadFile(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.filename) {
throw new Error("missing required field request.filename");
}
const path = `api/files/${request.filename}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "EveningDetectiveServer",
method: "DownloadFile",
}) as Promise<googleapi_HttpBody>;
},
AddScenario(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/scenario`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "AddScenario",
}) as Promise<AddScenarioRsp>;
},
GetMyScenarios(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
const path = `api/my-scenarios`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "EveningDetectiveServer",
method: "GetMyScenarios",
}) as Promise<GetMyScenariosRsp>;
},
GetScenario(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/scenarios/${request.id}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "GET",
body,
}, {
service: "EveningDetectiveServer",
method: "GetScenario",
}) as Promise<GetScenarioRsp>;
},
UpdateScenario(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/scenarios/${request.id}`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PUT",
body,
}, {
service: "EveningDetectiveServer",
method: "UpdateScenario",
}) as Promise<UpdateScenarioRsp>;
},
DeleteScenario(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/scenarios/${request.id}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "DELETE",
body,
}, {
service: "EveningDetectiveServer",
method: "DeleteScenario",
}) as Promise<DeleteScenarioRsp>;
},
AddScenarioPlace(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
const path = `api/scenarios/${request.id}/places`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "POST",
body,
}, {
service: "EveningDetectiveServer",
method: "AddScenarioPlace",
}) as Promise<AddScenarioPlaceRsp>;
},
UpdateScenarioPlace(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
if (!request.code) {
throw new Error("missing required field request.code");
}
const path = `api/scenarios/${request.id}/places/${request.code}`; // eslint-disable-line quotes
const body = JSON.stringify(request);
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "PUT",
body,
}, {
service: "EveningDetectiveServer",
method: "UpdateScenarioPlace",
}) as Promise<UpdateScenarioPlaceRsp>;
},
DeleteScenarioPlace(request) { // eslint-disable-line @typescript-eslint/no-unused-vars
if (!request.id) {
throw new Error("missing required field request.id");
}
if (!request.code) {
throw new Error("missing required field request.code");
}
const path = `api/scenarios/${request.id}/places/${request.code}`; // eslint-disable-line quotes
const body = null;
const queryParams: string[] = [];
let uri = path;
if (queryParams.length > 0) {
uri += `?${queryParams.join("&")}`
}
return handler({
path: uri,
method: "DELETE",
body,
}, {
service: "EveningDetectiveServer",
method: "DeleteScenarioPlace",
}) as Promise<DeleteScenarioPlaceRsp>;
},
};
}
// Message that represents an arbitrary HTTP body. It should only be used for
// payload formats that can't be represented as JSON, such as raw binary or
// an HTML page.
// This message can be used both in streaming and non-streaming API methods in
// the request as well as the response.
// It can be used as a top-level request field, which is convenient if one
// wants to extract parameters from either the URL or HTTP template into the
// request fields and also want access to the raw HTTP body.
// Example:
// message GetResourceRequest {
// // A unique request id.
// string request_id = 1;
// // The raw HTTP body is bound to this field.
// google.api.HttpBody http_body = 2;
// }
// service ResourceService {
// rpc GetResource(GetResourceRequest)
// returns (google.api.HttpBody);
// rpc UpdateResource(google.api.HttpBody)
// returns (google.protobuf.Empty);
// }
// Example with streaming methods:
// service CaldavService {
// rpc GetCalendar(stream google.api.HttpBody)
// returns (stream google.api.HttpBody);
// rpc UpdateCalendar(stream google.api.HttpBody)
// returns (stream google.api.HttpBody);
// }
// Use of this type only changes how the request and response bodies are
// handled, all other features will continue to work unchanged.
export type googleapi_HttpBody = {
// The HTTP Content-Type header value specifying the content type of the body.
contentType: string | undefined;
// The HTTP request/response body as raw binary.
data: string | undefined;
// Application specific response metadata. Must be set in the first response
// for streaming APIs.
extensions: wellKnownAny[] | undefined;
};
// If the Any contains a value that has a special JSON mapping,
// it will be converted as follows:
// {"@type": xxx, "value": yyy}.
// Otherwise, the value will be converted into a JSON object,
// and the "@type" field will be inserted to indicate the actual data type.
interface wellKnownAny {
"@type": string;
[key: string]: unknown;
}
// @@protoc_insertion_point(typescript-http-eof)