@mulingai-npm/redis 2.12.4 → 3.0.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.
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { RedisClient } from '../redis-client';
|
|
2
|
+
import type { StepStatus, SttProvider, MulingstreamChunkManager } from '../managers/mulingstream-chunk-manager';
|
|
3
|
+
type CommandArgs = {
|
|
4
|
+
addMulingstreamChunk: Parameters<MulingstreamChunkManager['addMulingstreamChunk']>[0];
|
|
5
|
+
updateStt: {
|
|
6
|
+
chunkNumber: number;
|
|
7
|
+
sttProvider: SttProvider;
|
|
8
|
+
options: {
|
|
9
|
+
transcription?: string;
|
|
10
|
+
sttStatus?: StepStatus;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
updateSttObject: {
|
|
14
|
+
chunkNumber: number;
|
|
15
|
+
newStt: Record<string, {
|
|
16
|
+
transcription: string;
|
|
17
|
+
status: StepStatus;
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
discardStt: {
|
|
21
|
+
chunkNumber: number;
|
|
22
|
+
};
|
|
23
|
+
updateFinalTranscription: {
|
|
24
|
+
chunkNumber: number;
|
|
25
|
+
options: {
|
|
26
|
+
transcription?: string;
|
|
27
|
+
sttStatus?: StepStatus;
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
discardPostStt: {
|
|
31
|
+
chunkNumber: number;
|
|
32
|
+
};
|
|
33
|
+
discardLanguage: {
|
|
34
|
+
chunkNumber: number;
|
|
35
|
+
language: string;
|
|
36
|
+
};
|
|
37
|
+
discardLanguages: {
|
|
38
|
+
chunkNumber: number;
|
|
39
|
+
options: {
|
|
40
|
+
translation?: string[];
|
|
41
|
+
tts?: string[];
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
updateTranslation: {
|
|
45
|
+
chunkNumber: number;
|
|
46
|
+
language: string;
|
|
47
|
+
options: {
|
|
48
|
+
translation?: string;
|
|
49
|
+
status?: StepStatus;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
updateTranslationInBulk: {
|
|
53
|
+
chunkNumber: number;
|
|
54
|
+
translations: Record<string, string>;
|
|
55
|
+
status?: StepStatus;
|
|
56
|
+
};
|
|
57
|
+
updateTts: {
|
|
58
|
+
chunkNumber: number;
|
|
59
|
+
language: string;
|
|
60
|
+
options: {
|
|
61
|
+
ttsAudioPath?: string;
|
|
62
|
+
status?: StepStatus;
|
|
63
|
+
isEmitted?: boolean;
|
|
64
|
+
totalCheck?: number;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
increaseTotalCheck: {
|
|
68
|
+
chunkNumber: number;
|
|
69
|
+
language: string;
|
|
70
|
+
};
|
|
71
|
+
/** read + write: may set some tts[].status = 'DISCARDED' */
|
|
72
|
+
getAllReadyTts: {
|
|
73
|
+
language: string;
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
export type OpName = keyof CommandArgs;
|
|
77
|
+
export interface ChunkCommand<O extends OpName = OpName> {
|
|
78
|
+
op: O;
|
|
79
|
+
args: CommandArgs[O];
|
|
80
|
+
ts?: number;
|
|
81
|
+
}
|
|
82
|
+
export declare function enqueueCommand<O extends OpName>(redis: RedisClient, roomId: string, command: ChunkCommand<O>): Promise<string>;
|
|
83
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.enqueueCommand = void 0;
|
|
4
|
+
/* ------------------------------------------------------------------ */
|
|
5
|
+
/* 3. enqueueCommand helper */
|
|
6
|
+
/* ------------------------------------------------------------------ */
|
|
7
|
+
async function enqueueCommand(redis, roomId, command) {
|
|
8
|
+
var _a;
|
|
9
|
+
const streamKey = `room:${roomId}:chunkCmds`;
|
|
10
|
+
return redis.xadd(streamKey, '*', 'cmd', JSON.stringify({ ...command, ts: (_a = command.ts) !== null && _a !== void 0 ? _a : Date.now() }));
|
|
11
|
+
}
|
|
12
|
+
exports.enqueueCommand = enqueueCommand;
|
package/dist/redis-client.d.ts
CHANGED
|
@@ -25,4 +25,5 @@ export declare class RedisClient {
|
|
|
25
25
|
jsonArrAppend<T>(key: string, path: string, ...values: T[]): Promise<number>;
|
|
26
26
|
jsonArrLen(key: string, path: string): Promise<number | null>;
|
|
27
27
|
jsonArrPop(key: string, path: string, index?: number): Promise<any>;
|
|
28
|
+
xadd(key: string, id: string, ...fieldValues: (string | number)[]): Promise<string>;
|
|
28
29
|
}
|
package/dist/redis-client.js
CHANGED
|
@@ -92,5 +92,10 @@ class RedisClient {
|
|
|
92
92
|
}
|
|
93
93
|
return this.client.call('JSON.ARRPOP', key, path);
|
|
94
94
|
}
|
|
95
|
+
async xadd(key, id, ...fieldValues) {
|
|
96
|
+
// IORedis already supports XADD natively
|
|
97
|
+
// key id ('*' for autogenerated) field1 value1 field2 value2 ...
|
|
98
|
+
return this.client.xadd(key, id, ...fieldValues);
|
|
99
|
+
}
|
|
95
100
|
}
|
|
96
101
|
exports.RedisClient = RedisClient;
|