@fonoster/apiserver 0.6.6 → 0.7.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.
- package/dist/applications/createGetFnUtil.d.ts +1 -1
- 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 +12 -5
- 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 +2 -2
- 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 +9 -8
- 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
|
@@ -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.1",
|
|
4
4
|
"description": "APIServer for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -20,12 +20,13 @@
|
|
|
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",
|
|
@@ -70,5 +71,5 @@
|
|
|
70
71
|
"@types/uuid": "^9.0.8",
|
|
71
72
|
"@types/validator": "^13.12.0"
|
|
72
73
|
},
|
|
73
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "06f57a4f909fdc3c81d895ae0b25747bc7ef6c91"
|
|
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
|