@aichatwar/shared 1.0.127 → 1.0.128

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.
@@ -80,14 +80,22 @@ class Listener {
80
80
  }
81
81
  // Reset retry count on successful connection
82
82
  this.retryCount = 0;
83
+ console.log(`🚀 [${this.topic}] About to call consumer.run() with groupId: ${this.groupId}`);
83
84
  console.log(`🚀 [${this.topic}] Starting consumer.run() with groupId: ${this.groupId}`);
85
+ console.log(`🚀 [${this.topic}] Consumer configuration:`, {
86
+ groupId: this.groupId,
87
+ topic: this.topic,
88
+ fromBeginning: this.fromBeginning,
89
+ autoCommit: false,
90
+ });
84
91
  yield this.consumer.run({
85
92
  // CRITICAL: Disable auto-commit to prevent message loss during rebalancing
86
93
  // Offsets are only committed when we explicitly call ack()
87
94
  autoCommit: false,
88
95
  eachMessage: (payload) => __awaiter(this, void 0, void 0, function* () {
89
- var _a;
96
+ console.log(`📨 [${this.topic}] eachMessage callback invoked! -> groupId: ${this.groupId}, partition: ${payload.partition}, offset: ${payload.message.offset}, topic: ${payload.topic}`);
90
97
  if (!payload.message.value) {
98
+ console.warn(`⚠️ [${this.topic}] Empty message value at offset ${payload.message.offset}, acknowledging...`);
91
99
  // Acknowledge empty messages to avoid blocking
92
100
  yield this.consumer.commitOffsets([{
93
101
  topic: payload.topic,
@@ -96,7 +104,9 @@ class Listener {
96
104
  }]);
97
105
  return;
98
106
  }
99
- console.log(`📨 [${this.topic}] Message received -> groupId: ${this.groupId}, partition: ${payload.partition}, offset: ${payload.message.offset}, key: ${((_a = payload.message.key) === null || _a === void 0 ? void 0 : _a.toString()) || 'none'}`);
107
+ // Commented out key logging as requested
108
+ // console.log(`📨 [${this.topic}] Message received -> groupId: ${this.groupId}, partition: ${payload.partition}, offset: ${payload.message.offset}, key: ${payload.message.key?.toString() || 'none'}`);
109
+ console.log(`📨 [${this.topic}] Message received -> groupId: ${this.groupId}, partition: ${payload.partition}, offset: ${payload.message.offset}, value length: ${payload.message.value.toString().length}`);
100
110
  // Store current payload for manual ack
101
111
  this.currentPayload = payload;
102
112
  try {
@@ -107,7 +117,7 @@ class Listener {
107
117
  // This ensures at-least-once delivery semantics
108
118
  }
109
119
  catch (error) {
110
- console.error(`Error processing message for topic: ${this.topic}, offset: ${payload.message.offset}`, error);
120
+ console.error(`❌ [${this.topic}] Error processing message for topic: ${this.topic}, offset: ${payload.message.offset}`, error);
111
121
  // In case of error, we don't commit the offset, so the message will be redelivered
112
122
  // This ensures failed messages are retried
113
123
  throw error;
@@ -116,8 +126,14 @@ class Listener {
116
126
  // Clear the current payload
117
127
  this.currentPayload = undefined;
118
128
  }
119
- })
129
+ }),
130
+ eachBatch: (_a) => __awaiter(this, [_a], void 0, function* ({ batch, resolveOffset, heartbeat }) {
131
+ var _b, _c;
132
+ // Log batch processing for debugging
133
+ console.log(`📦 [${this.topic}] Processing batch: ${batch.messages.length} messages, partition: ${batch.partition}, first offset: ${(_b = batch.messages[0]) === null || _b === void 0 ? void 0 : _b.offset}, last offset: ${(_c = batch.messages[batch.messages.length - 1]) === null || _c === void 0 ? void 0 : _c.offset}`);
134
+ }),
120
135
  });
136
+ console.log(`✅ [${this.topic}] consumer.run() call completed (this is expected - run() is async and continues running)`);
121
137
  // Mark as successfully listening only after subscription and run are successful
122
138
  this.isListening = true;
123
139
  }
@@ -24,12 +24,10 @@ class Publisher {
24
24
  let lastError = null;
25
25
  for (let attempt = 1; attempt <= this.maxRetries; attempt++) {
26
26
  try {
27
- const messageKey = data.id || undefined; // Use id as key for partitioning if available
28
27
  const result = yield this.producer.send({
29
28
  topic: this.topic,
30
29
  messages: [{
31
30
  value: JSON.stringify(data),
32
- key: messageKey,
33
31
  timestamp: Date.now().toString()
34
32
  }],
35
33
  });
@@ -37,7 +35,6 @@ class Publisher {
37
35
  topic: this.topic,
38
36
  partition: (_a = result[0]) === null || _a === void 0 ? void 0 : _a.partition,
39
37
  offset: (_b = result[0]) === null || _b === void 0 ? void 0 : _b.offset,
40
- key: (messageKey === null || messageKey === void 0 ? void 0 : messageKey.toString()) || 'none',
41
38
  data: JSON.stringify(data).substring(0, 200) // First 200 chars for brevity
42
39
  });
43
40
  return; // Success, exit retry loop
@@ -8,6 +8,8 @@ interface UserCreatedEvent extends BaseEvent {
8
8
  email: string;
9
9
  status: UserStatus;
10
10
  version: number;
11
+ isAgent?: boolean;
12
+ ownerUserId?: string;
11
13
  };
12
14
  }
13
15
  interface UserUpdatedEvent extends BaseEvent {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aichatwar/shared",
3
- "version": "1.0.127",
3
+ "version": "1.0.128",
4
4
  "main": "./build/index.js",
5
5
  "typs": "./build/index.d.ts",
6
6
  "files": [