diff --git a/package.json b/package.json index 00b8c6e..950da8e 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,10 @@ "@types/js-yaml": "^4.0.8", "@types/jsonata": "^1.5.1", "@types/lodash": "^4.14.200", + "@types/lz4": "^0.6.4", "@types/node": "^20.8.7", "@types/pascal-case": "^1.1.2", + "@types/stream-json": "^1.7.7", "@types/supertest": "^6.0.2", "@typescript-eslint/eslint-plugin": "^7.1.1", "@typescript-eslint/parser": "^7.1.1", diff --git a/src/controllers/async/asyncquery.ts b/src/controllers/async/asyncquery.ts index eb41c33..2e6559a 100644 --- a/src/controllers/async/asyncquery.ts +++ b/src/controllers/async/asyncquery.ts @@ -12,7 +12,7 @@ import { Telemetry } from "@biothings-explorer/utils"; import ErrorHandler from "../../middlewares/error"; import { Request, Response, NextFunction } from "express"; import { Queue } from "bull"; -import { TrapiQueryGraph, TrapiResponse } from "@biothings-explorer/types"; +import { QueueData, TrapiQueryGraph, TrapiResponse } from "@biothings-explorer/types"; import TRAPIQueryHandler from "@biothings-explorer/query_graph_handler"; import StatusError from "../../utils/errors/status_error"; @@ -20,7 +20,7 @@ export async function asyncquery( req: Request, res: Response, next: NextFunction, - queueData, // TODO: type + queueData: QueueData, queryQueue: Queue, ): Promise { try { @@ -46,7 +46,6 @@ export async function asyncquery( { ...queueData, url: url.replace("status", "response") }, { jobId: jobId, - url: url, timeout: parseInt(process.env.JOB_TIMEOUT ?? (1000 * 60 * 5).toString()), removeOnFail: { age: 24 * 60 * 60, // keep failed jobs for a day (in case user needs to review fail reason) @@ -84,7 +83,7 @@ async function storeQueryResponse(jobID: string, response: TrapiResponse | undef let i = 0; input .pipe(chunker(10000000, { flush: true })) - .on("data", async chunk => { + .on("data", async (chunk: Buffer) => { await redisClient.client.hsetTimeout( `asyncQueryResult:${jobID}:${key}`, String(i++), diff --git a/src/routes/v1/asyncquery_v1.ts b/src/routes/v1/asyncquery_v1.ts index 041eb53..c85a688 100644 --- a/src/routes/v1/asyncquery_v1.ts +++ b/src/routes/v1/asyncquery_v1.ts @@ -32,6 +32,7 @@ class V1AsyncQuery implements BteRoute { next: NextFunction, ) => { const queueData: QueueData = { + route: req.route.path, queryGraph: req.body.message.query_graph, workflow: req.body.workflow, callback_url: req.body.callback, diff --git a/src/routes/v1/asyncquery_v1_by_api.ts b/src/routes/v1/asyncquery_v1_by_api.ts index 6c34ff3..18fc28a 100644 --- a/src/routes/v1/asyncquery_v1_by_api.ts +++ b/src/routes/v1/asyncquery_v1_by_api.ts @@ -13,8 +13,8 @@ const predicatesPath = path.resolve( __dirname, process.env.STATIC_PATH ? `${process.env.STATIC_PATH}/data/predicates.json` : "../../../data/predicates.json", ); -import { Express, NextFunction, Request, RequestHandler, Response } from "express"; -import { QueueData, TaskInfo, TrapiQuery } from "@biothings-explorer/types"; +import { Express, NextFunction, Request, Response } from "express"; +import { QueueData, TaskInfo } from "@biothings-explorer/types"; import { BteRoute } from "../../types"; class V1AsyncQueryByAPI implements BteRoute { @@ -23,6 +23,7 @@ class V1AsyncQueryByAPI implements BteRoute { .route("/v1/smartapi/:smartapi_id/asyncquery") .post(swaggerValidation.validate, async (req: Request, res: Response, next: NextFunction) => { const queueData: QueueData = { + route: req.route.path, queryGraph: req.body.message.query_graph, smartAPIID: req.params.smartapi_id, workflow: req.body.workflow, diff --git a/src/routes/v1/asyncquery_v1_by_team.ts b/src/routes/v1/asyncquery_v1_by_team.ts index 1df0b71..a8d64c5 100644 --- a/src/routes/v1/asyncquery_v1_by_team.ts +++ b/src/routes/v1/asyncquery_v1_by_team.ts @@ -16,17 +16,17 @@ const predicatesPath = path.resolve( ); import { Express, NextFunction, Request, RequestHandler, Response } from "express"; -import { QueueData, TaskInfo, TrapiQuery, TrapiQueryGraph } from "@biothings-explorer/types"; +import { QueueData, TaskInfo } from "@biothings-explorer/types"; -class V1AsyncQueryByTeam { +class V1AsyncQueryByTeam implements BteRoute { setRoutes(app: Express) { app .route("/v1/team/:team_name/asyncquery") .post(swaggerValidation.validate, (async (req: Request, res: Response, next: NextFunction) => { - const queueData = { + const queueData: QueueData = { + route: req.route.path, queryGraph: req.body.message.query_graph, teamName: req.params.team_name, - logLevel: req.body.log_level, workflow: req.body.workflow, callback_url: req.body.callback, options: { @@ -34,7 +34,6 @@ class V1AsyncQueryByTeam { submitter: req.body.submitter, ...req.query, }, - enableIDResolution: true, }; await asyncquery(req, res, next, queueData, global.queryQueue["bte_query_queue_by_team"]); }) as RequestHandler)