@fonoster/apiserver 0.5.5 → 0.6.1-alpha.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/LICENSE +2 -2
- package/README.md +3 -0
- package/dist/applications/buildService.d.ts +29 -0
- package/dist/applications/buildService.js +44 -0
- package/dist/applications/createApplication.d.ts +6 -0
- package/dist/applications/createApplication.js +57 -0
- package/dist/applications/createGetFnUtil.d.ts +33 -0
- package/dist/applications/createGetFnUtil.js +32 -0
- package/dist/applications/deleteApplication.d.ts +6 -0
- package/dist/applications/deleteApplication.js +26 -0
- package/dist/applications/getApplication.d.ts +6 -0
- package/dist/applications/getApplication.js +47 -0
- package/dist/applications/hostOrHostPortSchema.d.ts +3 -0
- package/dist/applications/hostOrHostPortSchema.js +34 -0
- package/dist/applications/index.d.ts +1 -0
- package/dist/applications/index.js +23 -0
- package/dist/applications/listApplications.d.ts +6 -0
- package/dist/applications/listApplications.js +69 -0
- package/dist/applications/types.d.ts +27 -0
- package/dist/applications/types.js +2 -0
- package/dist/applications/updateApplication.d.ts +8 -0
- package/dist/applications/updateApplication.js +57 -0
- package/dist/applications/utils/applicationWithEncodedStruct.d.ts +3 -0
- package/dist/applications/utils/applicationWithEncodedStruct.js +23 -0
- package/dist/applications/utils/convertToApplicationData.d.ts +4 -0
- package/dist/applications/utils/convertToApplicationData.js +38 -0
- package/dist/applications/utils/getApplicationValidationSchema.d.ts +64 -0
- package/dist/applications/utils/getApplicationValidationSchema.js +64 -0
- package/dist/applications/utils/prepareForValidation.d.ts +3 -0
- package/dist/applications/utils/prepareForValidation.js +36 -0
- package/dist/applications/utils/validOrThrow.d.ts +3 -0
- package/dist/applications/utils/validOrThrow.js +15 -0
- package/dist/calls/ListCallsRequestSchema.d.ts +28 -0
- package/dist/calls/ListCallsRequestSchema.js +58 -0
- package/dist/calls/buildService.d.ts +26 -0
- package/dist/calls/buildService.js +58 -0
- package/dist/calls/createCall.d.ts +6 -0
- package/dist/calls/createCall.js +64 -0
- package/dist/calls/createCallPublisher.d.ts +7 -0
- package/dist/calls/createCallPublisher.js +47 -0
- package/dist/calls/createFetchCalls.d.ts +3 -0
- package/dist/calls/createFetchCalls.js +87 -0
- package/dist/calls/createFetchSingleCall.d.ts +3 -0
- package/dist/calls/createFetchSingleCall.js +48 -0
- package/dist/calls/createTrackCallSubscriber.d.ts +6 -0
- package/dist/calls/createTrackCallSubscriber.js +53 -0
- package/dist/calls/getCall.d.ts +6 -0
- package/dist/calls/getCall.js +60 -0
- package/dist/calls/index.d.ts +1 -0
- package/dist/calls/index.js +23 -0
- package/dist/calls/influxdb.d.ts +2 -0
- package/dist/calls/influxdb.js +29 -0
- package/dist/calls/listCalls.d.ts +6 -0
- package/dist/calls/listCalls.js +52 -0
- package/dist/calls/runCallManager.d.ts +8 -0
- package/dist/calls/runCallManager.js +82 -0
- package/dist/calls/trackCall.d.ts +14 -0
- package/dist/calls/trackCall.js +64 -0
- package/dist/calls/types.d.ts +96 -0
- package/dist/calls/types.js +42 -0
- package/dist/core/allowList.d.ts +2 -0
- package/dist/core/allowList.js +31 -0
- package/dist/core/db.d.ts +13 -0
- package/dist/core/db.js +29 -0
- package/dist/core/filesServer.d.ts +5 -0
- package/dist/{ari_proxy.js → core/filesServer.js} +24 -20
- package/dist/core/identityConfig.d.ts +21 -0
- package/dist/core/identityConfig.js +43 -0
- package/dist/core/loadServices.d.ts +8 -0
- package/dist/core/loadServices.js +43 -0
- package/dist/core/notFoundError.d.ts +6 -0
- package/dist/core/notFoundError.js +27 -0
- package/dist/core/removeSwaggerNotice.d.ts +2 -0
- package/dist/core/removeSwaggerNotice.js +34 -0
- package/dist/core/routrConfig.d.ts +5 -0
- package/dist/core/routrConfig.js +27 -0
- package/dist/core/runServices.d.ts +2 -0
- package/dist/core/runServices.js +97 -0
- package/dist/core/seed.js +76 -0
- package/dist/core/services.d.ts +438 -0
- package/dist/core/services.js +53 -0
- package/dist/core/upsertDefaultPeer.d.ts +3 -0
- package/dist/core/upsertDefaultPeer.js +92 -0
- package/dist/envs.d.ts +46 -6
- package/dist/envs.js +95 -8
- package/dist/events/createInfluxDbPub.d.ts +13 -0
- package/dist/events/createInfluxDbPub.js +54 -0
- package/dist/events/nats.d.ts +10 -0
- package/dist/events/nats.js +85 -0
- package/dist/events/types.d.ts +8 -0
- package/dist/events/types.js +20 -0
- package/dist/index.js +53 -122
- package/dist/secrets/buildService.d.ts +37 -0
- package/dist/secrets/buildService.js +44 -0
- package/dist/secrets/createGetFnUtil.d.ts +16 -0
- package/dist/secrets/createGetFnUtil.js +46 -0
- package/dist/secrets/createSecret.d.ts +7 -0
- package/dist/secrets/createSecret.js +57 -0
- package/dist/secrets/deleteSecret.d.ts +8 -0
- package/dist/secrets/deleteSecret.js +44 -0
- package/dist/secrets/getSecret.d.ts +6 -0
- package/dist/secrets/getSecret.js +43 -0
- package/dist/secrets/index.d.ts +1 -0
- package/dist/secrets/index.js +23 -0
- package/dist/secrets/listSecrets.d.ts +7 -0
- package/dist/secrets/listSecrets.js +62 -0
- package/dist/secrets/types.d.ts +32 -0
- package/dist/secrets/types.js +2 -0
- package/dist/secrets/updateSecret.d.ts +8 -0
- package/dist/secrets/updateSecret.js +53 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +35 -0
- package/dist/utils/makeCheckNumberPreconditions.d.ts +6 -0
- package/dist/utils/makeCheckNumberPreconditions.js +49 -0
- package/dist/voice/ChannelVarNotFoundError.d.ts +5 -0
- package/dist/voice/ChannelVarNotFoundError.js +10 -0
- package/dist/voice/MethodNotImplementedError.d.ts +4 -0
- package/dist/voice/MethodNotImplementedError.js +27 -0
- package/dist/voice/VoiceClientImpl.d.ts +42 -0
- package/dist/voice/VoiceClientImpl.js +192 -0
- package/dist/voice/VoiceDispatcher.d.ts +17 -0
- package/dist/voice/VoiceDispatcher.js +99 -0
- package/dist/voice/VoiceServiceClientConst.d.ts +3 -0
- package/dist/voice/VoiceServiceClientConst.js +53 -0
- package/dist/voice/connectToAri.d.ts +2 -0
- package/dist/voice/connectToAri.js +80 -0
- package/dist/voice/createExternalMediaConfig.d.ts +9 -0
- package/dist/voice/createExternalMediaConfig.js +35 -0
- package/dist/voice/handlers/Answer.d.ts +5 -0
- package/dist/voice/handlers/Answer.js +25 -0
- package/dist/voice/handlers/Hangup.d.ts +5 -0
- package/dist/voice/handlers/Hangup.js +26 -0
- package/dist/voice/handlers/Mute.d.ts +4 -0
- package/dist/voice/handlers/Mute.js +28 -0
- package/dist/voice/handlers/Play.d.ts +4 -0
- package/dist/voice/handlers/Play.js +34 -0
- package/dist/voice/handlers/PlayDtmf.d.ts +4 -0
- package/dist/voice/handlers/PlayDtmf.js +28 -0
- package/dist/voice/handlers/PlaybackControl.d.ts +4 -0
- package/dist/voice/handlers/PlaybackControl.js +28 -0
- package/dist/voice/handlers/Record.d.ts +4 -0
- package/dist/voice/handlers/Record.js +59 -0
- package/dist/voice/handlers/Say.d.ts +4 -0
- package/dist/voice/handlers/Say.js +46 -0
- package/dist/voice/handlers/StasisEnd.d.ts +4 -0
- package/dist/voice/handlers/StasisEnd.js +28 -0
- package/dist/voice/handlers/Unmute.d.ts +4 -0
- package/dist/voice/handlers/Unmute.js +28 -0
- package/dist/voice/handlers/awaitForPlaybackFinished.d.ts +3 -0
- package/dist/voice/handlers/awaitForPlaybackFinished.js +25 -0
- package/dist/voice/handlers/awaitForRecordingFinished.d.ts +5 -0
- package/dist/voice/handlers/awaitForRecordingFinished.js +54 -0
- package/dist/voice/handlers/dial/Dial.d.ts +5 -0
- package/dist/voice/handlers/dial/Dial.js +72 -0
- package/dist/voice/handlers/dial/handleChannelLeftBridge.d.ts +6 -0
- package/dist/voice/handlers/dial/handleChannelLeftBridge.js +30 -0
- package/dist/voice/handlers/dial/handleDialEvents.d.ts +5 -0
- package/dist/voice/handlers/dial/handleDialEvents.js +55 -0
- package/dist/voice/handlers/dial/handleStasisEnd.d.ts +3 -0
- package/dist/voice/handlers/dial/handleStasisEnd.js +20 -0
- package/dist/voice/handlers/dial/handleStasisStart.d.ts +9 -0
- package/dist/voice/handlers/dial/handleStasisStart.js +54 -0
- package/dist/voice/handlers/dial/recordChannel.d.ts +4 -0
- package/dist/voice/handlers/dial/recordChannel.js +46 -0
- package/dist/voice/handlers/gather/Gather.d.ts +3 -0
- package/dist/voice/handlers/gather/Gather.js +73 -0
- package/dist/voice/handlers/gather/getTimeoutPromise.d.ts +8 -0
- package/dist/voice/handlers/gather/getTimeoutPromise.js +19 -0
- package/dist/voice/handlers/withErrorHandling.d.ts +4 -0
- package/dist/voice/handlers/withErrorHandling.js +36 -0
- package/dist/voice/integrations/ApplicationNotFoundError.d.ts +4 -0
- package/dist/voice/integrations/ApplicationNotFoundError.js +28 -0
- package/dist/voice/integrations/findIntegrationsCredentials.d.ts +3 -0
- package/dist/voice/integrations/findIntegrationsCredentials.js +7 -0
- package/dist/voice/integrations/getSttConfig.d.ts +7 -0
- package/dist/voice/integrations/getSttConfig.js +10 -0
- package/dist/voice/integrations/getTtsConfig.d.ts +7 -0
- package/dist/voice/integrations/getTtsConfig.js +11 -0
- package/dist/voice/integrations/index.d.ts +1 -0
- package/dist/voice/integrations/index.js +35 -0
- package/dist/voice/integrations/makeCreateContainer.d.ts +4 -0
- package/dist/voice/integrations/makeCreateContainer.js +89 -0
- package/dist/voice/integrations/types.d.ts +15 -0
- package/dist/voice/integrations/types.js +2 -0
- package/dist/voice/makeCreateVoiceClient.d.ts +9 -0
- package/dist/voice/makeCreateVoiceClient.js +78 -0
- package/dist/voice/makeGetChannelVar.d.ts +4 -0
- package/dist/voice/makeGetChannelVar.js +26 -0
- package/dist/voice/stt/AbstractSpeechToText.d.ts +15 -0
- package/dist/voice/stt/AbstractSpeechToText.js +19 -0
- package/dist/voice/stt/Google.d.ts +20 -0
- package/dist/voice/stt/Google.js +99 -0
- package/dist/voice/stt/SpeechToTextFactory.d.ts +9 -0
- package/dist/voice/stt/SpeechToTextFactory.js +41 -0
- package/dist/voice/stt/types.d.ts +25 -0
- package/dist/voice/stt/types.js +2 -0
- package/dist/voice/transcribeOnConnection.d.ts +5 -0
- package/dist/voice/transcribeOnConnection.js +27 -0
- package/dist/voice/tts/AbstractTextToSpeech.d.ts +18 -0
- package/dist/voice/tts/AbstractTextToSpeech.js +82 -0
- package/dist/voice/tts/Azure.d.ts +30 -0
- package/dist/voice/tts/Azure.js +128 -0
- package/dist/voice/tts/Google.d.ts +25 -0
- package/dist/voice/tts/Google.js +116 -0
- package/dist/voice/tts/TextToSpeechFactory.d.ts +9 -0
- package/dist/voice/tts/TextToSpeechFactory.js +43 -0
- package/dist/voice/tts/computeFilename.d.ts +7 -0
- package/dist/voice/tts/computeFilename.js +39 -0
- package/dist/voice/tts/flattenObject.d.ts +2 -0
- package/dist/voice/tts/flattenObject.js +39 -0
- package/dist/voice/tts/isSsml.d.ts +2 -0
- package/dist/voice/tts/isSsml.js +26 -0
- package/dist/voice/tts/types.d.ts +7 -0
- package/dist/voice/tts/types.js +2 -0
- package/dist/voice/types/ari.d.ts +21 -0
- package/dist/voice/types/ari.js +43 -0
- package/dist/voice/types/index.d.ts +2 -0
- package/dist/voice/types/index.js +36 -0
- package/dist/voice/types/voice.d.ts +34 -0
- package/dist/voice/types/voice.js +2 -0
- package/package.json +45 -36
- package/dist/upsert_peer.d.ts +0 -1
- package/dist/upsert_peer.js +0 -63
- /package/dist/{ari_proxy.d.ts → core/seed.d.ts} +0 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TextToSpeechFactory = void 0;
|
|
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 Azure_1 = require("./Azure");
|
|
24
|
+
const Google_1 = require("./Google");
|
|
25
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
26
|
+
class TextToSpeechFactory {
|
|
27
|
+
static registerEngine(name, ctor) {
|
|
28
|
+
logger.info("registering tts engine", { name });
|
|
29
|
+
this.engines.set(name, ctor);
|
|
30
|
+
}
|
|
31
|
+
static getEngine(engineName, config) {
|
|
32
|
+
const EngineConstructor = this.engines.get(engineName);
|
|
33
|
+
if (!EngineConstructor) {
|
|
34
|
+
throw new Error(`Engine ${engineName} not found`);
|
|
35
|
+
}
|
|
36
|
+
return new EngineConstructor(config);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
exports.TextToSpeechFactory = TextToSpeechFactory;
|
|
40
|
+
TextToSpeechFactory.engines = new Map();
|
|
41
|
+
// Register engines
|
|
42
|
+
TextToSpeechFactory.registerEngine(Google_1.ENGINE_NAME, Google_1.Google);
|
|
43
|
+
TextToSpeechFactory.registerEngine(Azure_1.ENGINE_NAME, Azure_1.Azure);
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.computeFilename = void 0;
|
|
7
|
+
/*
|
|
8
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
9
|
+
* http://github.com/fonoster/fonoster
|
|
10
|
+
*
|
|
11
|
+
* This file is part of Fonoster
|
|
12
|
+
*
|
|
13
|
+
* Licensed under the MIT License (the "License");
|
|
14
|
+
* you may not use this file except in compliance with
|
|
15
|
+
* the License. You may obtain a copy of the License at
|
|
16
|
+
*
|
|
17
|
+
* https://opensource.org/licenses/MIT
|
|
18
|
+
*
|
|
19
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
20
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
21
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
22
|
+
* See the License for the specific language governing permissions and
|
|
23
|
+
* limitations under the License.
|
|
24
|
+
*/
|
|
25
|
+
const crypto_1 = __importDefault(require("crypto"));
|
|
26
|
+
const flattenObject_1 = require("./flattenObject");
|
|
27
|
+
function computeFilename(params) {
|
|
28
|
+
const { text, options, format, cachingFields } = params;
|
|
29
|
+
let c = "";
|
|
30
|
+
if ((cachingFields === null || cachingFields === void 0 ? void 0 : cachingFields.length) > 0) {
|
|
31
|
+
const flatObj = (0, flattenObject_1.flattenObject)(options);
|
|
32
|
+
c = cachingFields
|
|
33
|
+
.map((opt) => flatObj[opt])
|
|
34
|
+
.sort()
|
|
35
|
+
.join();
|
|
36
|
+
}
|
|
37
|
+
return (crypto_1.default.createHash("md5").update(`${text}${c}`).digest("hex") + "." + format);
|
|
38
|
+
}
|
|
39
|
+
exports.computeFilename = computeFilename;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.flattenObject = void 0;
|
|
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
|
+
function flattenObject(obj, parentKey = "", result = {}) {
|
|
23
|
+
// eslint-disable-next-line no-loops/no-loops
|
|
24
|
+
for (const key in obj) {
|
|
25
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
26
|
+
const newKey = parentKey ? `${parentKey}.${key}` : key;
|
|
27
|
+
if (typeof obj[key] === "object" &&
|
|
28
|
+
obj[key] !== null &&
|
|
29
|
+
!Array.isArray(obj[key])) {
|
|
30
|
+
flattenObject(obj[key], newKey, result);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
result[newKey] = obj[key];
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
exports.flattenObject = flattenObject;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isSsml = void 0;
|
|
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
|
+
function isSsml(text) {
|
|
23
|
+
const v = text.trim();
|
|
24
|
+
return v.startsWith("<") && v.endsWith(">");
|
|
25
|
+
}
|
|
26
|
+
exports.isSsml = isSsml;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
declare enum AriEvent {
|
|
2
|
+
STASIS_START = "StasisStart",
|
|
3
|
+
STASIS_END = "StasisEnd",
|
|
4
|
+
CHANNEL_USER_EVENT = "ChannelUserevent",
|
|
5
|
+
CHANNEL_DTMF_RECEIVED = "ChannelDtmfReceived",
|
|
6
|
+
PLAYBACK_FINISHED = "PlaybackFinished",
|
|
7
|
+
RECORDING_FINISHED = "RecordingFinished",
|
|
8
|
+
RECORDING_FAILED = "RecordingFailed",
|
|
9
|
+
WEB_SOCKET_RECONNECTING = "WebSocketReconnecting",
|
|
10
|
+
WEB_SOCKET_MAX_RETRIES = "WebSocketMaxRetries",
|
|
11
|
+
CHANNEL_LEFT_BRIDGE = "ChannelLeftBridge",
|
|
12
|
+
DIAL = "Dial"
|
|
13
|
+
}
|
|
14
|
+
declare enum ChannelVar {
|
|
15
|
+
INGRESS_NUMBER = "INGRESS_NUMBER",
|
|
16
|
+
APP_REF = "APP_REF",
|
|
17
|
+
APP_ENDPOINT = "APP_ENDPOINT",
|
|
18
|
+
METADATA = "METADATA",
|
|
19
|
+
CURRENT_BRIDGE = "CURRENT_BRIDGE"
|
|
20
|
+
}
|
|
21
|
+
export { AriEvent, ChannelVar };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ChannelVar = exports.AriEvent = void 0;
|
|
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
|
+
var AriEvent;
|
|
23
|
+
(function (AriEvent) {
|
|
24
|
+
AriEvent["STASIS_START"] = "StasisStart";
|
|
25
|
+
AriEvent["STASIS_END"] = "StasisEnd";
|
|
26
|
+
AriEvent["CHANNEL_USER_EVENT"] = "ChannelUserevent";
|
|
27
|
+
AriEvent["CHANNEL_DTMF_RECEIVED"] = "ChannelDtmfReceived";
|
|
28
|
+
AriEvent["PLAYBACK_FINISHED"] = "PlaybackFinished";
|
|
29
|
+
AriEvent["RECORDING_FINISHED"] = "RecordingFinished";
|
|
30
|
+
AriEvent["RECORDING_FAILED"] = "RecordingFailed";
|
|
31
|
+
AriEvent["WEB_SOCKET_RECONNECTING"] = "WebSocketReconnecting";
|
|
32
|
+
AriEvent["WEB_SOCKET_MAX_RETRIES"] = "WebSocketMaxRetries";
|
|
33
|
+
AriEvent["CHANNEL_LEFT_BRIDGE"] = "ChannelLeftBridge";
|
|
34
|
+
AriEvent["DIAL"] = "Dial";
|
|
35
|
+
})(AriEvent || (exports.AriEvent = AriEvent = {}));
|
|
36
|
+
var ChannelVar;
|
|
37
|
+
(function (ChannelVar) {
|
|
38
|
+
ChannelVar["INGRESS_NUMBER"] = "INGRESS_NUMBER";
|
|
39
|
+
ChannelVar["APP_REF"] = "APP_REF";
|
|
40
|
+
ChannelVar["APP_ENDPOINT"] = "APP_ENDPOINT";
|
|
41
|
+
ChannelVar["METADATA"] = "METADATA";
|
|
42
|
+
ChannelVar["CURRENT_BRIDGE"] = "CURRENT_BRIDGE";
|
|
43
|
+
})(ChannelVar || (exports.ChannelVar = ChannelVar = {}));
|
|
@@ -0,0 +1,36 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
/*
|
|
18
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Fonoster
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
__exportStar(require("./ari"), exports);
|
|
36
|
+
__exportStar(require("./voice"), exports);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Stream } from "stream";
|
|
3
|
+
import { SayOptions, StreamContent, VoiceClientConfig, VoiceIn, VoiceSessionStreamClient } from "@fonoster/common";
|
|
4
|
+
import * as grpc from "@grpc/grpc-js";
|
|
5
|
+
import { SpeechResult } from "../stt/types";
|
|
6
|
+
type VoiceClient = {
|
|
7
|
+
config: VoiceClientConfig;
|
|
8
|
+
sendResponse: (command: VoiceIn) => void;
|
|
9
|
+
on: (type: StreamContent, callback: (data: VoiceIn) => void) => void;
|
|
10
|
+
connect: () => void;
|
|
11
|
+
close: () => void;
|
|
12
|
+
synthesize: (text: string, options: SayOptions) => Promise<string>;
|
|
13
|
+
transcribe: () => Promise<SpeechResult>;
|
|
14
|
+
waitForDtmf: (params: {
|
|
15
|
+
sessionRef: string;
|
|
16
|
+
finishOnKey: string;
|
|
17
|
+
maxDigits: number;
|
|
18
|
+
timeout: number;
|
|
19
|
+
onDigitReceived: () => void;
|
|
20
|
+
}) => Promise<{
|
|
21
|
+
digits: string;
|
|
22
|
+
}>;
|
|
23
|
+
};
|
|
24
|
+
type TextToSpeech = {
|
|
25
|
+
synthesize: (text: string, options: Record<string, unknown>) => Promise<string>;
|
|
26
|
+
};
|
|
27
|
+
type SpeechToText = {
|
|
28
|
+
transcribe: (stream: Stream) => Promise<SpeechResult>;
|
|
29
|
+
};
|
|
30
|
+
type GRPCClient = {
|
|
31
|
+
createSession: (metadata: grpc.Metadata) => VoiceSessionStreamClient;
|
|
32
|
+
close: () => void;
|
|
33
|
+
};
|
|
34
|
+
export { VoiceClient, TextToSpeech, SpeechToText, GRPCClient };
|
package/package.json
CHANGED
|
@@ -1,26 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/apiserver",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.6.1-alpha.0",
|
|
4
|
+
"description": "APIServer for Fonoster",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"main": "dist/index",
|
|
9
9
|
"types": "dist/index",
|
|
10
|
+
"directories": {
|
|
11
|
+
"src": "src",
|
|
12
|
+
"test": "test"
|
|
13
|
+
},
|
|
10
14
|
"scripts": {
|
|
11
15
|
"prebuild": "rimraf ./dist tsconfig.tsbuildinfo",
|
|
12
|
-
"build": "tsc -b tsconfig.json"
|
|
16
|
+
"build": "tsc -b tsconfig.json",
|
|
17
|
+
"clean": "rimraf ./dist node_modules tsconfig.tsbuildinfo"
|
|
13
18
|
},
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"../"
|
|
17
|
-
],
|
|
18
|
-
"ext": "ts",
|
|
19
|
-
"exec": "ts-node",
|
|
20
|
-
"ignore": "**/*.d.ts"
|
|
19
|
+
"bin": {
|
|
20
|
+
"fonoster": "./dist/index.js"
|
|
21
21
|
},
|
|
22
|
-
"
|
|
23
|
-
"
|
|
22
|
+
"dependencies": {
|
|
23
|
+
"@fonoster/common": "^0.6.1-alpha.0",
|
|
24
|
+
"@fonoster/identity": "^0.6.1-alpha.0",
|
|
25
|
+
"@fonoster/logger": "^0.6.1-alpha.0",
|
|
26
|
+
"@fonoster/sipnet": "^0.6.1-alpha.0",
|
|
27
|
+
"@google-cloud/speech": "^6.6.0",
|
|
28
|
+
"@google-cloud/text-to-speech": "^5.3.0",
|
|
29
|
+
"@grpc/grpc-js": "^1.10.6",
|
|
30
|
+
"@influxdata/influxdb-client": "^1.33.2",
|
|
31
|
+
"@prisma/client": "^5.14.0",
|
|
32
|
+
"@routr/common": "^2.10.0",
|
|
33
|
+
"@routr/sdk": "^2.12.0",
|
|
34
|
+
"ari-client": "^2.2.0",
|
|
35
|
+
"dotenv": "^16.4.5",
|
|
36
|
+
"express": "^4.19.2",
|
|
37
|
+
"grpc-health-check": "^2.0.1",
|
|
38
|
+
"jsonwebtoken": "^9.0.2",
|
|
39
|
+
"jwt-decode": "^4.0.0",
|
|
40
|
+
"microsoft-cognitiveservices-speech-sdk": "^1.36.0",
|
|
41
|
+
"nanoid": "^3.3.6",
|
|
42
|
+
"nats": "^2.25.0",
|
|
43
|
+
"pb-util": "^1.0.3",
|
|
44
|
+
"pick-port": "^2.0.1",
|
|
45
|
+
"prisma-field-encryption": "^1.5.2",
|
|
46
|
+
"uuid": "^9.0.1",
|
|
47
|
+
"validator": "^13.12.0",
|
|
48
|
+
"wait-port": "^1.1.0",
|
|
49
|
+
"zod": "^3.23.8"
|
|
24
50
|
},
|
|
25
51
|
"files": [
|
|
26
52
|
"dist"
|
|
@@ -35,29 +61,12 @@
|
|
|
35
61
|
"bugs": {
|
|
36
62
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
37
63
|
},
|
|
38
|
-
"dependencies": {
|
|
39
|
-
"@fonoster/agents": "^0.5.5",
|
|
40
|
-
"@fonoster/apps": "^0.5.5",
|
|
41
|
-
"@fonoster/auth": "^0.5.5",
|
|
42
|
-
"@fonoster/autopilot": "^0.5.5",
|
|
43
|
-
"@fonoster/callmanager": "^0.5.5",
|
|
44
|
-
"@fonoster/common": "^0.5.5",
|
|
45
|
-
"@fonoster/dispatcher": "^0.5.5",
|
|
46
|
-
"@fonoster/domains": "^0.5.5",
|
|
47
|
-
"@fonoster/limiter": "^0.5.5",
|
|
48
|
-
"@fonoster/monitor": "^0.5.5",
|
|
49
|
-
"@fonoster/numbers": "^0.5.5",
|
|
50
|
-
"@fonoster/projects": "^0.5.5",
|
|
51
|
-
"@fonoster/providers": "^0.5.5",
|
|
52
|
-
"@fonoster/secrets": "^0.5.5",
|
|
53
|
-
"@fonoster/storage": "^0.5.5",
|
|
54
|
-
"@fonoster/users": "^0.5.5",
|
|
55
|
-
"dotenv": "^8.2.0",
|
|
56
|
-
"express": "^4.18.2",
|
|
57
|
-
"http-proxy": "^1.18.1"
|
|
58
|
-
},
|
|
59
|
-
"gitHead": "4a1438d9dedeaf7b2a5b6a50d5e233f994e2b2cf",
|
|
60
64
|
"devDependencies": {
|
|
61
|
-
"@types/
|
|
62
|
-
|
|
65
|
+
"@types/ari-client": "^2.2.12",
|
|
66
|
+
"@types/express": "^4.17.21",
|
|
67
|
+
"@types/jsonwebtoken": "^9.0.6",
|
|
68
|
+
"@types/uuid": "^9.0.8",
|
|
69
|
+
"@types/validator": "^13.12.0"
|
|
70
|
+
},
|
|
71
|
+
"gitHead": "2cdd1508146747550fe048c35d9a010d04f6d3aa"
|
|
63
72
|
}
|
package/dist/upsert_peer.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/upsert_peer.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
/*
|
|
4
|
-
* Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
|
|
5
|
-
* http://github.com/fonoster/fonoster
|
|
6
|
-
*
|
|
7
|
-
* This file is part of Fonoster
|
|
8
|
-
*
|
|
9
|
-
* Licensed under the MIT License (the "License");
|
|
10
|
-
* you may not use this file except in compliance with
|
|
11
|
-
* the License. You may obtain a copy of the License at
|
|
12
|
-
*
|
|
13
|
-
* https://opensource.org/licenses/MIT
|
|
14
|
-
*
|
|
15
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
16
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
17
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
18
|
-
* See the License for the specific language governing permissions and
|
|
19
|
-
* limitations under the License.
|
|
20
|
-
*/
|
|
21
|
-
const core_1 = require("@fonoster/core");
|
|
22
|
-
const logger_1 = require("@fonoster/logger");
|
|
23
|
-
const envs_1 = require("./envs");
|
|
24
|
-
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
25
|
-
async function upsertPeer(peerInfo) {
|
|
26
|
-
const redis = (0, core_1.getRedisConnection)();
|
|
27
|
-
logger.info(`upserting peer ${peerInfo.ref}`);
|
|
28
|
-
try {
|
|
29
|
-
await redis.sadd("peers", peerInfo.ref);
|
|
30
|
-
await redis.set(peerInfo.ref, buildPeer(peerInfo));
|
|
31
|
-
}
|
|
32
|
-
catch (err) {
|
|
33
|
-
logger.error(err);
|
|
34
|
-
process.exit(1);
|
|
35
|
-
}
|
|
36
|
-
return peerInfo.ref;
|
|
37
|
-
}
|
|
38
|
-
function buildPeer(peerInfo) {
|
|
39
|
-
const { ref, username, secret } = peerInfo;
|
|
40
|
-
const peerObj = {
|
|
41
|
-
apiVersion: "v1beta1",
|
|
42
|
-
kind: "Peer",
|
|
43
|
-
metadata: {
|
|
44
|
-
name: "Voice Media Server @ Default",
|
|
45
|
-
ref: ref,
|
|
46
|
-
createdOn: new Date().toISOString(),
|
|
47
|
-
modifiedOn: new Date().toISOString()
|
|
48
|
-
},
|
|
49
|
-
spec: {
|
|
50
|
-
device: "default",
|
|
51
|
-
credentials: {
|
|
52
|
-
username: username,
|
|
53
|
-
secret: secret
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
return JSON.stringify(peerObj);
|
|
58
|
-
}
|
|
59
|
-
upsertPeer({
|
|
60
|
-
ref: "default",
|
|
61
|
-
username: envs_1.APISERVER_ROUTR_DEFAULT_PEER_USERNAME,
|
|
62
|
-
secret: envs_1.APISERVER_ROUTR_DEFAULT_PEER_SECRET
|
|
63
|
-
}).catch(logger.error);
|
|
File without changes
|