@mulingai-npm/redis 3.0.2 → 3.1.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.
@@ -10,7 +10,6 @@ export interface ChunkLogOptions {
10
10
  stt?: boolean;
11
11
  translation?: boolean;
12
12
  tts?: boolean;
13
- retryMs?: number;
14
13
  label?: string;
15
14
  }
16
15
  export declare class MulingstreamChunkLogger extends MulingstreamChunkManager {
@@ -13,10 +13,8 @@ const defaults = {
13
13
  stt: false,
14
14
  translation: false,
15
15
  tts: true,
16
- retryMs: undefined,
17
16
  label: ''
18
17
  };
19
- const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
20
18
  class MulingstreamChunkLogger extends mulingstream_chunk_manager_1.MulingstreamChunkManager {
21
19
  /* ------------ one chunk ------------------------------------ */
22
20
  /* ------------ one chunk ------------------------------------ */
@@ -25,7 +23,6 @@ class MulingstreamChunkLogger extends mulingstream_chunk_manager_1.MulingstreamC
25
23
  const prefix = cfg.label ? `[${cfg.label}] ` : '';
26
24
  let chunk = await this.getMulingstreamChunkById(roomId, chunkNumber);
27
25
  if (!chunk) {
28
- await sleep(cfg.retryMs);
29
26
  chunk = await this.getMulingstreamChunkById(roomId, chunkNumber);
30
27
  }
31
28
  if (!chunk) {
@@ -42,7 +39,6 @@ class MulingstreamChunkLogger extends mulingstream_chunk_manager_1.MulingstreamC
42
39
  const prefix = cfg.label ? `[${cfg.label}] ` : '';
43
40
  let chunks = await this.getRoomById(roomId);
44
41
  if (!(chunks === null || chunks === void 0 ? void 0 : chunks.length)) {
45
- await sleep(cfg.retryMs);
46
42
  chunks = await this.getRoomById(roomId);
47
43
  }
48
44
  if (!(chunks === null || chunks === void 0 ? void 0 : chunks.length)) {
@@ -58,7 +58,7 @@ class MulingstreamChunkManager {
58
58
  // if (len < 8_000) return 10_000;
59
59
  // if (len < 12_000) return 15_000;
60
60
  // if (len < 20_000) return 20_000;
61
- return 25000;
61
+ return 30000;
62
62
  }
63
63
  /* ---------------------------------------------------------------------- */
64
64
  /* Public API (same) */
@@ -82,13 +82,16 @@ class MulingstreamChunkManager {
82
82
  const pipe = this.redisClient.pipeline();
83
83
  ids.forEach((cid) => pipe.hgetall(this.chunkHashKey(cid)));
84
84
  const res = await pipe.exec();
85
- return res.map(([, d]) => this.hashToChunk(d));
85
+ if (!res)
86
+ return null;
87
+ return res === null || res === void 0 ? void 0 : res.map(([, d]) => this.hashToChunk(d));
86
88
  }
87
89
  getRoomById(roomId) {
88
90
  return this.getMulingstreamChunksByRoom(roomId);
89
91
  }
90
92
  /* ------------------------- chunk insertion ---------------------------- */
91
93
  async addMulingstreamChunk(params) {
94
+ var _a, _b;
92
95
  const { roomId, chunkNumber, language, start, end, duration, isFirst, isLast, theme, sttProviders, targetLanguages, shortCodeTargetLanguages } = params;
93
96
  /* ---------- reset room on first chunk ---------- */
94
97
  if (chunkNumber === 1) {
@@ -145,7 +148,8 @@ class MulingstreamChunkManager {
145
148
  pipe.expire(this.roomZsetKey(roomId), EXPIRATION);
146
149
  pipe.zrange(this.roomZsetKey(roomId), 0, -ROOM_ARRAY_LENGTH - 1, 'WITHSCORES');
147
150
  const execResults = await pipe.exec();
148
- const oldPairs = execResults[4][1]; // [id1, score1, id2, score2, ...]
151
+ /* execResults can be null or shorter than expected — fall back to an empty list */
152
+ const oldPairs = ((_b = (_a = execResults === null || execResults === void 0 ? void 0 : execResults[4]) === null || _a === void 0 ? void 0 : _a[1]) !== null && _b !== void 0 ? _b : []); // [id1, score1, id2, score2, ...]
149
153
  if (Array.isArray(oldPairs) && oldPairs.length) {
150
154
  const oldIds = [];
151
155
  for (let i = 0; i < oldPairs.length; i += 2)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mulingai-npm/redis",
3
- "version": "3.0.2",
3
+ "version": "3.1.1",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "repository": {