@axxel/event-bus 1.0.3 → 1.0.4

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.
package/dist/index.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  export * from './config/kafka';
2
2
  export * from './topics';
3
3
  export * from './types';
4
+ export * from './validation/tokenPriceEvent.schema';
5
+ export * from './validation/walletTransactionEvent.schema';
4
6
  export * from './producers/tokenPriceProducer';
5
7
  export * from './producers/walletTransactionProducer';
6
8
  export * from './consumers/tokenPriceConsumer';
@@ -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;AAExB,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AAEtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,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;AAE3D,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC;AAEtD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,uCAAuC,CAAC"}
package/dist/index.js CHANGED
@@ -17,6 +17,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./config/kafka"), exports);
18
18
  __exportStar(require("./topics"), exports);
19
19
  __exportStar(require("./types"), exports);
20
+ __exportStar(require("./validation/tokenPriceEvent.schema"), exports);
21
+ __exportStar(require("./validation/walletTransactionEvent.schema"), exports);
20
22
  __exportStar(require("./producers/tokenPriceProducer"), exports);
21
23
  __exportStar(require("./producers/walletTransactionProducer"), exports);
22
24
  __exportStar(require("./consumers/tokenPriceConsumer"), exports);
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ export declare const chainIdSchema: z.ZodPipe<z.ZodPipe<z.ZodUnion<readonly [z.ZodNumber, z.ZodPipe<z.ZodString, z.ZodTransform<number, string>>]>, z.ZodTransform<number, number>>, z.ZodNumber>;
3
+ export declare const addressSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4
+ export declare const txHashSchema: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
5
+ //# sourceMappingURL=common.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/validation/common.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,eAAO,MAAM,aAAa,+JAEM,CAAC;AAEjC,eAAO,MAAM,aAAa,wDAGkB,CAAC;AAE7C,eAAO,MAAM,YAAY,wDAGmB,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.txHashSchema = exports.addressSchema = exports.chainIdSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const HEX_ADDRESS_REGEX = /^0x[a-fA-F0-9]{40}$/;
6
+ const TX_HASH_REGEX = /^0x[a-fA-F0-9]{64}$/;
7
+ const numericChainIdInput = zod_1.z.union([
8
+ zod_1.z.number().int(),
9
+ zod_1.z
10
+ .string()
11
+ .regex(/^-?\d+$/)
12
+ .transform((value) => Number(value)),
13
+ ]);
14
+ exports.chainIdSchema = numericChainIdInput
15
+ .transform((value) => (typeof value === 'number' ? value : Number(value)))
16
+ .pipe(zod_1.z.number().int().min(0));
17
+ exports.addressSchema = zod_1.z
18
+ .string()
19
+ .refine((value) => HEX_ADDRESS_REGEX.test(value), { message: 'invalid_address' })
20
+ .transform((value) => value.toLowerCase());
21
+ exports.txHashSchema = zod_1.z
22
+ .string()
23
+ .refine((value) => TX_HASH_REGEX.test(value), { message: 'invalid_tx_hash' })
24
+ .transform((value) => value.toLowerCase());
@@ -0,0 +1,17 @@
1
+ import { z } from 'zod';
2
+ export declare const tokenPriceEventSchema: 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
+ tokenAddress: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
5
+ blockNumber: z.ZodNumber;
6
+ price: z.ZodPipe<z.ZodTransform<{}, unknown>, z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodObject<{
7
+ price: z.ZodNumber;
8
+ exchange: z.ZodString;
9
+ liquidity: z.ZodNumber;
10
+ }, z.core.$strip>>>>;
11
+ marketcap: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
12
+ symbol: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
+ updatedAt: z.ZodOptional<z.ZodNumber>;
14
+ }, z.core.$strip>;
15
+ export type TokenPriceEventSchema = z.infer<typeof tokenPriceEventSchema>;
16
+ export declare function ensureTokenPriceEvent(input: unknown): TokenPriceEventSchema;
17
+ //# sourceMappingURL=tokenPriceEvent.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenPriceEvent.schema.d.ts","sourceRoot":"","sources":["../../src/validation/tokenPriceEvent.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAuCxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;iBAQhC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,CAE3E"}
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.tokenPriceEventSchema = void 0;
4
+ exports.ensureTokenPriceEvent = ensureTokenPriceEvent;
5
+ const zod_1 = require("zod");
6
+ const common_1 = require("./common");
7
+ const priceEntrySchema = zod_1.z.object({
8
+ price: zod_1.z.number().finite(),
9
+ exchange: zod_1.z.string().min(1),
10
+ liquidity: zod_1.z.number().finite(),
11
+ });
12
+ const priceRecordSchema = zod_1.z.preprocess((value) => {
13
+ if (value instanceof Map) {
14
+ const normalized = {};
15
+ for (const [key, entry] of value.entries()) {
16
+ if (typeof key !== 'string') {
17
+ throw new Error(`Invalid price key type: expected string, got ${typeof key}`);
18
+ }
19
+ if (typeof entry === 'object' && entry !== null && 'price' in entry && 'exchange' in entry && 'liquidity' in entry) {
20
+ normalized[key] = {
21
+ price: Number(entry.price),
22
+ exchange: String(entry.exchange),
23
+ liquidity: Number(entry.liquidity),
24
+ };
25
+ continue;
26
+ }
27
+ throw new Error(`Invalid price entry for key "${key}": expected { price, exchange, liquidity }`);
28
+ }
29
+ return normalized;
30
+ }
31
+ if (value === undefined || value === null) {
32
+ return {};
33
+ }
34
+ return value;
35
+ }, zod_1.z.record(zod_1.z.string(), priceEntrySchema).default({}));
36
+ exports.tokenPriceEventSchema = zod_1.z.object({
37
+ chainId: common_1.chainIdSchema,
38
+ tokenAddress: common_1.addressSchema,
39
+ blockNumber: zod_1.z.number().int().min(0),
40
+ price: priceRecordSchema,
41
+ marketcap: zod_1.z.number().nullable().optional(),
42
+ symbol: zod_1.z.string().nullable().optional(),
43
+ updatedAt: zod_1.z.number().int().min(0).optional(),
44
+ });
45
+ function ensureTokenPriceEvent(input) {
46
+ return exports.tokenPriceEventSchema.parse(input);
47
+ }
@@ -0,0 +1,21 @@
1
+ import { z } from 'zod';
2
+ export declare const walletTransactionEventSchema: 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.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
5
+ type: z.ZodString;
6
+ pool: z.ZodOptional<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>>>;
7
+ txHash: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
8
+ baseAmount: z.ZodString;
9
+ quoteAmount: z.ZodString;
10
+ baseTokenAddress: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
11
+ baseTokenSymbol: z.ZodString;
12
+ quoteTokenAddress: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
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 WalletTransactionEventSchema = z.infer<typeof walletTransactionEventSchema>;
20
+ export declare function ensureWalletTransactionEvent(input: unknown): WalletTransactionEventSchema;
21
+ //# sourceMappingURL=walletTransactionEvent.schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"walletTransactionEvent.schema.d.ts","sourceRoot":"","sources":["../../src/validation/walletTransactionEvent.schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,4BAA4B;;;;;;;;;;;;;;;;iBAkBvC,CAAC;AAEH,MAAM,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,4BAA4B,CAAC,CAAC;AAExF,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,OAAO,GAAG,4BAA4B,CAEzF"}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.walletTransactionEventSchema = void 0;
4
+ exports.ensureWalletTransactionEvent = ensureWalletTransactionEvent;
5
+ const zod_1 = require("zod");
6
+ const common_1 = require("./common");
7
+ exports.walletTransactionEventSchema = 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 ensureWalletTransactionEvent(input) {
25
+ return exports.walletTransactionEventSchema.parse(input);
26
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axxel/event-bus",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "Axxel Kafka Event Bus SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -27,7 +27,8 @@
27
27
  "license": "ISC",
28
28
  "dependencies": {
29
29
  "dotenv": "^17.2.3",
30
- "kafkajs": "^2.2.4"
30
+ "kafkajs": "^2.2.4",
31
+ "zod": "^4.1.12"
31
32
  },
32
33
  "devDependencies": {
33
34
  "@types/node": "^24.9.2",