@axxel/event-bus 1.0.5 → 1.0.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.
Files changed (56) hide show
  1. package/README.md +36 -3
  2. package/dist/config/kafka.d.ts +0 -0
  3. package/dist/config/kafka.d.ts.map +0 -0
  4. package/dist/config/kafka.js +0 -0
  5. package/dist/consumers/index.d.ts +0 -0
  6. package/dist/consumers/index.d.ts.map +0 -0
  7. package/dist/consumers/index.js +0 -0
  8. package/dist/consumers/tokenPriceConsumer.d.ts +0 -0
  9. package/dist/consumers/tokenPriceConsumer.d.ts.map +0 -0
  10. package/dist/consumers/tokenPriceConsumer.js +0 -0
  11. package/dist/consumers/tradeExecutionConsumer.d.ts +0 -0
  12. package/dist/consumers/tradeExecutionConsumer.d.ts.map +0 -0
  13. package/dist/consumers/tradeExecutionConsumer.js +0 -0
  14. package/dist/consumers/walletTransactionConsumer.d.ts +0 -0
  15. package/dist/consumers/walletTransactionConsumer.d.ts.map +0 -0
  16. package/dist/consumers/walletTransactionConsumer.js +0 -0
  17. package/dist/index.d.ts +0 -0
  18. package/dist/index.d.ts.map +0 -0
  19. package/dist/index.js +0 -0
  20. package/dist/producers/index.d.ts +0 -0
  21. package/dist/producers/index.d.ts.map +0 -0
  22. package/dist/producers/index.js +0 -0
  23. package/dist/producers/tokenPriceProducer.d.ts +0 -0
  24. package/dist/producers/tokenPriceProducer.d.ts.map +0 -0
  25. package/dist/producers/tokenPriceProducer.js +0 -0
  26. package/dist/producers/tradeExecutionProducer.d.ts +0 -0
  27. package/dist/producers/tradeExecutionProducer.d.ts.map +0 -0
  28. package/dist/producers/tradeExecutionProducer.js +0 -0
  29. package/dist/producers/walletTransactionProducer.d.ts +0 -0
  30. package/dist/producers/walletTransactionProducer.d.ts.map +0 -0
  31. package/dist/producers/walletTransactionProducer.js +0 -0
  32. package/dist/topics.d.ts +0 -0
  33. package/dist/topics.d.ts.map +0 -0
  34. package/dist/topics.js +0 -0
  35. package/dist/types/TokenPriceEvent.d.ts +2 -1
  36. package/dist/types/TokenPriceEvent.d.ts.map +1 -1
  37. package/dist/types/TokenPriceEvent.js +0 -0
  38. package/dist/types/TradeExecutionEvent.d.ts +0 -0
  39. package/dist/types/TradeExecutionEvent.d.ts.map +0 -0
  40. package/dist/types/TradeExecutionEvent.js +0 -0
  41. package/dist/types/WalletTransactionEvent.d.ts +0 -0
  42. package/dist/types/WalletTransactionEvent.d.ts.map +0 -0
  43. package/dist/types/WalletTransactionEvent.js +0 -0
  44. package/dist/types/index.d.ts +0 -0
  45. package/dist/types/index.d.ts.map +0 -0
  46. package/dist/types/index.js +0 -0
  47. package/dist/validation/common.d.ts +0 -0
  48. package/dist/validation/common.d.ts.map +0 -0
  49. package/dist/validation/common.js +0 -0
  50. package/dist/validation/tokenPriceEvent.schema.d.ts +2 -1
  51. package/dist/validation/tokenPriceEvent.schema.d.ts.map +1 -1
  52. package/dist/validation/tokenPriceEvent.schema.js +2 -1
  53. package/dist/validation/walletTransactionEvent.schema.d.ts +0 -0
  54. package/dist/validation/walletTransactionEvent.schema.d.ts.map +0 -0
  55. package/dist/validation/walletTransactionEvent.schema.js +0 -0
  56. package/package.json +2 -2
package/README.md CHANGED
@@ -40,7 +40,12 @@ KAFKA_BROKER="localhost:9092"
40
40
  ### 1️⃣ Producing messages
41
41
 
42
42
  ```ts
43
- import { produceTokenPrice, produceWalletTransaction } from '@axxel/event-bus';
43
+ import {
44
+ produceTokenPrice,
45
+ produceWalletTransaction,
46
+ ensureTokenPriceEvent,
47
+ ensureWalletTransactionEvent,
48
+ } from '@axxel/event-bus';
44
49
 
45
50
  await produceTokenPrice({
46
51
  chainId: 1,
@@ -49,7 +54,8 @@ await produceTokenPrice({
49
54
  price: {
50
55
  USD: { price: 3250.42, exchange: 'uniswap-v3', liquidity: 1250000 },
51
56
  },
52
- marketcap: 1234567890,
57
+ priceInUsd: 3250.42,
58
+ fdvInUsd: 1234567890,
53
59
  symbol: 'WETH',
54
60
  updatedAt: Math.floor(Date.now() / 1000),
55
61
  });
@@ -71,6 +77,19 @@ await produceWalletTransaction({
71
77
  marketcap: 500000000,
72
78
  totalSupply: 1000000,
73
79
  });
80
+
81
+ // Optional: validate and normalize before producing
82
+ const safePricePayload = ensureTokenPriceEvent({
83
+ chainId: 1,
84
+ tokenAddress: '0xC02a...',
85
+ blockNumber: 21345678,
86
+ price: new Map([
87
+ ['USD', { price: 3250.42, exchange: 'uniswap-v3', liquidity: 1250000 }],
88
+ ]),
89
+ priceInUsd: 3250.42,
90
+ fdvInUsd: 1234567890,
91
+ });
92
+ await produceTokenPrice(safePricePayload);
74
93
  ```
75
94
 
76
95
  ---
@@ -126,7 +145,8 @@ interface TokenPriceEvent {
126
145
  tokenAddress: string;
127
146
  blockNumber: number;
128
147
  price: Record<string, PriceInfo> | Map<string, PriceInfo>;
129
- marketcap?: number | null;
148
+ priceInUsd?: number | null;
149
+ fdvInUsd?: number | null;
130
150
  symbol?: string | null;
131
151
  updatedAt?: number;
132
152
  }
@@ -154,6 +174,19 @@ interface WalletTransactionEvent {
154
174
  }
155
175
  ```
156
176
 
177
+ ### Runtime validation helpers
178
+
179
+ Shared Zod schemas are exported to normalize inputs consistently:
180
+
181
+ ```ts
182
+ import { ensureTokenPriceEvent, ensureWalletTransactionEvent } from '@axxel/event-bus';
183
+
184
+ const normalizedPrice = ensureTokenPriceEvent(rawPricePayload);
185
+ const normalizedTx = ensureWalletTransactionEvent(rawTxPayload);
186
+ ```
187
+
188
+ `ensureTokenPriceEvent` accepts either a `Record` or `Map` for `price`, and both helpers lowercase EVM addresses / tx hashes while rejecting malformed numeric fields.
189
+
157
190
  ---
158
191
 
159
192
  ## ⚙️ Environment Variables
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/index.d.ts CHANGED
File without changes
File without changes
package/dist/index.js CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
package/dist/topics.d.ts CHANGED
File without changes
File without changes
package/dist/topics.js CHANGED
File without changes
@@ -8,7 +8,8 @@ export interface TokenPriceEvent {
8
8
  tokenAddress: string;
9
9
  blockNumber: number;
10
10
  price: Record<string, PriceInfo> | Map<string, PriceInfo>;
11
- marketcap?: number | null;
11
+ priceInUsd?: number | null;
12
+ fdvInUsd?: number | null;
12
13
  symbol?: string | null;
13
14
  updatedAt?: number;
14
15
  }
@@ -1 +1 @@
1
- {"version":3,"file":"TokenPriceEvent.d.ts","sourceRoot":"","sources":["../../src/types/TokenPriceEvent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IAEpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1D,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
1
+ {"version":3,"file":"TokenPriceEvent.d.ts","sourceRoot":"","sources":["../../src/types/TokenPriceEvent.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IAEpB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;IAC1D,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -8,7 +8,8 @@ export declare const tokenPriceEventSchema: z.ZodObject<{
8
8
  exchange: z.ZodString;
9
9
  liquidity: z.ZodNumber;
10
10
  }, z.core.$strip>>>>;
11
- marketcap: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
11
+ priceInUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
12
+ fdvInUsd: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
12
13
  symbol: z.ZodOptional<z.ZodNullable<z.ZodString>>;
13
14
  updatedAt: z.ZodOptional<z.ZodNumber>;
14
15
  }, z.core.$strip>;
@@ -1 +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;AAiDxB,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"}
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;AAiDxB,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;iBAShC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,qBAAqB,CAAC,CAAC;AAE1E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,GAAG,qBAAqB,CAE3E"}
@@ -42,7 +42,8 @@ exports.tokenPriceEventSchema = zod_1.z.object({
42
42
  tokenAddress: common_1.addressSchema,
43
43
  blockNumber: zod_1.z.number().int().min(0),
44
44
  price: priceRecordSchema,
45
- marketcap: zod_1.z.number().nullable().optional(),
45
+ priceInUsd: zod_1.z.number().nullable().optional(),
46
+ fdvInUsd: zod_1.z.number().nullable().optional(),
46
47
  symbol: zod_1.z.string().nullable().optional(),
47
48
  updatedAt: zod_1.z.number().int().min(0).optional(),
48
49
  });
File without changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@axxel/event-bus",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "Axxel Kafka Event Bus SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -36,4 +36,4 @@
36
36
  "tsx": "^4.20.6",
37
37
  "typescript": "^5.9.3"
38
38
  }
39
- }
39
+ }