@mulingai-npm/redis 2.5.4 → 2.5.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.
@@ -92,7 +92,7 @@ export declare class MulingstreamChunkManager {
92
92
  status: StepStatus;
93
93
  }>): Promise<boolean>;
94
94
  discardStt(roomId: string, chunkNumber: number): Promise<boolean>;
95
- updateFinalTranscription(roomId: string, chunkNumber: number, transcription: string, sttStatus: StepStatus): Promise<boolean>;
95
+ updateFinalTranscription(roomId: string, chunkNumber: number, transcription: string, sttStatus: StepStatus): Promise<MulingstreamChunkData | null>;
96
96
  /**
97
97
  * Discards all post-STT steps for a given chunk:
98
98
  * sets all translation[].status & tts[].status to "DISCARDED".
@@ -106,4 +106,5 @@ export declare class MulingstreamChunkManager {
106
106
  translation?: string;
107
107
  status?: StepStatus;
108
108
  }): Promise<boolean>;
109
+ updateTranslationInBulk(roomId: string, chunkNumber: number, translations: Record<string, string>, status?: StepStatus): Promise<MulingstreamChunkData | null>;
109
110
  }
@@ -195,17 +195,19 @@ class MulingstreamChunkManager {
195
195
  }
196
196
  async updateFinalTranscription(roomId, chunkNumber, transcription, sttStatus) {
197
197
  const chunks = await this.getMulingstreamChunksByRoom(roomId);
198
- if (!chunks)
199
- return false;
200
- // Find the chunk
201
- const chunkIndex = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
202
- if (chunkIndex === -1)
203
- return false;
204
- chunks[chunkIndex].finalTranscription = transcription;
205
- chunks[chunkIndex].sttStatus = sttStatus;
206
- // Write back
198
+ if (!chunks) {
199
+ return null;
200
+ }
201
+ // locate the chunk
202
+ const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
203
+ if (idx === -1) {
204
+ return null;
205
+ }
206
+ // update fields
207
+ chunks[idx].finalTranscription = transcription;
208
+ chunks[idx].sttStatus = sttStatus;
207
209
  await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
208
- return true;
210
+ return chunks[idx];
209
211
  }
210
212
  /**
211
213
  * Discards all post-STT steps for a given chunk:
@@ -277,5 +279,30 @@ class MulingstreamChunkManager {
277
279
  await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
278
280
  return true;
279
281
  }
282
+ async updateTranslationInBulk(roomId, chunkNumber, translations, status = 'READY') {
283
+ // 1) fetch the room array
284
+ const chunks = await this.getMulingstreamChunksByRoom(roomId);
285
+ if (!chunks) {
286
+ return null;
287
+ }
288
+ // 2) locate the target chunk
289
+ const chunkIdx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
290
+ if (chunkIdx === -1) {
291
+ return null;
292
+ }
293
+ const chunk = chunks[chunkIdx];
294
+ // 3) apply updates only for the languages provided
295
+ for (const [lang, translationText] of Object.entries(translations)) {
296
+ if (!chunk.translation[lang]) {
297
+ continue;
298
+ }
299
+ chunk.translation[lang].translation = translationText;
300
+ chunk.translation[lang].status = status;
301
+ }
302
+ // 4) write the full room array back to Redis
303
+ chunks[chunkIdx] = chunk;
304
+ await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
305
+ return chunk;
306
+ }
280
307
  }
281
308
  exports.MulingstreamChunkManager = MulingstreamChunkManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "2.5.4",
3
+ "version": "2.5.6",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {