1
- import { array , assertNumber , createNormalizer } from '../protocol/serialization' ;
1
+ import { Schema } from 'when-json-met-bigint' ;
2
+ import { assertNumber , bigint } from '../protocol/serialization' ;
2
3
import { Entry } from './entry' ;
3
4
import { OutputElementStyle } from './styles' ;
4
5
5
- export const TimeGraphEntry = createNormalizer < TimeGraphEntry > ( {
6
- end : BigInt ,
6
+ export const TimeGraphEntrySchema : Schema = {
7
+ end : bigint ,
7
8
id : assertNumber ,
8
9
parentId : assertNumber ,
9
- start : BigInt ,
10
- style : OutputElementStyle ,
11
- } ) ;
10
+ start : bigint ,
11
+ } ;
12
12
13
13
/**
14
14
* Entry in a time graph
@@ -25,12 +25,11 @@ export interface TimeGraphEntry extends Entry {
25
25
end : bigint ;
26
26
}
27
27
28
- const TimeGraphState = createNormalizer < TimeGraphState > ( {
29
- end : BigInt ,
30
- start : BigInt ,
28
+ const TimeGraphStateSchema : Schema = {
29
+ end : bigint ,
30
+ start : bigint ,
31
31
tags : assertNumber ,
32
- style : OutputElementStyle ,
33
- } ) ;
32
+ } ;
34
33
35
34
/**
36
35
* Time graph state
@@ -62,10 +61,10 @@ export interface TimeGraphState {
62
61
style ?: OutputElementStyle ;
63
62
}
64
63
65
- export const TimeGraphRow = createNormalizer < TimeGraphRow > ( {
64
+ export const TimeGraphRowSchema : Schema = {
66
65
entryId : assertNumber ,
67
- states : array ( TimeGraphState ) ,
68
- } ) ;
66
+ states : [ TimeGraphStateSchema ] ,
67
+ } ;
69
68
70
69
/**
71
70
* Time graph row described by an array of states for a specific entry
@@ -82,9 +81,9 @@ export interface TimeGraphRow {
82
81
states : TimeGraphState [ ] ;
83
82
}
84
83
85
- export const TimeGraphModel = createNormalizer < TimeGraphModel > ( {
86
- rows : array ( TimeGraphRow ) ,
87
- } ) ;
84
+ export const TimeGraphModelSchema : Schema = {
85
+ rows : [ TimeGraphRowSchema ] ,
86
+ } ;
88
87
89
88
/**
90
89
* Time Graph model that will be returned by the server
@@ -93,13 +92,12 @@ export interface TimeGraphModel {
93
92
rows : TimeGraphRow [ ] ;
94
93
}
95
94
96
- export const TimeGraphArrow = createNormalizer < TimeGraphArrow > ( {
97
- end : BigInt ,
95
+ export const TimeGraphArrowSchema : Schema = {
96
+ end : bigint ,
98
97
sourceId : assertNumber ,
99
- start : BigInt ,
98
+ start : bigint ,
100
99
targetId : assertNumber ,
101
- style : OutputElementStyle ,
102
- } ) ;
100
+ } ;
103
101
104
102
/**
105
103
* Arrow for time graph
0 commit comments