1- import { array , assertNumber , createNormalizer } from '../protocol/serialization' ;
1+ import { Schema } from 'when-json-met-bigint' ;
2+ import { assertNumber , bigint } from '../protocol/serialization' ;
23import { Entry } from './entry' ;
34import { OutputElementStyle } from './styles' ;
45
5- export const TimeGraphEntry = createNormalizer < TimeGraphEntry > ( {
6- end : BigInt ,
6+ export const TimeGraphEntrySchema : Schema = {
7+ end : bigint ,
78 id : assertNumber ,
89 parentId : assertNumber ,
9- start : BigInt ,
10- style : OutputElementStyle ,
11- } ) ;
10+ start : bigint ,
11+ } ;
1212
1313/**
1414 * Entry in a time graph
@@ -25,12 +25,11 @@ export interface TimeGraphEntry extends Entry {
2525 end : bigint ;
2626}
2727
28- const TimeGraphState = createNormalizer < TimeGraphState > ( {
29- end : BigInt ,
30- start : BigInt ,
28+ const TimeGraphStateSchema : Schema = {
29+ end : bigint ,
30+ start : bigint ,
3131 tags : assertNumber ,
32- style : OutputElementStyle ,
33- } ) ;
32+ } ;
3433
3534/**
3635 * Time graph state
@@ -62,10 +61,10 @@ export interface TimeGraphState {
6261 style ?: OutputElementStyle ;
6362}
6463
65- export const TimeGraphRow = createNormalizer < TimeGraphRow > ( {
64+ export const TimeGraphRowSchema : Schema = {
6665 entryId : assertNumber ,
67- states : array ( TimeGraphState ) ,
68- } ) ;
66+ states : [ TimeGraphStateSchema ] ,
67+ } ;
6968
7069/**
7170 * Time graph row described by an array of states for a specific entry
@@ -82,9 +81,9 @@ export interface TimeGraphRow {
8281 states : TimeGraphState [ ] ;
8382}
8483
85- export const TimeGraphModel = createNormalizer < TimeGraphModel > ( {
86- rows : array ( TimeGraphRow ) ,
87- } ) ;
84+ export const TimeGraphModelSchema : Schema = {
85+ rows : [ TimeGraphRowSchema ] ,
86+ } ;
8887
8988/**
9089 * Time Graph model that will be returned by the server
@@ -93,13 +92,12 @@ export interface TimeGraphModel {
9392 rows : TimeGraphRow [ ] ;
9493}
9594
96- export const TimeGraphArrow = createNormalizer < TimeGraphArrow > ( {
97- end : BigInt ,
95+ export const TimeGraphArrowSchema : Schema = {
96+ end : bigint ,
9897 sourceId : assertNumber ,
99- start : BigInt ,
98+ start : bigint ,
10099 targetId : assertNumber ,
101- style : OutputElementStyle ,
102- } ) ;
100+ } ;
103101
104102/**
105103 * Arrow for time graph
0 commit comments