@fonoster/apiserver 0.6.2 → 0.7.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.
- package/dist/applications/buildService.d.ts +3 -3
- package/dist/applications/createApplication.d.ts +2 -2
- package/dist/applications/createGetFnUtil.d.ts +2 -2
- package/dist/applications/deleteApplication.d.ts +3 -3
- package/dist/applications/getApplication.d.ts +2 -2
- package/dist/applications/getApplication.js +1 -3
- package/dist/applications/types.d.ts +1 -1
- package/dist/applications/utils/applicationWithEncodedStruct.js +20 -1
- package/dist/applications/utils/convertToApplicationData.js +1 -1
- package/dist/applications/utils/getApplicationValidationSchema.d.ts +3 -3
- package/dist/applications/utils/getApplicationValidationSchema.js +6 -3
- package/dist/applications/utils/prepareForValidation.js +1 -1
- package/dist/calls/ListCallsRequestSchema.d.ts +1 -4
- package/dist/calls/ListCallsRequestSchema.js +0 -4
- package/dist/calls/buildService.d.ts +2 -2
- package/dist/calls/buildService.js +6 -5
- package/dist/calls/createCall.d.ts +6 -4
- package/dist/calls/createCall.js +18 -8
- package/dist/calls/createFetchCalls.js +3 -7
- package/dist/calls/createFetchSingleCall.js +9 -2
- package/dist/calls/{trackCall.d.ts → makeTrackCall.d.ts} +3 -3
- package/dist/calls/makeTrackCall.js +67 -0
- package/dist/calls/runCallManager.js +12 -13
- package/dist/calls/types.d.ts +8 -42
- package/dist/calls/types.js +5 -38
- package/dist/core/seed.js +20 -0
- package/dist/core/services.d.ts +24 -25
- package/dist/envs.d.ts +0 -2
- package/dist/envs.js +1 -3
- package/dist/events/createInfluxDbPub.js +2 -1
- package/dist/events/mapCallDirectionToEnum.d.ts +3 -0
- package/dist/events/mapCallDirectionToEnum.js +37 -0
- package/dist/events/nats.js +5 -6
- package/dist/events/transformEvent.d.ts +2 -0
- package/dist/events/transformEvent.js +72 -0
- package/dist/index.js +4 -5
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/dist/utils/makeHandleDialEventsWithNats.d.ts +5 -0
- package/dist/{voice/handlers/StasisEnd.js → utils/makeHandleDialEventsWithNats.js} +10 -15
- package/dist/utils/makeHandleDialEventsWithVoiceClient.d.ts +5 -0
- package/dist/{voice/handlers/dial/handleDialEvents.js → utils/makeHandleDialEventsWithVoiceClient.js} +6 -17
- package/dist/utils/mapDialStatus.d.ts +3 -0
- package/dist/utils/mapDialStatus.js +38 -0
- package/dist/voice/VoiceClientImpl.d.ts +10 -1
- package/dist/voice/VoiceClientImpl.js +47 -7
- package/dist/voice/VoiceDispatcher.d.ts +6 -2
- package/dist/voice/VoiceDispatcher.js +50 -37
- package/dist/voice/connectToAri.js +3 -1
- package/dist/voice/createExternalMediaConfig.d.ts +3 -0
- package/dist/voice/createExternalMediaConfig.js +4 -1
- package/dist/voice/handlers/Answer.js +1 -1
- package/dist/voice/handlers/Hangup.js +1 -1
- package/dist/voice/handlers/Mute.js +1 -1
- package/dist/voice/handlers/Play.js +2 -2
- package/dist/voice/handlers/PlayDtmf.js +1 -1
- package/dist/voice/handlers/PlaybackControl.js +1 -1
- package/dist/voice/handlers/Record.js +2 -2
- package/dist/voice/handlers/Say.js +2 -2
- package/dist/voice/handlers/StreamGather.d.ts +3 -0
- package/dist/voice/handlers/StreamGather.js +66 -0
- package/dist/voice/handlers/Unmute.js +1 -1
- package/dist/voice/handlers/dial/Dial.js +10 -6
- package/dist/voice/handlers/gather/Gather.js +5 -4
- package/dist/voice/handlers/index.d.ts +12 -0
- package/dist/voice/handlers/index.js +46 -0
- package/dist/voice/handlers/{awaitForPlaybackFinished.js → utils/awaitForPlaybackFinished.js} +1 -1
- package/dist/voice/handlers/{awaitForRecordingFinished.js → utils/awaitForRecordingFinished.js} +1 -1
- package/dist/voice/handlers/utils/index.d.ts +3 -0
- package/dist/voice/handlers/utils/index.js +37 -0
- package/dist/voice/handlers/utils/isDtmf.d.ts +2 -0
- package/dist/voice/handlers/utils/isDtmf.js +24 -0
- package/dist/voice/integrations/findIntegrationsCredentials.d.ts +1 -1
- package/dist/voice/integrations/findIntegrationsCredentials.js +2 -1
- package/dist/voice/integrations/getSttConfig.d.ts +4 -2
- package/dist/voice/integrations/getSttConfig.js +4 -1
- package/dist/voice/integrations/getTtsConfig.d.ts +2 -1
- package/dist/voice/integrations/getTtsConfig.js +5 -1
- package/dist/voice/integrations/makeCreateContainer.js +1 -1
- package/dist/voice/integrations/types.d.ts +1 -1
- package/dist/voice/makeCreateVoiceClient.js +4 -10
- package/dist/voice/makeGetChannelVar.d.ts +2 -1
- package/dist/voice/makeGetChannelVar.js +13 -0
- package/dist/voice/stt/AbstractSpeechToText.d.ts +4 -3
- package/dist/voice/stt/Deepgram.d.ts +18 -0
- package/dist/voice/stt/Deepgram.js +156 -0
- package/dist/voice/stt/Google.d.ts +5 -6
- package/dist/voice/stt/Google.js +13 -13
- package/dist/voice/stt/SpeechToTextFactory.js +2 -0
- package/dist/voice/stt/types.d.ts +22 -10
- package/dist/voice/stt/types.js +7 -0
- package/dist/voice/tts/Deepgram.d.ts +25 -0
- package/dist/voice/tts/Deepgram.js +122 -0
- package/dist/voice/tts/Google.d.ts +2 -1
- package/dist/voice/tts/Google.js +7 -8
- package/dist/voice/tts/TextToSpeechFactory.js +2 -0
- package/dist/voice/types/ari.d.ts +2 -1
- package/dist/voice/types/ari.js +1 -0
- package/dist/voice/types/voice.d.ts +9 -1
- package/package.json +10 -9
- package/dist/calls/createTrackCallSubscriber.d.ts +0 -5
- package/dist/calls/createTrackCallSubscriber.js +0 -52
- package/dist/calls/trackCall.js +0 -63
- package/dist/voice/handlers/StasisEnd.d.ts +0 -4
- package/dist/voice/handlers/dial/handleDialEvents.d.ts +0 -5
- /package/dist/voice/handlers/{awaitForPlaybackFinished.d.ts → utils/awaitForPlaybackFinished.d.ts} +0 -0
- /package/dist/voice/handlers/{awaitForRecordingFinished.d.ts → utils/awaitForRecordingFinished.d.ts} +0 -0
- /package/dist/voice/handlers/{withErrorHandling.d.ts → utils/withErrorHandling.d.ts} +0 -0
- /package/dist/voice/handlers/{withErrorHandling.js → utils/withErrorHandling.js} +0 -0
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.ENGINE_NAME = exports.Deepgram = void 0;
|
|
36
|
+
/*
|
|
37
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
38
|
+
* http://github.com/fonoster/fonoster
|
|
39
|
+
*
|
|
40
|
+
* This file is part of Fonoster
|
|
41
|
+
*
|
|
42
|
+
* Licensed under the MIT License (the "License");
|
|
43
|
+
* you may not use this file except in compliance with
|
|
44
|
+
* the License. You may obtain a copy of the License at
|
|
45
|
+
*
|
|
46
|
+
* https://opensource.org/licenses/MIT
|
|
47
|
+
*
|
|
48
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
49
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
50
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
51
|
+
* See the License for the specific language governing permissions and
|
|
52
|
+
* limitations under the License.
|
|
53
|
+
*/
|
|
54
|
+
const fs = __importStar(require("fs"));
|
|
55
|
+
const util = __importStar(require("util"));
|
|
56
|
+
const common_1 = require("@fonoster/common");
|
|
57
|
+
const logger_1 = require("@fonoster/logger");
|
|
58
|
+
const z = __importStar(require("zod"));
|
|
59
|
+
const AbstractTextToSpeech_1 = require("./AbstractTextToSpeech");
|
|
60
|
+
const isSsml_1 = require("./isSsml");
|
|
61
|
+
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
|
62
|
+
const { DeepgramClient, createClient } = require("@deepgram/sdk");
|
|
63
|
+
const ENGINE_NAME = "tts.deepgram";
|
|
64
|
+
exports.ENGINE_NAME = ENGINE_NAME;
|
|
65
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
66
|
+
class Deepgram extends AbstractTextToSpeech_1.AbstractTextToSpeech {
|
|
67
|
+
constructor(config) {
|
|
68
|
+
super(config);
|
|
69
|
+
this.engineName = ENGINE_NAME;
|
|
70
|
+
this.OUTPUT_FORMAT = "sln16";
|
|
71
|
+
this.CACHING_FIELDS = ["voice"];
|
|
72
|
+
this.AUDIO_ENCODING = "linear16";
|
|
73
|
+
this.SAMPLE_RATE_HERTZ = 16000;
|
|
74
|
+
this.client = createClient(config.credentials.apiKey);
|
|
75
|
+
this.engineConfig = config;
|
|
76
|
+
}
|
|
77
|
+
synthesize(text, options) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
logger.verbose(`synthesize [input: ${text}, isSsml=${(0, isSsml_1.isSsml)(text)} options: ${JSON.stringify(options)}]`);
|
|
80
|
+
const effectiveOptions = Object.assign(Object.assign({}, this.engineConfig), options);
|
|
81
|
+
const { voice } = this.engineConfig.config;
|
|
82
|
+
const filename = this.createFilename(text, effectiveOptions);
|
|
83
|
+
if (this.fileExists(this.getFullPathToFile(filename))) {
|
|
84
|
+
return this.getFilenameWithoutExtension(filename);
|
|
85
|
+
}
|
|
86
|
+
const response = yield this.client.speak.request({ text }, {
|
|
87
|
+
model: voice || common_1.DeepgramVoice.AURA_ASTERIA_EN,
|
|
88
|
+
encoding: this.AUDIO_ENCODING,
|
|
89
|
+
sample_rate: this.SAMPLE_RATE_HERTZ
|
|
90
|
+
});
|
|
91
|
+
const writeFile = util.promisify(fs.writeFile);
|
|
92
|
+
const audioBuffer = yield getAudioBuffer(yield response.getStream());
|
|
93
|
+
yield writeFile(this.getFullPathToFile(filename), audioBuffer, "binary");
|
|
94
|
+
return this.getFilenameWithoutExtension(filename);
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
static getConfigValidationSchema() {
|
|
98
|
+
return z.object({
|
|
99
|
+
voice: z.nativeEnum(common_1.DeepgramVoice)
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
static getCredentialsValidationSchema() {
|
|
103
|
+
return z.object({
|
|
104
|
+
apiKey: z.string()
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
exports.Deepgram = Deepgram;
|
|
109
|
+
// helper function to convert stream to audio buffer
|
|
110
|
+
const getAudioBuffer = (response) => __awaiter(void 0, void 0, void 0, function* () {
|
|
111
|
+
const reader = response.getReader();
|
|
112
|
+
const chunks = [];
|
|
113
|
+
// eslint-disable-next-line no-loops/no-loops, no-constant-condition
|
|
114
|
+
while (true) {
|
|
115
|
+
const { done, value } = yield reader.read();
|
|
116
|
+
if (done)
|
|
117
|
+
break;
|
|
118
|
+
chunks.push(value);
|
|
119
|
+
}
|
|
120
|
+
const dataArray = chunks.reduce((acc, chunk) => Uint8Array.from([...acc, ...chunk]), new Uint8Array(0));
|
|
121
|
+
return Buffer.from(dataArray.buffer);
|
|
122
|
+
});
|
|
@@ -12,11 +12,12 @@ type GoogleTtsConfig = TtsConfig & {
|
|
|
12
12
|
};
|
|
13
13
|
declare class Google extends AbstractTextToSpeech<typeof ENGINE_NAME> {
|
|
14
14
|
client: TextToSpeechClient;
|
|
15
|
-
|
|
15
|
+
engineConfig: GoogleTtsConfig;
|
|
16
16
|
readonly engineName = "tts.google";
|
|
17
17
|
protected readonly OUTPUT_FORMAT = "sln16";
|
|
18
18
|
protected readonly CACHING_FIELDS: string[];
|
|
19
19
|
protected readonly AUDIO_ENCODING: "LINEAR16";
|
|
20
|
+
protected readonly SAMPLE_RATE_HERTZ = 16000;
|
|
20
21
|
constructor(config: GoogleTtsConfig);
|
|
21
22
|
synthesize(text: string, options: SynthOptions): Promise<string>;
|
|
22
23
|
static getConfigValidationSchema(): z.Schema;
|
package/dist/voice/tts/Google.js
CHANGED
|
@@ -61,8 +61,6 @@ const AbstractTextToSpeech_1 = require("./AbstractTextToSpeech");
|
|
|
61
61
|
const isSsml_1 = require("./isSsml");
|
|
62
62
|
const ENGINE_NAME = "tts.google";
|
|
63
63
|
exports.ENGINE_NAME = ENGINE_NAME;
|
|
64
|
-
const AUDIO_ENCODING = "LINEAR16";
|
|
65
|
-
const SAMPLE_RATE_HERTZ = 16000;
|
|
66
64
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
67
65
|
class Google extends AbstractTextToSpeech_1.AbstractTextToSpeech {
|
|
68
66
|
constructor(config) {
|
|
@@ -70,15 +68,16 @@ class Google extends AbstractTextToSpeech_1.AbstractTextToSpeech {
|
|
|
70
68
|
this.engineName = ENGINE_NAME;
|
|
71
69
|
this.OUTPUT_FORMAT = "sln16";
|
|
72
70
|
this.CACHING_FIELDS = ["voice"];
|
|
73
|
-
this.AUDIO_ENCODING =
|
|
71
|
+
this.AUDIO_ENCODING = "LINEAR16";
|
|
72
|
+
this.SAMPLE_RATE_HERTZ = 16000;
|
|
74
73
|
this.client = new text_to_speech_1.TextToSpeechClient(config);
|
|
75
|
-
this.
|
|
74
|
+
this.engineConfig = config;
|
|
76
75
|
}
|
|
77
76
|
synthesize(text, options) {
|
|
78
77
|
return __awaiter(this, void 0, void 0, function* () {
|
|
79
78
|
logger.verbose(`synthesize [input: ${text}, isSsml=${(0, isSsml_1.isSsml)(text)} options: ${JSON.stringify(options)}]`);
|
|
80
|
-
const effectiveOptions = Object.assign(Object.assign({}, this.
|
|
81
|
-
const { voice } =
|
|
79
|
+
const effectiveOptions = Object.assign(Object.assign({}, this.engineConfig), options);
|
|
80
|
+
const { voice } = this.engineConfig.config;
|
|
82
81
|
const lang = `${voice.split("-")[0]}-${voice.split("-")[1]}`;
|
|
83
82
|
const filename = this.createFilename(text, effectiveOptions);
|
|
84
83
|
if (this.fileExists(this.getFullPathToFile(filename))) {
|
|
@@ -87,8 +86,8 @@ class Google extends AbstractTextToSpeech_1.AbstractTextToSpeech {
|
|
|
87
86
|
const request = {
|
|
88
87
|
input: (0, isSsml_1.isSsml)(text) ? { ssml: text } : { text },
|
|
89
88
|
audioConfig: {
|
|
90
|
-
audioEncoding: AUDIO_ENCODING,
|
|
91
|
-
sampleRateHertz: SAMPLE_RATE_HERTZ
|
|
89
|
+
audioEncoding: this.AUDIO_ENCODING,
|
|
90
|
+
sampleRateHertz: this.SAMPLE_RATE_HERTZ
|
|
92
91
|
},
|
|
93
92
|
voice: {
|
|
94
93
|
languageCode: lang,
|
|
@@ -21,6 +21,7 @@ exports.TextToSpeechFactory = void 0;
|
|
|
21
21
|
*/
|
|
22
22
|
const logger_1 = require("@fonoster/logger");
|
|
23
23
|
const Azure_1 = require("./Azure");
|
|
24
|
+
const Deepgram_1 = require("./Deepgram");
|
|
24
25
|
const Google_1 = require("./Google");
|
|
25
26
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
26
27
|
class TextToSpeechFactory {
|
|
@@ -41,3 +42,4 @@ TextToSpeechFactory.engines = new Map();
|
|
|
41
42
|
// Register engines
|
|
42
43
|
TextToSpeechFactory.registerEngine(Google_1.ENGINE_NAME, Google_1.Google);
|
|
43
44
|
TextToSpeechFactory.registerEngine(Azure_1.ENGINE_NAME, Azure_1.Azure);
|
|
45
|
+
TextToSpeechFactory.registerEngine(Deepgram_1.ENGINE_NAME, Deepgram_1.Deepgram);
|
|
@@ -16,6 +16,7 @@ declare enum ChannelVar {
|
|
|
16
16
|
APP_REF = "APP_REF",
|
|
17
17
|
APP_ENDPOINT = "APP_ENDPOINT",
|
|
18
18
|
METADATA = "METADATA",
|
|
19
|
-
CURRENT_BRIDGE = "CURRENT_BRIDGE"
|
|
19
|
+
CURRENT_BRIDGE = "CURRENT_BRIDGE",
|
|
20
|
+
FROM_EXTERNAL_MEDIA = "FROM_EXTERNAL_MEDIA"
|
|
20
21
|
}
|
|
21
22
|
export { AriEvent, ChannelVar };
|
package/dist/voice/types/ari.js
CHANGED
|
@@ -40,4 +40,5 @@ var ChannelVar;
|
|
|
40
40
|
ChannelVar["APP_ENDPOINT"] = "APP_ENDPOINT";
|
|
41
41
|
ChannelVar["METADATA"] = "METADATA";
|
|
42
42
|
ChannelVar["CURRENT_BRIDGE"] = "CURRENT_BRIDGE";
|
|
43
|
+
ChannelVar["FROM_EXTERNAL_MEDIA"] = "FROM_EXTERNAL_MEDIA";
|
|
43
44
|
})(ChannelVar || (exports.ChannelVar = ChannelVar = {}));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Stream } from "stream";
|
|
2
2
|
import { SayOptions, StreamContent, VoiceClientConfig, VoiceIn, VoiceSessionStreamClient } from "@fonoster/common";
|
|
3
3
|
import * as grpc from "@grpc/grpc-js";
|
|
4
|
-
import { SpeechResult } from "../stt/types";
|
|
4
|
+
import { SpeechResult, StreamSpeech } from "../stt/types";
|
|
5
5
|
type VoiceClient = {
|
|
6
6
|
config: VoiceClientConfig;
|
|
7
7
|
sendResponse: (command: VoiceIn) => void;
|
|
@@ -10,6 +10,13 @@ type VoiceClient = {
|
|
|
10
10
|
close: () => void;
|
|
11
11
|
synthesize: (text: string, options: SayOptions) => Promise<string>;
|
|
12
12
|
transcribe: () => Promise<SpeechResult>;
|
|
13
|
+
startSpeechGather: (callback: (stream: {
|
|
14
|
+
speech?: string;
|
|
15
|
+
}) => void) => void;
|
|
16
|
+
startDtmfGather: (sessionRef: string, callback: (event: {
|
|
17
|
+
digit: string;
|
|
18
|
+
}) => void) => void;
|
|
19
|
+
stopStreamGather: () => void;
|
|
13
20
|
waitForDtmf: (params: {
|
|
14
21
|
sessionRef: string;
|
|
15
22
|
finishOnKey: string;
|
|
@@ -25,6 +32,7 @@ type TextToSpeech = {
|
|
|
25
32
|
};
|
|
26
33
|
type SpeechToText = {
|
|
27
34
|
transcribe: (stream: Stream) => Promise<SpeechResult>;
|
|
35
|
+
streamTranscribe(stream: Stream): StreamSpeech;
|
|
28
36
|
};
|
|
29
37
|
type GRPCClient = {
|
|
30
38
|
createSession: (metadata: grpc.Metadata) => VoiceSessionStreamClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/apiserver",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "APIServer for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -20,19 +20,20 @@
|
|
|
20
20
|
"fonoster": "./dist/index.js"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@
|
|
24
|
-
"@fonoster/
|
|
25
|
-
"@fonoster/
|
|
26
|
-
"@fonoster/
|
|
27
|
-
"@fonoster/
|
|
28
|
-
"@fonoster/
|
|
23
|
+
"@deepgram/sdk": "^3.5.1",
|
|
24
|
+
"@fonoster/common": "^0.7.0",
|
|
25
|
+
"@fonoster/identity": "^0.7.0",
|
|
26
|
+
"@fonoster/logger": "^0.7.0",
|
|
27
|
+
"@fonoster/sipnet": "^0.7.0",
|
|
28
|
+
"@fonoster/streams": "^0.7.0",
|
|
29
|
+
"@fonoster/types": "^0.7.0",
|
|
29
30
|
"@google-cloud/speech": "^6.6.0",
|
|
30
31
|
"@google-cloud/text-to-speech": "^5.3.0",
|
|
31
32
|
"@grpc/grpc-js": "~1.10.6",
|
|
32
33
|
"@influxdata/influxdb-client": "^1.33.2",
|
|
33
34
|
"@prisma/client": "^5.14.0",
|
|
34
35
|
"@routr/common": "^2.10.0",
|
|
35
|
-
"@routr/sdk": "^2.
|
|
36
|
+
"@routr/sdk": "^2.13.1",
|
|
36
37
|
"ari-client": "^2.2.0",
|
|
37
38
|
"dotenv": "^16.4.5",
|
|
38
39
|
"express": "^4.19.2",
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"@types/uuid": "^9.0.8",
|
|
71
72
|
"@types/validator": "^13.12.0"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "afa950ace3b1d022b6dc8be0c3b87a6b8a5ba3c5"
|
|
74
75
|
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.createTrackCallSubscriber = createTrackCallSubscriber;
|
|
16
|
-
/*
|
|
17
|
-
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
18
|
-
* http://github.com/fonoster/fonoster
|
|
19
|
-
*
|
|
20
|
-
* This file is part of Fonoster
|
|
21
|
-
*
|
|
22
|
-
* Licensed under the MIT License (the "License");
|
|
23
|
-
* you may not use this file except in compliance with
|
|
24
|
-
* the License. You may obtain a copy of the License at
|
|
25
|
-
*
|
|
26
|
-
* https://opensource.org/licenses/MIT
|
|
27
|
-
*
|
|
28
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
29
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
30
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
31
|
-
* See the License for the specific language governing permissions and
|
|
32
|
-
* limitations under the License.
|
|
33
|
-
*/
|
|
34
|
-
const events_1 = __importDefault(require("events"));
|
|
35
|
-
const nats_1 = require("nats");
|
|
36
|
-
const envs_1 = require("../envs");
|
|
37
|
-
function createTrackCallSubscriber(natsUrl) {
|
|
38
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const nc = yield (0, nats_1.connect)({ servers: natsUrl });
|
|
40
|
-
return () => {
|
|
41
|
-
const events = new events_1.default();
|
|
42
|
-
const subscription = nc.subscribe(envs_1.CALLS_TRACK_CALL_SUBJECT);
|
|
43
|
-
subscription.callback = (err, msg) => {
|
|
44
|
-
if (err) {
|
|
45
|
-
events.emit("error", err);
|
|
46
|
-
}
|
|
47
|
-
events.emit("status", msg.json());
|
|
48
|
-
};
|
|
49
|
-
return { events };
|
|
50
|
-
};
|
|
51
|
-
});
|
|
52
|
-
}
|
package/dist/calls/trackCall.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.trackCall = trackCall;
|
|
4
|
-
/*
|
|
5
|
-
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
6
|
-
* http://github.com/fonoster/fonoster
|
|
7
|
-
*
|
|
8
|
-
* This file is part of Fonoster
|
|
9
|
-
*
|
|
10
|
-
* Licensed under the MIT License (the "License");
|
|
11
|
-
* you may not use this file except in compliance with
|
|
12
|
-
* the License. You may obtain a copy of the License at
|
|
13
|
-
*
|
|
14
|
-
* https://opensource.org/licenses/MIT
|
|
15
|
-
*
|
|
16
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
17
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
18
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
19
|
-
* See the License for the specific language governing permissions and
|
|
20
|
-
* limitations under the License.
|
|
21
|
-
*/
|
|
22
|
-
const logger_1 = require("@fonoster/logger");
|
|
23
|
-
const grpc_js_1 = require("@grpc/grpc-js");
|
|
24
|
-
const zod_1 = require("zod");
|
|
25
|
-
const types_1 = require("./types");
|
|
26
|
-
const FINAL_STATUSES = [
|
|
27
|
-
types_1.CallStatus.COMPLETED,
|
|
28
|
-
types_1.CallStatus.FAILED,
|
|
29
|
-
types_1.CallStatus.BUSY,
|
|
30
|
-
types_1.CallStatus.NO_ANSWER,
|
|
31
|
-
types_1.CallStatus.CANCELED,
|
|
32
|
-
types_1.CallStatus.REJECTED,
|
|
33
|
-
types_1.CallStatus.TIMEOUT,
|
|
34
|
-
types_1.CallStatus.UNKNOWN
|
|
35
|
-
];
|
|
36
|
-
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
37
|
-
const TrackCallRequestSchema = zod_1.z.object({
|
|
38
|
-
ref: zod_1.z.string()
|
|
39
|
-
});
|
|
40
|
-
function trackCall(subs) {
|
|
41
|
-
return (call) => {
|
|
42
|
-
const stream = call;
|
|
43
|
-
const { events } = subs;
|
|
44
|
-
const { ref } = call.request;
|
|
45
|
-
logger.verbose("call to trackCall", { ref });
|
|
46
|
-
stream.write({ ref, status: types_1.CallStatus.QUEUED });
|
|
47
|
-
events.on("status", (data) => {
|
|
48
|
-
logger.verbose("tracked call status change", Object.assign({}, data));
|
|
49
|
-
if (data instanceof Error) {
|
|
50
|
-
logger.error("tracked call status change error", Object.assign({}, data));
|
|
51
|
-
stream.write({ code: grpc_js_1.status.INTERNAL, message: data.message });
|
|
52
|
-
stream.end();
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
if (data.ref === ref) {
|
|
56
|
-
stream.write(data);
|
|
57
|
-
if (FINAL_STATUSES.includes(data.status)) {
|
|
58
|
-
stream.end();
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
};
|
|
63
|
-
}
|
/package/dist/voice/handlers/{awaitForPlaybackFinished.d.ts → utils/awaitForPlaybackFinished.d.ts}
RENAMED
|
File without changes
|
/package/dist/voice/handlers/{awaitForRecordingFinished.d.ts → utils/awaitForRecordingFinished.d.ts}
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|