Skip to content

Commit 339f1e7

Browse files
authored
Merge pull request #4 from tahini/align_tsp
Align client classes with the TSP specification
2 parents 1a3b29c + 5993f70 commit 339f1e7

File tree

8 files changed

+72
-83
lines changed

8 files changed

+72
-83
lines changed

src/models/entry.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,19 @@ export interface Entry {
1010
id: number;
1111

1212
/**
13-
* Parent entry Id, or -1 if the entry does not have a parent
13+
* Array of string that represant the content of each column
1414
*/
15-
parentId: number;
15+
labels: string[];
1616

1717
/**
18-
* Array of string that represant the content of each column
18+
* Parent entry Id. if unset, the entry does not have a parent
1919
*/
20-
labels: string[];
20+
parentId?: number;
21+
22+
/**
23+
* Indicate if the entry will have row data
24+
*/
25+
hasData?: boolean;
2126

2227
/**
2328
* Style key used to search for a The style map can be obtained by using the style endpoint.
@@ -33,16 +38,20 @@ export interface EntryHeader {
3338
* Displayed name
3439
*/
3540
name: string
41+
/**
42+
* The description of this header field
43+
*/
44+
tooltip: string
3645
}
3746

3847
/**
3948
* Entry model that will be returned by the server
4049
*/
41-
export interface EntryModel<T extends Entry, U extends EntryHeader> {
50+
export interface EntryModel<T extends Entry> {
4251
/**
4352
* Array of entry header
4453
*/
45-
headers: U[];
54+
headers: EntryHeader[];
4655

4756
/**
4857
* Array of entry

src/models/query/query-helper.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,17 @@ export class QueryHelper {
1717
/**
1818
* Starting index key
1919
*/
20-
public static readonly REQUESTED_TABLE_INDEX_KEY: string = 'requested_table_index';
20+
public static readonly REQUESTED_TABLE_INDEX_KEY: string = 'lowIndex';
2121

2222
/**
2323
* Key for the number of element to return
2424
*/
25-
public static readonly REQUESTED_TABLE_COUNT_KEY: string = 'requested_table_count';
25+
public static readonly REQUESTED_TABLE_COUNT_KEY: string = 'size';
2626

2727
/**
2828
* Table column IDs key
2929
*/
30-
public static readonly REQUESTED_COLUMN_IDS_KEY = 'requested_table_column_ids';
30+
public static readonly REQUESTED_COLUMN_IDS_KEY = 'columnIds';
3131

3232
/**
3333
* Build a simple query

src/models/styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export interface OutputElementStyle {
1313
/**
1414
* Style values to override or define properties
1515
*/
16-
styleValues: { [key: string]: any };
16+
values: { [key: string]: any };
1717
}
1818

1919
/**

src/models/table.ts

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ export interface ColumnHeaderEntry {
1515
/**
1616
* Description of the column
1717
*/
18-
columnDescription: string;
18+
description: string;
1919

2020
/**
2121
* Hint on the Type of data associated to the column
2222
*/
23-
columnType: string;
23+
type: string;
2424
}
2525

2626
/**
@@ -58,18 +58,14 @@ export interface Cell {
5858
tags: number;
5959
}
6060

61-
export interface ColumnsModel {
62-
columns: ColumnHeaderEntry[];
63-
}
64-
6561
/**
6662
* Model of a table
6763
*/
6864
export interface TableModel {
6965
/**
7066
* Index of the first returned line
7167
*/
72-
index: number;
68+
lowIndex: number;
7369

7470
/**
7571
* Number of lines

src/models/timegraph.ts

Lines changed: 9 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,15 @@ import { OutputElementStyle } from './styles';
55
* Entry in a time graph
66
*/
77
export interface TimeGraphEntry extends Entry {
8-
/**
9-
* Type of the entry
10-
*/
11-
type: string;
12-
138
/**
149
* Start time of the entry
1510
*/
16-
startTime: number;
11+
start: number;
1712

1813
/**
1914
* End time of the entry
2015
*/
21-
endTime: number;
22-
23-
/**
24-
* Indicate if the entry will have row data
25-
*/
26-
hasRowModel: boolean;
16+
end: number;
2717
}
2818

2919
/**
@@ -55,27 +45,22 @@ export interface TimeGraphState {
5545
/**
5646
* Start time of the state
5747
*/
58-
startTime: number;
48+
start: number;
5949

6050
/**
6151
* End time of the state
6252
*/
63-
duration: number;
53+
end: number;
6454

6555
/**
6656
* Label to apply to the state
6757
*/
68-
label: string;
69-
70-
/**
71-
* Values associated to the state
72-
*/
73-
value: number;
58+
label?: string;
7459

7560
/**
7661
* Tags for the state, used when the state pass a filter
7762
*/
78-
tags: number;
63+
tags?: number;
7964

8065
/**
8166
* Optional information on the style to format this state
@@ -95,22 +80,17 @@ export interface TimeGraphArrow {
9580
/**
9681
* Destination entry Id for the arrow
9782
*/
98-
destinationId: number;
83+
targetId: number;
9984

10085
/**
10186
* Start time of the arrow
10287
*/
103-
startTime: number;
88+
start: number;
10489

10590
/**
10691
* Duration of the arrow
10792
*/
108-
duration: number;
109-
110-
/**
111-
* Value associated to the arrow
112-
*/
113-
value: number;
93+
end: number;
11494

11595
/**
11696
* Optional information on the style to format this arrow

src/models/xy.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export interface XYModel {
1515
/**
1616
* Array of XY series
1717
*/
18-
series: { [key: string]: XYSeries };
18+
series: XYSeries[];
1919
}
2020

2121
/**
@@ -25,22 +25,22 @@ export interface XYSeries {
2525
/**
2626
* Name of the series
2727
*/
28-
name: string;
28+
seriesName: string;
2929

3030
/**
3131
* Ìd of the series
3232
*/
33-
id: string;
33+
seriesId: number;
3434

3535
/**
3636
* Description of the X axis
3737
*/
38-
xAxis: Axis;
38+
xAxis: XYAxis;
3939

4040
/**
4141
* Description of the Y axis
4242
*/
43-
yAxis: Axis;
43+
yAxis: XYAxis;
4444

4545
/**
4646
* Series' X values
@@ -61,14 +61,19 @@ export interface XYSeries {
6161
/**
6262
* Description of an axis for XY chart
6363
*/
64-
export interface Axis {
64+
export interface XYAxis {
6565
/**
6666
* Label of the axis
6767
*/
6868
label: string;
6969

7070
/**
71-
* Type of units used for the axis
71+
* The units used for the axis, to be appended to the numbers
7272
*/
7373
unit: string;
74+
75+
/**
76+
* Type of data for this axis, to give hint on number formatting
77+
*/
78+
dataType: string;
7479
}

src/protocol/tsp-client.ts

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import { Query } from '../models/query/query';
22
import { GenericResponse } from '../models/response/responses';
33
import { XYModel } from '../models/xy';
4-
import { TimeGraphArrow, TimeGraphModel } from '../models/timegraph';
5-
import { TableModel } from '../models/table';
4+
import { TimeGraphEntry, TimeGraphArrow, TimeGraphModel } from '../models/timegraph';
5+
import { TableModel, ColumnHeaderEntry } from '../models/table';
66
import { Trace } from '../models/trace';
77
import { RestClient } from './rest-client';
88
import { Experiment } from '../models/experiment';
@@ -137,24 +137,24 @@ export class TspClient {
137137
* @param expUUID Experiment UUID
138138
* @param outputID Output ID
139139
* @param parameters Query object
140-
* @returns Generic entry response with entries of type T
140+
* @returns Generic entry response with entries
141141
*/
142-
public async fetchXYTree<M extends Entry, H extends EntryHeader>(expUUID: string,
143-
outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<EntryModel<M, H>>>> {
142+
public async fetchXYTree(expUUID: string,
143+
outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<EntryModel<Entry>>>> {
144144
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/XY/' + outputID + '/tree';
145-
return await RestClient.post<GenericResponse<EntryModel<M, H>>>(url, parameters);
145+
return await RestClient.post<GenericResponse<EntryModel<Entry>>>(url, parameters);
146146
}
147147

148148
/**
149149
* Fetch XY. model extends XYModel
150150
* @param expUUID Experiment UUID
151151
* @param outputID Output ID
152152
* @param parameters Query object
153-
* @returns XY model response with the model of type T
153+
* @returns XY model response with the model
154154
*/
155-
public async fetchXY<T extends XYModel>(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<T>>> {
155+
public async fetchXY(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<XYModel>>> {
156156
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/XY/' + outputID + '/xy';
157-
return await RestClient.post<GenericResponse<T>>(url, parameters);
157+
return await RestClient.post<GenericResponse<XYModel>>(url, parameters);
158158
}
159159

160160
/**
@@ -186,36 +186,36 @@ export class TspClient {
186186
* @param expUUID Experiment UUID
187187
* @param outputID Output ID
188188
* @param parameters Query object
189-
* @returns Time graph entry response with entries of type T and headers of type U
189+
* @returns Time graph entry response with entries of type TimeGraphEntry
190190
*/
191-
public async fetchTimeGraphTree<M extends Entry, H extends EntryHeader>(expUUID: string,
192-
outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<EntryModel<M, H>>>> {
191+
public async fetchTimeGraphTree(expUUID: string,
192+
outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<EntryModel<TimeGraphEntry>>>> {
193193
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/timeGraph/' + outputID + '/tree';
194-
return await RestClient.post<GenericResponse<EntryModel<M, H>>>(url, parameters);
194+
return await RestClient.post<GenericResponse<EntryModel<TimeGraphEntry>>>(url, parameters);
195195
}
196196

197197
/**
198198
* Fetch Time Graph states. Model extends TimeGraphModel
199199
* @param expUUID Experiment UUID
200200
* @param outputID Output ID
201201
* @param parameters Query object
202-
* @returns Generic response with the model of type T
202+
* @returns Generic response with the model
203203
*/
204-
public async fetchTimeGraphStates<T extends TimeGraphModel>(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<T>>> {
204+
public async fetchTimeGraphStates(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<TimeGraphModel>>> {
205205
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/timeGraph/' + outputID + '/states';
206-
return await RestClient.post<GenericResponse<T>>(url, parameters);
206+
return await RestClient.post<GenericResponse<TimeGraphModel>>(url, parameters);
207207
}
208208

209209
/**
210210
* Fetch Time Graph arrows. Model extends TimeGraphArrow
211211
* @param expUUID Experiment UUID
212212
* @param outputID Output ID
213213
* @param parameters Query object
214-
* @returns Generic response with the model of type T
214+
* @returns Generic response with the model
215215
*/
216-
public async fetchTimeGraphArrows<T extends TimeGraphArrow>(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<T>>> {
216+
public async fetchTimeGraphArrows(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<TimeGraphArrow>>> {
217217
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/timeGraph/' + outputID + '/arrows';
218-
return await RestClient.post<GenericResponse<T>>(url, parameters);
218+
return await RestClient.post<GenericResponse<TimeGraphArrow>>(url, parameters);
219219
}
220220

221221
/**
@@ -246,35 +246,35 @@ export class TspClient {
246246
* @param expUUID Experiment UUID
247247
* @param outputID Output ID
248248
* @param parameters Query object
249-
* @returns Generic entry response with entries of type T
249+
* @returns Generic entry response with columns headers as model
250250
*/
251-
public async fetchTableColumns<M extends Entry, H extends EntryHeader>(expUUID: string,
252-
outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<EntryModel<M, H>>>> {
251+
public async fetchTableColumns(expUUID: string,
252+
outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<ColumnHeaderEntry[]>>> {
253253
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/table/' + outputID + '/columns';
254-
return await RestClient.post<GenericResponse<EntryModel<M, H>>>(url, parameters);
254+
return await RestClient.post<GenericResponse<ColumnHeaderEntry[]>>(url, parameters);
255255
}
256256

257257
/**
258258
* Fetch Table lines
259259
* @param expUUID Experiment UUID
260260
* @param outputID Output ID
261261
* @param parameters Query object
262-
* @returns Generic response with the model of type T
262+
* @returns Generic response with the model
263263
*/
264-
public async fetchTableLines<T extends TableModel>(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<T>>> {
264+
public async fetchTableLines(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<TableModel>>> {
265265
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/table/' + outputID + '/lines';
266-
return await RestClient.post<GenericResponse<T>>(url, parameters);
266+
return await RestClient.post<GenericResponse<TableModel>>(url, parameters);
267267
}
268268

269269
/**
270270
* Fetch output styles
271271
* @param expUUID Experiment UUID
272272
* @param outputID Output ID
273273
* @param parameters Query object
274-
* @returns Generic response with the model of type T
274+
* @returns Generic response with the model
275275
*/
276-
public async fetchStyles<T extends OutputStyleModel>(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<T>>> {
276+
public async fetchStyles(expUUID: string, outputID: string, parameters: Query): Promise<TspClientResponse<GenericResponse<OutputStyleModel>>> {
277277
const url = this.baseUrl + '/experiments/' + expUUID + '/outputs/' + outputID + '/style';
278-
return await RestClient.post<GenericResponse<T>>(url, parameters);
278+
return await RestClient.post<GenericResponse<OutputStyleModel>>(url, parameters);
279279
}
280280
}

tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"compilerOptions": {
3-
"composite": true,
43
"declaration": true,
54
"declarationMap": true,
65
"sourceMap": true,

0 commit comments

Comments
 (0)