@hastehaul/common 1.0.12 → 1.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (43) hide show
  1. package/build/connections-wrappers/nats-wrapper.d.ts +8 -0
  2. package/build/connections-wrappers/nats-wrapper.js +31 -0
  3. package/build/events/base/base-consumer.d.ts +26 -0
  4. package/build/events/base/base-consumer.js +96 -0
  5. package/build/events/base/base-publisher.d.ts +14 -0
  6. package/build/events/base/base-publisher.js +32 -0
  7. package/build/events/base/base-stream.d.ts +13 -0
  8. package/build/events/base/base-stream.js +28 -0
  9. package/build/events/common/enums/durable-names/index.d.ts +3 -0
  10. package/build/events/common/enums/durable-names/index.js +2 -0
  11. package/build/events/common/enums/durable-names/order-dname.d.ts +5 -0
  12. package/build/events/common/enums/durable-names/order-dname.js +9 -0
  13. package/build/events/common/enums/durable-names/payment-dname.d.ts +4 -0
  14. package/build/events/common/enums/durable-names/payment-dname.js +8 -0
  15. package/build/events/common/enums/index.d.ts +3 -0
  16. package/build/events/common/enums/index.js +19 -0
  17. package/build/events/common/enums/streams/index.d.ts +3 -0
  18. package/build/events/common/enums/streams/index.js +2 -0
  19. package/build/events/common/enums/streams/order-stream.d.ts +3 -0
  20. package/build/events/common/enums/streams/order-stream.js +7 -0
  21. package/build/events/common/enums/streams/payment-stream.d.ts +3 -0
  22. package/build/events/common/enums/streams/payment-stream.js +7 -0
  23. package/build/events/common/enums/subjects/index.d.ts +3 -0
  24. package/build/events/common/enums/subjects/index.js +2 -0
  25. package/build/events/common/enums/subjects/main-subjects.d.ts +10 -0
  26. package/build/events/common/enums/subjects/main-subjects.js +11 -0
  27. package/build/events/common/enums/subjects/order-subjects.d.ts +5 -0
  28. package/build/events/common/enums/subjects/order-subjects.js +9 -0
  29. package/build/events/common/enums/subjects/payment-subjects.d.ts +4 -0
  30. package/build/events/common/enums/subjects/payment-subjects.js +8 -0
  31. package/build/events/common/interfaces/order-events-interfaces/order-cancelled-event.d.ts +15 -0
  32. package/build/events/common/interfaces/order-events-interfaces/order-cancelled-event.js +2 -0
  33. package/build/events/common/interfaces/order-events-interfaces/order-completed-event.d.ts +15 -0
  34. package/build/events/common/interfaces/order-events-interfaces/order-completed-event.js +2 -0
  35. package/build/events/common/interfaces/order-events-interfaces/order-requested-event.d.ts +15 -0
  36. package/build/events/common/interfaces/order-events-interfaces/order-requested-event.js +2 -0
  37. package/build/events/common/interfaces/payment-event-interfaces/payment-created-event.d.ts +0 -0
  38. package/build/events/common/interfaces/payment-event-interfaces/payment-created-event.js +1 -0
  39. package/build/events/common/interfaces/payment-event-interfaces/payment-failed-event.d.ts +0 -0
  40. package/build/events/common/interfaces/payment-event-interfaces/payment-failed-event.js +1 -0
  41. package/build/events/common/interfaces/stream-interfaces/order-stream-interface.d.ts +6 -0
  42. package/build/events/common/interfaces/stream-interfaces/order-stream-interface.js +2 -0
  43. package/package.json +2 -1
@@ -0,0 +1,8 @@
1
+ import { ConnectionOptions, NatsConnection } from 'nats';
2
+ declare class NatsWrapper {
3
+ private _client?;
4
+ get client(): NatsConnection;
5
+ connect(opts?: ConnectionOptions): Promise<void>;
6
+ }
7
+ export declare const natsWrapper: NatsWrapper;
8
+ export {};
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.natsWrapper = void 0;
13
+ const nats_1 = require("nats");
14
+ class NatsWrapper {
15
+ get client() {
16
+ if (!this._client)
17
+ throw new Error("Cannot access NATS CLIENT before connecting");
18
+ return this._client;
19
+ }
20
+ connect(opts) {
21
+ return __awaiter(this, void 0, void 0, function* () {
22
+ try {
23
+ this._client = yield (0, nats_1.connect)(opts);
24
+ }
25
+ catch (error) {
26
+ console.log(`error connecting to ${JSON.stringify(opts === null || opts === void 0 ? void 0 : opts.servers)}`);
27
+ }
28
+ });
29
+ }
30
+ }
31
+ exports.natsWrapper = new NatsWrapper();
@@ -0,0 +1,26 @@
1
+ import { NatsConnection, ConsumerConfig, JsMsg } from "nats";
2
+ import { DurableName, Subjects, Streams } from "../common/enums";
3
+ import { MainSubjects, ValidateSubjectFormat } from "../common/enums/subjects/main-subjects";
4
+ interface Event {
5
+ subject: ValidateSubjectFormat<Subjects, MainSubjects>;
6
+ durableName?: DurableName;
7
+ stream: Streams;
8
+ data: any;
9
+ }
10
+ export declare abstract class NatsConsumer<T extends Event> {
11
+ protected client: NatsConnection;
12
+ protected jc: import("nats").Codec<T>;
13
+ protected sc: import("nats").Codec<string>;
14
+ abstract stream: T["stream"];
15
+ abstract subject: T["subject"];
16
+ abstract durableName: T["durableName"];
17
+ abstract maxConcurrentMessages: number;
18
+ protected ackWait: number;
19
+ constructor(client: NatsConnection);
20
+ get consumerOptions(): Partial<ConsumerConfig>;
21
+ consume(): Promise<void>;
22
+ abstract processMessage(data: T["data"], msg: JsMsg): Promise<void>;
23
+ protected close(): Promise<void>;
24
+ protected parsedMessage: (msg: JsMsg) => string | T;
25
+ }
26
+ export {};
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __asyncValues = (this && this.__asyncValues) || function (o) {
12
+ if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
13
+ var m = o[Symbol.asyncIterator], i;
14
+ return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
15
+ function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
16
+ function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
17
+ };
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.NatsConsumer = void 0;
20
+ const nats_1 = require("nats");
21
+ class NatsConsumer {
22
+ constructor(client) {
23
+ this.jc = (0, nats_1.JSONCodec)();
24
+ this.sc = (0, nats_1.StringCodec)();
25
+ this.ackWait = (0, nats_1.nanos)(5 * 1000);
26
+ this.parsedMessage = (msg) => typeof msg.data === "string" ? this.sc.decode(msg.data) : this.jc.decode(msg.data);
27
+ this.client = client;
28
+ }
29
+ get consumerOptions() {
30
+ return {
31
+ deliver_policy: nats_1.DeliverPolicy.All,
32
+ ack_policy: nats_1.AckPolicy.Explicit,
33
+ ack_wait: this.ackWait,
34
+ durable_name: this.durableName,
35
+ replay_policy: nats_1.ReplayPolicy.Instant,
36
+ filter_subject: this.subject,
37
+ };
38
+ }
39
+ consume() {
40
+ var _a, e_1, _b, _c;
41
+ return __awaiter(this, void 0, void 0, function* () {
42
+ console.log(this.stream, this.durableName, this.subject);
43
+ try {
44
+ const jsm = yield this.client.jetstreamManager();
45
+ yield jsm.consumers.add(this.stream, this.consumerOptions);
46
+ const js = this.client.jetstream();
47
+ const consumer = yield js.consumers.get(this.stream, this.durableName);
48
+ const messages = yield consumer.consume({ max_messages: 5 });
49
+ let pendingMessages = [];
50
+ let inFlight = 0;
51
+ try {
52
+ for (var _d = true, messages_1 = __asyncValues(messages), messages_1_1; messages_1_1 = yield messages_1.next(), _a = messages_1_1.done, !_a; _d = true) {
53
+ _c = messages_1_1.value;
54
+ _d = false;
55
+ const msg = _c;
56
+ // Process messages asynchronously up to the maximum concurrent limit
57
+ if (inFlight < this.maxConcurrentMessages) {
58
+ const parsedMessage = this.parsedMessage(msg);
59
+ inFlight++;
60
+ yield this.processMessage(parsedMessage, msg).then(() => { inFlight--; }).catch(() => { inFlight--; });
61
+ }
62
+ else {
63
+ console.log("PENDING MESSAGES: ", pendingMessages);
64
+ pendingMessages.push(msg); // Store the message to be processed later
65
+ }
66
+ // Check if there are pending messages that can be processed
67
+ while (pendingMessages.length && inFlight < this.maxConcurrentMessages) {
68
+ console.log("PENDING MESSAGES: ", pendingMessages);
69
+ const pendingMessage = pendingMessages.shift();
70
+ const parsedMessage = this.parsedMessage(pendingMessage);
71
+ inFlight++;
72
+ yield this.processMessage(parsedMessage, pendingMessage).then(() => { inFlight--; }).catch(() => { inFlight--; });
73
+ }
74
+ }
75
+ }
76
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
77
+ finally {
78
+ try {
79
+ if (!_d && !_a && (_b = messages_1.return)) yield _b.call(messages_1);
80
+ }
81
+ finally { if (e_1) throw e_1.error; }
82
+ }
83
+ }
84
+ catch (error) {
85
+ console.error(error.message);
86
+ // throw new Error("Failed to consume messages");
87
+ }
88
+ });
89
+ }
90
+ close() {
91
+ return __awaiter(this, void 0, void 0, function* () {
92
+ yield this.client.drain();
93
+ });
94
+ }
95
+ }
96
+ exports.NatsConsumer = NatsConsumer;
@@ -0,0 +1,14 @@
1
+ import { PubAck, NatsConnection } from "nats";
2
+ import { Subjects } from "../common/enums";
3
+ import { MainSubjects, ValidateSubjectFormat } from "../common/enums/subjects/main-subjects";
4
+ interface Event {
5
+ subject: ValidateSubjectFormat<Subjects, MainSubjects>;
6
+ data: any;
7
+ }
8
+ export declare abstract class NatsPublisher<T extends Event> {
9
+ private jc;
10
+ private sc;
11
+ abstract subject: T["subject"];
12
+ publish(nc: NatsConnection, data: T["data"]): Promise<PubAck>;
13
+ }
14
+ export {};
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.NatsPublisher = void 0;
13
+ const nats_1 = require("nats");
14
+ class NatsPublisher {
15
+ constructor() {
16
+ this.jc = (0, nats_1.JSONCodec)();
17
+ this.sc = (0, nats_1.StringCodec)();
18
+ }
19
+ publish(nc, data) {
20
+ return __awaiter(this, void 0, void 0, function* () {
21
+ try {
22
+ const jetStreamClient = nc.jetstream();
23
+ return yield jetStreamClient.publish(this.subject, typeof data === "string" ? this.sc.encode(data) : this.jc.encode(data));
24
+ }
25
+ catch (error) {
26
+ console.error(error.message);
27
+ throw new Error(`Failed to publish message. Error: [${error.message}]`);
28
+ }
29
+ });
30
+ }
31
+ }
32
+ exports.NatsPublisher = NatsPublisher;
@@ -0,0 +1,13 @@
1
+ import { NatsConnection } from "nats";
2
+ import { Streams } from "../common/enums";
3
+ import { MainSubjects } from "../common/enums/subjects/main-subjects";
4
+ interface Event {
5
+ subject: MainSubjects;
6
+ stream: Streams;
7
+ }
8
+ export declare abstract class NatsStream<T extends Event> {
9
+ abstract subject: T["subject"];
10
+ abstract stream: T['stream'];
11
+ init(client: NatsConnection): Promise<void>;
12
+ }
13
+ export {};
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.NatsStream = void 0;
13
+ class NatsStream {
14
+ init(client) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ try {
17
+ const jsm = yield client.jetstreamManager();
18
+ yield jsm.streams.add({ name: this.stream, subjects: [this.subject] });
19
+ return;
20
+ }
21
+ catch (error) {
22
+ console.error(error.message);
23
+ throw new Error("Failed to add stream");
24
+ }
25
+ });
26
+ }
27
+ }
28
+ exports.NatsStream = NatsStream;
@@ -0,0 +1,3 @@
1
+ import { PaymentDurableName } from "./payment-dname";
2
+ import { OrderDurableName } from "./order-dname";
3
+ export type DurableName = OrderDurableName | PaymentDurableName;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,5 @@
1
+ export declare enum OrderDurableName {
2
+ OrderCancelledDurablename = "order-cancelled-consumer",
3
+ OrderRequestDurablename = "order-requested-consumer",
4
+ OrderCompletedDurablename = "order-completed-consumer"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderDurableName = void 0;
4
+ var OrderDurableName;
5
+ (function (OrderDurableName) {
6
+ OrderDurableName["OrderCancelledDurablename"] = "order-cancelled-consumer";
7
+ OrderDurableName["OrderRequestDurablename"] = "order-requested-consumer";
8
+ OrderDurableName["OrderCompletedDurablename"] = "order-completed-consumer";
9
+ })(OrderDurableName || (exports.OrderDurableName = OrderDurableName = {}));
@@ -0,0 +1,4 @@
1
+ export declare enum PaymentDurableName {
2
+ PaymentFailedDurableName = "payment-failed-consumer",
3
+ PaymentCreatedDurableName = "payment-created-consumer"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentDurableName = void 0;
4
+ var PaymentDurableName;
5
+ (function (PaymentDurableName) {
6
+ PaymentDurableName["PaymentFailedDurableName"] = "payment-failed-consumer";
7
+ PaymentDurableName["PaymentCreatedDurableName"] = "payment-created-consumer";
8
+ })(PaymentDurableName || (exports.PaymentDurableName = PaymentDurableName = {}));
@@ -0,0 +1,3 @@
1
+ export * from "./durable-names";
2
+ export * from "./streams";
3
+ export * from "./subjects";
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./durable-names"), exports);
18
+ __exportStar(require("./streams"), exports);
19
+ __exportStar(require("./subjects"), exports);
@@ -0,0 +1,3 @@
1
+ import { PaymentStream } from './payment-stream';
2
+ import { OrderStream } from './order-stream';
3
+ export type Streams = OrderStream | PaymentStream;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,3 @@
1
+ export declare enum OrderStream {
2
+ Order = "ORDER"
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderStream = void 0;
4
+ var OrderStream;
5
+ (function (OrderStream) {
6
+ OrderStream["Order"] = "ORDER";
7
+ })(OrderStream || (exports.OrderStream = OrderStream = {}));
@@ -0,0 +1,3 @@
1
+ export declare enum PaymentStream {
2
+ Payment = "PAYMENT"
3
+ }
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentStream = void 0;
4
+ var PaymentStream;
5
+ (function (PaymentStream) {
6
+ PaymentStream["Payment"] = "PAYMENT";
7
+ })(PaymentStream || (exports.PaymentStream = PaymentStream = {}));
@@ -0,0 +1,3 @@
1
+ import { PaymentSubjects } from './payment-subjects';
2
+ import { OrderSubjects } from './order-subjects';
3
+ export type Subjects = OrderSubjects | PaymentSubjects;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,10 @@
1
+ export declare enum MainSubjects {
2
+ ORDER = "order.*",
3
+ PAYMENT = "payment.*",
4
+ ETA = "eta.*"
5
+ }
6
+ type SubjectFormat<T extends string, U extends string> = `${T}.${U}`;
7
+ type ExtractStringBeforeColon<T extends string> = T extends `${infer StringBeforeColon}.*` ? StringBeforeColon : never;
8
+ export type ValidateSubjectFormat<T extends string, U extends string> = U extends MainSubjects ? T extends SubjectFormat<ExtractStringBeforeColon<MainSubjects>, string> ? T : never : never;
9
+ export declare const spreadEnumValues: <T extends Record<string, string>>(enumObject: T) => string[];
10
+ export {};
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.spreadEnumValues = exports.MainSubjects = void 0;
4
+ var MainSubjects;
5
+ (function (MainSubjects) {
6
+ MainSubjects["ORDER"] = "order.*";
7
+ MainSubjects["PAYMENT"] = "payment.*";
8
+ MainSubjects["ETA"] = "eta.*";
9
+ })(MainSubjects || (exports.MainSubjects = MainSubjects = {}));
10
+ const spreadEnumValues = (enumObject) => Object.values(enumObject);
11
+ exports.spreadEnumValues = spreadEnumValues;
@@ -0,0 +1,5 @@
1
+ export declare enum OrderSubjects {
2
+ OrderCancelled = "order.cancelled",
3
+ OrderRequested = "order.requested",
4
+ OrderCompleted = "order.completed"
5
+ }
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OrderSubjects = void 0;
4
+ var OrderSubjects;
5
+ (function (OrderSubjects) {
6
+ OrderSubjects["OrderCancelled"] = "order.cancelled";
7
+ OrderSubjects["OrderRequested"] = "order.requested";
8
+ OrderSubjects["OrderCompleted"] = "order.completed";
9
+ })(OrderSubjects || (exports.OrderSubjects = OrderSubjects = {}));
@@ -0,0 +1,4 @@
1
+ export declare enum PaymentSubjects {
2
+ PaymentCreated = "payment.created",
3
+ PaymentFailed = "payment.failed"
4
+ }
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PaymentSubjects = void 0;
4
+ var PaymentSubjects;
5
+ (function (PaymentSubjects) {
6
+ PaymentSubjects["PaymentCreated"] = "payment.created";
7
+ PaymentSubjects["PaymentFailed"] = "payment.failed";
8
+ })(PaymentSubjects || (exports.PaymentSubjects = PaymentSubjects = {}));
@@ -0,0 +1,15 @@
1
+ import { OrderDurableName } from '../../enums/durable-names/order-dname';
2
+ import { OrderStream } from '../../enums/streams/order-stream';
3
+ import { OrderSubjects } from '../../enums/subjects/order-subjects';
4
+ export interface OrderCancelledEvent {
5
+ subject: OrderSubjects.OrderCancelled;
6
+ durableName?: OrderDurableName.OrderCancelledDurablename;
7
+ stream: OrderStream.Order;
8
+ data: {
9
+ id: string;
10
+ version: number;
11
+ status: string;
12
+ userid: string;
13
+ tripid: string;
14
+ };
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { OrderDurableName } from '../../enums/durable-names/order-dname';
2
+ import { OrderStream } from '../../enums/streams/order-stream';
3
+ import { OrderSubjects } from '../../enums/subjects/order-subjects';
4
+ export interface OrderCompletedEvent {
5
+ subject: OrderSubjects.OrderCompleted;
6
+ durableName?: OrderDurableName.OrderCompletedDurablename;
7
+ stream: OrderStream.Order;
8
+ data: {
9
+ id: string;
10
+ version: number;
11
+ status: string;
12
+ userid: string;
13
+ tripid: string;
14
+ };
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,15 @@
1
+ import { OrderDurableName } from '../../enums/durable-names/order-dname';
2
+ import { OrderStream } from '../../enums/streams/order-stream';
3
+ import { OrderSubjects } from '../../enums/subjects/order-subjects';
4
+ export interface OrderRequestedEvent {
5
+ subject: OrderSubjects.OrderRequested;
6
+ durableName?: OrderDurableName.OrderRequestDurablename;
7
+ stream: OrderStream.Order;
8
+ data: {
9
+ id: string;
10
+ version: number;
11
+ status: string;
12
+ userid: string;
13
+ tripid: string;
14
+ };
15
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,6 @@
1
+ import { OrderStream } from '../../enums/streams/order-stream';
2
+ import { MainSubjects } from '../../enums/subjects/main-subjects';
3
+ export interface OrderStreamEvent {
4
+ subject: MainSubjects.ORDER;
5
+ stream: OrderStream.Order;
6
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hastehaul/common",
3
- "version": "1.0.12",
3
+ "version": "1.0.13",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",
@@ -27,6 +27,7 @@
27
27
  "express": "^4.18.2",
28
28
  "ioredis": "^5.3.2",
29
29
  "jsonwebtoken": "^9.0.1",
30
+ "nats": "^2.15.1",
30
31
  "socket.io": "^4.7.1"
31
32
  }
32
33
  }