@mulingai-npm/redis 1.9.0 → 1.10.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.
@@ -4,13 +4,13 @@ export type TranslationStatus = 'INIT' | 'DISCARDED' | 'READY' | 'USED';
4
4
  export type TtsStatus = 'INIT' | 'DISCARDED' | 'READY' | 'USED';
5
5
  export type MulingstreamChunkStatus = 'INIT' | 'IN_PROGRESS' | 'DISCARDED' | 'USED';
6
6
  export type MulingstreamChunkStep = 'RECEIVED' | 'STT' | 'TRANSLATION' | 'TTS' | 'EMITTED' | 'COMPLETED' | 'CANCELED';
7
- export type SttService = 'azure' | 'whisper' | 'google' | 'someOtherService';
7
+ export type SttProvider = 'azure' | 'whisper' | 'google' | 'aws';
8
8
  export type MulingstreamChunkData = {
9
9
  mulingstreamChunkId: string;
10
10
  roomId: string;
11
11
  chunkNumber: number;
12
12
  language: string;
13
- sttServices: SttService[];
13
+ sttProviders: SttProvider[];
14
14
  targetLanguages: string[];
15
15
  finalTranscription: string;
16
16
  mulingstreamChunkStatus: MulingstreamChunkStatus;
@@ -58,32 +58,15 @@ export declare class MulingstreamChunkManager {
58
58
  isFirst: boolean;
59
59
  isLast: boolean;
60
60
  theme: string;
61
- sttServices: SttService[];
61
+ sttProviders: SttProvider[];
62
62
  targetLanguages: string[];
63
63
  }): Promise<string>;
64
64
  getMulingstreamChunks(): Promise<MulingstreamChunkData[]>;
65
65
  getMulingstreamChunk(mulingstreamChunkId: string): Promise<MulingstreamChunkData | null>;
66
66
  getMulingstreamChunksByRoom(roomId: string): Promise<MulingstreamChunkData[]>;
67
67
  getByChunkNumber(chunkNumber: number, roomId: string): Promise<MulingstreamChunkData | null>;
68
- /**
69
- * Updates the STT status for a given service in the chunk's STT data.
70
- *
71
- * @param mulingstreamChunkId The chunk ID.
72
- * @param status The new SttStatus to set (INIT, DISCARDED, READY, USED).
73
- * @param service Which STT service to update (must be among the chunk's services).
74
- * @param chunkStatus Overall chunk status (e.g. IN_PROGRESS, DISCARDED, USED).
75
- * @param chunkStep Overall chunk step (e.g. STT, TRANSLATION, etc.).
76
- */
77
- updateSttStatus(mulingstreamChunkId: string, status: SttStatus, service: SttService, chunkStatus: MulingstreamChunkStatus, chunkStep: MulingstreamChunkStep): Promise<boolean>;
78
- /**
79
- * Updates the transcription + status for a given service in the chunk's STT data.
80
- *
81
- * @param mulingstreamChunkId The chunk ID.
82
- * @param transcription The transcription text to store.
83
- * @param sttStatus The new status for this STT service.
84
- * @param service Which STT service to update.
85
- * @param chunkStatus Overall chunk status (e.g. IN_PROGRESS, DISCARDED, USED).
86
- * @param chunkStep Overall chunk step (e.g. STT, TRANSLATION, etc.).
87
- */
88
- updateTranscription(mulingstreamChunkId: string, transcription: string, sttStatus: SttStatus, service: SttService, chunkStatus: MulingstreamChunkStatus, chunkStep: MulingstreamChunkStep): Promise<boolean>;
68
+ updateMulingstreamChunkStatus(mulingstreamChunkId: string, mulingstreamChunkStatus: MulingstreamChunkStatus, mulingstreamChunkStep: MulingstreamChunkStep): Promise<boolean>;
69
+ updateFinalTranscription(mulingstreamChunkId: string, finalTranscription: string): Promise<boolean>;
70
+ updateSttStatus(mulingstreamChunkId: string, service: SttProvider, status: SttStatus): Promise<boolean>;
71
+ updateTranscription(mulingstreamChunkId: string, service: SttProvider, transcription: string, sttStatus: SttStatus): Promise<boolean>;
89
72
  }
@@ -9,7 +9,7 @@ class MulingstreamChunkManager {
9
9
  }
10
10
  parseHashData(data) {
11
11
  // Parse the arrays and nested JSON fields
12
- const sttServices = JSON.parse(data.sttServices);
12
+ const sttProviders = JSON.parse(data.sttProviders);
13
13
  const targetLanguages = JSON.parse(data.targetLanguages);
14
14
  const audioChunk = JSON.parse(data.audioChunk);
15
15
  const stt = JSON.parse(data.stt);
@@ -20,7 +20,7 @@ class MulingstreamChunkManager {
20
20
  roomId: data.roomId,
21
21
  chunkNumber: parseInt(data.chunkNumber, 10),
22
22
  language: data.language,
23
- sttServices,
23
+ sttProviders,
24
24
  targetLanguages,
25
25
  finalTranscription: data.finalTranscription,
26
26
  mulingstreamChunkStatus: data.mulingstreamChunkStatus,
@@ -36,7 +36,7 @@ class MulingstreamChunkManager {
36
36
  // - Stores the chunk data in a Redis hash under `mulingstreamChunk:{mulingstreamChunkId}`.
37
37
  // - Applies an expiration (12h).
38
38
  async addMulingstreamChunk(params) {
39
- const { roomId, chunkNumber, language, start, end, duration, isFirst, isLast, theme, sttServices, targetLanguages } = params;
39
+ const { roomId, chunkNumber, language, start, end, duration, isFirst, isLast, theme, sttProviders, targetLanguages } = params;
40
40
  const mulingstreamChunkId = `[${roomId}]-[${chunkNumber}]-[${(0, uuid_1.v4)()}]`;
41
41
  // Prepare the nested objects
42
42
  const audioChunk = {
@@ -51,7 +51,7 @@ class MulingstreamChunkManager {
51
51
  // Build the STT object
52
52
  // For each service in `services`, create { transcription: '', status: 'INIT' }
53
53
  const stt = {};
54
- for (const service of sttServices) {
54
+ for (const service of sttProviders) {
55
55
  stt[service] = {
56
56
  transcription: '',
57
57
  status: 'INIT'
@@ -79,7 +79,7 @@ class MulingstreamChunkManager {
79
79
  roomId,
80
80
  chunkNumber: chunkNumber.toString(),
81
81
  language,
82
- sttServices: JSON.stringify(sttServices),
82
+ sttProviders: JSON.stringify(sttProviders),
83
83
  targetLanguages: JSON.stringify(targetLanguages),
84
84
  finalTranscription,
85
85
  mulingstreamChunkStatus: 'INIT',
@@ -148,16 +148,33 @@ class MulingstreamChunkManager {
148
148
  }
149
149
  return this.parseHashData(data);
150
150
  }
151
- /**
152
- * Updates the STT status for a given service in the chunk's STT data.
153
- *
154
- * @param mulingstreamChunkId The chunk ID.
155
- * @param status The new SttStatus to set (INIT, DISCARDED, READY, USED).
156
- * @param service Which STT service to update (must be among the chunk's services).
157
- * @param chunkStatus Overall chunk status (e.g. IN_PROGRESS, DISCARDED, USED).
158
- * @param chunkStep Overall chunk step (e.g. STT, TRANSLATION, etc.).
159
- */
160
- async updateSttStatus(mulingstreamChunkId, status, service, chunkStatus, chunkStep) {
151
+ async updateMulingstreamChunkStatus(mulingstreamChunkId, mulingstreamChunkStatus, mulingstreamChunkStep) {
152
+ // Fetch the chunk data first
153
+ const data = await this.redisClient.hgetall(`mulingstreamChunk:${mulingstreamChunkId}`);
154
+ if (!data || !data.mulingstreamChunkId) {
155
+ return false; // The chunk may not exist or has expired
156
+ }
157
+ // Update only the chunk status and step
158
+ await this.redisClient.hset(`mulingstreamChunk:${mulingstreamChunkId}`, {
159
+ mulingstreamChunkStatus,
160
+ mulingstreamChunkStep
161
+ });
162
+ return true;
163
+ }
164
+ async updateFinalTranscription(mulingstreamChunkId, finalTranscription) {
165
+ // Fetch the chunk data first
166
+ const data = await this.redisClient.hgetall(`mulingstreamChunk:${mulingstreamChunkId}`);
167
+ if (!data || !data.mulingstreamChunkId) {
168
+ return false; // The chunk may not exist or has expired
169
+ }
170
+ // Update the finalTranscription field
171
+ await this.redisClient.hset(`mulingstreamChunk:${mulingstreamChunkId}`, {
172
+ finalTranscription
173
+ });
174
+ return true;
175
+ }
176
+ // Updates the STT status for a given service in the chunk's STT data.
177
+ async updateSttStatus(mulingstreamChunkId, service, status) {
161
178
  const data = await this.redisClient.hgetall(`mulingstreamChunk:${mulingstreamChunkId}`);
162
179
  if (!data || !data.mulingstreamChunkId) {
163
180
  return false;
@@ -168,23 +185,12 @@ class MulingstreamChunkManager {
168
185
  }
169
186
  stt[service].status = status;
170
187
  await this.redisClient.hset(`mulingstreamChunk:${mulingstreamChunkId}`, {
171
- mulingstreamChunkStatus: chunkStatus,
172
- mulingstreamChunkStep: chunkStep,
173
188
  stt: JSON.stringify(stt)
174
189
  });
175
190
  return true;
176
191
  }
177
- /**
178
- * Updates the transcription + status for a given service in the chunk's STT data.
179
- *
180
- * @param mulingstreamChunkId The chunk ID.
181
- * @param transcription The transcription text to store.
182
- * @param sttStatus The new status for this STT service.
183
- * @param service Which STT service to update.
184
- * @param chunkStatus Overall chunk status (e.g. IN_PROGRESS, DISCARDED, USED).
185
- * @param chunkStep Overall chunk step (e.g. STT, TRANSLATION, etc.).
186
- */
187
- async updateTranscription(mulingstreamChunkId, transcription, sttStatus, service, chunkStatus, chunkStep) {
192
+ // Updates the transcription + status for a given service in the chunk's STT data.
193
+ async updateTranscription(mulingstreamChunkId, service, transcription, sttStatus) {
188
194
  const data = await this.redisClient.hgetall(`mulingstreamChunk:${mulingstreamChunkId}`);
189
195
  if (!data || !data.mulingstreamChunkId) {
190
196
  return false;
@@ -196,8 +202,6 @@ class MulingstreamChunkManager {
196
202
  stt[service].transcription = transcription;
197
203
  stt[service].status = sttStatus;
198
204
  await this.redisClient.hset(`mulingstreamChunk:${mulingstreamChunkId}`, {
199
- mulingstreamChunkStatus: chunkStatus,
200
- mulingstreamChunkStep: chunkStep,
201
205
  stt: JSON.stringify(stt)
202
206
  });
203
207
  return true;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "1.9.0",
3
+ "version": "1.10.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {