Skip to content

Commit 6fb1f08

Browse files
authored
Merge pull request #49 from dolittle/interfaces-to-abstract
Change all interfaces to abstract classes.
2 parents 67da1bd + 66b6bd2 commit 6fb1f08

42 files changed

Lines changed: 286 additions & 313 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Source/aggregates/AggregateOf.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,30 @@
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+
import { Guid } from '@dolittle/rudiments';
45
import { AggregateRootVersionIsOutOfOrder, CommittedAggregateEvent, CommittedAggregateEvents, EventSourceId, EventTypeId, EventWasAppliedByOtherAggregateRoot, EventWasAppliedToOtherEventSource, IEventStore, IEventTypes } from '@dolittle/sdk.events';
5-
import { IAggregateOf } from './IAggregateOf';
6-
import { IAggregateRootOperations } from './IAggregateRootOperations';
7-
import { Logger } from 'winston';
86
import { Constructor } from '@dolittle/types';
9-
import { AggregateRootOperations } from './AggregateRootOperations';
7+
import { Logger } from 'winston';
108
import { AggregateRoot } from './AggregateRoot';
119
import { AggregateRootDecoratedTypes } from './AggregateRootDecoratedTypes';
12-
import { OnDecoratedMethods } from './OnDecoratedMethods';
10+
import { AggregateRootOperations } from './AggregateRootOperations';
11+
import { IAggregateOf } from './IAggregateOf';
12+
import { IAggregateRootOperations } from './IAggregateRootOperations';
1313
import { OnDecoratedMethod } from './OnDecoratedMethod';
14-
import { Guid } from '@dolittle/rudiments';
14+
import { OnDecoratedMethods } from './OnDecoratedMethods';
1515

1616
/**
1717
* Represents an implementation of {@link IAggregateOf<TAggregateRoot>}.
1818
* @template TAggregateRoot
1919
*/
20-
export class AggregateOf<TAggregateRoot extends AggregateRoot> implements IAggregateOf<TAggregateRoot> {
20+
export class AggregateOf<TAggregateRoot extends AggregateRoot> extends IAggregateOf<TAggregateRoot> {
2121

2222
constructor(
2323
private readonly _type: Constructor<TAggregateRoot>,
2424
private readonly _eventStore: IEventStore,
2525
private readonly _eventTypes: IEventTypes,
2626
private readonly _logger: Logger) {
27+
super();
2728
}
2829

2930
/** @inheritdoc */
@@ -112,4 +113,4 @@ export class AggregateOf<TAggregateRoot extends AggregateRoot> implements IAggre
112113
}
113114
}
114115

115-
}
116+
}

Source/aggregates/AggregateRootOperations.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,26 @@
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-
import { IAggregateRootOperations } from './IAggregateRootOperations';
5-
import { AggregateRootAction } from './AggregateRootAction';
6-
import { AggregateRoot } from './AggregateRoot';
7-
import { AggregateRootVersion, AggregateRootId, CommittedAggregateEvents, IEventStore, UncommittedAggregateEvent, IEventTypes } from '@dolittle/sdk.events';
8-
import { Logger } from 'winston';
4+
import { AggregateRootId, AggregateRootVersion, CommittedAggregateEvents, IEventStore, IEventTypes, UncommittedAggregateEvent } from '@dolittle/sdk.events';
95
import { Constructor } from '@dolittle/types';
6+
import { Logger } from 'winston';
7+
import { AggregateRoot } from './AggregateRoot';
8+
import { AggregateRootAction } from './AggregateRootAction';
9+
import { IAggregateRootOperations } from './IAggregateRootOperations';
1010

1111

1212
/**
1313
* Represents an implementation of {@link IAggregateRootOperations<TAggregate>}
1414
* @template TAggregateRoot
1515
*/
16-
export class AggregateRootOperations<TAggregateRoot extends AggregateRoot> implements IAggregateRootOperations<TAggregateRoot> {
16+
export class AggregateRootOperations<TAggregateRoot extends AggregateRoot> extends IAggregateRootOperations<TAggregateRoot> {
1717
constructor(
1818
private readonly _aggregateRootType: Constructor<any>,
1919
private readonly _eventStore: IEventStore,
2020
private readonly _aggregateRoot: TAggregateRoot,
2121
private readonly _eventTypes: IEventTypes,
2222
private readonly _logger: Logger) {
23+
super();
2324
}
2425

2526
/** @inheritdoc */

Source/aggregates/IAggregateOf.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,26 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
import { EventSourceId } from '@dolittle/sdk.events';
5-
import { IAggregateRootOperations } from './IAggregateRootOperations';
65
import { AggregateRoot } from './AggregateRoot';
6+
import { IAggregateRootOperations } from './IAggregateRootOperations';
77

88
/**
99
* Defines a way to work with an {@link AggregateRoot}
1010
* @template TAggregate
1111
*/
1212

13-
export interface IAggregateOf<TAggregate extends AggregateRoot> {
13+
export abstract class IAggregateOf<TAggregate extends AggregateRoot> {
1414

1515
/**
1616
* Create a new {@link AggregateRoot} with a random {@link EventSourceId}
1717
* @returns {IAggregateRootOperations<TAggregate>}
1818
*/
19-
create(): IAggregateRootOperations<TAggregate>;
19+
abstract create (): IAggregateRootOperations<TAggregate>;
2020

2121
/**
2222
* Gets an {@link AggregateRoot} with a given {@link EventSourceId}
2323
* @param {EventSourceId} eventSourceId {@link EventSourceId} of the {@link AggregateRoot}
2424
* @returns {IAggregateRootOperations<TAggregate>}
2525
*/
26-
get(eventSourceId: EventSourceId): IAggregateRootOperations<TAggregate>;
26+
abstract get (eventSourceId: EventSourceId): IAggregateRootOperations<TAggregate>;
2727
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
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-
import { AggregateRootAction } from './AggregateRootAction';
54
import { AggregateRoot } from './AggregateRoot';
5+
import { AggregateRootAction } from './AggregateRootAction';
66

77
/**
88
* Defines a system for working with operations that can be formed on an {@link AggregateRoot}.
99
* @template TAggregate {@link AggregateRoot} type
1010
*/
1111

12-
export interface IAggregateRootOperations<TAggregate extends AggregateRoot> {
12+
export abstract class IAggregateRootOperations<TAggregate extends AggregateRoot> {
1313

1414
/**
1515
* Perform an operation on an {@link AggregateRoot}
1616
* @param {AggregateRootAction<TAggregate> action Callback for working with the aggregate root.
1717
* @returns {Promise<void>}
1818
*/
19-
perform(action: AggregateRootAction<TAggregate>): Promise<void>;
19+
abstract perform (action: AggregateRootAction<TAggregate>): Promise<void>;
2020
}

Source/artifacts/EventTypes.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,26 @@
33

44
import { Guid } from '@dolittle/rudiments';
55
import { Constructor } from '@dolittle/types';
6-
import { UnknownType } from './UnknownType';
7-
import { EventTypeMap } from './EventTypeMap';
8-
import { IEventTypes } from './IEventTypes';
6+
import { CannotHaveMultipleEventTypesAssociatedWithType } from './CannotHaveMultipleEventTypesAssociatedWithType';
7+
import { CannotHaveMultipleTypesAssociatedWithEventType } from './CannotHaveMultipleTypesAssociatedWithEventType';
98
import { EventType } from './EventType';
10-
import { UnknownEventType } from './UnknownEventType';
119
import { EventTypeId } from './EventTypeId';
10+
import { EventTypeMap } from './EventTypeMap';
11+
import { IEventTypes } from './IEventTypes';
1212
import { UnableToResolveEventType } from './UnableToResolveEventType';
13-
import { CannotHaveMultipleEventTypesAssociatedWithType } from './CannotHaveMultipleEventTypesAssociatedWithType';
14-
import { CannotHaveMultipleTypesAssociatedWithEventType } from './CannotHaveMultipleTypesAssociatedWithEventType';
13+
import { UnknownEventType } from './UnknownEventType';
14+
import { UnknownType } from './UnknownType';
1515

1616
/**
1717
* Represents an implementation of {@link IEventTypes}
1818
*/
19-
export class EventTypes implements IEventTypes {
19+
export class EventTypes extends IEventTypes {
2020
/**
2121
* Initializes a new instance of {@link EventTypes}
2222
* @param {EventTypeMap<Constructor<any>>} [associations] Known associations
2323
*/
2424
constructor(private _associations: EventTypeMap<Constructor<any>> = new EventTypeMap()) {
25+
super();
2526
}
2627
/** @inheritdoc */
2728
hasTypeFor(input: EventType): boolean {

Source/artifacts/IEventTypes.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,41 @@
33

44
import { Guid } from '@dolittle/rudiments';
55
import { Constructor } from '@dolittle/types';
6-
import { EventType } from './EventType';
6+
import { EventType } from './EventType';
77
import { EventTypeId } from './EventTypeId';
88

99
/**
1010
* Defines the system for working with {@link EventType}
1111
*/
12-
export interface IEventTypes {
12+
export abstract class IEventTypes {
1313

1414
/**
1515
* Check if there is a type associated with an artifact.
1616
* @param {EventType} input Artifact.
1717
* @returns {boolean} true if there is, false if not.
1818
*/
19-
hasTypeFor(input: EventType): boolean;
19+
abstract hasTypeFor (input: EventType): boolean;
2020

2121
/**
2222
* Get type for a given artifact.
2323
* @param {EventType} input Artifact.
2424
* @returns type for artifact.
2525
*/
26-
getTypeFor(input: EventType): Constructor<any>;
26+
abstract getTypeFor (input: EventType): Constructor<any>;
2727

2828
/**
2929
* Check if there is an {Artifact} definition for a given type.
3030
* @param {Function} type Type to check for.
3131
* @returns true if there is, false if not.
3232
*/
33-
hasFor(type: Constructor<any>): boolean;
33+
abstract hasFor (type: Constructor<any>): boolean;
3434

3535
/**
3636
* Get {Artifact} definition for a given type.
3737
* @param {Function} type Type to get for.
3838
* @returns {EventType} The artifact associated.
3939
*/
40-
getFor(type: Constructor<any>): EventType;
40+
abstract getFor (type: Constructor<any>): EventType;
4141

4242
/**
4343
* Resolves an artifact from optional input or the given object.
@@ -46,12 +46,12 @@ export interface IEventTypes {
4646
* @returns {EventType} Resolved event type.
4747
* @throws {UnableToResolveArtifact} If not able to resolve artifact.
4848
*/
49-
resolveFrom(object: any, input?: EventType | EventTypeId | Guid | string): EventType;
49+
abstract resolveFrom (object: any, input?: EventType | EventTypeId | Guid | string): EventType;
5050

5151
/**
5252
* Associate a type with a unique artifact identifier and optional generation.
5353
* @param {Constructor<any>} type Type to associate.
5454
* @param {EventType} eventType Artifact to associate with.
5555
*/
56-
associate(type: Constructor<any>, eventType: EventType): void;
56+
abstract associate (type: Constructor<any>, eventType: EventType): void;
5757
}

Source/common/Container.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
import { Constructor } from '@dolittle/types';
5-
import { IContainer } from './IContainer';
65
import { DefaultContainerDoesNotSupportConstructorArguments } from './DefaultContainerDoesNotSupportConstructorArguments';
6+
import { IContainer } from './IContainer';
77

88
/**
99
* Represents an implementation of {@link IContainer}.
1010
*/
11-
export class Container implements IContainer {
11+
export class Container extends IContainer {
1212

1313
/** @inheritdoc */
1414
get(service: Constructor) {

Source/common/IContainer.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ import { Constructor } from '@dolittle/types';
66
/**
77
* Defines an IoC Container for dependency inversion.
88
*/
9-
export interface IContainer {
9+
export abstract class IContainer {
1010

1111
/**
1212
* Get the instance of a service.
1313
* @param {Function} service Type of service by its constructor to get
1414
* @returns The instance.
1515
*/
16-
get(service: Constructor): any;
16+
abstract get (service: Constructor): any;
1717
}
18-

Source/eventHorizon/EventHorizons.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,24 +2,24 @@
22
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
33

44
import { Guid } from '@dolittle/rudiments';
5-
import { Logger } from 'winston';
6-
import * as grpc from '@grpc/grpc-js';
7-
import { ExecutionContext } from '@dolittle/sdk.execution';
8-
import { callContexts, failures, guids } from '@dolittle/sdk.protobuf';
95
import { SubscriptionsClient } from '@dolittle/runtime.contracts/EventHorizon/Subscriptions_grpc_pb';
106
import { Subscription as PbSubscription, SubscriptionResponse as PbSubscriptionResponse } from '@dolittle/runtime.contracts/EventHorizon/Subscriptions_pb';
7+
import { ExecutionContext } from '@dolittle/sdk.execution';
8+
import { callContexts, failures, guids } from '@dolittle/sdk.protobuf';
9+
import * as grpc from '@grpc/grpc-js';
10+
import { Logger } from 'winston';
11+
import { IEventHorizons } from './IEventHorizons';
12+
import { Subscription } from './Subscription';
13+
import { SubscriptionCallbacks } from './SubscriptionCallbacks';
14+
import { SubscriptionDoesNotExist } from './SubscriptionDoesNotExist';
15+
import { SubscriptionResponse } from './SubscriptionResponse';
16+
import { TenantWithSubscriptions } from './TenantWithSubscriptions';
1117

12-
import { Subscription } from './Subscription';
13-
import { IEventHorizons } from './IEventHorizons';
14-
import { SubscriptionResponse } from './SubscriptionResponse';
15-
import { TenantWithSubscriptions } from './TenantWithSubscriptions';
16-
import { SubscriptionCallbacks } from './SubscriptionCallbacks';
17-
import { SubscriptionDoesNotExist } from './SubscriptionDoesNotExist';
1818

1919
/**
2020
* Represents an implementation of {@link IEventHorizons}.
2121
*/
22-
export class EventHorizons implements IEventHorizons {
22+
export class EventHorizons extends IEventHorizons {
2323
private _subscriptionResponses: Map<Subscription, SubscriptionResponse> = new Map();
2424

2525
/**
@@ -36,6 +36,7 @@ export class EventHorizons implements IEventHorizons {
3636
readonly subscriptions: TenantWithSubscriptions[],
3737
readonly callbacks: SubscriptionCallbacks,
3838
private _logger: Logger) {
39+
super();
3940
this.subscribeAll();
4041
}
4142

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,23 @@
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-
import { Subscription } from './Subscription';
5-
import { TenantWithSubscriptions } from './TenantWithSubscriptions';
4+
import { Subscription } from './Subscription';
65
import { SubscriptionResponse } from './SubscriptionResponse';
6+
import { TenantWithSubscriptions } from './TenantWithSubscriptions';
77

88
/**
99
* Defines the capabilities of the event horizons.
1010
*/
11-
export interface IEventHorizons {
11+
export abstract class IEventHorizons {
1212
/**
1313
* Subscriptions by tenant.
1414
*/
15-
readonly subscriptions: TenantWithSubscriptions[];
15+
abstract readonly subscriptions: TenantWithSubscriptions[];
1616

1717
/**
1818
* Gets response for a specific {@link Subscription}.
1919
* @param {Subscription} subscription Subscription to get response for.
2020
* @throws {SubscriptionDoesNotExist} If subscription does not exist.
2121
*/
22-
getResponseFor(subscription: Subscription): SubscriptionResponse;
22+
abstract getResponseFor (subscription: Subscription): SubscriptionResponse;
2323
}

0 commit comments

Comments
 (0)