From 0d4aa8a8c91d7f1b162e1670114c0ecbb39dffc0 Mon Sep 17 00:00:00 2001 From: Fedorov Vladimir Date: Wed, 15 Jul 2026 00:38:26 +0700 Subject: [PATCH] fix --- package.json | 2 +- .../crabs/evening_detective_server/index.ts | 754 ++++++++++++++++++ 2 files changed, 755 insertions(+), 1 deletion(-) create mode 100644 src/api/generated/crabs/evening_detective_server/index.ts diff --git a/package.json b/package.json index bb4dfae..d6bc22e 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "type-check": "vue-tsc --build", "lint": "eslint . --fix", "format": "prettier --write src/", - "proto:gen": "protoc --typescript-http_out=src/api/generated --proto_path=proto api/main.proto" + "proto:gen": "protoc --typescript-http_out=src/api/generated --proto_path=proto proto/main.proto" }, "dependencies": { "axios": "^1.18.1", diff --git a/src/api/generated/crabs/evening_detective_server/index.ts b/src/api/generated/crabs/evening_detective_server/index.ts new file mode 100644 index 0000000..d574a9c --- /dev/null +++ b/src/api/generated/crabs/evening_detective_server/index.ts @@ -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; + Echo(request: EchoReq): Promise; + Signup(request: SignupReq): Promise; + RefreshPassword(request: RefreshPasswordReq): Promise; + Login(request: LoginReq): Promise; + Refresh(request: RefreshReq): Promise; + GetUsers(request: GetUsersReq): Promise; + GetUserById(request: GetUserByIdReq): Promise; + GetMe(request: GetMeReq): Promise; + AddUserRole(request: AddUserRoleReq): Promise; + DeleteUserRole(request: DeleteUserRoleReq): Promise; + GetPermissions(request: GetPermissionsReq): Promise; + UploadFile(request: UploadFileReq): Promise; + DownloadFile(request: DownloadFileReq): Promise; + AddScenario(request: AddScenarioReq): Promise; + GetMyScenarios(request: GetMyScenariosReq): Promise; + GetScenario(request: GetScenarioReq): Promise; + UpdateScenario(request: UpdateScenarioReq): Promise; + DeleteScenario(request: DeleteScenarioReq): Promise; + AddScenarioPlace(request: AddScenarioPlaceReq): Promise; + UpdateScenarioPlace(request: UpdateScenarioPlaceReq): Promise; + DeleteScenarioPlace(request: DeleteScenarioPlaceReq): Promise; +} + +type RequestType = { + path: string; + method: string; + body: string | null; +}; + +type RequestHandler = (request: RequestType, meta: { service: string, method: string }) => Promise; + +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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + 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; + }, + }; +} +// 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)