diff --git a/components/webui/client/eslint.config.mjs b/components/webui/client/eslint.config.mjs index ea24b4121c..9dc0ed82c5 100644 --- a/components/webui/client/eslint.config.mjs +++ b/components/webui/client/eslint.config.mjs @@ -31,16 +31,12 @@ const EslintConfig = [ "new-cap": [ "error", { + // TypeBox imports capIsNewExceptions: [ - // TypeBox imports "Decode", "Encode", - "Type.Literal", - "Type.Optional", - "Type.Transform", - "Type.Union", - "Value.Parse", ], + capIsNewExceptionPattern: "^(Type|Value)\\.", }, ], }, diff --git a/components/webui/client/src/api/presto-search/index.ts b/components/webui/client/src/api/presto-search/index.ts index 25b093fca6..5b31d7bbb9 100644 --- a/components/webui/client/src/api/presto-search/index.ts +++ b/components/webui/client/src/api/presto-search/index.ts @@ -1,19 +1,10 @@ +import { + type PrestoQueryJob, + type PrestoQueryJobCreation, +} from "@webui/common/schemas/presto-search"; import axios, {AxiosResponse} from "axios"; -// eslint-disable-next-line no-warning-comments -// TODO: Replace with shared type from the `@common` directory once refactoring is completed. -// Currently, server schema types require typebox dependency so they cannot be moved to the -// `@common` directory with current implementation. -type PrestoQueryJobCreationSchema = { - queryString: string; -}; - -type PrestoQueryJobSchema = { - searchJobId: string; -}; - - /** * Sends post request to server to submit presto query. * @@ -21,11 +12,11 @@ type PrestoQueryJobSchema = { * @return */ const submitQuery = async ( - payload: PrestoQueryJobCreationSchema -): Promise> => { + payload: PrestoQueryJobCreation +): Promise> => { console.log("Submitting query:", JSON.stringify(payload)); - return axios.post("/api/presto-search/query", payload); + return axios.post("/api/presto-search/query", payload); }; @@ -36,7 +27,7 @@ const submitQuery = async ( * @return */ const cancelQuery = async ( - payload: PrestoQueryJobSchema + payload: PrestoQueryJob ): Promise> => { console.log("Cancelling query:", JSON.stringify(payload)); @@ -50,16 +41,12 @@ const cancelQuery = async ( * @param payload * @return */ -const clearQueryResults = (payload: PrestoQueryJobSchema): Promise> => { +const clearQueryResults = (payload: PrestoQueryJob): Promise> => { console.log("Clearing query:", JSON.stringify(payload)); return axios.delete("/api/presto-search/results", {data: payload}); }; -export type { - PrestoQueryJobCreationSchema, - PrestoQueryJobSchema, -}; export { cancelQuery, diff --git a/components/webui/client/src/api/search/index.ts b/components/webui/client/src/api/search/index.ts index 3f6e42973c..c4e08a00e3 100644 --- a/components/webui/client/src/api/search/index.ts +++ b/components/webui/client/src/api/search/index.ts @@ -1,29 +1,9 @@ +import { + type QueryJob, + type QueryJobCreation, +} from "@webui/common/schemas/search"; import axios, {AxiosResponse} from "axios"; -import {Nullable} from "../../typings/common"; - - -// eslint-disable-next-line no-warning-comments -// TODO: Replace with shared type from the `@common` directory once refactoring is completed. -// Currently, server schema types require typebox dependency so they cannot be moved to the -// `@common` directory with current implementation. -type QueryJobSchema = { - searchJobId: string; - aggregationJobId: string; -}; - -// eslint-disable-next-line no-warning-comments -// TODO: Replace with shared type from the `@common` directory once refactoring is completed. -// Currently, server schema types require typebox dependency so they cannot be moved to the -// `@common` directory with current implementation. -type QueryJobCreationSchema = { - dataset: Nullable; - ignoreCase: boolean; - queryString: string; - timeRangeBucketSizeMillis: number; - timestampBegin: number; - timestampEnd: number; -}; /** * Sends post request to server to submit query. @@ -31,10 +11,10 @@ type QueryJobCreationSchema = { * @param payload * @return */ -const submitQuery = (payload: QueryJobCreationSchema): Promise> => { +const submitQuery = (payload: QueryJobCreation): Promise> => { console.log("Submitting query:", JSON.stringify(payload)); - return axios.post("/api/search/query", payload); + return axios.post("/api/search/query", payload); }; /** @@ -43,7 +23,7 @@ const submitQuery = (payload: QueryJobCreationSchema): Promise> => { +const cancelQuery = (payload: QueryJob): Promise> => { console.log("Cancelling query:", JSON.stringify(payload)); return axios.post("/api/search/cancel", payload); @@ -55,15 +35,12 @@ const cancelQuery = (payload: QueryJobSchema): Promise> => { * @param payload * @return */ -const clearQueryResults = (payload: QueryJobSchema): Promise> => { +const clearQueryResults = (payload: QueryJob): Promise> => { console.log("Clearing query:", JSON.stringify(payload)); return axios.delete("/api/search/results", {data: payload}); }; -export type { - QueryJobCreationSchema, - QueryJobSchema, -}; + export { cancelQuery, clearQueryResults, diff --git a/components/webui/client/src/api/socket/MongoSocketCollection.ts b/components/webui/client/src/api/socket/MongoSocketCollection.ts index e1d1d1b092..a79583f91e 100644 --- a/components/webui/client/src/api/socket/MongoSocketCollection.ts +++ b/components/webui/client/src/api/socket/MongoSocketCollection.ts @@ -1,7 +1,7 @@ import { ClientToServerEvents, ServerToClientEvents, -} from "@webui/common"; +} from "@webui/common/socket"; import {Socket} from "socket.io-client"; import {MongoSocketCursor} from "./MongoSocketCursor.js"; diff --git a/components/webui/client/src/api/socket/MongoSocketCursor.ts b/components/webui/client/src/api/socket/MongoSocketCursor.ts index 363f0b185e..52f3eae794 100644 --- a/components/webui/client/src/api/socket/MongoSocketCursor.ts +++ b/components/webui/client/src/api/socket/MongoSocketCursor.ts @@ -3,11 +3,10 @@ import { QueryId, Response, ServerToClientEvents, -} from "@webui/common"; +} from "@webui/common/socket"; +import {Nullable} from "@webui/common/utility-types"; import {Socket} from "socket.io-client"; -import {Nullable} from "../../typings/common"; - /** * A cursor-like object receiving MongoDB documents over a socket connection. diff --git a/components/webui/client/src/api/socket/SocketSingleton.ts b/components/webui/client/src/api/socket/SocketSingleton.ts index dee90283d6..de64c88562 100644 --- a/components/webui/client/src/api/socket/SocketSingleton.ts +++ b/components/webui/client/src/api/socket/SocketSingleton.ts @@ -1,14 +1,13 @@ import { ClientToServerEvents, ServerToClientEvents, -} from "@webui/common"; +} from "@webui/common/socket"; +import {Nullable} from "@webui/common/utility-types"; import { io, Socket, } from "socket.io-client"; -import {Nullable} from "../../typings/common"; - let sharedSocket: Nullable> = null; diff --git a/components/webui/client/src/api/socket/useCursor.tsx b/components/webui/client/src/api/socket/useCursor.tsx index 0022576731..c3a55547f4 100644 --- a/components/webui/client/src/api/socket/useCursor.tsx +++ b/components/webui/client/src/api/socket/useCursor.tsx @@ -4,7 +4,8 @@ import { useState, } from "react"; -import {Nullable} from "../../typings/common"; +import {Nullable} from "@webui/common/utility-types"; + import {MongoSocketCursor} from "./MongoSocketCursor.js"; diff --git a/components/webui/client/src/api/stream-files/index.ts b/components/webui/client/src/api/stream-files/index.ts index 2552263b14..b8a52be2c6 100644 --- a/components/webui/client/src/api/stream-files/index.ts +++ b/components/webui/client/src/api/stream-files/index.ts @@ -1,13 +1,11 @@ +import {QUERY_JOB_TYPE} from "@webui/common/query"; +import {Nullable} from "@webui/common/utility-types"; import axios, { AxiosProgressEvent, AxiosResponse, } from "axios"; -import {Nullable} from "src/typings/common"; -import { - ExtractStreamResp, - QUERY_JOB_TYPE, -} from "../../typings/query"; +import {ExtractStreamResp} from "../../typings/query"; interface SubmitExtractStreamJobProps { diff --git a/components/webui/client/src/components/QueryBox/index.tsx b/components/webui/client/src/components/QueryBox/index.tsx index f0b710072a..84e4e241b0 100644 --- a/components/webui/client/src/components/QueryBox/index.tsx +++ b/components/webui/client/src/components/QueryBox/index.tsx @@ -1,8 +1,8 @@ +import {Nullable} from "@webui/common/utility-types"; import { Progress, theme, } from "antd"; -import {Nullable} from "src/typings/common"; import styles from "./index.module.css"; import InputWithCaseSensitive, {InputWithCaseSensitiveProps} from "./InputWithCaseSensitive"; diff --git a/components/webui/client/src/config/index.ts b/components/webui/client/src/config/index.ts index cc77f022ba..08a29413ea 100644 --- a/components/webui/client/src/config/index.ts +++ b/components/webui/client/src/config/index.ts @@ -1,4 +1,4 @@ -import {CLP_QUERY_ENGINES} from "@webui/common"; +import {CLP_QUERY_ENGINES} from "@webui/common/config"; import {settings} from "../settings"; diff --git a/components/webui/client/src/pages/IngestPage/Details/Files.tsx b/components/webui/client/src/pages/IngestPage/Details/Files.tsx index 5e5b913719..88b47c9273 100644 --- a/components/webui/client/src/pages/IngestPage/Details/Files.tsx +++ b/components/webui/client/src/pages/IngestPage/Details/Files.tsx @@ -1,4 +1,4 @@ -import {Nullable} from "src/typings/common"; +import {Nullable} from "@webui/common/utility-types"; import {DashboardCard} from "../../../components/DashboardCard"; import Stat from "../../../components/Stat"; diff --git a/components/webui/client/src/pages/IngestPage/Details/Messages.tsx b/components/webui/client/src/pages/IngestPage/Details/Messages.tsx index a43c3c2f5d..78b5bbf332 100644 --- a/components/webui/client/src/pages/IngestPage/Details/Messages.tsx +++ b/components/webui/client/src/pages/IngestPage/Details/Messages.tsx @@ -1,4 +1,4 @@ -import {Nullable} from "src/typings/common"; +import {Nullable} from "@webui/common/utility-types"; import {DashboardCard} from "../../../components/DashboardCard"; import Stat from "../../../components/Stat"; diff --git a/components/webui/client/src/pages/IngestPage/Details/sql.ts b/components/webui/client/src/pages/IngestPage/Details/sql.ts index bf74da7272..d20b289bd6 100644 --- a/components/webui/client/src/pages/IngestPage/Details/sql.ts +++ b/components/webui/client/src/pages/IngestPage/Details/sql.ts @@ -1,4 +1,4 @@ -import {Nullable} from "src/typings/common"; +import {Nullable} from "@webui/common/utility-types"; import {querySql} from "../../../api/sql"; import {SqlTableSuffix} from "../../../config/sql-table-suffix"; diff --git a/components/webui/client/src/pages/IngestPage/Jobs/sql.ts b/components/webui/client/src/pages/IngestPage/Jobs/sql.ts index d66f41238f..cd1dc20e68 100644 --- a/components/webui/client/src/pages/IngestPage/Jobs/sql.ts +++ b/components/webui/client/src/pages/IngestPage/Jobs/sql.ts @@ -1,4 +1,4 @@ -import {Nullable} from "src/typings/common"; +import {Nullable} from "@webui/common/utility-types"; import {settings} from "../../../settings"; import {COMPRESSION_JOBS_TABLE_COLUMN_NAMES} from "../sqlConfig"; diff --git a/components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlQueryInput/index.tsx b/components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlQueryInput/index.tsx index 4c5d3572e7..283d07ca8a 100644 --- a/components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlQueryInput/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchControls/Presto/SqlQueryInput/index.tsx @@ -5,11 +5,12 @@ import { useState, } from "react"; +import {Nullable} from "@webui/common/utility-types"; + import SqlEditor, {SqlEditorType} from "../../../../../components/SqlEditor"; import useSearchStore from "../../../SearchState/index"; import {SEARCH_UI_STATE} from "../../../SearchState/typings"; import styles from "./index.module.css"; -import {Nullable} from "../../../../../typings/common"; /** diff --git a/components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts b/components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts index 21fb7f2bdb..4661f3c7f1 100644 --- a/components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts +++ b/components/webui/client/src/pages/SearchPage/SearchControls/Presto/presto-search-requests.ts @@ -1,8 +1,11 @@ +import { + type PrestoQueryJob, + type PrestoQueryJobCreation, +} from "@webui/common/schemas/presto-search"; + import { cancelQuery, clearQueryResults, - type PrestoQueryJobCreationSchema, - type PrestoQueryJobSchema, submitQuery, } from "../../../../api/presto-search"; import useSearchStore from "../../SearchState"; @@ -39,7 +42,7 @@ const handlePrestoClearResults = () => { * * @param payload */ -const handlePrestoQuerySubmit = (payload: PrestoQueryJobCreationSchema) => { +const handlePrestoQuerySubmit = (payload: PrestoQueryJobCreation) => { const {updateSearchJobId, updateSearchUiState, searchUiState} = useSearchStore.getState(); // User should NOT be able to submit a new query while an existing query is in progress. @@ -78,7 +81,7 @@ const handlePrestoQuerySubmit = (payload: PrestoQueryJobCreationSchema) => { * * @param payload */ -const handlePrestoQueryCancel = (payload: PrestoQueryJobSchema) => { +const handlePrestoQueryCancel = (payload: PrestoQueryJob) => { const {searchUiState, updateSearchUiState} = useSearchStore.getState(); if (searchUiState !== SEARCH_UI_STATE.QUERYING) { console.error("Cannot cancel query if there is no ongoing query."); diff --git a/components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/CancelButton.tsx b/components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/CancelButton.tsx index 36984d801d..6416e2be04 100644 --- a/components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/CancelButton.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchControls/SearchButton/CancelButton.tsx @@ -32,7 +32,10 @@ const CancelButton = () => { return; } handleQueryCancel( - {searchJobId, aggregationJobId} + { + searchJobId: Number(searchJobId), + aggregationJobId: Number(aggregationJobId), + } ); }, [searchJobId, aggregationJobId]); diff --git a/components/webui/client/src/pages/SearchPage/SearchControls/search-requests.ts b/components/webui/client/src/pages/SearchPage/SearchControls/search-requests.ts index 7d99fa7f9d..998e49ec3a 100644 --- a/components/webui/client/src/pages/SearchPage/SearchControls/search-requests.ts +++ b/components/webui/client/src/pages/SearchPage/SearchControls/search-requests.ts @@ -1,10 +1,12 @@ +import { + type QueryJob, + type QueryJobCreation, +} from "@webui/common/schemas/search"; import {message} from "antd"; import { cancelQuery, clearQueryResults, - QueryJobCreationSchema, - QueryJobSchema, submitQuery, } from "../../../api/search"; import { @@ -40,7 +42,10 @@ const handleClearResults = () => { } clearQueryResults( - {searchJobId, aggregationJobId} + { + searchJobId: Number(searchJobId), + aggregationJobId: Number(aggregationJobId), + } ).catch((err: unknown) => { console.error("Failed to clear query results:", err); }); @@ -51,7 +56,7 @@ const handleClearResults = () => { * * @param payload */ -const handleQuerySubmit = (payload: QueryJobCreationSchema) => { +const handleQuerySubmit = (payload: QueryJobCreation) => { const store = useSearchStore.getState(); // User should NOT be able to submit a new query while an existing query is in progress. @@ -95,8 +100,8 @@ const handleQuerySubmit = (payload: QueryJobCreationSchema) => { submitQuery(payload) .then((result) => { const {searchJobId, aggregationJobId} = result.data; - store.updateSearchJobId(searchJobId); - store.updateAggregationJobId(aggregationJobId); + store.updateSearchJobId(searchJobId.toString()); + store.updateAggregationJobId(aggregationJobId.toString()); store.updateSearchUiState(SEARCH_UI_STATE.QUERYING); console.debug( "Search job created - ", @@ -116,7 +121,7 @@ const handleQuerySubmit = (payload: QueryJobCreationSchema) => { * * @param payload */ -const handleQueryCancel = (payload: QueryJobSchema) => { +const handleQueryCancel = (payload: QueryJob) => { const store = useSearchStore.getState(); if (store.searchUiState !== SEARCH_UI_STATE.QUERYING) { diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx index ca8a9657e8..ba9d5ce923 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/index.tsx @@ -3,7 +3,7 @@ import { useMemo, } from "react"; -import type {PrestoSearchResult} from "@webui/common"; +import type {PrestoSearchResult} from "@webui/common/presto"; import VirtualTable from "../../../../../../components/VirtualTable"; import useSearchStore from "../../../../SearchState/index"; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts index 5a2f54d232..2262830d37 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/usePrestoSearchResults.ts @@ -1,4 +1,4 @@ -import type {PrestoSearchResult} from "@webui/common"; +import type {PrestoSearchResult} from "@webui/common/presto"; import MongoSocketCollection from "../../../../../../api/socket/MongoSocketCollection"; import {useCursor} from "../../../../../../api/socket/useCursor"; diff --git a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts index 3b37abe303..0c66dd5552 100644 --- a/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts +++ b/components/webui/client/src/pages/SearchPage/SearchResults/SearchResultsTable/Presto/PrestoResultsVirtualTable/utils.ts @@ -1,4 +1,4 @@ -import type {PrestoSearchResult} from "@webui/common"; +import type {PrestoSearchResult} from "@webui/common/presto"; import {TableProps} from "antd"; diff --git a/components/webui/client/src/pages/SearchPage/SearchState/index.tsx b/components/webui/client/src/pages/SearchPage/SearchState/index.tsx index 8fc97841bf..a16ca04969 100644 --- a/components/webui/client/src/pages/SearchPage/SearchState/index.tsx +++ b/components/webui/client/src/pages/SearchPage/SearchState/index.tsx @@ -1,5 +1,5 @@ +import {Nullable} from "@webui/common/utility-types"; import dayjs from "dayjs"; -import {Nullable} from "src/typings/common"; import {create} from "zustand"; import {TimelineConfig} from "../../../components/ResultsTimeline/typings"; diff --git a/components/webui/client/src/pages/SearchPage/SearchState/usePseudoProgress.ts b/components/webui/client/src/pages/SearchPage/SearchState/usePseudoProgress.ts index ac978deb33..2f98ee5528 100644 --- a/components/webui/client/src/pages/SearchPage/SearchState/usePseudoProgress.ts +++ b/components/webui/client/src/pages/SearchPage/SearchState/usePseudoProgress.ts @@ -5,7 +5,7 @@ import { useState, } from "react"; -import {Nullable} from "../../../typings/common"; +import {Nullable} from "@webui/common/utility-types"; /** diff --git a/components/webui/client/src/pages/SearchPage/SearchState/useResultsMetadata.ts b/components/webui/client/src/pages/SearchPage/SearchState/useResultsMetadata.ts index 83988797fd..876a0e905b 100644 --- a/components/webui/client/src/pages/SearchPage/SearchState/useResultsMetadata.ts +++ b/components/webui/client/src/pages/SearchPage/SearchState/useResultsMetadata.ts @@ -1,4 +1,4 @@ -import {SearchResultsMetadataDocument} from "@webui/common"; +import {SearchResultsMetadataDocument} from "@webui/common/metadata"; import MongoSocketCollection from "../../../api/socket/MongoSocketCollection"; import {useCursor} from "../../../api/socket/useCursor"; diff --git a/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts b/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts index c989712bbb..0bf86b47cb 100644 --- a/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts +++ b/components/webui/client/src/pages/SearchPage/SearchState/useUpdateStateWithMetadata.ts @@ -3,7 +3,7 @@ import {useEffect} from "react"; import { PRESTO_SEARCH_SIGNAL, SEARCH_SIGNAL, -} from "@webui/common"; +} from "@webui/common/metadata"; import {notification} from "antd"; import useSearchStore from "./index"; diff --git a/components/webui/client/src/typings/query.ts b/components/webui/client/src/typings/query.ts index 0fffe772e9..0b3f386547 100644 --- a/components/webui/client/src/typings/query.ts +++ b/components/webui/client/src/typings/query.ts @@ -1,4 +1,5 @@ import {Type} from "@sinclair/typebox"; +import {QUERY_JOB_TYPE} from "@webui/common/query"; /** @@ -22,16 +23,6 @@ const QUERY_LOADING_STATE_VALUES = Object.freeze( Object.values(QUERY_LOADING_STATE).filter((value) => "number" === typeof value) ); -/** - * Enum of job type, matching the `QueryJobType` class in - * `job_orchestration.query_scheduler.constants`. - */ -enum QUERY_JOB_TYPE { - SEARCH_OR_AGGREGATION = 0, - EXTRACT_IR, - EXTRACT_JSON, -} - /** * Mapping between extract job type enums and stream type. */ @@ -91,7 +82,6 @@ export type {ExtractStreamResp}; export { EXTRACT_JOB_TYPE, ExtractJobSearchParams, - QUERY_JOB_TYPE, QUERY_LOADING_STATE, QUERY_LOADING_STATE_DESCRIPTIONS, QUERY_LOADING_STATE_VALUES, diff --git a/components/webui/client/src/ui/Loading.tsx b/components/webui/client/src/ui/Loading.tsx index e8fd77369f..eb134d7400 100644 --- a/components/webui/client/src/ui/Loading.tsx +++ b/components/webui/client/src/ui/Loading.tsx @@ -10,8 +10,8 @@ import { Typography, } from "@mui/joy"; import {DefaultColorPalette} from "@mui/joy/styles/types"; +import {Nullable} from "@webui/common/utility-types"; -import {Nullable} from "../typings/common"; import { QUERY_LOADING_STATE, QUERY_LOADING_STATE_DESCRIPTIONS, diff --git a/components/webui/client/src/ui/QueryStatus.tsx b/components/webui/client/src/ui/QueryStatus.tsx index 094da2ca83..c2a72c9342 100644 --- a/components/webui/client/src/ui/QueryStatus.tsx +++ b/components/webui/client/src/ui/QueryStatus.tsx @@ -8,10 +8,10 @@ import { AssertError, Value, } from "@sinclair/typebox/value"; +import {Nullable} from "@webui/common/utility-types"; import {isAxiosError} from "axios"; import {submitExtractStreamJob} from "../api/stream-files"; -import {Nullable} from "../typings/common"; import { EXTRACT_JOB_TYPE, ExtractJobSearchParams, diff --git a/components/webui/common/eslint.config.mjs b/components/webui/common/eslint.config.mjs index 858c71ebed..8388c255b3 100644 --- a/components/webui/common/eslint.config.mjs +++ b/components/webui/common/eslint.config.mjs @@ -13,6 +13,17 @@ const EslintConfig = [ CommonConfig, ...TsConfigArray, ...StylisticConfigArray, + { + rules: { + "new-cap": [ + "error", + { + // TypeBox imports + capIsNewExceptionPattern: "^(Type|Value)\\.", + }, + ], + }, + }, ]; diff --git a/components/webui/common/package.json b/components/webui/common/package.json index 78a31783f3..9e9e612d52 100644 --- a/components/webui/common/package.json +++ b/components/webui/common/package.json @@ -2,9 +2,9 @@ "name": "@webui/common", "version": "0.1.0", "exports": { - ".": { - "import": "./dist/index.js", - "types": "./dist/index.d.ts" + "./*": { + "types": "./dist/*.d.ts", + "import": "./dist/*.js" } }, "scripts": { diff --git a/components/webui/common/src/config.ts b/components/webui/common/src/config.ts new file mode 100644 index 0000000000..1b56113857 --- /dev/null +++ b/components/webui/common/src/config.ts @@ -0,0 +1,10 @@ +/** + * CLP query engines. + */ +enum CLP_QUERY_ENGINES { + CLP = "clp", + CLP_S = "clp-s", + PRESTO = "presto", +} + +export {CLP_QUERY_ENGINES}; diff --git a/components/webui/common/src/index.ts b/components/webui/common/src/index.ts deleted file mode 100644 index f14b49e863..0000000000 --- a/components/webui/common/src/index.ts +++ /dev/null @@ -1,177 +0,0 @@ -import {Type} from "@sinclair/typebox"; - - -/** - * Unique ID for each active unique query. Multiple clients can subscribe to the same ID if the - * queries are identical. The ID is also used to represent the socket room, and MongoDB - * change stream. - */ -type QueryId = number; - -/** - * Error response to event. - */ -interface Err { - error: string; - queryId?: QueryId; -} - -/** - * Success response to event. - */ -interface Success { - data: T; -} - -/** - * Event response. - */ -type Response = Err | Success; - - -/** - * Events that the client can emit to the server. - */ -type ClientToServerEvents = { - "disconnect": () => void; - "collection::find::subscribe": ( - requestArgs: { - collectionName: string; - query: object; - options: object; - }, - callback: (res: Response<{queryId: QueryId; initialDocuments: object[]}>) => void) => void; - "collection::find::unsubscribe": ( - requestArgs: { - queryId: QueryId; - } - ) => Promise; -}; - -/** - * Events that the server can emit to the client. - */ -interface ServerToClientEvents { - // eslint-disable-next-line no-warning-comments - // TODO: Consider replacing this with `collection::find::update${number}`, which will - // limit callbacks being triggered in the client to their respective query IDs. - "collection::find::update": (respArgs: { - queryId: QueryId; - data: object[]; - }) => void; -} - -/** - * Empty but required by Socket IO. - */ -// eslint-disable-next-line @typescript-eslint/no-empty-object-type -interface InterServerEvents { -} - -/** - * Collection associated with each socket connection. - */ -interface SocketData { - collectionName?: string; -} - -/** - * Enum of search-related signals. - * - * This includes request and response signals for various search operations and their respective - * states. - */ -enum SEARCH_SIGNAL { - NONE = "none", - - REQ_CANCELLING = "req-cancelling", - REQ_CLEARING = "req-clearing", - REQ_QUERYING = "req-querying", - - RESP_DONE = "resp-done", - RESP_QUERYING = "resp-querying", -} - -/** - * Presto search-related signals. - */ -enum PRESTO_SEARCH_SIGNAL { - WAITING_FOR_PREREQUISITES = "WAITING_FOR_PREREQUISITES", - QUEUED = "QUEUED", - WAITING_FOR_RESOURCES = "WAITING_FOR_RESOURCES", - DISPATCHING = "DISPATCHING", - PLANNING = "PLANNING", - STARTING = "STARTING", - RUNNING = "RUNNING", - FINISHING = "FINISHING", - FINISHED = "FINISHED", - CANCELED = "CANCELED", - FAILED = "FAILED", -} - -/** - * CLP query engines. - */ -enum CLP_QUERY_ENGINES { - CLP = "clp", - CLP_S = "clp-s", - PRESTO = "presto", -} - -/** - * MongoDB document for search results metadata. `numTotalResults` is optional - * since it is only set when the search job is completed. - */ -interface SearchResultsMetadataDocument { - _id: string; - - // eslint-disable-next-line no-warning-comments - // TODO: Replace with Nullable when the `@common` directory refactoring is completed. - errorMsg: string | null; - errorName: string | null; - lastSignal: SEARCH_SIGNAL | PRESTO_SEARCH_SIGNAL; - numTotalResults?: number; - queryEngine: CLP_QUERY_ENGINES; -} - -/** - * Presto row wrapped in a `row` property to prevent conflicts with MongoDB's `_id` field. - */ -interface PrestoRowObject { - row: Record; -} - -/** - * Presto search result in MongoDB. - */ -interface PrestoSearchResult extends PrestoRowObject { - _id: string; -} - -/** - * Test TypeBox schema for testing dependency. - */ -// eslint-disable-next-line no-warning-comments -// TODO: Will be removed once shared server/client route types are migrated into common. -const TestTypeBoxSchema = Type.Object({ - type: Type.String(), -}); - -export { - CLP_QUERY_ENGINES, - PRESTO_SEARCH_SIGNAL, - SEARCH_SIGNAL, - TestTypeBoxSchema, -}; -export type { - ClientToServerEvents, - Err, - InterServerEvents, - PrestoRowObject, - PrestoSearchResult, - QueryId, - Response, - SearchResultsMetadataDocument, - ServerToClientEvents, - SocketData, -}; diff --git a/components/webui/common/src/metadata.ts b/components/webui/common/src/metadata.ts new file mode 100644 index 0000000000..38c3dcbcf2 --- /dev/null +++ b/components/webui/common/src/metadata.ts @@ -0,0 +1,57 @@ +import {CLP_QUERY_ENGINES} from "./config"; +import {Nullable} from "./utility-types"; + + +/** + * Enum of search-related signals. + * + * This includes request and response signals for various search operations and their respective + * states. + */ +enum SEARCH_SIGNAL { + NONE = "none", + + REQ_CANCELLING = "req-cancelling", + REQ_CLEARING = "req-clearing", + REQ_QUERYING = "req-querying", + + RESP_DONE = "resp-done", + RESP_QUERYING = "resp-querying", +} + +/** + * Presto search-related signals. + */ +enum PRESTO_SEARCH_SIGNAL { + WAITING_FOR_PREREQUISITES = "WAITING_FOR_PREREQUISITES", + QUEUED = "QUEUED", + WAITING_FOR_RESOURCES = "WAITING_FOR_RESOURCES", + DISPATCHING = "DISPATCHING", + PLANNING = "PLANNING", + STARTING = "STARTING", + RUNNING = "RUNNING", + FINISHING = "FINISHING", + FINISHED = "FINISHED", + CANCELED = "CANCELED", + FAILED = "FAILED", +} + + +/** + * MongoDB document for search results metadata. `numTotalResults` is optional + * since it is only set when the search job is completed. + */ +interface SearchResultsMetadataDocument { + _id: string; + errorMsg: Nullable; + errorName: Nullable; + lastSignal: SEARCH_SIGNAL | PRESTO_SEARCH_SIGNAL; + numTotalResults?: number; + queryEngine: CLP_QUERY_ENGINES; +} + +export { + PRESTO_SEARCH_SIGNAL, + SEARCH_SIGNAL, +}; +export type {SearchResultsMetadataDocument}; diff --git a/components/webui/common/src/presto.ts b/components/webui/common/src/presto.ts new file mode 100644 index 0000000000..f01c5126da --- /dev/null +++ b/components/webui/common/src/presto.ts @@ -0,0 +1,18 @@ +/** + * Presto row wrapped in a `row` property to prevent conflicts with MongoDB's `_id` field. + */ +interface PrestoRowObject { + row: Record; +} + +/** + * Presto search result in MongoDB. + */ +interface PrestoSearchResult extends PrestoRowObject { + _id: string; +} + +export type { + PrestoRowObject, + PrestoSearchResult, +}; diff --git a/components/webui/common/src/query.ts b/components/webui/common/src/query.ts new file mode 100644 index 0000000000..8ba5eaa74c --- /dev/null +++ b/components/webui/common/src/query.ts @@ -0,0 +1,21 @@ +/** + * Matching the `QueryJobType` class in `job_orchestration.query_scheduler.constants`. + */ +enum QUERY_JOB_TYPE { + SEARCH_OR_AGGREGATION = 0, + EXTRACT_IR, + EXTRACT_JSON, +} + +/** + * List of valid extract job types. + */ +const EXTRACT_JOB_TYPES = new Set([ + QUERY_JOB_TYPE.EXTRACT_IR, + QUERY_JOB_TYPE.EXTRACT_JSON, +]); + +export { + EXTRACT_JOB_TYPES, + QUERY_JOB_TYPE, +}; diff --git a/components/webui/server/src/schemas/archive-metadata.ts b/components/webui/common/src/schemas/archive-metadata.ts similarity index 99% rename from components/webui/server/src/schemas/archive-metadata.ts rename to components/webui/common/src/schemas/archive-metadata.ts index 338d798197..a9fc2ccab5 100644 --- a/components/webui/server/src/schemas/archive-metadata.ts +++ b/components/webui/common/src/schemas/archive-metadata.ts @@ -10,4 +10,5 @@ const SqlSchema = Type.Object({ queryString: StringSchema, }); + export {SqlSchema}; diff --git a/components/webui/server/src/schemas/common.ts b/components/webui/common/src/schemas/common.ts similarity index 100% rename from components/webui/server/src/schemas/common.ts rename to components/webui/common/src/schemas/common.ts diff --git a/components/webui/server/src/schemas/error.ts b/components/webui/common/src/schemas/error.ts similarity index 100% rename from components/webui/server/src/schemas/error.ts rename to components/webui/common/src/schemas/error.ts diff --git a/components/webui/server/src/schemas/presto-search.ts b/components/webui/common/src/schemas/presto-search.ts similarity index 60% rename from components/webui/server/src/schemas/presto-search.ts rename to components/webui/common/src/schemas/presto-search.ts index ec4a92002d..097806b7f7 100644 --- a/components/webui/server/src/schemas/presto-search.ts +++ b/components/webui/common/src/schemas/presto-search.ts @@ -1,4 +1,7 @@ -import {Type} from "@sinclair/typebox"; +import { + Static, + Type, +} from "@sinclair/typebox"; import {StringSchema} from "./common.js"; @@ -17,7 +20,16 @@ const PrestoQueryJobSchema = Type.Object({ searchJobId: StringSchema, }); +type PrestoQueryJobCreation = Static; + +type PrestoQueryJob = Static; + + export { PrestoQueryJobCreationSchema, PrestoQueryJobSchema, }; +export type { + PrestoQueryJob, + PrestoQueryJobCreation, +}; diff --git a/components/webui/server/src/schemas/search.ts b/components/webui/common/src/schemas/search.ts similarity index 76% rename from components/webui/server/src/schemas/search.ts rename to components/webui/common/src/schemas/search.ts index 9be62a4b66..07b6d33d84 100644 --- a/components/webui/server/src/schemas/search.ts +++ b/components/webui/common/src/schemas/search.ts @@ -1,4 +1,7 @@ -import {Type} from "@sinclair/typebox"; +import { + Static, + Type, +} from "@sinclair/typebox"; import { IdSchema, @@ -29,7 +32,15 @@ const QueryJobSchema = Type.Object({ aggregationJobId: IdSchema, }); +type QueryJobCreation = Static; + +type QueryJob = Static; + export { QueryJobCreationSchema, QueryJobSchema, }; +export type { + QueryJob, + QueryJobCreation, +}; diff --git a/components/webui/server/src/schemas/stream-files.ts b/components/webui/common/src/schemas/stream-files.ts similarity index 91% rename from components/webui/server/src/schemas/stream-files.ts rename to components/webui/common/src/schemas/stream-files.ts index bf0c3d3edb..def378bfd4 100644 --- a/components/webui/server/src/schemas/stream-files.ts +++ b/components/webui/common/src/schemas/stream-files.ts @@ -1,6 +1,6 @@ import {Type} from "@sinclair/typebox"; -import {QUERY_JOB_TYPE} from "../typings/query.js"; +import {QUERY_JOB_TYPE} from "../query.js"; import {StringSchema} from "./common.js"; diff --git a/components/webui/common/src/socket.ts b/components/webui/common/src/socket.ts new file mode 100644 index 0000000000..d3e102667c --- /dev/null +++ b/components/webui/common/src/socket.ts @@ -0,0 +1,83 @@ +/** + * Unique ID for each active unique query. Multiple clients can subscribe to the same ID if the + * queries are identical. The ID is also used to represent the socket room, and MongoDB + * change stream. + */ +type QueryId = number; + +/** + * Error response to event. + */ +interface Err { + error: string; + queryId?: QueryId; +} + +/** + * Success response to event. + */ +interface Success { + data: T; +} + +/** + * Event response. + */ +type Response = Err | Success; + + +/** + * Events that the client can emit to the server. + */ +type ClientToServerEvents = { + "disconnect": () => void; + "collection::find::subscribe": ( + requestArgs: { + collectionName: string; + query: object; + options: object; + }, + callback: (res: Response<{queryId: QueryId; initialDocuments: object[]}>) => void) => void; + "collection::find::unsubscribe": ( + requestArgs: { + queryId: QueryId; + } + ) => Promise; +}; + +/** + * Events that the server can emit to the client. + */ +interface ServerToClientEvents { + // eslint-disable-next-line no-warning-comments + // TODO: Consider replacing this with `collection::find::update${number}`, which will + // limit callbacks being triggered in the client to their respective query IDs. + "collection::find::update": (respArgs: { + queryId: QueryId; + data: object[]; + }) => void; +} + +/** + * Empty but required by Socket IO. + */ +// eslint-disable-next-line @typescript-eslint/no-empty-object-type +interface InterServerEvents { +} + +/** + * Collection associated with each socket connection. + */ +interface SocketData { + collectionName?: string; +} + +export type { + ClientToServerEvents, + Err, + InterServerEvents, + QueryId, + Response, + ServerToClientEvents, + SocketData, +}; diff --git a/components/webui/client/src/typings/common.ts b/components/webui/common/src/utility-types.ts similarity index 100% rename from components/webui/client/src/typings/common.ts rename to components/webui/common/src/utility-types.ts diff --git a/components/webui/server/eslint.config.mjs b/components/webui/server/eslint.config.mjs index 214f3aae69..5782f411c4 100644 --- a/components/webui/server/eslint.config.mjs +++ b/components/webui/server/eslint.config.mjs @@ -19,17 +19,7 @@ const EslintConfig = [ "error", { // TypeBox imports - capIsNewExceptions: [ - "Type.Any", - "Type.Enum", - "Type.Integer", - "Type.Literal", - "Type.Null", - "Type.Required", - "Type.Union", - "Value.Errors", - "Value.Parse", - ], + capIsNewExceptionPattern: "^(Type|Value)\\.", }, ], }, diff --git a/components/webui/server/src/plugins/app/Presto.ts b/components/webui/server/src/plugins/app/Presto.ts index c0946778bf..300489fe02 100644 --- a/components/webui/server/src/plugins/app/Presto.ts +++ b/components/webui/server/src/plugins/app/Presto.ts @@ -1,4 +1,4 @@ -import {CLP_QUERY_ENGINES} from "@webui/common"; +import {CLP_QUERY_ENGINES} from "@webui/common/config"; import fp from "fastify-plugin"; import { Client, diff --git a/components/webui/server/src/plugins/app/QueryJobDbManager/index.ts b/components/webui/server/src/plugins/app/QueryJobDbManager/index.ts index 6e84ad5e45..f14f728ec1 100644 --- a/components/webui/server/src/plugins/app/QueryJobDbManager/index.ts +++ b/components/webui/server/src/plugins/app/QueryJobDbManager/index.ts @@ -2,6 +2,7 @@ import {setTimeout} from "node:timers/promises"; import type {MySQLPromisePool} from "@fastify/mysql"; import {encode} from "@msgpack/msgpack"; +import {QUERY_JOB_TYPE} from "@webui/common/query"; import {FastifyInstance} from "fastify"; import fp from "fastify-plugin"; import {ResultSetHeader} from "mysql2"; @@ -10,7 +11,6 @@ import settings from "../../../../settings.json" with {type: "json"}; import { QUERY_JOB_STATUS, QUERY_JOB_STATUS_WAITING_STATES, - QUERY_JOB_TYPE, QUERY_JOBS_TABLE_COLUMN_NAMES, QueryJob, } from "../../../typings/query.js"; diff --git a/components/webui/server/src/plugins/app/S3Manager/index.ts b/components/webui/server/src/plugins/app/S3Manager/index.ts index 7c1b02a667..bea5c995bf 100644 --- a/components/webui/server/src/plugins/app/S3Manager/index.ts +++ b/components/webui/server/src/plugins/app/S3Manager/index.ts @@ -3,10 +3,10 @@ import { S3Client, } from "@aws-sdk/client-s3"; import {getSignedUrl} from "@aws-sdk/s3-request-presigner"; +import {Nullable} from "@webui/common/utility-types"; import fp from "fastify-plugin"; import settings from "../../../../settings.json" with {type: "json"}; -import {Nullable} from "../../../typings/common.js"; import {PRE_SIGNED_URL_EXPIRY_TIME_SECONDS} from "./typings.js"; diff --git a/components/webui/server/src/plugins/app/StreamFileManager.ts b/components/webui/server/src/plugins/app/StreamFileManager.ts index 203f5bc873..aff49ef87f 100644 --- a/components/webui/server/src/plugins/app/StreamFileManager.ts +++ b/components/webui/server/src/plugins/app/StreamFileManager.ts @@ -1,3 +1,5 @@ +import {QUERY_JOB_TYPE} from "@webui/common/query"; +import {Nullable} from "@webui/common/utility-types"; import { FastifyBaseLogger, FastifyInstance, @@ -5,8 +7,6 @@ import { import fp from "fastify-plugin"; import settings from "../../../settings.json" with {type: "json"}; -import {Nullable} from "../../typings/common.js"; -import {QUERY_JOB_TYPE} from "../../typings/query.js"; import { StreamFileMetadata, StreamFilesCollection, diff --git a/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/MongoWatcherCollection.ts b/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/MongoWatcherCollection.ts index 79c6d00ba6..af560d94fe 100644 --- a/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/MongoWatcherCollection.ts +++ b/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/MongoWatcherCollection.ts @@ -1,4 +1,4 @@ -import {QueryId} from "@webui/common"; +import {QueryId} from "@webui/common/socket"; import {FastifyBaseLogger} from "fastify"; import type { Collection, diff --git a/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/index.ts b/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/index.ts index c24d537413..4cd8e4ae16 100644 --- a/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/index.ts +++ b/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/index.ts @@ -13,7 +13,7 @@ import type { Response, ServerToClientEvents, SocketData, -} from "@webui/common"; +} from "@webui/common/socket"; import { FastifyBaseLogger, FastifyInstance, diff --git a/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/typings.ts b/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/typings.ts index 3a525783d9..d08ec34770 100644 --- a/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/typings.ts +++ b/components/webui/server/src/plugins/app/socket/MongoSocketIoServer/typings.ts @@ -3,7 +3,7 @@ import { InterServerEvents, ServerToClientEvents, SocketData, -} from "@webui/common"; +} from "@webui/common/socket"; import { ChangeStream, Document, diff --git a/components/webui/server/src/routes/api/archive-metadata/index.ts b/components/webui/server/src/routes/api/archive-metadata/index.ts index f52a9dc685..8d1076ab26 100644 --- a/components/webui/server/src/routes/api/archive-metadata/index.ts +++ b/components/webui/server/src/routes/api/archive-metadata/index.ts @@ -2,10 +2,9 @@ import { FastifyPluginAsyncTypebox, Type, } from "@fastify/type-provider-typebox"; +import {SqlSchema} from "@webui/common/schemas/archive-metadata"; import {StatusCodes} from "http-status-codes"; -import {SqlSchema} from "../../../schemas/archive-metadata.js"; - /** * Archive metadata API routes. diff --git a/components/webui/server/src/routes/api/presto-search/index.ts b/components/webui/server/src/routes/api/presto-search/index.ts index 66fb603b6a..4dd4331a4c 100644 --- a/components/webui/server/src/routes/api/presto-search/index.ts +++ b/components/webui/server/src/routes/api/presto-search/index.ts @@ -2,19 +2,19 @@ import { FastifyPluginAsyncTypebox, Type, } from "@fastify/type-provider-typebox"; +import {CLP_QUERY_ENGINES} from "@webui/common/config"; import { - CLP_QUERY_ENGINES, PRESTO_SEARCH_SIGNAL, type SearchResultsMetadataDocument, -} from "@webui/common"; -import {StatusCodes} from "http-status-codes"; - -import settings from "../../../../settings.json" with {type: "json"}; -import {ErrorSchema} from "../../../schemas/error.js"; +} from "@webui/common/metadata"; +import {ErrorSchema} from "@webui/common/schemas/error"; import { PrestoQueryJobCreationSchema, PrestoQueryJobSchema, -} from "../../../schemas/presto-search.js"; +} from "@webui/common/schemas/presto-search"; +import {StatusCodes} from "http-status-codes"; + +import settings from "../../../../settings.json" with {type: "json"}; import {MAX_PRESTO_SEARCH_RESULTS} from "./typings.js"; import {insertPrestoRowsToMongo} from "./utils.js"; diff --git a/components/webui/server/src/routes/api/presto-search/utils.ts b/components/webui/server/src/routes/api/presto-search/utils.ts index 4f4f2bcfb5..316537501a 100644 --- a/components/webui/server/src/routes/api/presto-search/utils.ts +++ b/components/webui/server/src/routes/api/presto-search/utils.ts @@ -1,4 +1,4 @@ -import type {PrestoRowObject} from "@webui/common"; +import type {PrestoRowObject} from "@webui/common/presto"; import type { Db, InsertManyResult, diff --git a/components/webui/server/src/routes/api/search/index.ts b/components/webui/server/src/routes/api/search/index.ts index 1f64d5d31f..1090415966 100644 --- a/components/webui/server/src/routes/api/search/index.ts +++ b/components/webui/server/src/routes/api/search/index.ts @@ -2,20 +2,20 @@ import { FastifyPluginAsyncTypebox, Type, } from "@fastify/type-provider-typebox"; +import {CLP_QUERY_ENGINES} from "@webui/common/config"; import { - CLP_QUERY_ENGINES, SEARCH_SIGNAL, type SearchResultsMetadataDocument, -} from "@webui/common"; -import {StatusCodes} from "http-status-codes"; - -import settings from "../../../../settings.json" with {type: "json"}; -import {ErrorSchema} from "../../../schemas/error.js"; +} from "@webui/common/metadata"; +import {QUERY_JOB_TYPE} from "@webui/common/query"; +import {ErrorSchema} from "@webui/common/schemas/error"; import { QueryJobCreationSchema, QueryJobSchema, -} from "../../../schemas/search.js"; -import {QUERY_JOB_TYPE} from "../../../typings/query.js"; +} from "@webui/common/schemas/search"; +import {StatusCodes} from "http-status-codes"; + +import settings from "../../../../settings.json" with {type: "json"}; import {SEARCH_MAX_NUM_RESULTS} from "./typings.js"; import { createMongoIndexes, diff --git a/components/webui/server/src/routes/api/search/typings.ts b/components/webui/server/src/routes/api/search/typings.ts index 8ab7241e5f..86ddbd4ac6 100644 --- a/components/webui/server/src/routes/api/search/typings.ts +++ b/components/webui/server/src/routes/api/search/typings.ts @@ -1,4 +1,4 @@ -import {type SearchResultsMetadataDocument} from "@webui/common"; +import {type SearchResultsMetadataDocument} from "@webui/common/metadata"; import { FastifyBaseLogger, FastifyInstance, diff --git a/components/webui/server/src/routes/api/search/utils.ts b/components/webui/server/src/routes/api/search/utils.ts index 373569860b..a37bf0e19c 100644 --- a/components/webui/server/src/routes/api/search/utils.ts +++ b/components/webui/server/src/routes/api/search/utils.ts @@ -1,4 +1,4 @@ -import {SEARCH_SIGNAL} from "@webui/common"; +import {SEARCH_SIGNAL} from "@webui/common/metadata"; import type {Db} from "mongodb"; import { diff --git a/components/webui/server/src/routes/api/stream-files/index.ts b/components/webui/server/src/routes/api/stream-files/index.ts index 599b5609f1..ac6002cfca 100644 --- a/components/webui/server/src/routes/api/stream-files/index.ts +++ b/components/webui/server/src/routes/api/stream-files/index.ts @@ -1,10 +1,10 @@ import {FastifyPluginAsyncTypebox} from "@fastify/type-provider-typebox"; +import {EXTRACT_JOB_TYPES} from "@webui/common/query"; +import {ErrorSchema} from "@webui/common/schemas/error"; +import {StreamFileExtractionSchema} from "@webui/common/schemas/stream-files"; import {StatusCodes} from "http-status-codes"; import settings from "../../../../settings.json" with {type: "json"}; -import {ErrorSchema} from "../../../schemas/error.js"; -import {StreamFileExtractionSchema} from "../../../schemas/stream-files.js"; -import {EXTRACT_JOB_TYPES} from "../../../typings/query.js"; import {StreamFileMetadataSchema} from "../../../typings/stream-files.js"; diff --git a/components/webui/server/src/typings/common.ts b/components/webui/server/src/typings/common.ts deleted file mode 100644 index 10043cddc1..0000000000 --- a/components/webui/server/src/typings/common.ts +++ /dev/null @@ -1,4 +0,0 @@ -type Nullable = T | null; - - -export type {Nullable}; diff --git a/components/webui/server/src/typings/query.ts b/components/webui/server/src/typings/query.ts index 1cefbe614f..5a08635ced 100644 --- a/components/webui/server/src/typings/query.ts +++ b/components/webui/server/src/typings/query.ts @@ -1,23 +1,7 @@ +import {QUERY_JOB_TYPE} from "@webui/common/query"; import {RowDataPacket} from "mysql2/promise"; -/** - * Matching the `QueryJobType` class in `job_orchestration.query_scheduler.constants`. - */ -enum QUERY_JOB_TYPE { - SEARCH_OR_AGGREGATION = 0, - EXTRACT_IR, - EXTRACT_JSON, -} - -/** - * List of valid extract job types. - */ -const EXTRACT_JOB_TYPES = new Set([ - QUERY_JOB_TYPE.EXTRACT_IR, - QUERY_JOB_TYPE.EXTRACT_JSON, -]); - /** * Matching the `QueryJobStatus` class in * `job_orchestration.query_scheduler.constants`. @@ -64,9 +48,7 @@ interface QueryJob extends RowDataPacket { export type {QueryJob}; export { - EXTRACT_JOB_TYPES, QUERY_JOB_STATUS, QUERY_JOB_STATUS_WAITING_STATES, - QUERY_JOB_TYPE, QUERY_JOBS_TABLE_COLUMN_NAMES, };