@mulingai-npm/redis 2.5.5 → 2.6.0
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<MulingstreamChunkData | null>;
|
|
95
|
+
updateFinalTranscription(roomId: string, chunkNumber: number, transcription: string | null, sttStatus: StepStatus | null): 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,6 @@ 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>;
|
|
110
|
+
areTranslationsProcessed(roomId: string, chunkNumber: number): Promise<boolean>;
|
|
109
111
|
}
|
|
@@ -198,14 +198,17 @@ class MulingstreamChunkManager {
|
|
|
198
198
|
if (!chunks) {
|
|
199
199
|
return null;
|
|
200
200
|
}
|
|
201
|
-
// locate the chunk
|
|
202
201
|
const idx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
|
|
203
202
|
if (idx === -1) {
|
|
204
203
|
return null;
|
|
205
204
|
}
|
|
206
|
-
//
|
|
207
|
-
|
|
208
|
-
|
|
205
|
+
// mutate only when a non-null value is supplied
|
|
206
|
+
if (transcription !== null) {
|
|
207
|
+
chunks[idx].finalTranscription = transcription;
|
|
208
|
+
}
|
|
209
|
+
if (sttStatus !== null) {
|
|
210
|
+
chunks[idx].sttStatus = sttStatus;
|
|
211
|
+
}
|
|
209
212
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
210
213
|
return chunks[idx];
|
|
211
214
|
}
|
|
@@ -279,5 +282,37 @@ class MulingstreamChunkManager {
|
|
|
279
282
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
280
283
|
return true;
|
|
281
284
|
}
|
|
285
|
+
async updateTranslationInBulk(roomId, chunkNumber, translations, status = 'READY') {
|
|
286
|
+
// 1) fetch the room array
|
|
287
|
+
const chunks = await this.getMulingstreamChunksByRoom(roomId);
|
|
288
|
+
if (!chunks) {
|
|
289
|
+
return null;
|
|
290
|
+
}
|
|
291
|
+
// 2) locate the target chunk
|
|
292
|
+
const chunkIdx = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
|
|
293
|
+
if (chunkIdx === -1) {
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
const chunk = chunks[chunkIdx];
|
|
297
|
+
// 3) apply updates only for the languages provided
|
|
298
|
+
for (const [lang, translationText] of Object.entries(translations)) {
|
|
299
|
+
if (!chunk.translation[lang]) {
|
|
300
|
+
continue;
|
|
301
|
+
}
|
|
302
|
+
chunk.translation[lang].translation = translationText;
|
|
303
|
+
chunk.translation[lang].status = status;
|
|
304
|
+
}
|
|
305
|
+
// 4) write the full room array back to Redis
|
|
306
|
+
chunks[chunkIdx] = chunk;
|
|
307
|
+
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
308
|
+
return chunk;
|
|
309
|
+
}
|
|
310
|
+
async areTranslationsProcessed(roomId, chunkNumber) {
|
|
311
|
+
const chunk = await this.getMulingstreamChunkById(roomId, chunkNumber);
|
|
312
|
+
if (!chunk) {
|
|
313
|
+
return false;
|
|
314
|
+
}
|
|
315
|
+
return Object.values(chunk.translation).every((t) => t.status !== 'INIT');
|
|
316
|
+
}
|
|
282
317
|
}
|
|
283
318
|
exports.MulingstreamChunkManager = MulingstreamChunkManager;
|