UNPKG

@dolittle/sdk.projections

Version:

Dolittle is a decentralized, distributed, event-driven microservice platform built to harness the power of events.

31 lines (25 loc) 1.55 kB
// Copyright (c) Dolittle. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. import { Constructor } from '@dolittle/types'; import { ProjectionCurrentState } from '@dolittle/contracts/Runtime/Projections/State_pb'; import { Key } from '../../Key'; import { CurrentState } from '../CurrentState'; /** * Defines a system that converts projections to SDK representations. */ export abstract class IConvertProjectionsToSDK { /** * Convert from the runtime respresentation to the SDK's representation of the current state of a projection. * @param {Constructor<TProjection> | undefined} type - The optional read model type to convert to. * @param {ProjectionCurrentState} source - The current state to convert. * @template TProjection The type of the projection. */ abstract convert<TProjection = any>(type: Constructor<TProjection> | undefined, source: ProjectionCurrentState): CurrentState<TProjection>; /** * Convert from an list of runtime respresentations of the current state of a projection to the SDK's representation. * @param {Constructor<TProjection> | undefined} type - The optional read model type to convert to. * @param {ProjectionCurrentState[]} sources - A list of states to convert. * @template TProjection The type of the projection. */ abstract convertAll<TProjection = any>(type: Constructor<TProjection> | undefined, sources: ProjectionCurrentState[]): Map<Key, CurrentState<TProjection>>; }