@dolittle/sdk.aggregates
Version:
Dolittle is a decentralized, distributed, event-driven microservice platform built to harness the power of events.
40 lines • 2.97 kB
JavaScript
;
// Copyright (c) Dolittle. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
Object.defineProperty(exports, "__esModule", { value: true });
exports.AggregateOf = void 0;
const sdk_events_1 = require("@dolittle/sdk.events");
const AggregateRootOperations_1 = require("./AggregateRootOperations");
const IAggregateOf_1 = require("./IAggregateOf");
/**
* Represents an implementation of {@link IAggregateOf<TAggregateRoot>}.
* @template TAggregateRoot
*/
class AggregateOf extends IAggregateOf_1.IAggregateOf {
/**
* Initialises a new instance of the {@link AggregateOf} class.
* @param {Constructor<TAggregateRoot>} _type - The class implementing the aggregate root.
* @param {AggregateRootType} _aggregateRootType - The aggregate root type associated with the aggregate root.
* @param {IEventStore} _eventStore - The event store to fetch committed events from and commit aggregate events with.
* @param {IEventTypes} _eventTypes - All registered event types.
* @param {Logger} _logger - The logger to use for logging.
*/
constructor(_type, _aggregateRootType, _eventStore, _eventTypes, _logger) {
super();
this._type = _type;
this._aggregateRootType = _aggregateRootType;
this._eventStore = _eventStore;
this._eventTypes = _eventTypes;
this._logger = _logger;
}
/** @inheritdoc */
create() {
return this.get(sdk_events_1.EventSourceId.new());
}
/** @inheritdoc */
get(eventSourceId) {
return new AggregateRootOperations_1.AggregateRootOperations(this._type, this._aggregateRootType, sdk_events_1.EventSourceId.from(eventSourceId), this._eventStore, this._eventTypes, this._logger);
}
}
exports.AggregateOf = AggregateOf;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiQWdncmVnYXRlT2YuanMiLCJzb3VyY2VSb290IjoiLi4vIiwic291cmNlcyI6WyJBZ2dyZWdhdGVPZi50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiO0FBQUEsK0NBQStDO0FBQy9DLHFHQUFxRzs7O0FBS3JHLHFEQUFrRztBQUdsRyx1RUFBb0U7QUFFcEUsaURBQTh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