@nestjs/cqrs 7.0.0 → 8.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/.circleci/config.yml +1 -1
  2. package/.github/ISSUE_TEMPLATE/Bug_report.yml +106 -0
  3. package/.github/ISSUE_TEMPLATE/Feature_request.yml +52 -0
  4. package/.github/ISSUE_TEMPLATE/Regression.yml +78 -0
  5. package/.github/ISSUE_TEMPLATE/config.yml +7 -0
  6. package/.github/PULL_REQUEST_TEMPLATE.md +10 -14
  7. package/CONTRIBUTING.md +4 -3
  8. package/LICENSE +21 -0
  9. package/dist/aggregate-root.d.ts +4 -2
  10. package/dist/aggregate-root.js +2 -1
  11. package/dist/command-bus.d.ts +4 -4
  12. package/dist/command-bus.js +56 -53
  13. package/dist/cqrs.module.js +25 -28
  14. package/dist/decorators/command-handler.decorator.d.ts +10 -0
  15. package/dist/decorators/command-handler.decorator.js +16 -1
  16. package/dist/decorators/constants.d.ts +4 -1
  17. package/dist/decorators/constants.js +5 -2
  18. package/dist/decorators/events-handler.decorator.d.ts +10 -0
  19. package/dist/decorators/events-handler.decorator.js +18 -1
  20. package/dist/decorators/index.js +2 -2
  21. package/dist/decorators/query-handler.decorator.d.ts +10 -0
  22. package/dist/decorators/query-handler.decorator.js +16 -1
  23. package/dist/decorators/saga.decorator.d.ts +5 -0
  24. package/dist/decorators/saga.decorator.js +7 -1
  25. package/dist/event-bus.d.ts +4 -4
  26. package/dist/event-bus.js +78 -81
  27. package/dist/event-publisher.js +29 -26
  28. package/dist/exceptions/index.js +2 -2
  29. package/dist/helpers/default-get-event-id.d.ts +4 -0
  30. package/dist/helpers/default-get-event-id.js +13 -0
  31. package/dist/helpers/default-get-event-name.js +2 -1
  32. package/dist/index.js +8 -2
  33. package/dist/interfaces/commands/command-bus.interface.d.ts +1 -1
  34. package/dist/interfaces/commands/command-metadata.interface.d.ts +3 -0
  35. package/dist/interfaces/commands/command-metadata.interface.js +2 -0
  36. package/dist/interfaces/index.js +2 -2
  37. package/dist/interfaces/queries/query-metadata.interface.d.ts +3 -0
  38. package/dist/interfaces/queries/query-metadata.interface.js +2 -0
  39. package/dist/operators/index.js +2 -2
  40. package/dist/operators/of-type.d.ts +8 -0
  41. package/dist/operators/of-type.js +9 -1
  42. package/dist/query-bus.d.ts +3 -3
  43. package/dist/query-bus.js +59 -56
  44. package/dist/services/explorer.service.js +35 -38
  45. package/dist/utils/index.js +2 -2
  46. package/package.json +26 -23
  47. package/.github/ISSUE_TEMPLATE.md +0 -46
@@ -3,8 +3,25 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EventsHandler = void 0;
4
4
  require("reflect-metadata");
5
5
  const constants_1 = require("./constants");
6
- exports.EventsHandler = (...events) => {
6
+ const uuid_1 = require("uuid");
7
+ /**
8
+ * Decorator that marks a class as a Nest event handler. An event handler
9
+ * handles events executed by your application code.
10
+ *
11
+ * The decorated class must implement the `IEventHandler` interface.
12
+ *
13
+ * @param events one or more event *types* to be handled by this handler.
14
+ *
15
+ * @see https://docs.nestjs.com/recipes/cqrs#events
16
+ */
17
+ const EventsHandler = (...events) => {
7
18
  return (target) => {
19
+ events.forEach((event) => {
20
+ if (!Reflect.hasMetadata(constants_1.EVENT_METADATA, event)) {
21
+ Reflect.defineMetadata(constants_1.EVENT_METADATA, { id: (0, uuid_1.v4)() }, event);
22
+ }
23
+ });
8
24
  Reflect.defineMetadata(constants_1.EVENTS_HANDLER_METADATA, events, target);
9
25
  };
10
26
  };
27
+ exports.EventsHandler = EventsHandler;
@@ -7,8 +7,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
7
7
  o[k2] = m[k];
8
8
  }));
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
- }
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./command-handler.decorator"), exports);
14
14
  __exportStar(require("./events-handler.decorator"), exports);
@@ -1,3 +1,13 @@
1
1
  import 'reflect-metadata';
2
2
  import { IQuery } from '../interfaces';
3
+ /**
4
+ * Decorator that marks a class as a Nest query handler. A query handler
5
+ * handles queries executed by your application code.
6
+ *
7
+ * The decorated class must implement the `IQueryHandler` interface.
8
+ *
9
+ * @param query query *type* to be handled by this handler.
10
+ *
11
+ * @see https://docs.nestjs.com/recipes/cqrs#queries
12
+ */
3
13
  export declare const QueryHandler: (query: IQuery) => ClassDecorator;
@@ -3,8 +3,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.QueryHandler = void 0;
4
4
  require("reflect-metadata");
5
5
  const constants_1 = require("./constants");
6
- exports.QueryHandler = (query) => {
6
+ const uuid_1 = require("uuid");
7
+ /**
8
+ * Decorator that marks a class as a Nest query handler. A query handler
9
+ * handles queries executed by your application code.
10
+ *
11
+ * The decorated class must implement the `IQueryHandler` interface.
12
+ *
13
+ * @param query query *type* to be handled by this handler.
14
+ *
15
+ * @see https://docs.nestjs.com/recipes/cqrs#queries
16
+ */
17
+ const QueryHandler = (query) => {
7
18
  return (target) => {
19
+ if (!Reflect.hasMetadata(constants_1.QUERY_METADATA, query)) {
20
+ Reflect.defineMetadata(constants_1.QUERY_METADATA, { id: (0, uuid_1.v4)() }, query);
21
+ }
8
22
  Reflect.defineMetadata(constants_1.QUERY_HANDLER_METADATA, query, target);
9
23
  };
10
24
  };
25
+ exports.QueryHandler = QueryHandler;
@@ -1,2 +1,7 @@
1
1
  import 'reflect-metadata';
2
+ /**
3
+ * Decorator that marks a class as a Nest saga. Sagas may listen and react to 1..N events.
4
+ *
5
+ * @see https://docs.nestjs.com/recipes/cqrs#sagas
6
+ */
2
7
  export declare const Saga: () => PropertyDecorator;
@@ -3,9 +3,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Saga = void 0;
4
4
  require("reflect-metadata");
5
5
  const constants_1 = require("./constants");
6
- exports.Saga = () => {
6
+ /**
7
+ * Decorator that marks a class as a Nest saga. Sagas may listen and react to 1..N events.
8
+ *
9
+ * @see https://docs.nestjs.com/recipes/cqrs#sagas
10
+ */
11
+ const Saga = () => {
7
12
  return (target, propertyKey) => {
8
13
  const properties = Reflect.getMetadata(constants_1.SAGA_METADATA, target.constructor) || [];
9
14
  Reflect.defineMetadata(constants_1.SAGA_METADATA, [...properties, propertyKey], target.constructor);
10
15
  };
11
16
  };
17
+ exports.Saga = Saga;
@@ -8,7 +8,7 @@ export declare type EventHandlerType<EventBase extends IEvent = IEvent> = Type<I
8
8
  export declare class EventBus<EventBase extends IEvent = IEvent> extends ObservableBus<EventBase> implements IEventBus<EventBase>, OnModuleDestroy {
9
9
  private readonly commandBus;
10
10
  private readonly moduleRef;
11
- protected getEventName: (event: EventBase) => string;
11
+ protected getEventId: (event: EventBase) => string;
12
12
  protected readonly subscriptions: Subscription[];
13
13
  private _publisher;
14
14
  constructor(commandBus: CommandBus, moduleRef: ModuleRef);
@@ -17,12 +17,12 @@ export declare class EventBus<EventBase extends IEvent = IEvent> extends Observa
17
17
  onModuleDestroy(): void;
18
18
  publish<T extends EventBase>(event: T): any;
19
19
  publishAll<T extends EventBase>(events: T[]): any;
20
- bind(handler: IEventHandler<EventBase>, name: string): void;
20
+ bind(handler: IEventHandler<EventBase>, id: string): void;
21
21
  registerSagas(types?: Type<unknown>[]): void;
22
22
  register(handlers?: EventHandlerType<EventBase>[]): void;
23
23
  protected registerHandler(handler: EventHandlerType<EventBase>): void;
24
- protected ofEventName(name: string): Observable<EventBase>;
24
+ protected ofEventId(name: string): Observable<EventBase>;
25
25
  protected registerSaga(saga: ISaga<EventBase>): void;
26
- private reflectEventsNames;
26
+ private reflectEvents;
27
27
  private useDefaultPublisher;
28
28
  }
package/dist/event-bus.js CHANGED
@@ -18,94 +18,91 @@ const util_1 = require("util");
18
18
  const command_bus_1 = require("./command-bus");
19
19
  const constants_1 = require("./decorators/constants");
20
20
  const exceptions_1 = require("./exceptions");
21
- const default_get_event_name_1 = require("./helpers/default-get-event-name");
21
+ const default_get_event_id_1 = require("./helpers/default-get-event-id");
22
22
  const default_pubsub_1 = require("./helpers/default-pubsub");
23
23
  const utils_1 = require("./utils");
24
- let EventBus = (() => {
25
- let EventBus = class EventBus extends utils_1.ObservableBus {
26
- constructor(commandBus, moduleRef) {
27
- super();
28
- this.commandBus = commandBus;
29
- this.moduleRef = moduleRef;
30
- this.subscriptions = [];
31
- this.getEventName = default_get_event_name_1.defaultGetEventName;
32
- this.useDefaultPublisher();
24
+ let EventBus = class EventBus extends utils_1.ObservableBus {
25
+ constructor(commandBus, moduleRef) {
26
+ super();
27
+ this.commandBus = commandBus;
28
+ this.moduleRef = moduleRef;
29
+ this.subscriptions = [];
30
+ this.getEventId = default_get_event_id_1.defaultGetEventId;
31
+ this.useDefaultPublisher();
32
+ }
33
+ get publisher() {
34
+ return this._publisher;
35
+ }
36
+ set publisher(_publisher) {
37
+ this._publisher = _publisher;
38
+ }
39
+ onModuleDestroy() {
40
+ this.subscriptions.forEach((subscription) => subscription.unsubscribe());
41
+ }
42
+ publish(event) {
43
+ return this._publisher.publish(event);
44
+ }
45
+ publishAll(events) {
46
+ if (this._publisher.publishAll) {
47
+ return this._publisher.publishAll(events);
33
48
  }
34
- get publisher() {
35
- return this._publisher;
36
- }
37
- set publisher(_publisher) {
38
- this._publisher = _publisher;
39
- }
40
- onModuleDestroy() {
41
- this.subscriptions.forEach((subscription) => subscription.unsubscribe());
42
- }
43
- publish(event) {
44
- return this._publisher.publish(event);
45
- }
46
- publishAll(events) {
47
- if (this._publisher.publishAll) {
48
- return this._publisher.publishAll(events);
49
- }
50
- return (events || []).map((event) => this._publisher.publish(event));
51
- }
52
- bind(handler, name) {
53
- const stream$ = name ? this.ofEventName(name) : this.subject$;
54
- const subscription = stream$.subscribe((event) => handler.handle(event));
55
- this.subscriptions.push(subscription);
56
- }
57
- registerSagas(types = []) {
58
- const sagas = types
59
- .map((target) => {
60
- const metadata = Reflect.getMetadata(constants_1.SAGA_METADATA, target) || [];
61
- const instance = this.moduleRef.get(target, { strict: false });
62
- if (!instance) {
63
- throw new exceptions_1.InvalidSagaException();
64
- }
65
- return metadata.map((key) => instance[key]);
66
- })
67
- .reduce((a, b) => a.concat(b), []);
68
- sagas.forEach((saga) => this.registerSaga(saga));
69
- }
70
- register(handlers = []) {
71
- handlers.forEach((handler) => this.registerHandler(handler));
72
- }
73
- registerHandler(handler) {
74
- const instance = this.moduleRef.get(handler, { strict: false });
49
+ return (events || []).map((event) => this._publisher.publish(event));
50
+ }
51
+ bind(handler, id) {
52
+ const stream$ = id ? this.ofEventId(id) : this.subject$;
53
+ const subscription = stream$.subscribe((event) => handler.handle(event));
54
+ this.subscriptions.push(subscription);
55
+ }
56
+ registerSagas(types = []) {
57
+ const sagas = types
58
+ .map((target) => {
59
+ const metadata = Reflect.getMetadata(constants_1.SAGA_METADATA, target) || [];
60
+ const instance = this.moduleRef.get(target, { strict: false });
75
61
  if (!instance) {
76
- return;
77
- }
78
- const eventsNames = this.reflectEventsNames(handler);
79
- eventsNames.map((event) => this.bind(instance, event.name));
80
- }
81
- ofEventName(name) {
82
- return this.subject$.pipe(operators_1.filter((event) => this.getEventName(event) === name));
83
- }
84
- registerSaga(saga) {
85
- if (!util_1.isFunction(saga)) {
86
62
  throw new exceptions_1.InvalidSagaException();
87
63
  }
88
- const stream$ = saga(this);
89
- if (!(stream$ instanceof rxjs_1.Observable)) {
90
- throw new exceptions_1.InvalidSagaException();
91
- }
92
- const subscription = stream$
93
- .pipe(operators_1.filter((e) => !!e))
94
- .subscribe((command) => this.commandBus.execute(command));
95
- this.subscriptions.push(subscription);
64
+ return metadata.map((key) => instance[key].bind(instance));
65
+ })
66
+ .reduce((a, b) => a.concat(b), []);
67
+ sagas.forEach((saga) => this.registerSaga(saga));
68
+ }
69
+ register(handlers = []) {
70
+ handlers.forEach((handler) => this.registerHandler(handler));
71
+ }
72
+ registerHandler(handler) {
73
+ const instance = this.moduleRef.get(handler, { strict: false });
74
+ if (!instance) {
75
+ return;
96
76
  }
97
- reflectEventsNames(handler) {
98
- return Reflect.getMetadata(constants_1.EVENTS_HANDLER_METADATA, handler);
77
+ const events = this.reflectEvents(handler);
78
+ events.map((event) => this.bind(instance, (0, default_get_event_id_1.defaultReflectEventId)(event)));
79
+ }
80
+ ofEventId(name) {
81
+ return this.subject$.pipe((0, operators_1.filter)((event) => this.getEventId(event) === name));
82
+ }
83
+ registerSaga(saga) {
84
+ if (!(0, util_1.isFunction)(saga)) {
85
+ throw new exceptions_1.InvalidSagaException();
99
86
  }
100
- useDefaultPublisher() {
101
- this._publisher = new default_pubsub_1.DefaultPubSub(this.subject$);
87
+ const stream$ = saga(this);
88
+ if (!(stream$ instanceof rxjs_1.Observable)) {
89
+ throw new exceptions_1.InvalidSagaException();
102
90
  }
103
- };
104
- EventBus = __decorate([
105
- common_1.Injectable(),
106
- __metadata("design:paramtypes", [command_bus_1.CommandBus,
107
- core_1.ModuleRef])
108
- ], EventBus);
109
- return EventBus;
110
- })();
91
+ const subscription = stream$
92
+ .pipe((0, operators_1.filter)((e) => !!e))
93
+ .subscribe((command) => this.commandBus.execute(command));
94
+ this.subscriptions.push(subscription);
95
+ }
96
+ reflectEvents(handler) {
97
+ return Reflect.getMetadata(constants_1.EVENTS_HANDLER_METADATA, handler);
98
+ }
99
+ useDefaultPublisher() {
100
+ this._publisher = new default_pubsub_1.DefaultPubSub(this.subject$);
101
+ }
102
+ };
103
+ EventBus = __decorate([
104
+ (0, common_1.Injectable)(),
105
+ __metadata("design:paramtypes", [command_bus_1.CommandBus,
106
+ core_1.ModuleRef])
107
+ ], EventBus);
111
108
  exports.EventBus = EventBus;
@@ -12,31 +12,34 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.EventPublisher = void 0;
13
13
  const common_1 = require("@nestjs/common");
14
14
  const event_bus_1 = require("./event-bus");
15
- let EventPublisher = (() => {
16
- let EventPublisher = class EventPublisher {
17
- constructor(eventBus) {
18
- this.eventBus = eventBus;
19
- }
20
- mergeClassContext(metatype) {
21
- const eventBus = this.eventBus;
22
- return class extends metatype {
23
- publish(event) {
24
- eventBus.publish(event);
25
- }
26
- };
27
- }
28
- mergeObjectContext(object) {
29
- const eventBus = this.eventBus;
30
- object.publish = (event) => {
15
+ let EventPublisher = class EventPublisher {
16
+ constructor(eventBus) {
17
+ this.eventBus = eventBus;
18
+ }
19
+ mergeClassContext(metatype) {
20
+ const eventBus = this.eventBus;
21
+ return class extends metatype {
22
+ publish(event) {
31
23
  eventBus.publish(event);
32
- };
33
- return object;
34
- }
35
- };
36
- EventPublisher = __decorate([
37
- common_1.Injectable(),
38
- __metadata("design:paramtypes", [event_bus_1.EventBus])
39
- ], EventPublisher);
40
- return EventPublisher;
41
- })();
24
+ }
25
+ publishAll(events) {
26
+ eventBus.publishAll(events);
27
+ }
28
+ };
29
+ }
30
+ mergeObjectContext(object) {
31
+ const eventBus = this.eventBus;
32
+ object.publish = (event) => {
33
+ eventBus.publish(event);
34
+ };
35
+ object.publishAll = (events) => {
36
+ eventBus.publishAll(events);
37
+ };
38
+ return object;
39
+ }
40
+ };
41
+ EventPublisher = __decorate([
42
+ (0, common_1.Injectable)(),
43
+ __metadata("design:paramtypes", [event_bus_1.EventBus])
44
+ ], EventPublisher);
42
45
  exports.EventPublisher = EventPublisher;
@@ -7,8 +7,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
7
7
  o[k2] = m[k];
8
8
  }));
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
- }
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./command-not-found.exception"), exports);
14
14
  __exportStar(require("./invalid-command-handler.exception"), exports);
@@ -0,0 +1,4 @@
1
+ import { IEvent } from '../interfaces';
2
+ import { Type } from '@nestjs/common';
3
+ export declare const defaultGetEventId: <EventBase extends IEvent = IEvent>(event: EventBase) => string;
4
+ export declare const defaultReflectEventId: <EventBase extends Type<IEvent> = Type<IEvent>>(event: EventBase) => string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.defaultReflectEventId = exports.defaultGetEventId = void 0;
4
+ const constants_1 = require("../decorators/constants");
5
+ const defaultGetEventId = (event) => {
6
+ const { constructor } = Object.getPrototypeOf(event);
7
+ return Reflect.getMetadata(constants_1.EVENT_METADATA, constructor).id;
8
+ };
9
+ exports.defaultGetEventId = defaultGetEventId;
10
+ const defaultReflectEventId = (event) => {
11
+ return Reflect.getMetadata(constants_1.EVENT_METADATA, event).id;
12
+ };
13
+ exports.defaultReflectEventId = defaultReflectEventId;
@@ -1,7 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultGetEventName = void 0;
4
- exports.defaultGetEventName = (event) => {
4
+ const defaultGetEventName = (event) => {
5
5
  const { constructor } = Object.getPrototypeOf(event);
6
6
  return constructor.name;
7
7
  };
8
+ exports.defaultGetEventName = defaultGetEventName;
package/dist/index.js CHANGED
@@ -1,4 +1,10 @@
1
1
  "use strict";
2
+ /*
3
+ * Nest CQRS Module
4
+ * Copyright(c) 2017-... Kamil Mysliwiec
5
+ * www.kamilmysliwiec.com
6
+ * MIT Licensed
7
+ */
2
8
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
9
  if (k2 === undefined) k2 = k;
4
10
  Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
@@ -7,8 +13,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
7
13
  o[k2] = m[k];
8
14
  }));
9
15
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
- }
16
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
17
+ };
12
18
  Object.defineProperty(exports, "__esModule", { value: true });
13
19
  __exportStar(require("./aggregate-root"), exports);
14
20
  __exportStar(require("./command-bus"), exports);
@@ -1,4 +1,4 @@
1
1
  import { ICommand } from './command.interface';
2
2
  export interface ICommandBus<CommandBase extends ICommand = ICommand> {
3
- execute<T extends CommandBase>(command: T): Promise<any>;
3
+ execute<T extends CommandBase, R = any>(command: T): Promise<R>;
4
4
  }
@@ -0,0 +1,3 @@
1
+ export interface CommandMetadata {
2
+ id: string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -7,8 +7,8 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
7
7
  o[k2] = m[k];
8
8
  }));
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
- }
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./commands/command-bus.interface"), exports);
14
14
  __exportStar(require("./commands/command-handler.interface"), exports);
@@ -0,0 +1,3 @@
1
+ export interface QueryMetadata {
2
+ id: string;
3
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -7,7 +7,7 @@ var __createBinding = (this && this.__createBinding) || (Object.create ? (functi
7
7
  o[k2] = m[k];
8
8
  }));
9
9
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
11
- }
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  __exportStar(require("./of-type"), exports);
@@ -1,4 +1,12 @@
1
1
  import { Type } from '@nestjs/common';
2
2
  import { Observable } from 'rxjs';
3
3
  import { IEvent } from '../interfaces';
4
+ /**
5
+ * Filter values depending on their instance type (comparison is made
6
+ * using native `instanceof`).
7
+ *
8
+ * @param types List of types implementing `IEvent`.
9
+ *
10
+ * @return A stream only emitting the filtered instances.
11
+ */
4
12
  export declare function ofType<TInput extends IEvent, TOutput extends IEvent>(...types: Type<TOutput>[]): (source: Observable<TInput>) => Observable<TOutput>;
@@ -2,8 +2,16 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.ofType = void 0;
4
4
  const operators_1 = require("rxjs/operators");
5
+ /**
6
+ * Filter values depending on their instance type (comparison is made
7
+ * using native `instanceof`).
8
+ *
9
+ * @param types List of types implementing `IEvent`.
10
+ *
11
+ * @return A stream only emitting the filtered instances.
12
+ */
5
13
  function ofType(...types) {
6
14
  const isInstanceOf = (event) => !!types.find((classType) => event instanceof classType);
7
- return (source) => source.pipe(operators_1.filter(isInstanceOf));
15
+ return (source) => source.pipe((0, operators_1.filter)(isInstanceOf));
8
16
  }
9
17
  exports.ofType = ofType;
@@ -12,10 +12,10 @@ export declare class QueryBus<QueryBase extends IQuery = IQuery> extends Observa
12
12
  get publisher(): IQueryPublisher<QueryBase>;
13
13
  set publisher(_publisher: IQueryPublisher<QueryBase>);
14
14
  execute<T extends QueryBase, TResult = any>(query: T): Promise<TResult>;
15
- bind<T extends QueryBase, TResult = any>(handler: IQueryHandler<T, TResult>, name: string): void;
15
+ bind<T extends QueryBase, TResult = any>(handler: IQueryHandler<T, TResult>, queryId: string): void;
16
16
  register(handlers?: QueryHandlerType<QueryBase>[]): void;
17
17
  protected registerHandler(handler: QueryHandlerType<QueryBase>): void;
18
- private getQueryName;
19
- private reflectQueryName;
18
+ private getQueryId;
19
+ private reflectQueryId;
20
20
  private useDefaultPublisher;
21
21
  }