import { PersistedEvent } from '@centsideas/models' ; import { EventTopics } from '@centsideas/enums' ; import { EventName } from '@centsideas/types' ; import { SchemaMessage } from './schema-message' ; import { serializableMessageMap } from './serializable-message' ; export function serializeEventMessage ( event , topic ) { const message = getMessage ( topic ) ; return message . encode ( event ) ; } export function deserializeEventMessage ( buffer , event ) { const message = getMessage ( event . getTopic ( ) ) ; return message . decode ( buffer , event ) ; } function getMessage ( topic ) { return serializableMessageMap . get ( topic ) ; }