@eratu/common 1.0.3 → 1.0.5

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.
@@ -1,5 +1,5 @@
1
- import { Streams } from "./streams";
2
- import { Subjects } from "./subjects";
1
+ import { Streams } from "../streams";
2
+ import { Subjects } from "../subjects";
3
3
  export interface BookCreatedEvent {
4
4
  subject: Subjects.BookCreated;
5
5
  stream: Streams.BookServiceStream;
@@ -0,0 +1,10 @@
1
+ import { Streams } from "../streams";
2
+ import { Subjects } from "../subjects";
3
+ export interface BookDeletedEvent {
4
+ subject: Subjects.BookDeleted;
5
+ stream: Streams.BookServiceStream;
6
+ data: {
7
+ id: string;
8
+ version: number;
9
+ };
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,11 @@
1
+ import { Streams } from "../streams";
2
+ import { Subjects } from "../subjects";
3
+ export interface BookUpdatedEvent {
4
+ subject: Subjects.BookUpdated;
5
+ stream: Streams.BookServiceStream;
6
+ data: {
7
+ id: string;
8
+ version: number;
9
+ title: string;
10
+ };
11
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -7,7 +7,7 @@ export interface Event {
7
7
  export declare abstract class Publisher<T extends Event> {
8
8
  abstract subject: T["subject"];
9
9
  abstract stream: T["stream"];
10
- protected js: JetStreamClient;
10
+ protected jsClient: JetStreamClient;
11
11
  protected codec: import("nats").Codec<unknown>;
12
12
  constructor(js: JetStreamClient);
13
13
  publish(data: T["data"]): Promise<void>;
@@ -14,12 +14,12 @@ const nats_1 = require("nats");
14
14
  class Publisher {
15
15
  constructor(js) {
16
16
  this.codec = (0, nats_1.JSONCodec)();
17
- this.js = js;
17
+ this.jsClient = js;
18
18
  }
19
19
  publish(data) {
20
20
  return __awaiter(this, void 0, void 0, function* () {
21
21
  const message = this.codec.encode(data);
22
- yield this.js.publish(this.subject, message);
22
+ yield this.jsClient.publish(this.subject, message);
23
23
  console.log(`Message published to ${this.subject}:`, data);
24
24
  });
25
25
  }
@@ -1,6 +1,10 @@
1
1
  export declare enum Subjects {
2
- UserRegistered = "user:registered",
2
+ UserCreated = "user:created",
3
+ UserUpdated = "user:updated",
4
+ UserDeleted = "user:deleted",
3
5
  BookCreated = "book:created",
6
+ BookUpdated = "book:updated",
7
+ BookDeleted = "book:deleted",
4
8
  OrderCreated = "order:created",
5
9
  OrderCancelled = "order:cancelled"
6
10
  }
@@ -3,8 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.Subjects = void 0;
4
4
  var Subjects;
5
5
  (function (Subjects) {
6
- Subjects["UserRegistered"] = "user:registered";
6
+ Subjects["UserCreated"] = "user:created";
7
+ Subjects["UserUpdated"] = "user:updated";
8
+ Subjects["UserDeleted"] = "user:deleted";
7
9
  Subjects["BookCreated"] = "book:created";
10
+ Subjects["BookUpdated"] = "book:updated";
11
+ Subjects["BookDeleted"] = "book:deleted";
8
12
  Subjects["OrderCreated"] = "order:created";
9
13
  Subjects["OrderCancelled"] = "order:cancelled";
10
14
  })(Subjects || (exports.Subjects = Subjects = {}));
@@ -0,0 +1,12 @@
1
+ import { Streams } from "../streams";
2
+ import { Subjects } from "../subjects";
3
+ export interface UserCreatedEvent {
4
+ subject: Subjects.UserCreated;
5
+ stream: Streams.UserServiceStream;
6
+ data: {
7
+ id: string;
8
+ firstName: string;
9
+ lastName: string;
10
+ email: string;
11
+ };
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ import { Streams } from "../streams";
2
+ import { Subjects } from "../subjects";
3
+ export interface UserDeletedEvent {
4
+ subject: Subjects.UserDeleted;
5
+ stream: Streams.UserServiceStream;
6
+ data: {
7
+ id: string;
8
+ version: number;
9
+ };
10
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,12 @@
1
+ import { Streams } from "../streams";
2
+ import { Subjects } from "../subjects";
3
+ export interface UserUpdatedEvent {
4
+ subject: Subjects.UserUpdated;
5
+ stream: Streams.UserServiceStream;
6
+ data: {
7
+ id: string;
8
+ firstName: string;
9
+ lastName: string;
10
+ email: string;
11
+ };
12
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/build/index.d.ts CHANGED
@@ -6,6 +6,11 @@ export * from "./errors/not-found-error";
6
6
  export * from "./errors/request-validation-error";
7
7
  export * from "./events/listeners/base-listener";
8
8
  export * from "./events/publishers/base-publisher";
9
- export * from "./events/book-created-event";
9
+ export * from "./events/book/book-created-event";
10
+ export * from "./events/book/book-updated-event";
11
+ export * from "./events/book/book-deleted-event";
12
+ export * from "./events/user/user-created-event";
13
+ export * from "./events/user/user-updated-event";
14
+ export * from "./events/user/user-deleted-event";
10
15
  export * from "./events/subjects";
11
16
  export * from "./events/streams";
package/build/index.js CHANGED
@@ -22,6 +22,11 @@ __exportStar(require("./errors/not-found-error"), exports);
22
22
  __exportStar(require("./errors/request-validation-error"), exports);
23
23
  __exportStar(require("./events/listeners/base-listener"), exports);
24
24
  __exportStar(require("./events/publishers/base-publisher"), exports);
25
- __exportStar(require("./events/book-created-event"), exports);
25
+ __exportStar(require("./events/book/book-created-event"), exports);
26
+ __exportStar(require("./events/book/book-updated-event"), exports);
27
+ __exportStar(require("./events/book/book-deleted-event"), exports);
28
+ __exportStar(require("./events/user/user-created-event"), exports);
29
+ __exportStar(require("./events/user/user-updated-event"), exports);
30
+ __exportStar(require("./events/user/user-deleted-event"), exports);
26
31
  __exportStar(require("./events/subjects"), exports);
27
32
  __exportStar(require("./events/streams"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eratu/common",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "A package for shared code across microservices",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -8,8 +8,8 @@
8
8
  "build/**/*"
9
9
  ],
10
10
  "scripts": {
11
- "clean": "del ./build/*",
12
- "build": "tsc",
11
+ "clean": "del-cli ./build/*",
12
+ "build": "npm run clean && tsc",
13
13
  "pub": "git add . && git commit -m \"Updates\" && npm version patch && npm publish"
14
14
  },
15
15
  "keywords": [],