From 7a5449b4c5b0472a0dc69a42d24579340a73c90f Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 23 Jun 2025 20:26:19 +0000 Subject: [PATCH 1/5] latest --- .../client/src/pages/IngestPage/sqlConfig.ts | 2 +- .../routes/api/archive-metadata/index.ts | 36 +++++++++++++++++++ .../fastify-v2/schemas/archive-metadata.ts | 14 ++++++++ .../server/src/plugins/DbManager.ts | 12 ------- .../server/src/routes/query.ts | 15 -------- 5 files changed, 51 insertions(+), 28 deletions(-) create mode 100644 components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts create mode 100644 components/log-viewer-webui/server/src/fastify-v2/schemas/archive-metadata.ts diff --git a/components/log-viewer-webui/client/src/pages/IngestPage/sqlConfig.ts b/components/log-viewer-webui/client/src/pages/IngestPage/sqlConfig.ts index 1c8edbfdae..131cac75ee 100644 --- a/components/log-viewer-webui/client/src/pages/IngestPage/sqlConfig.ts +++ b/components/log-viewer-webui/client/src/pages/IngestPage/sqlConfig.ts @@ -52,7 +52,7 @@ enum COMPRESSION_JOBS_TABLE_COLUMN_NAMES { * @return */ const querySql = async (queryString: string) => { - return axios.post("/query/sql", {queryString}); + return axios.post("/api/archive-metadata/sql", {queryString}); }; export { diff --git a/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts b/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts new file mode 100644 index 0000000000..00726ef726 --- /dev/null +++ b/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts @@ -0,0 +1,36 @@ +import { + FastifyPluginAsyncTypebox, + Type, +} from "@fastify/type-provider-typebox"; +import {StatusCodes} from "http-status-codes"; + +import {SqlSchema} from "../../../schemas/archive-metadata.js"; +/** + * Search API routes. + * + * @param fastify + */ +// eslint-disable-next-line max-lines-per-function +const plugin: FastifyPluginAsyncTypebox = async (fastify) => { + const mysqlConnectionPool = fastify.mysql.pool; + + fastify.post( + "/sql", + { + schema: { + body: SqlSchema, + response: { + [StatusCodes.OK]: Type.Any(), + }, + tags: ["Archive Metadata"], + }, + }, + async (req, reply) => { + const {queryString} = req.body; + reply.code(StatusCodes.OK); + return await mysqlConnectionPool.query(queryString); + }, + ); +}; + +export default plugin; diff --git a/components/log-viewer-webui/server/src/fastify-v2/schemas/archive-metadata.ts b/components/log-viewer-webui/server/src/fastify-v2/schemas/archive-metadata.ts new file mode 100644 index 0000000000..522dfb179b --- /dev/null +++ b/components/log-viewer-webui/server/src/fastify-v2/schemas/archive-metadata.ts @@ -0,0 +1,14 @@ +import {Type} from "@sinclair/typebox"; + +import {StringSchema} from "./common.js"; + +/** + * Schema for SQL query request. + */ +const SqlSchema = Type.Object({ + queryString: StringSchema, +}); + +export { + SqlSchema, +}; diff --git a/components/log-viewer-webui/server/src/plugins/DbManager.ts b/components/log-viewer-webui/server/src/plugins/DbManager.ts index ca2ed88f18..a1f863c21e 100644 --- a/components/log-viewer-webui/server/src/plugins/DbManager.ts +++ b/components/log-viewer-webui/server/src/plugins/DbManager.ts @@ -82,18 +82,6 @@ class DbManager { }); } - /** - * Submits a query to MySQL. - * - * @param queryString - * @return The result from MySQL. - */ - async queryMySql (queryString: string) { - const [result] = await this.#mysqlConnectionPool.query(queryString); - return result; - } - - /** * Submits a stream extraction job to the scheduler and waits for it to finish. * diff --git a/components/log-viewer-webui/server/src/routes/query.ts b/components/log-viewer-webui/server/src/routes/query.ts index e3713a252c..f32d970dfb 100644 --- a/components/log-viewer-webui/server/src/routes/query.ts +++ b/components/log-viewer-webui/server/src/routes/query.ts @@ -20,21 +20,6 @@ import { const routes: FastifyPluginAsync = async (app) => { const fastify = app.withTypeProvider(); - fastify.post( - "/query/sql", - { - schema: { - body: Type.Object({ - queryString: Type.String({minLength: 1}), - }), - }, - }, - async (req) => { - const {queryString} = req.body; - return await fastify.dbManager.queryMySql(queryString); - }, - ); - fastify.post("/query/extract-stream", { schema: { body: Type.Object({ From 5e88f4dc7f0377b7a908d301ecc923eafaed0316 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 23 Jun 2025 20:32:39 +0000 Subject: [PATCH 2/5] latest --- .../src/fastify-v2/routes/api/archive-metadata/index.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts b/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts index 00726ef726..1d65f5723b 100644 --- a/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts +++ b/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts @@ -5,12 +5,13 @@ import { import {StatusCodes} from "http-status-codes"; import {SqlSchema} from "../../../schemas/archive-metadata.js"; + + /** - * Search API routes. + * Archive metadata API routes. * * @param fastify */ -// eslint-disable-next-line max-lines-per-function const plugin: FastifyPluginAsyncTypebox = async (fastify) => { const mysqlConnectionPool = fastify.mysql.pool; @@ -28,7 +29,8 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => { async (req, reply) => { const {queryString} = req.body; reply.code(StatusCodes.OK); - return await mysqlConnectionPool.query(queryString); + const [result] = await mysqlConnectionPool.query(queryString); + return result; }, ); }; From ecc61992a92d99c9329c0fafda6c372d252fa68f Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 23 Jun 2025 20:44:58 +0000 Subject: [PATCH 3/5] latest --- .../src/fastify-v2/routes/api/archive-metadata/index.ts | 3 ++- .../server/src/fastify-v2/schemas/archive-metadata.ts | 5 ++--- components/log-viewer-webui/server/src/routes/query.ts | 1 - 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts b/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts index 1d65f5723b..f52a9dc685 100644 --- a/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts +++ b/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts @@ -28,8 +28,9 @@ const plugin: FastifyPluginAsyncTypebox = async (fastify) => { }, async (req, reply) => { const {queryString} = req.body; - reply.code(StatusCodes.OK); const [result] = await mysqlConnectionPool.query(queryString); + reply.code(StatusCodes.OK); + return result; }, ); diff --git a/components/log-viewer-webui/server/src/fastify-v2/schemas/archive-metadata.ts b/components/log-viewer-webui/server/src/fastify-v2/schemas/archive-metadata.ts index 522dfb179b..338d798197 100644 --- a/components/log-viewer-webui/server/src/fastify-v2/schemas/archive-metadata.ts +++ b/components/log-viewer-webui/server/src/fastify-v2/schemas/archive-metadata.ts @@ -2,6 +2,7 @@ import {Type} from "@sinclair/typebox"; import {StringSchema} from "./common.js"; + /** * Schema for SQL query request. */ @@ -9,6 +10,4 @@ const SqlSchema = Type.Object({ queryString: StringSchema, }); -export { - SqlSchema, -}; +export {SqlSchema}; diff --git a/components/log-viewer-webui/server/src/routes/query.ts b/components/log-viewer-webui/server/src/routes/query.ts index f32d970dfb..a8500e53c5 100644 --- a/components/log-viewer-webui/server/src/routes/query.ts +++ b/components/log-viewer-webui/server/src/routes/query.ts @@ -16,7 +16,6 @@ import { * @param app * @return */ -// eslint-disable-next-line max-lines-per-function const routes: FastifyPluginAsync = async (app) => { const fastify = app.withTypeProvider(); From 1fde043f836c856c8a88f962632eca9933ba0df2 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 23 Jun 2025 20:49:21 +0000 Subject: [PATCH 4/5] latest --- components/log-viewer-webui/server/eslint.config.mjs | 1 + 1 file changed, 1 insertion(+) diff --git a/components/log-viewer-webui/server/eslint.config.mjs b/components/log-viewer-webui/server/eslint.config.mjs index 476fa04c30..a83674d43c 100644 --- a/components/log-viewer-webui/server/eslint.config.mjs +++ b/components/log-viewer-webui/server/eslint.config.mjs @@ -22,6 +22,7 @@ const EslintConfig = [ { // TypeBox imports capIsNewExceptions: [ + "Type.Any", "Type.Enum", "Type.Integer", "Type.Literal", From 644cc2691ed7bb712914512b837bbd78cfd25921 Mon Sep 17 00:00:00 2001 From: Marco Date: Wed, 2 Jul 2025 14:08:53 +0000 Subject: [PATCH 5/5] latest --- .../server/src/fastify-v2/routes/api/archive-metadata/index.ts | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename components/{log-viewer-webui => webui}/server/src/fastify-v2/routes/api/archive-metadata/index.ts (100%) diff --git a/components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts b/components/webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts similarity index 100% rename from components/log-viewer-webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts rename to components/webui/server/src/fastify-v2/routes/api/archive-metadata/index.ts