@mulingai-npm/redis 2.5.5 → 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.
|
@@ -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
|
}
|
|
@@ -279,5 +279,30 @@ class MulingstreamChunkManager {
|
|
|
279
279
|
await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
|
|
280
280
|
return true;
|
|
281
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
|
+
}
|
|
282
307
|
}
|
|
283
308
|
exports.MulingstreamChunkManager = MulingstreamChunkManager;
|