Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@nestjs/cqrs

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nestjs/cqrs - npm Package Compare versions

Comparing version 2.0.1 to 4.0.0

interfaces/saga.type.d.ts

8

aggregate-root.d.ts
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"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc