From 3602d61d1ba134c2e7e5f4f829db13e66895bbc0 Mon Sep 17 00:00:00 2001 From: Simon Graband Date: Fri, 21 Jul 2023 10:39:50 +0200 Subject: [PATCH] Make TspClient reuseable interface The new interface is called `ITspClient`. `ITspClient` can be used for typing and other implementations. The existing functionality was moved to the `HttpTspClient`. To not break the existing behavior `TspClient` is still exported as an alias for the `HttpTspClient`, but is being deprecated. This way adopters should be notified to migrate to `HttpTspClient`. This makes the package more flexible as different implementations can be provided, e.g. a proxy client in a Theia frontend. Part of https://github.com/eclipse-cdt-cloud/theia-trace-extension/issues/976 Contributed on behalf of STMicroelectronics --- tsp-typescript-client/src/index.ts | 1 + .../src/protocol/http-tsp-client.ts | 519 ++++++++++++++++++ .../src/protocol/tsp-client.test.ts | 6 +- .../src/protocol/tsp-client.ts | 255 +++------ 4 files changed, 609 insertions(+), 172 deletions(-) create mode 100644 tsp-typescript-client/src/protocol/http-tsp-client.ts diff --git a/tsp-typescript-client/src/index.ts b/tsp-typescript-client/src/index.ts index 3ceff8d..5ef4b80 100644 --- a/tsp-typescript-client/src/index.ts +++ b/tsp-typescript-client/src/index.ts @@ -12,5 +12,6 @@ export * from './models/trace'; export * from './models/xy'; export * from './models/styles'; export * from './protocol/tsp-client'; +export * from './protocol/http-tsp-client'; export * from './protocol/rest-client'; export * from './protocol/tsp-client-response'; diff --git a/tsp-typescript-client/src/protocol/http-tsp-client.ts b/tsp-typescript-client/src/protocol/http-tsp-client.ts new file mode 100644 index 0000000..abe5d9f --- /dev/null +++ b/tsp-typescript-client/src/protocol/http-tsp-client.ts @@ -0,0 +1,519 @@ +import { Query } from "../models/query/query"; +import { GenericResponse } from "../models/response/responses"; +import { XyEntry, XYModel } from "../models/xy"; +import { + TimeGraphEntry, + TimeGraphArrow, + TimeGraphModel, +} from "../models/timegraph"; +import { + AnnotationCategoriesModel, + AnnotationModel, +} from "../models/annotation"; +import { TableModel, ColumnHeaderEntry } from "../models/table"; +import { Trace } from "../models/trace"; +import { RestClient } from "./rest-client"; +import { Experiment } from "../models/experiment"; +import { OutputDescriptor } from "../models/output-descriptor"; +import { EntryModel, Entry } from "../models/entry"; +import { TspClientResponse } from "./tsp-client-response"; +import { OutputStyleModel } from "../models/styles"; +import { HealthStatus } from "../models/health"; +import { MarkerSet } from "../models/markerset"; +import { array } from "./serialization"; +import { DataTreeEntry } from "../models/data-tree"; +import { ITspClient } from "./tsp-client"; + +/** + * Http request implementation, using the RestClient helper, of the Trace Server Protocol client + */ +export class HttpTspClient implements ITspClient { + private baseUrl: string; + + /** + * Constructor + * @param baseUrl Base URL of the server (ex. https://localhost:8080/tsp/api) + */ + public constructor(baseUrl: string) { + this.baseUrl = baseUrl; + } + + /** + * Fetch all available traces on the server + * @returns List of Trace + */ + public async fetchTraces(): Promise> { + const url = this.baseUrl + "/traces"; + return RestClient.get(url, undefined, array(Trace)); + } + + /** + * Fetch a specific trace information + * @param traceUUID Trace UUID to fetch + */ + public async fetchTrace( + traceUUID: string + ): Promise> { + const url = this.baseUrl + "/traces/" + traceUUID; + return RestClient.get(url, undefined, Trace); + } + + /** + * Open a trace on the server + * @param parameters Query object + * @returns The opened trace + */ + public async openTrace( + parameters: Query + ): Promise> { + const url = this.baseUrl + "/traces"; + return RestClient.post(url, parameters, Trace); + } + + /** + * Delete a trace on the server + * @param traceUUID Trace UUID to delete + * @param deleteTrace Also delete the trace from disk + * @param removeCache Remove all cache for this trace + * @returns The deleted trace + */ + public async deleteTrace( + traceUUID: string, + deleteTrace?: boolean, + removeCache?: boolean + ): Promise> { + const url = this.baseUrl + "/traces/" + traceUUID; + const deleteParameters: Map = new Map(); + if (deleteTrace) { + deleteParameters.set("deleteTrace", deleteTrace.toString()); + } + if (removeCache) { + deleteParameters.set("removeCache", removeCache.toString()); + } + return RestClient.delete(url, deleteParameters, Trace); + } + + /** + * Fetch all available experiments on the server + * @returns List of Experiment + */ + public async fetchExperiments(): Promise> { + const url = this.baseUrl + "/experiments"; + return RestClient.get(url, undefined, array(Experiment)); + } + + /** + * Fetch a specific experiment information + * @param expUUID Experiment UUID to fetch + * @returns The experiment + */ + public async fetchExperiment( + expUUID: string + ): Promise> { + const url = this.baseUrl + "/experiments/" + expUUID; + return RestClient.get(url, undefined, Experiment); + } + + /** + * Create an experiment on the server + * @param parameters Query object + * @returns The created experiment + */ + public async createExperiment( + parameters: Query + ): Promise> { + const url = this.baseUrl + "/experiments"; + return RestClient.post(url, parameters, Experiment); + } + + /** + * Update an experiment + * @param expUUID Experiment UUID to update + * @param parameters Query object + * @returns The updated experiment + */ + public async updateExperiment( + expUUID: string, + parameters: Query + ): Promise> { + const url = this.baseUrl + "/experiments/" + expUUID; + return RestClient.put(url, parameters, Experiment); + } + + /** + * Delete an experiment on the server + * @param expUUID Experiment UUID to delete + * @returns The deleted experiment + */ + public async deleteExperiment( + expUUID: string + ): Promise> { + const url = this.baseUrl + "/experiments/" + expUUID; + return RestClient.delete(url, undefined, Experiment); + } + + /** + * List all the outputs associated to this experiment + * @param expUUID Experiment UUID + * @returns List of OutputDescriptor + */ + public async experimentOutputs( + expUUID: string + ): Promise> { + const url = this.baseUrl + "/experiments/" + expUUID + "/outputs"; + return RestClient.get(url, undefined, array(OutputDescriptor)); + } + + /** + * Fetch Data tree + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Generic entry response with entries + */ + public async fetchDataTree( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/data/" + + outputID + + "/tree"; + return RestClient.post( + url, + parameters, + GenericResponse(EntryModel(DataTreeEntry)) + ); + } + + /** + * Fetch XY tree + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Generic entry response with entries + */ + public async fetchXYTree( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/XY/" + + outputID + + "/tree"; + return RestClient.post( + url, + parameters, + GenericResponse(EntryModel(Entry)) + ); + } + + /** + * Fetch XY. model extends XYModel + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns XY model response with the model + */ + public async fetchXY( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/XY/" + + outputID + + "/xy"; + return RestClient.post(url, parameters, GenericResponse(XYModel)); + } + + /** + * Fetch XY tooltip + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param xValue X value + * @param yValue Optional Y value + * @param seriesID Optional series ID + * @returns Map of key=name of the property and value=string value associated + */ + public async fetchXYToolTip( + expUUID: string, + outputID: string, + xValue: number, + yValue?: number, + seriesID?: string + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/XY/" + + outputID + + "/tooltip"; + + const parametersMap: Map = new Map(); + parametersMap.set("xValue", xValue.toString()); + if (yValue) { + parametersMap.set("yValue", yValue.toString()); + } + if (seriesID) { + parametersMap.set("seriesId", seriesID); + } + return RestClient.get(url, parametersMap); + } + + /** + * Fetch Time Graph tree, Model extends TimeGraphEntry + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Time graph entry response with entries of type TimeGraphEntry + */ + public async fetchTimeGraphTree( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/timeGraph/" + + outputID + + "/tree"; + return RestClient.post( + url, + parameters, + GenericResponse(EntryModel(TimeGraphEntry)) + ); + } + + /** + * Fetch Time Graph states. Model extends TimeGraphModel + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Generic response with the model + */ + public async fetchTimeGraphStates( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/timeGraph/" + + outputID + + "/states"; + return RestClient.post( + url, + parameters, + GenericResponse(TimeGraphModel) + ); + } + + /** + * Fetch Time Graph arrows. Model extends TimeGraphArrow + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Generic response with the model + */ + public async fetchTimeGraphArrows( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/timeGraph/" + + outputID + + "/arrows"; + return RestClient.post( + url, + parameters, + GenericResponse(array(TimeGraphArrow)) + ); + } + + /** + * Fetch marker sets. + * @returns Generic response with the model + */ + public async fetchMarkerSets( + expUUID: string + ): Promise>> { + const url = + this.baseUrl + "/experiments/" + expUUID + "/outputs/markerSets"; + return RestClient.get(url); + } + + /** + * Fetch annotations categories. + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param markerSetId Marker Set ID + * @returns Generic response with the model + */ + public async fetchAnnotationsCategories( + expUUID: string, + outputID: string, + markerSetId?: string + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/" + + outputID + + "/annotations"; + let parametersMap: Map | undefined = undefined; + if (markerSetId) { + parametersMap = new Map(); + parametersMap.set("markerSetId", markerSetId); + } + return RestClient.get(url, parametersMap); + } + + /** + * Fetch annotations. + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Generic response with the model + */ + public async fetchAnnotations( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/" + + outputID + + "/annotations"; + return RestClient.post( + url, + parameters, + GenericResponse(AnnotationModel) + ); + } + + /** + * Fetch tooltip for a Time Graph element. + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Map of key=name of the property and value=string value associated + */ + public async fetchTimeGraphTooltip( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/timeGraph/" + + outputID + + "/tooltip"; + return RestClient.post(url, parameters); + } + + /** + * Fetch Table columns + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Generic entry response with columns headers as model + */ + public async fetchTableColumns( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/table/" + + outputID + + "/columns"; + return RestClient.post( + url, + parameters, + GenericResponse(array(ColumnHeaderEntry)) + ); + } + + /** + * Fetch Table lines + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Generic response with the model + */ + public async fetchTableLines( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/table/" + + outputID + + "/lines"; + return RestClient.post(url, parameters, GenericResponse(TableModel)); + } + + /** + * Fetch output styles + * @param expUUID Experiment UUID + * @param outputID Output ID + * @param parameters Query object + * @returns Generic response with the model + */ + public async fetchStyles( + expUUID: string, + outputID: string, + parameters: Query + ): Promise>> { + const url = + this.baseUrl + + "/experiments/" + + expUUID + + "/outputs/" + + outputID + + "/style"; + return RestClient.post(url, parameters); + } + + /** + * Check the health status of the server + * @returns The Health Status + */ + public async checkHealth(): Promise> { + const url = this.baseUrl + "/health"; + return RestClient.get(url); + } +} diff --git a/tsp-typescript-client/src/protocol/tsp-client.test.ts b/tsp-typescript-client/src/protocol/tsp-client.test.ts index e45ed7d..4aadf5e 100644 --- a/tsp-typescript-client/src/protocol/tsp-client.test.ts +++ b/tsp-typescript-client/src/protocol/tsp-client.test.ts @@ -4,12 +4,12 @@ import { Headers } from 'node-fetch'; import { Query } from '../models/query/query'; import { HttpRequest, HttpResponse, RestClient } from './rest-client'; import { FixtureSet } from './test-utils'; -import { TspClient } from './tsp-client'; +import { HttpTspClient } from './http-tsp-client'; import { DataType } from '../models/data-type'; -describe('TspClient Deserialization', () => { +describe('HttpTspClient Deserialization', () => { - const client = new TspClient('not-relevant'); + const client = new HttpTspClient('not-relevant'); const httpRequestMock = jest.fn, [req: HttpRequest]>(); let fixtures: FixtureSet; diff --git a/tsp-typescript-client/src/protocol/tsp-client.ts b/tsp-typescript-client/src/protocol/tsp-client.ts index 932fb52..ac82ad2 100644 --- a/tsp-typescript-client/src/protocol/tsp-client.ts +++ b/tsp-typescript-client/src/protocol/tsp-client.ts @@ -1,62 +1,55 @@ -import { Query } from '../models/query/query'; -import { GenericResponse } from '../models/response/responses'; -import { XyEntry, XYModel } from '../models/xy'; -import { TimeGraphEntry, TimeGraphArrow, TimeGraphModel } from '../models/timegraph'; -import { AnnotationCategoriesModel, AnnotationModel } from '../models/annotation'; -import { TableModel, ColumnHeaderEntry } from '../models/table'; -import { Trace } from '../models/trace'; -import { RestClient } from './rest-client'; -import { Experiment } from '../models/experiment'; -import { OutputDescriptor } from '../models/output-descriptor'; -import { EntryModel, Entry } from '../models/entry'; -import { TspClientResponse } from './tsp-client-response'; -import { OutputStyleModel } from '../models/styles'; -import { HealthStatus } from '../models/health'; -import { MarkerSet } from '../models/markerset'; -import { array } from './serialization'; -import { DataTreeEntry } from '../models/data-tree'; +import { Query } from "../models/query/query"; +import { GenericResponse } from "../models/response/responses"; +import { XyEntry, XYModel } from "../models/xy"; +import { + TimeGraphEntry, + TimeGraphArrow, + TimeGraphModel, +} from "../models/timegraph"; +import { + AnnotationCategoriesModel, + AnnotationModel, +} from "../models/annotation"; +import { TableModel, ColumnHeaderEntry } from "../models/table"; +import { Trace } from "../models/trace"; +import { Experiment } from "../models/experiment"; +import { OutputDescriptor } from "../models/output-descriptor"; +import { EntryModel } from "../models/entry"; +import { TspClientResponse } from "./tsp-client-response"; +import { OutputStyleModel } from "../models/styles"; +import { HealthStatus } from "../models/health"; +import { MarkerSet } from "../models/markerset"; +import { DataTreeEntry } from "../models/data-tree"; +import { HttpTspClient } from "./http-tsp-client"; + +// Export both const and type to allow TspClient to be used as constructor and type +/** @deprecated use {@link HttpTspClient} directly instead. */ +export const TspClient = HttpTspClient; +/** @deprecated use {@link HttpTspClient} directly instead. */ +export type TspClient = HttpTspClient; /** - * Trace Server Protocol client + * Trace Server Protocol client interface */ -export class TspClient { - private baseUrl: string; - - /** - * Constructor - * @param baseUrl Base URL of the server (ex. https://localhost:8080/tsp/api) - */ - public constructor(baseUrl: string) { - this.baseUrl = baseUrl; - } - +export interface ITspClient { /** * Fetch all available traces on the server * @returns List of Trace */ - public async fetchTraces(): Promise> { - const url = this.baseUrl + '/traces'; - return RestClient.get(url, undefined, array(Trace)); - } + fetchTraces(): Promise>; /** * Fetch a specific trace information * @param traceUUID Trace UUID to fetch */ - public async fetchTrace(traceUUID: string): Promise> { - const url = this.baseUrl + '/traces/' + traceUUID; - return RestClient.get(url, undefined, Trace); - } + fetchTrace(traceUUID: string): Promise>; /** * Open a trace on the server * @param parameters Query object * @returns The opened trace */ - public async openTrace(parameters: Query): Promise> { - const url = this.baseUrl + '/traces'; - return RestClient.post(url, parameters, Trace); - } + openTrace(parameters: Query): Promise>; /** * Delete a trace on the server @@ -65,46 +58,31 @@ export class TspClient { * @param removeCache Remove all cache for this trace * @returns The deleted trace */ - public async deleteTrace(traceUUID: string, deleteTrace?: boolean, removeCache?: boolean): Promise> { - const url = this.baseUrl + '/traces/' + traceUUID; - const deleteParameters: Map = new Map(); - if (deleteTrace) { - deleteParameters.set('deleteTrace', deleteTrace.toString()); - } - if (removeCache) { - deleteParameters.set('removeCache', removeCache.toString()); - } - return RestClient.delete(url, deleteParameters, Trace); - } + deleteTrace( + traceUUID: string, + deleteTrace?: boolean, + removeCache?: boolean + ): Promise>; /** * Fetch all available experiments on the server * @returns List of Experiment */ - public async fetchExperiments(): Promise> { - const url = this.baseUrl + '/experiments'; - return RestClient.get(url, undefined, array(Experiment)); - } + fetchExperiments(): Promise>; /** * Fetch a specific experiment information * @param expUUID Experiment UUID to fetch * @returns The experiment */ - public async fetchExperiment(expUUID: string): Promise> { - const url = this.baseUrl + '/experiments/' + expUUID; - return RestClient.get(url, undefined, Experiment); - } + fetchExperiment(expUUID: string): Promise>; /** * Create an experiment on the server * @param parameters Query object * @returns The created experiment */ - public async createExperiment(parameters: Query): Promise> { - const url = this.baseUrl + '/experiments'; - return RestClient.post(url, parameters, Experiment); - } + createExperiment(parameters: Query): Promise>; /** * Update an experiment @@ -112,30 +90,26 @@ export class TspClient { * @param parameters Query object * @returns The updated experiment */ - public async updateExperiment(expUUID: string, parameters: Query): Promise> { - const url = this.baseUrl + '/experiments/' + expUUID; - return RestClient.put(url, parameters, Experiment); - } + updateExperiment( + expUUID: string, + parameters: Query + ): Promise>; /** * Delete an experiment on the server * @param expUUID Experiment UUID to delete * @returns The deleted experiment */ - public async deleteExperiment(expUUID: string): Promise> { - const url = this.baseUrl + '/experiments/' + expUUID; - return RestClient.delete(url, undefined, Experiment); - } + deleteExperiment(expUUID: string): Promise>; /** * List all the outputs associated to this experiment * @param expUUID Experiment UUID * @returns List of OutputDescriptor */ - public async experimentOutputs(expUUID: string): Promise> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs'; - return RestClient.get(url, undefined, array(OutputDescriptor)); - } + experimentOutputs( + expUUID: string + ): Promise>; /** * Fetch Data tree @@ -144,14 +118,11 @@ export class TspClient { * @param parameters Query object * @returns Generic entry response with entries */ - public async fetchDataTree( + fetchDataTree( expUUID: string, outputID: string, - parameters: Query, - ): Promise>>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/data/' + outputID + '/tree'; - return RestClient.post(url, parameters, GenericResponse(EntryModel(DataTreeEntry))); - } + parameters: Query + ): Promise>>>; /** * Fetch XY tree @@ -160,14 +131,11 @@ export class TspClient { * @param parameters Query object * @returns Generic entry response with entries */ - public async fetchXYTree( + fetchXYTree( expUUID: string, outputID: string, - parameters: Query, - ): Promise>>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/XY/' + outputID + '/tree'; - return RestClient.post(url, parameters, GenericResponse(EntryModel(Entry))); - } + parameters: Query + ): Promise>>>; /** * Fetch XY. model extends XYModel @@ -176,14 +144,11 @@ export class TspClient { * @param parameters Query object * @returns XY model response with the model */ - public async fetchXY( + fetchXY( expUUID: string, outputID: string, - parameters: Query, - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/XY/' + outputID + '/xy'; - return RestClient.post(url, parameters, GenericResponse(XYModel)); - } + parameters: Query + ): Promise>>; /** * Fetch XY tooltip @@ -194,25 +159,13 @@ export class TspClient { * @param seriesID Optional series ID * @returns Map of key=name of the property and value=string value associated */ - public async fetchXYToolTip( + fetchXYToolTip( expUUID: string, outputID: string, xValue: number, yValue?: number, - seriesID?: string, - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/XY/' + outputID + '/tooltip'; - - const parametersMap: Map = new Map(); - parametersMap.set('xValue', xValue.toString()); - if (yValue) { - parametersMap.set('yValue', yValue.toString()); - } - if (seriesID) { - parametersMap.set('seriesId', seriesID); - } - return RestClient.get(url, parametersMap); - } + seriesID?: string + ): Promise>>; /** * Fetch Time Graph tree, Model extends TimeGraphEntry @@ -221,14 +174,11 @@ export class TspClient { * @param parameters Query object * @returns Time graph entry response with entries of type TimeGraphEntry */ - public async fetchTimeGraphTree( + fetchTimeGraphTree( expUUID: string, outputID: string, parameters: Query - ): Promise>>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/timeGraph/' + outputID + '/tree'; - return RestClient.post(url, parameters, GenericResponse(EntryModel(TimeGraphEntry))); - } + ): Promise>>>; /** * Fetch Time Graph states. Model extends TimeGraphModel @@ -237,14 +187,11 @@ export class TspClient { * @param parameters Query object * @returns Generic response with the model */ - public async fetchTimeGraphStates( + fetchTimeGraphStates( expUUID: string, outputID: string, parameters: Query - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/timeGraph/' + outputID + '/states'; - return RestClient.post(url, parameters, GenericResponse(TimeGraphModel)); - } + ): Promise>>; /** * Fetch Time Graph arrows. Model extends TimeGraphArrow @@ -253,23 +200,19 @@ export class TspClient { * @param parameters Query object * @returns Generic response with the model */ - public async fetchTimeGraphArrows( + fetchTimeGraphArrows( expUUID: string, outputID: string, parameters: Query - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/timeGraph/' + outputID + '/arrows'; - return RestClient.post(url, parameters, GenericResponse(array(TimeGraphArrow))); - } + ): Promise>>; /** * Fetch marker sets. * @returns Generic response with the model */ - public async fetchMarkerSets(expUUID: string): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/markerSets'; - return RestClient.get(url, undefined); - } + fetchMarkerSets( + expUUID: string + ): Promise>>; /** * Fetch annotations categories. @@ -278,19 +221,11 @@ export class TspClient { * @param markerSetId Marker Set ID * @returns Generic response with the model */ - public async fetchAnnotationsCategories( + fetchAnnotationsCategories( expUUID: string, outputID: string, - markerSetId?: string, - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/annotations'; - let parametersMap: Map | undefined = undefined; - if (markerSetId) { - parametersMap = new Map(); - parametersMap.set('markerSetId', markerSetId); - } - return RestClient.get(url, parametersMap); - } + markerSetId?: string + ): Promise>>; /** * Fetch annotations. @@ -299,14 +234,11 @@ export class TspClient { * @param parameters Query object * @returns Generic response with the model */ - public async fetchAnnotations( + fetchAnnotations( expUUID: string, outputID: string, parameters: Query - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/annotations'; - return RestClient.post(url, parameters, GenericResponse(AnnotationModel)); - } + ): Promise>>; /** * Fetch tooltip for a Time Graph element. @@ -315,14 +247,11 @@ export class TspClient { * @param parameters Query object * @returns Map of key=name of the property and value=string value associated */ - public async fetchTimeGraphTooltip( + fetchTimeGraphTooltip( expUUID: string, outputID: string, parameters: Query - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/timeGraph/' + outputID + '/tooltip'; - return RestClient.post(url, parameters); - } + ): Promise>>; /** * Fetch Table columns @@ -331,14 +260,11 @@ export class TspClient { * @param parameters Query object * @returns Generic entry response with columns headers as model */ - public async fetchTableColumns( + fetchTableColumns( expUUID: string, outputID: string, parameters: Query - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/table/' + outputID + '/columns'; - return RestClient.post(url, parameters, GenericResponse(array(ColumnHeaderEntry))); - } + ): Promise>>; /** * Fetch Table lines @@ -347,14 +273,11 @@ export class TspClient { * @param parameters Query object * @returns Generic response with the model */ - public async fetchTableLines( + fetchTableLines( expUUID: string, outputID: string, parameters: Query - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/table/' + outputID + '/lines'; - return RestClient.post(url, parameters, GenericResponse(TableModel)); - } + ): Promise>>; /** * Fetch output styles @@ -363,21 +286,15 @@ export class TspClient { * @param parameters Query object * @returns Generic response with the model */ - public async fetchStyles( + fetchStyles( expUUID: string, outputID: string, - parameters: Query, - ): Promise>> { - const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/style'; - return RestClient.post(url, parameters); - } + parameters: Query + ): Promise>>; /** * Check the health status of the server * @returns The Health Status */ - public async checkHealth(): Promise> { - const url = this.baseUrl + '/health'; - return RestClient.get(url); - } + checkHealth(): Promise>; }