@nestjs/cqrs
Advanced tools
Comparing version 2.0.1 to 4.0.0
import { IEvent } from './interfaces/index'; | ||
export declare abstract class AggregateRoot { | ||
private readonly changes; | ||
private readonly events; | ||
autoCommit: boolean; | ||
publish(event: IEvent): void; | ||
uncommitChanges(): void; | ||
getUncommittedChanges(): IEvent[]; | ||
commit(): void; | ||
uncommit(): void; | ||
getUncommittedEvents(): IEvent[]; | ||
loadFromHistory(history: IEvent[]): void; | ||
@@ -8,0 +10,0 @@ apply(event: IEvent, isFromHistory?: boolean): void; |
@@ -5,19 +5,24 @@ "use strict"; | ||
constructor() { | ||
this.changes = []; | ||
this.events = []; | ||
this.autoCommit = false; | ||
} | ||
publish(event) { } | ||
uncommitChanges() { | ||
this.changes.length = 0; | ||
commit() { | ||
this.events.forEach((event) => this.publish(event)); | ||
this.events.length = 0; | ||
} | ||
getUncommittedChanges() { | ||
return this.changes; | ||
uncommit() { | ||
this.events.length = 0; | ||
} | ||
getUncommittedEvents() { | ||
return this.events; | ||
} | ||
loadFromHistory(history) { | ||
history.forEach((event) => this.apply(event, true)); | ||
history.forEach(event => this.apply(event, true)); | ||
} | ||
apply(event, isFromHistory = false) { | ||
if (!isFromHistory) { | ||
this.changes.push(event); | ||
if (!isFromHistory && !this.autoCommit) { | ||
this.events.push(event); | ||
} | ||
this.publish(event); | ||
this.autoCommit && this.publish(event); | ||
const handler = this.getEventHandler(event); | ||
@@ -24,0 +29,0 @@ handler && handler(event); |
import { IEventBus, IEvent, IEventHandler } from './interfaces/index'; | ||
import { ObservableBus } from './utils/observable-bus'; | ||
import { Metatype } from '@nestjs/common/interfaces'; | ||
import { EventObservable } from './interfaces/event-observable.interface'; | ||
import { Observable } from 'rxjs/Observable'; | ||
import { CommandBus } from './command-bus'; | ||
import { Saga } from './index'; | ||
import 'rxjs/add/operator/filter'; | ||
export declare type EventHandlerMetatype = Metatype<IEventHandler<IEvent>>; | ||
export declare type Saga = (events$: EventObservable<IEvent>) => any; | ||
export declare class EventBus extends ObservableBus<IEvent> implements IEventBus { | ||
@@ -18,3 +16,3 @@ private readonly commandBus; | ||
name: string; | ||
}): Observable<IEvent>; | ||
}): any; | ||
bind<T extends IEvent>(handler: IEventHandler<IEvent>, name: string): void; | ||
@@ -24,3 +22,3 @@ combineSagas(sagas: Saga[]): void; | ||
protected registerHandler(handler: EventHandlerMetatype): void; | ||
protected ofEventName(name: string): Observable<IEvent>; | ||
protected ofEventName(name: string): any; | ||
private getEventName(event); | ||
@@ -27,0 +25,0 @@ protected registerSaga(saga: Saga): void; |
@@ -9,4 +9,4 @@ import { EventBus } from './event-bus'; | ||
constructor(eventBus: EventBus); | ||
mergeContext<T extends Constructor<AggregateRoot>>(metatype: T): T; | ||
mergeClassContext<T extends Constructor<AggregateRoot>>(metatype: T): T; | ||
mergeObjectContext<T extends AggregateRoot>(object: T): T; | ||
} |
@@ -18,3 +18,3 @@ "use strict"; | ||
} | ||
mergeContext(metatype) { | ||
mergeClassContext(metatype) { | ||
const eventBus = this.eventBus; | ||
@@ -21,0 +21,0 @@ return class extends metatype { |
@@ -8,1 +8,2 @@ export * from './commands/command-bus.interface'; | ||
export * from './event-observable.interface'; | ||
export * from './saga.type'; |
{ | ||
"name": "@nestjs/cqrs", | ||
"version": "2.0.1", | ||
"version": "4.0.0", | ||
"description": "A lightweight CQRS module for Nest framework (node.js)", | ||
@@ -8,6 +8,6 @@ "author": "Kamil Mysliwiec", | ||
"peerDependencies": { | ||
"@nestjs/common": "~2.*", | ||
"@nestjs/common": "^4.*", | ||
"reflect-metadata": "0.1.10", | ||
"rxjs": "5.*" | ||
"rxjs": "^5.4.3" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31275
55
525
1