Skip to content

Commit 9c79588

Browse files
haoadoreorangehaoadoresorange
authored andcommitted
Add type to schemas
Signed-off-by: Quoc-Hao Tran <[email protected]>
1 parent d8e23e4 commit 9c79588

File tree

14 files changed

+25
-26
lines changed

14 files changed

+25
-26
lines changed

tsp-typescript-client/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"dependencies": {
2424
"node-fetch": "^2.5.0",
2525
"rimraf": "latest",
26-
"when-json-met-bigint": "^0.21.0"
26+
"when-json-met-bigint": "^0.25.0"
2727
},
2828
"scripts": {
2929
"prepare": "yarn run clean && yarn run build",

tsp-typescript-client/src/models/annotation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface AnnotationCategoriesModel {
1111
annotationCategories: string[];
1212
}
1313

14-
export const AnnotationSchema: Schema = {
14+
export const AnnotationSchema: Schema<AnnotationModel> = {
1515
annotations: {
1616
[Symbol.for(`any`)]: [{
1717
duration: bigint,

tsp-typescript-client/src/models/bookmark.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Schema } from 'when-json-met-bigint';
22
import { bigint } from '../protocol/serialization';
33

4-
export const BookmarkSchema: Schema = {
4+
export const BookmarkSchema: Schema<Bookmark> = {
55
endTime: bigint,
66
startTime: bigint,
77
};

tsp-typescript-client/src/models/entry.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Schema } from 'when-json-met-bigint';
22
import { assertNumber } from '../protocol/serialization';
33
import { OutputElementStyle } from './styles';
44

5-
export const EntrySchema: Schema = {
5+
export const EntrySchema: Schema<Entry> = {
66
id: assertNumber,
77
parentId: assertNumber,
88
};
@@ -52,7 +52,7 @@ export interface EntryHeader {
5252
tooltip: string
5353
}
5454

55-
export const EntryModelSchema = (schema: Schema): Schema => ({ entries: [schema] });
55+
export const EntryModelSchema = <T extends Entry>(schema: Schema<T>): Schema<EntryModel<T>> => ({ entries: [schema] });
5656

5757
/**
5858
* Entry model that will be returned by the server

tsp-typescript-client/src/models/experiment.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Schema } from 'when-json-met-bigint';
22
import { assertNumber, bigint } from '../protocol/serialization';
33
import { TraceSchema, Trace } from './trace';
44

5-
export const ExperimentSchema: Schema = {
5+
export const ExperimentSchema: Schema<Experiment> = {
66
end: bigint,
77
nbEvents: assertNumber,
88
start: bigint,

tsp-typescript-client/src/models/output-descriptor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Schema } from 'when-json-met-bigint';
22
import { bigint } from '../protocol/serialization';
33

4-
export const OutputDescriptorSchema: Schema = {
4+
export const OutputDescriptorSchema: Schema<OutputDescriptor> = {
55
end: bigint,
66
start: bigint,
77
};

tsp-typescript-client/src/models/response/responses.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export enum ResponseStatus {
2424
CANCELLED = 'CANCELLED'
2525
}
2626

27-
export const GenericResponseSchema = (schema: Schema): Schema => ({ model: schema });
27+
export const GenericResponseSchema = <T>(schema: Schema<T>): Schema<GenericResponse<T>> => ({ model: schema });
2828

2929
/**
3030
* Generic response that contains a model

tsp-typescript-client/src/models/table.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Schema } from 'when-json-met-bigint';
22
import { assertNumber } from '../protocol/serialization';
33

4-
export const ColumnHeaderEntrySchema: Schema = {
4+
export const ColumnHeaderEntrySchema: Schema<ColumnHeaderEntry> = {
55
id: assertNumber,
66
};
77

@@ -30,7 +30,7 @@ export interface ColumnHeaderEntry {
3030
type: string;
3131
}
3232

33-
export const CellSchema: Schema = {
33+
export const CellSchema: Schema<Cell> = {
3434
tags: assertNumber,
3535
};
3636

@@ -49,7 +49,7 @@ export interface Cell {
4949
tags?: number;
5050
}
5151

52-
export const LineSchema = {
52+
export const LineSchema: Schema<Line> = {
5353
cells: [CellSchema],
5454
index: assertNumber,
5555
tags: assertNumber,
@@ -75,7 +75,7 @@ export interface Line {
7575
tags?: number;
7676
}
7777

78-
export const TableModelSchema = {
78+
export const TableModelSchema: Schema<TableModel> = {
7979
columnIds: [assertNumber],
8080
lines: [LineSchema],
8181
lowIndex: assertNumber,

tsp-typescript-client/src/models/timegraph.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { assertNumber, bigint } from '../protocol/serialization';
33
import { Entry } from './entry';
44
import { OutputElementStyle } from './styles';
55

6-
export const TimeGraphEntrySchema: Schema = {
6+
export const TimeGraphEntrySchema: Schema<TimeGraphEntry> = {
77
end: bigint,
88
id: assertNumber,
99
parentId: assertNumber,
@@ -25,7 +25,7 @@ export interface TimeGraphEntry extends Entry {
2525
end: bigint;
2626
}
2727

28-
const TimeGraphStateSchema: Schema = {
28+
const TimeGraphStateSchema: Schema<TimeGraphState> = {
2929
end: bigint,
3030
start: bigint,
3131
tags: assertNumber,
@@ -61,7 +61,7 @@ export interface TimeGraphState {
6161
style?: OutputElementStyle;
6262
}
6363

64-
export const TimeGraphRowSchema: Schema = {
64+
export const TimeGraphRowSchema: Schema<TimeGraphRow> = {
6565
entryId: assertNumber,
6666
states: [TimeGraphStateSchema],
6767
};
@@ -81,7 +81,7 @@ export interface TimeGraphRow {
8181
states: TimeGraphState[];
8282
}
8383

84-
export const TimeGraphModelSchema: Schema = {
84+
export const TimeGraphModelSchema: Schema<TimeGraphModel> = {
8585
rows: [TimeGraphRowSchema],
8686
};
8787

@@ -92,7 +92,7 @@ export interface TimeGraphModel {
9292
rows: TimeGraphRow[];
9393
}
9494

95-
export const TimeGraphArrowSchema: Schema = {
95+
export const TimeGraphArrowSchema: Schema<TimeGraphArrow> = {
9696
end: bigint,
9797
sourceId: assertNumber,
9898
start: bigint,

tsp-typescript-client/src/models/trace.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Schema } from 'when-json-met-bigint';
22
import { assertNumber, bigint } from '../protocol/serialization';
33

4-
export const TraceSchema: Schema = {
4+
export const TraceSchema: Schema<Trace> = {
55
end: bigint,
66
nbEvents: assertNumber,
77
start: bigint,

0 commit comments

Comments
 (0)