@nestjs/cqrs 8.0.2 → 8.0.3

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.
@@ -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 getEventId: (event: EventBase) => string;
11
+ protected getEventId: (event: EventBase) => string | null;
12
12
  protected readonly subscriptions: Subscription[];
13
13
  private _publisher;
14
14
  constructor(commandBus: CommandBus, moduleRef: ModuleRef);
@@ -21,7 +21,7 @@ export declare class EventBus<EventBase extends IEvent = IEvent> extends Observa
21
21
  registerSagas(types?: Type<unknown>[]): void;
22
22
  register(handlers?: EventHandlerType<EventBase>[]): void;
23
23
  protected registerHandler(handler: EventHandlerType<EventBase>): void;
24
- protected ofEventId(name: string): Observable<EventBase>;
24
+ protected ofEventId(id: string): Observable<EventBase>;
25
25
  protected registerSaga(saga: ISaga<EventBase>): void;
26
26
  private reflectEvents;
27
27
  private useDefaultPublisher;
package/dist/event-bus.js CHANGED
@@ -77,8 +77,8 @@ let EventBus = class EventBus extends utils_1.ObservableBus {
77
77
  const events = this.reflectEvents(handler);
78
78
  events.map((event) => this.bind(instance, (0, default_get_event_id_1.defaultReflectEventId)(event)));
79
79
  }
80
- ofEventId(name) {
81
- return this.subject$.pipe((0, operators_1.filter)((event) => this.getEventId(event) === name));
80
+ ofEventId(id) {
81
+ return this.subject$.pipe((0, operators_1.filter)((event) => this.getEventId(event) === id));
82
82
  }
83
83
  registerSaga(saga) {
84
84
  if (!(0, util_1.isFunction)(saga)) {
@@ -1,4 +1,9 @@
1
1
  import { IEvent } from '../interfaces';
2
2
  import { Type } from '@nestjs/common';
3
+ /**
4
+ * Null if the published class is not connected to any handler
5
+ * @param event
6
+ * @returns
7
+ */
3
8
  export declare const defaultGetEventId: <EventBase extends IEvent = IEvent>(event: EventBase) => string;
4
9
  export declare const defaultReflectEventId: <EventBase extends Type<IEvent> = Type<IEvent>>(event: EventBase) => string;
@@ -2,9 +2,15 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.defaultReflectEventId = exports.defaultGetEventId = void 0;
4
4
  const constants_1 = require("../decorators/constants");
5
+ /**
6
+ * Null if the published class is not connected to any handler
7
+ * @param event
8
+ * @returns
9
+ */
5
10
  const defaultGetEventId = (event) => {
11
+ var _a, _b;
6
12
  const { constructor } = Object.getPrototypeOf(event);
7
- return Reflect.getMetadata(constants_1.EVENT_METADATA, constructor).id;
13
+ return (_b = (_a = Reflect.getMetadata(constants_1.EVENT_METADATA, constructor)) === null || _a === void 0 ? void 0 : _a.id) !== null && _b !== void 0 ? _b : null;
8
14
  };
9
15
  exports.defaultGetEventId = defaultGetEventId;
10
16
  const defaultReflectEventId = (event) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nestjs/cqrs",
3
- "version": "8.0.2",
3
+ "version": "8.0.3",
4
4
  "description": "A lightweight CQRS module for Nest framework (node.js)",
5
5
  "license": "MIT",
6
6
  "url": "https://github.com/nestjs/cqrs#readme",
@@ -22,24 +22,24 @@
22
22
  "devDependencies": {
23
23
  "@commitlint/cli": "16.2.1",
24
24
  "@commitlint/config-angular": "16.2.1",
25
- "@nestjs/common": "8.3.0",
26
- "@nestjs/core": "8.3.0",
27
- "@types/node": "16.11.24",
28
- "@types/jest": "27.4.0",
29
- "@typescript-eslint/eslint-plugin": "5.11.0",
30
- "@typescript-eslint/parser": "5.11.0",
31
- "eslint": "8.9.0",
32
- "eslint-config-prettier": "8.3.0",
25
+ "@nestjs/common": "8.4.0",
26
+ "@nestjs/core": "8.4.0",
27
+ "@types/node": "16.11.26",
28
+ "@types/jest": "27.4.1",
29
+ "@typescript-eslint/eslint-plugin": "5.13.0",
30
+ "@typescript-eslint/parser": "5.13.0",
31
+ "eslint": "8.10.0",
32
+ "eslint-config-prettier": "8.4.0",
33
33
  "eslint-plugin-import": "2.25.4",
34
34
  "husky": "7.0.4",
35
35
  "jest": "27.5.1",
36
36
  "lint-staged": "12.3.4",
37
37
  "prettier": "2.5.1",
38
38
  "reflect-metadata": "0.1.13",
39
- "release-it": "14.12.4",
39
+ "release-it": "14.12.5",
40
40
  "rxjs": "7.5.4",
41
41
  "ts-jest": "27.1.3",
42
- "typescript": "4.5.5"
42
+ "typescript": "4.6.2"
43
43
  },
44
44
  "peerDependencies": {
45
45
  "@nestjs/common": "^8.0.0",