@dolittle/sdk.projections
Version:
Dolittle is a decentralized, distributed, event-driven microservice platform built to harness the power of events.
61 lines • 3.71 kB
TypeScript
import { Guid } from '@dolittle/rudiments';
import { Constructor } from '@dolittle/types';
import { IClientBuildResults, IModelBuilder } from '@dolittle/sdk.common';
import { Generation } from '@dolittle/sdk.artifacts';
import { EventType, EventTypeIdLike, IEventTypes, ScopeId } from '@dolittle/sdk.events';
import { IProjection } from '../IProjection';
import { ProjectionCallback } from '../ProjectionCallback';
import { ProjectionId } from '../ProjectionId';
import { CopyToMongoDBCallback } from './Copies/CopyToMongoDBCallback';
import { IProjectionBuilderForReadModel } from './IProjectionBuilderForReadModel';
import { KeySelectorBuilderCallback } from './KeySelectorBuilderCallback';
import { ProjectionBuilder } from './ProjectionBuilder';
import { ProjectionAliasLike } from '../ProjectionAlias';
/**
* Represents an implementation of {@link IProjectionBuilderForReadModel}.
* @template T The type of the projection read model.
*/
export declare class ProjectionBuilderForReadModel<T> extends IProjectionBuilderForReadModel<T> {
private readonly _projectionId;
private readonly _readModelTypeOrInstance;
private _scopeId;
private readonly _modelBuilder;
private readonly _parentBuilder;
private _onMethods;
private _alias?;
private _copyToMongoDBCallback?;
/**
* Initializes a new instance of {@link ProjectionBuilder}.
* @param {ProjectionId} _projectionId - The unique identifier of the projection to build for.
* @param {Constructor<T> | T} _readModelTypeOrInstance - The type or instance of the read model to build a projection for.
* @param {ScopeId} _scopeId - The scope of the projection.
* @param {IModelBuilder} _modelBuilder - For binding the parent projection builder and read model to its identifier.
* @param {ProjectionBuilder} _parentBuilder - For binding the builder to the identifier.
*/
constructor(_projectionId: ProjectionId, _readModelTypeOrInstance: Constructor<T> | T, _scopeId: ScopeId, _modelBuilder: IModelBuilder, _parentBuilder: ProjectionBuilder);
/** @inheritdoc */
on<TEvent>(type: Constructor<TEvent>, keySelectorCallback: KeySelectorBuilderCallback<TEvent>, callback: ProjectionCallback<T, TEvent>): IProjectionBuilderForReadModel<T>;
on(eventType: EventType, keySelectorCallback: KeySelectorBuilderCallback<any>, callback: ProjectionCallback<T, any>): IProjectionBuilderForReadModel<T>;
on(eventTypeId: EventTypeIdLike, keySelectorCallback: KeySelectorBuilderCallback<any>, callback: ProjectionCallback<T, any>): IProjectionBuilderForReadModel<T>;
on(eventTypeId: EventTypeIdLike, generation: number | Generation, keySelectorCallback: KeySelectorBuilderCallback<any>, callback: ProjectionCallback<T, any>): IProjectionBuilderForReadModel<T>;
/** @inheritdoc */
inScope(scopeId: string | Guid | ScopeId): IProjectionBuilderForReadModel<T>;
/** @inheritdoc */
withAlias(alias: ProjectionAliasLike): IProjectionBuilderForReadModel<T>;
/** @inheritdoc */
copyToMongoDB(callback?: CopyToMongoDBCallback<T>): IProjectionBuilderForReadModel<T>;
/**
* Builds the projection.
* @param {IEventTypes} eventTypes - For event types resolution.
* @param {IClientBuildResults} results - For keeping track of build results.
* @returns {IProjection | undefined} The built projection if successful.
*/
build(eventTypes: IEventTypes, results: IClientBuildResults): IProjection<T> | undefined;
private tryAddOnMethods;
private getTypeOrEventTypeFrom;
private getEventType;
private buildCopies;
private buildMongoDBCopies;
private get _modelId();
}
//# sourceMappingURL=ProjectionBuilderForReadModel.d.ts.map