import { PersistedEvent } from '@centsideas/models' ; import { EventName } from '@centsideas/types' ; export function serializeEvent ( event ) { const data = event . data ; const eventName = EventName . fromString ( event . name ) ; return { ... event , data : { [ eventName . name ] : data } , } ; } export function deserializeEvent ( event ) { const eventName = EventName . fromString ( event . name ) ; return { ... event , data : ( event . data as any ) [ eventName . name ] , } ; }