@mulingai-npm/redis 2.2.0 → 2.2.1

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.
@@ -100,4 +100,8 @@ export declare class MulingstreamChunkManager {
100
100
  * Discards a specific language in both translation and tts for a chunk.
101
101
  */
102
102
  discardLanguage(roomId: string, chunkNumber: number, language: string): Promise<boolean>;
103
+ updateTranslation(roomId: string, chunkNumber: number, language: string, options: {
104
+ translation?: string;
105
+ status?: StepStatus;
106
+ }): Promise<boolean>;
103
107
  }
@@ -215,5 +215,30 @@ class MulingstreamChunkManager {
215
215
  await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
216
216
  return true;
217
217
  }
218
+ async updateTranslation(roomId, chunkNumber, language, options) {
219
+ // Fetch all chunks for this room
220
+ const chunks = await this.getMulingstreamChunksByRoom(roomId);
221
+ if (!chunks)
222
+ return false;
223
+ // Locate the target chunk
224
+ const chunkIndex = chunks.findIndex((c) => c.chunkNumber === chunkNumber);
225
+ if (chunkIndex === -1)
226
+ return false;
227
+ const chunk = chunks[chunkIndex];
228
+ // Make sure the requested language exists in this chunk
229
+ if (!chunk.translation[language]) {
230
+ return false;
231
+ }
232
+ if (options.translation !== undefined) {
233
+ chunk.translation[language].translation = options.translation;
234
+ }
235
+ if (options.status !== undefined) {
236
+ chunk.translation[language].status = options.status;
237
+ }
238
+ // Persist the whole array back to Redis
239
+ chunks[chunkIndex] = chunk;
240
+ await this.redisClient.jsonSet(`[${roomId}]`, '.', chunks);
241
+ return true;
242
+ }
218
243
  }
219
244
  exports.MulingstreamChunkManager = MulingstreamChunkManager;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "2.2.0",
3
+ "version": "2.2.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {