@axxel/event-bus 1.1.4 → 1.1.6

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,6 @@
1
1
  export * from './tokenPriceConsumer';
2
2
  export * from './walletTransactionConsumer';
3
+ export * from './liveTransactionConsumer';
3
4
  export * from './tradeExecutionConsumer';
4
5
  export * from './poolCreatedConsumer';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consumers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./tokenPriceConsumer"), exports);
18
18
  __exportStar(require("./walletTransactionConsumer"), exports);
19
+ __exportStar(require("./liveTransactionConsumer"), exports);
19
20
  __exportStar(require("./tradeExecutionConsumer"), exports);
20
21
  __exportStar(require("./poolCreatedConsumer"), exports);
@@ -0,0 +1,8 @@
1
+ import type { LiveTransactionEvent } from '../types/LiveTransactionEvent';
2
+ /**
3
+ * Start consuming live transaction events.
4
+ * @param groupId - unique consumer group ID (e.g., 'analytics' or 'wallet-tracker')
5
+ * @param handler - function that processes each LiveTransactionEvent
6
+ */
7
+ export declare function startLiveTransactionConsumer(groupId: string, handler: (event: LiveTransactionEvent) => Promise<void> | void): Promise<void>;
8
+ //# sourceMappingURL=liveTransactionConsumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveTransactionConsumer.d.ts","sourceRoot":"","sources":["../../src/consumers/liveTransactionConsumer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E;;;;GAIG;AACH,wBAAsB,4BAA4B,CAChD,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,iBAoB/D"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.startLiveTransactionConsumer = startLiveTransactionConsumer;
4
+ const kafka_1 = require("../config/kafka");
5
+ const topics_1 = require("../topics");
6
+ /**
7
+ * Start consuming live transaction events.
8
+ * @param groupId - unique consumer group ID (e.g., 'analytics' or 'wallet-tracker')
9
+ * @param handler - function that processes each LiveTransactionEvent
10
+ */
11
+ async function startLiveTransactionConsumer(groupId, handler) {
12
+ const consumer = kafka_1.kafka.consumer({ groupId });
13
+ await consumer.connect();
14
+ await consumer.subscribe({
15
+ topic: topics_1.TOPICS.LIVE_TRANSACTIONS,
16
+ fromBeginning: false,
17
+ });
18
+ await consumer.run({
19
+ eachMessage: async ({ message }) => {
20
+ if (!message.value)
21
+ return;
22
+ const event = JSON.parse(message.value.toString());
23
+ await handler(event);
24
+ },
25
+ });
26
+ console.log(`📡 Listening for live transactions (group: ${groupId})`);
27
+ }
package/dist/index.d.ts CHANGED
@@ -3,12 +3,15 @@ export * from './topics';
3
3
  export * from './types';
4
4
  export * from './validation/tokenPriceEvent.schema';
5
5
  export * from './validation/walletTransactionEvent.schema';
6
+ export * from './validation/liveTransactionEvent.schema';
6
7
  export * from './producers/tokenPriceProducer';
7
8
  export * from './producers/walletTransactionProducer';
9
+ export * from './producers/liveTransactionProducer';
8
10
  export * from './producers/tradeExecutionProducer';
9
11
  export * from './producers/poolCreatedProducer';
10
12
  export * from './consumers/tokenPriceConsumer';
11
13
  export * from './consumers/walletTransactionConsumer';
14
+ export * from './consumers/liveTransactionConsumer';
12
15
  export * from './consumers/tradeExecutionConsumer';
13
16
  export * from './consumers/poolCreatedConsumer';
14
17
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAE3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAEhD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,qCAAqC,CAAC;AACpD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,0CAA0C,CAAC;AAEzD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC;AAEhD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AACtD,cAAc,qCAAqC,CAAC;AACpD,cAAc,oCAAoC,CAAC;AACnD,cAAc,iCAAiC,CAAC"}
package/dist/index.js CHANGED
@@ -19,11 +19,14 @@ __exportStar(require("./topics"), exports);
19
19
  __exportStar(require("./types"), exports);
20
20
  __exportStar(require("./validation/tokenPriceEvent.schema"), exports);
21
21
  __exportStar(require("./validation/walletTransactionEvent.schema"), exports);
22
+ __exportStar(require("./validation/liveTransactionEvent.schema"), exports);
22
23
  __exportStar(require("./producers/tokenPriceProducer"), exports);
23
24
  __exportStar(require("./producers/walletTransactionProducer"), exports);
25
+ __exportStar(require("./producers/liveTransactionProducer"), exports);
24
26
  __exportStar(require("./producers/tradeExecutionProducer"), exports);
25
27
  __exportStar(require("./producers/poolCreatedProducer"), exports);
26
28
  __exportStar(require("./consumers/tokenPriceConsumer"), exports);
27
29
  __exportStar(require("./consumers/walletTransactionConsumer"), exports);
30
+ __exportStar(require("./consumers/liveTransactionConsumer"), exports);
28
31
  __exportStar(require("./consumers/tradeExecutionConsumer"), exports);
29
32
  __exportStar(require("./consumers/poolCreatedConsumer"), exports);
@@ -1,5 +1,6 @@
1
1
  export * from './tokenPriceProducer';
2
2
  export * from './walletTransactionProducer';
3
+ export * from './liveTransactionProducer';
3
4
  export * from './tradeExecutionProducer';
4
5
  export * from './poolCreatedProducer';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/producers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/producers/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC"}
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./tokenPriceProducer"), exports);
18
18
  __exportStar(require("./walletTransactionProducer"), exports);
19
+ __exportStar(require("./liveTransactionProducer"), exports);
19
20
  __exportStar(require("./tradeExecutionProducer"), exports);
20
21
  __exportStar(require("./poolCreatedProducer"), exports);
@@ -0,0 +1,3 @@
1
+ import type { LiveTransactionEvent } from '../types/LiveTransactionEvent';
2
+ export declare function produceLiveTransaction(event: LiveTransactionEvent): Promise<void>;
3
+ //# sourceMappingURL=liveTransactionProducer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveTransactionProducer.d.ts","sourceRoot":"","sources":["../../src/producers/liveTransactionProducer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAE1E,wBAAsB,sBAAsB,CAAC,KAAK,EAAE,oBAAoB,iBAoBvE"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.produceLiveTransaction = produceLiveTransaction;
4
+ const kafka_1 = require("../config/kafka");
5
+ const topics_1 = require("../topics");
6
+ async function produceLiveTransaction(event) {
7
+ const producer = kafka_1.kafka.producer();
8
+ await producer.connect();
9
+ const key = `${event.chainId}:${event.walletAddress}`;
10
+ await producer.send({
11
+ topic: topics_1.TOPICS.LIVE_TRANSACTIONS,
12
+ messages: [
13
+ {
14
+ key,
15
+ value: JSON.stringify(event),
16
+ },
17
+ ],
18
+ });
19
+ await producer.disconnect();
20
+ console.log(`✅ Sent live transaction for ${event.walletAddress} (${event.type})`);
21
+ }
package/dist/topics.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  export declare const TOPICS: {
2
2
  readonly TOKEN_PRICES: "token-prices";
3
3
  readonly WALLET_TRANSACTIONS: "wallet-transactions";
4
+ readonly LIVE_TRANSACTIONS: "live-transactions";
4
5
  readonly TRADE_EXECUTION: "trade-execution";
5
6
  readonly POOL_CREATED: "pool-created";
6
7
  };
@@ -1 +1 @@
1
- {"version":3,"file":"topics.d.ts","sourceRoot":"","sources":["../src/topics.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;CAKT,CAAC;AAEX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
1
+ {"version":3,"file":"topics.d.ts","sourceRoot":"","sources":["../src/topics.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,MAAM;;;;;;CAMT,CAAC;AAEX,MAAM,MAAM,KAAK,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,OAAO,MAAM,CAAC,CAAC"}
package/dist/topics.js CHANGED
@@ -4,6 +4,7 @@ exports.TOPICS = void 0;
4
4
  exports.TOPICS = {
5
5
  TOKEN_PRICES: 'token-prices',
6
6
  WALLET_TRANSACTIONS: 'wallet-transactions',
7
+ LIVE_TRANSACTIONS: 'live-transactions',
7
8
  TRADE_EXECUTION: 'trade-execution',
8
9
  POOL_CREATED: 'pool-created',
9
10
  };
@@ -0,0 +1,18 @@
1
+ export interface LiveTransactionEvent {
2
+ chainId: number;
3
+ walletAddress: string;
4
+ type: string;
5
+ pool?: string | null;
6
+ txHash: string;
7
+ baseAmount: string;
8
+ quoteAmount: string;
9
+ baseTokenAddress: string;
10
+ baseTokenSymbol: string;
11
+ quoteTokenAddress: string;
12
+ quoteTokenSymbol: string;
13
+ blockTimestamp: number;
14
+ liquidity?: number | null;
15
+ marketcap?: number | null;
16
+ totalSupply?: number | null;
17
+ }
18
+ //# sourceMappingURL=LiveTransactionEvent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LiveTransactionEvent.d.ts","sourceRoot":"","sources":["../../src/types/LiveTransactionEvent.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,eAAe,EAAE,MAAM,CAAC;IACxB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,EAAE,MAAM,CAAC;IAEvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,5 +1,6 @@
1
1
  export * from './TokenPriceEvent';
2
2
  export * from './WalletTransactionEvent';
3
+ export * from './LiveTransactionEvent';
3
4
  export * from './TradeExecutionEvent';
4
5
  export * from './PoolCreatedEvent';
5
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,0BAA0B,CAAC;AACzC,cAAc,wBAAwB,CAAC;AACvC,cAAc,uBAAuB,CAAC;AACtC,cAAc,oBAAoB,CAAC"}
@@ -16,5 +16,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./TokenPriceEvent"), exports);
18
18
  __exportStar(require("./WalletTransactionEvent"), exports);
19
+ __exportStar(require("./LiveTransactionEvent"), exports);
19
20
  __exportStar(require("./TradeExecutionEvent"), exports);
20
21
  __exportStar(require("./PoolCreatedEvent"), exports);
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export declare const liveTransactionEventSchema: z.ZodObject<{
3
+ chainId: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>, z.ZodTransform<number, number>>, z.ZodNumber>;
4
+ walletAddress: z.ZodString;
5
+ type: z.ZodString;
6
+ pool: z.ZodOptional<z.ZodNullable<z.ZodString>>;
7
+ txHash: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
8
+ baseAmount: z.ZodString;
9
+ quoteAmount: z.ZodString;
10
+ baseTokenAddress: z.ZodString;
11
+ baseTokenSymbol: z.ZodString;
12
+ quoteTokenAddress: z.ZodString;
13
+ quoteTokenSymbol: z.ZodString;
14
+ blockTimestamp: z.ZodNumber;
15
+ liquidity: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
16
+ marketcap: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
17
+ totalSupply: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
18
+ }, z.core.$strip>;
19
+ export type LiveTransactionEventSchema = z.infer<typeof liveTransactionEventSchema>;
20
+ export declare function ensureLiveTransactionEvent(input: unknown): LiveTransactionEventSchema;
21
+ //# sourceMappingURL=liveTransactionEvent.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"liveTransactionEvent.schema.d.ts","sourceRoot":"","sources":["../../src/validation/liveTransactionEvent.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;iBAkBrC,CAAC;AAEH,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAC9C,OAAO,0BAA0B,CAClC,CAAC;AAEF,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,OAAO,GAAG,0BAA0B,CAErF"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.liveTransactionEventSchema = void 0;
4
+ exports.ensureLiveTransactionEvent = ensureLiveTransactionEvent;
5
+ const zod_1 = require("zod");
6
+ const common_1 = require("./common");
7
+ exports.liveTransactionEventSchema = zod_1.z.object({
8
+ chainId: common_1.chainIdSchema,
9
+ walletAddress: common_1.addressSchema,
10
+ type: zod_1.z.string().min(1),
11
+ pool: common_1.addressSchema.nullable().optional(),
12
+ txHash: common_1.txHashSchema,
13
+ baseAmount: zod_1.z.string(),
14
+ quoteAmount: zod_1.z.string(),
15
+ baseTokenAddress: common_1.addressSchema,
16
+ baseTokenSymbol: zod_1.z.string(),
17
+ quoteTokenAddress: common_1.addressSchema,
18
+ quoteTokenSymbol: zod_1.z.string(),
19
+ blockTimestamp: zod_1.z.number().int().positive(),
20
+ liquidity: zod_1.z.number().nullable().optional(),
21
+ marketcap: zod_1.z.number().nullable().optional(),
22
+ totalSupply: zod_1.z.number().nullable().optional(),
23
+ });
24
+ function ensureLiveTransactionEvent(input) {
25
+ return exports.liveTransactionEventSchema.parse(input);
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axxel/event-bus",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Axxel Kafka Event Bus SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -37,4 +37,4 @@
37
37
  "tsx": "^4.20.6",
38
38
  "typescript": "^5.9.3"
39
39
  }
40
- }
40
+ }