@mulingai-npm/redis 2.5.2 → 2.5.3

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.
@@ -87,9 +87,11 @@ export declare class MulingstreamChunkManager {
87
87
  transcription?: string;
88
88
  sttStatus?: StepStatus;
89
89
  }): Promise<boolean>;
90
- /**
91
- * Update the final transcription field for a chunk.
92
- */
90
+ updateSttObject(roomId: string, chunkNumber: number, newStt: Record<string, {
91
+ transcription: string;
92
+ status: StepStatus;
93
+ }>): Promise<boolean>;
94
+ discardStt(roomId: string, chunkNumber: number): Promise<boolean>;
93
95
  updateFinalTranscription(roomId: string, chunkNumber: number, transcription: string, sttStatus: StepStatus): Promise<boolean>;
94
96
  /**
95
97
  * Discards all post-STT steps for a given chunk:
@@ -151,9 +151,48 @@ class MulingstreamChunkManager {
151
151
  await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
152
152
  return true;
153
153
  }
154
- /**
155
- * Update the final transcription field for a chunk.
156
- */
154
+ async updateSttObject(roomId, chunkNumber, newStt) {
155
+ // Fetch all chunks in the room
156
+ const chunks = await this.getMulingstreamChunksByRoom(roomId);
157
+ if (!chunks) {
158
+ return false;
159
+ }
160
+ // Locate the target chunk
161
+ const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
162
+ if (idx === -1) {
163
+ return false;
164
+ }
165
+ // Replace the stt object
166
+ chunks[idx].stt = newStt;
167
+ // Persist back to Redis
168
+ await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
169
+ return true;
170
+ }
171
+ async discardStt(roomId, chunkNumber) {
172
+ // Fetch all chunks in this room
173
+ const chunks = await this.getMulingstreamChunksByRoom(roomId);
174
+ if (!chunks) {
175
+ return false;
176
+ }
177
+ // Locate the desired chunk
178
+ const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
179
+ if (idx === -1) {
180
+ return false;
181
+ }
182
+ const chunk = chunks[idx];
183
+ // Reset every STT provider entry
184
+ for (const provider of Object.keys(chunk.stt)) {
185
+ chunk.stt[provider].transcription = '';
186
+ chunk.stt[provider].status = 'DISCARDED';
187
+ }
188
+ // Reset aggregate STT fields
189
+ chunk.finalTranscription = '';
190
+ chunk.sttStatus = 'DISCARDED';
191
+ // Persist back to Redis
192
+ chunks[idx] = chunk;
193
+ await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
194
+ return true;
195
+ }
157
196
  async updateFinalTranscription(roomId, chunkNumber, transcription, sttStatus) {
158
197
  const chunks = await this.getMulingstreamChunksByRoom(roomId);
159
198
  if (!chunks)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {