diff --git a/dist/cqrs/event.publisher.d.ts b/dist/cqrs/event.publisher.d.ts new file mode 100644 index 0000000..e616e04 --- /dev/null +++ b/dist/cqrs/event.publisher.d.ts @@ -0,0 +1,9 @@ +import { IEvent } from "./event.interface"; +export interface IEventPublisher { + publish(event: TEvent): Promise; + publishAll(event: TEvent[]): Promise; +} +export declare class EventPublisher implements EventPublisher { + publish(event: TEvent): Promise; + publishAll(events: TEvent[]): Promise[]; +} diff --git a/dist/cqrs/event.publisher.js b/dist/cqrs/event.publisher.js new file mode 100644 index 0000000..885ef2b --- /dev/null +++ b/dist/cqrs/event.publisher.js @@ -0,0 +1,34 @@ +"use strict"; +var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { + var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; + if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); + else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; + return c > 3 && r && Object.defineProperty(target, key, r), r; +}; +var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { + function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } + return new (P || (P = Promise))(function (resolve, reject) { + function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } + function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } + function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } + step((generator = generator.apply(thisArg, _arguments || [])).next()); + }); +}; +Object.defineProperty(exports, "__esModule", { value: true }); +exports.EventPublisher = void 0; +const typedi_1 = require("typedi"); +const cqrs_config_1 = require("../cqrs.config"); +let EventPublisher = class EventPublisher { + publish(event) { + return __awaiter(this, void 0, void 0, function* () { + cqrs_config_1.default.publish(event); + }); + } + publishAll(events) { + return (events || []).map((event) => cqrs_config_1.default.publish(event)); + } +}; +EventPublisher = __decorate([ + (0, typedi_1.Service)() +], EventPublisher); +exports.EventPublisher = EventPublisher; diff --git a/dist/cqrs/index.d.ts b/dist/cqrs/index.d.ts index aea3a90..1f7e1ec 100644 --- a/dist/cqrs/index.d.ts +++ b/dist/cqrs/index.d.ts @@ -1,4 +1,5 @@ import "reflect-metadata"; +export * from "./event.publisher"; export * from "./hooks/command.hook"; export * from "./hooks/query.hook"; export * from "./query.interface"; diff --git a/dist/cqrs/index.js b/dist/cqrs/index.js index 45e55dc..b4507ba 100644 --- a/dist/cqrs/index.js +++ b/dist/cqrs/index.js @@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { }; Object.defineProperty(exports, "__esModule", { value: true }); require("reflect-metadata"); +__exportStar(require("./event.publisher"), exports); __exportStar(require("./hooks/command.hook"), exports); __exportStar(require("./hooks/query.hook"), exports); __exportStar(require("./query.interface"), exports); diff --git a/dist/index.d.ts b/dist/index.d.ts index 45111a0..ebea3de 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -1,3 +1,3 @@ -export * from "./utils/errorsFormatter"; +import "reflect-metadata"; export * from "./cqrs.config"; export * from "./cqrs"; diff --git a/dist/index.js b/dist/index.js index 90d707b..15150e7 100644 --- a/dist/index.js +++ b/dist/index.js @@ -10,6 +10,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("./utils/errorsFormatter"), exports); +require("reflect-metadata"); __exportStar(require("./cqrs.config"), exports); __exportStar(require("./cqrs"), exports); diff --git a/package.json b/package.json index 3749f1f..f64fab8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "use-cqrs", - "version": "1.1.11-alpha", + "version": "1.2.1-alpha", "description": "React hooks library for applying CQRS design patterns and Single Responsibility Principle (SRP) in frontend development", "keywords": [ "cqrs", @@ -67,9 +67,7 @@ "@wry/equality": "^0.5.2", "class-transformer": "^0.5.1", "class-validator": "^0.13.2", - "iterare": "^1.2.1", "mediatr-ts": "^0.2.1", "typedi": "^0.10.0" - } -} +} \ No newline at end of file