Skip to content

Commit 3df3114

Browse files
committed
Introduce IProjectionStoreBuilder
1 parent 22fb816 commit 3df3114

5 files changed

Lines changed: 38 additions & 12 deletions

File tree

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// Copyright (c) Dolittle. All rights reserved.
2+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3+
import { TenantIdLike } from '@dolittle/sdk.execution';
4+
import { IProjectionStore } from '..';
5+
6+
/**
7+
* Defines a builder for {@link IProjectionStore}.
8+
*/
9+
10+
export abstract class IProjectionStoreBuilder {
11+
/**
12+
* Build an {@link IProjectionStore} for the given tenant.
13+
* @param { TenantIdLike } tenantId The tenant id.
14+
* @returns {IProjectionStore} The projection store.
15+
*/
16+
abstract forTenant(tenantId: TenantIdLike): IProjectionStore;
17+
}

Source/projections/Store/Builder/ProjectionStoreBuilder.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,31 +3,36 @@
33

44
import { Logger } from 'winston';
55

6-
import { ExecutionContext, TenantId } from '@dolittle/sdk.execution';
6+
import { ExecutionContext, TenantIdLike } from '@dolittle/sdk.execution';
77
import { Guid } from '@dolittle/rudiments';
88

99
import { ProjectionsClient } from '@dolittle/runtime.contracts/Projections/Store_grpc_pb';
1010

1111
import { IProjectionAssociations, IProjectionStore, ProjectionStore } from '..';
12+
import { IProjectionStoreBuilder } from './IProjectionStoreBuilder';
1213

1314
/**
14-
* Represents a builder for builing a projection store.
15+
* Represents an implementation of {@link IProjectionsStoreBuilder}.
1516
*/
16-
export class ProjectionStoreBuilder {
17+
export class ProjectionStoreBuilder extends IProjectionStoreBuilder {
1718

19+
/**
20+
* Initializes a new instance of {@link ProjectionStoreBuilder}.
21+
* @param {ProjectionsClient} projectionsClient The client for the projections.
22+
* @param {ExecutionContext} executionContext The execution context.
23+
* @param {IProjectionAssociations} projectionAssociations The projection associations.
24+
* @param {Logger} logger The logger.
25+
*/
1826
constructor(
1927
private readonly _projectionsClient: ProjectionsClient,
2028
private readonly _executionContext: ExecutionContext,
2129
private readonly _projectionAssociations: IProjectionAssociations,
2230
private readonly _logger: Logger) {
31+
super();
2332
}
2433

25-
/**
26-
* Build an {@link IProjectionStore} for the given tenant.
27-
* @param {TenantId | Guid | string} tenantId The tenant id.
28-
* @returns {IProjectionStore} The projection store.
29-
*/
30-
forTenant(tenantId: TenantId | Guid | string): IProjectionStore {
34+
/** @inheritdoc */
35+
forTenant(tenantId: TenantIdLike): IProjectionStore {
3136
const executionContext = this._executionContext
3237
.forTenant(tenantId)
3338
.forCorrelation(Guid.create());
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// Copyright (c) Dolittle. All rights reserved.
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

4+
export { IProjectionStoreBuilder } from './IProjectionStoreBuilder';
45
export { ProjectionStoreBuilder } from './ProjectionStoreBuilder';

Source/projections/Store/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ export { ProjectionStore } from './ProjectionStore';
1616
export { TypeIsNotAProjection } from './TypeIsNotAProjection';
1717

1818
export {
19-
ProjectionStoreBuilder
19+
ProjectionStoreBuilder,
20+
IProjectionStoreBuilder
2021
} from './Builder';
2122

2223
export {

Source/projections/index.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ export {
2121
ProjectionsBuilder,
2222
ProjectionsBuilderCallback,
2323
ReadModelAlreadyDefinedForProjection,
24-
TypeOrEventType
24+
TypeOrEventType,
25+
OnMethodSpecification
2526
} from './Builder';
2627
export { DeleteReadModelInstance } from './DeleteReadModelInstance';
2728
export { EventPropertyKeySelector } from './EventPropertyKeySelector';
@@ -56,6 +57,7 @@ export {
5657
ProjectionStoreBuilder,
5758
ProjectionsToSDKConverter,
5859
TypeIsNotAProjection,
59-
UnknownCurrentStateType
60+
UnknownCurrentStateType,
61+
IProjectionStoreBuilder
6062
} from './Store';
6163
export { UnknownKeySelectorType } from './UnknownKeySelectorType';

0 commit comments

Comments
 (0)