@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.
Files changed (224) hide show
  1. package/LICENSE +2 -2
  2. package/README.md +3 -0
  3. package/dist/applications/buildService.d.ts +29 -0
  4. package/dist/applications/buildService.js +44 -0
  5. package/dist/applications/createApplication.d.ts +6 -0
  6. package/dist/applications/createApplication.js +57 -0
  7. package/dist/applications/createGetFnUtil.d.ts +33 -0
  8. package/dist/applications/createGetFnUtil.js +32 -0
  9. package/dist/applications/deleteApplication.d.ts +6 -0
  10. package/dist/applications/deleteApplication.js +26 -0
  11. package/dist/applications/getApplication.d.ts +6 -0
  12. package/dist/applications/getApplication.js +47 -0
  13. package/dist/applications/hostOrHostPortSchema.d.ts +3 -0
  14. package/dist/applications/hostOrHostPortSchema.js +34 -0
  15. package/dist/applications/index.d.ts +1 -0
  16. package/dist/applications/index.js +23 -0
  17. package/dist/applications/listApplications.d.ts +6 -0
  18. package/dist/applications/listApplications.js +69 -0
  19. package/dist/applications/types.d.ts +27 -0
  20. package/dist/applications/types.js +2 -0
  21. package/dist/applications/updateApplication.d.ts +8 -0
  22. package/dist/applications/updateApplication.js +57 -0
  23. package/dist/applications/utils/applicationWithEncodedStruct.d.ts +3 -0
  24. package/dist/applications/utils/applicationWithEncodedStruct.js +23 -0
  25. package/dist/applications/utils/convertToApplicationData.d.ts +4 -0
  26. package/dist/applications/utils/convertToApplicationData.js +38 -0
  27. package/dist/applications/utils/getApplicationValidationSchema.d.ts +64 -0
  28. package/dist/applications/utils/getApplicationValidationSchema.js +64 -0
  29. package/dist/applications/utils/prepareForValidation.d.ts +3 -0
  30. package/dist/applications/utils/prepareForValidation.js +36 -0
  31. package/dist/applications/utils/validOrThrow.d.ts +3 -0
  32. package/dist/applications/utils/validOrThrow.js +15 -0
  33. package/dist/calls/ListCallsRequestSchema.d.ts +28 -0
  34. package/dist/calls/ListCallsRequestSchema.js +58 -0
  35. package/dist/calls/buildService.d.ts +26 -0
  36. package/dist/calls/buildService.js +58 -0
  37. package/dist/calls/createCall.d.ts +6 -0
  38. package/dist/calls/createCall.js +64 -0
  39. package/dist/calls/createCallPublisher.d.ts +7 -0
  40. package/dist/calls/createCallPublisher.js +47 -0
  41. package/dist/calls/createFetchCalls.d.ts +3 -0
  42. package/dist/calls/createFetchCalls.js +87 -0
  43. package/dist/calls/createFetchSingleCall.d.ts +3 -0
  44. package/dist/calls/createFetchSingleCall.js +48 -0
  45. package/dist/calls/createTrackCallSubscriber.d.ts +6 -0
  46. package/dist/calls/createTrackCallSubscriber.js +53 -0
  47. package/dist/calls/getCall.d.ts +6 -0
  48. package/dist/calls/getCall.js +60 -0
  49. package/dist/calls/index.d.ts +1 -0
  50. package/dist/calls/index.js +23 -0
  51. package/dist/calls/influxdb.d.ts +2 -0
  52. package/dist/calls/influxdb.js +29 -0
  53. package/dist/calls/listCalls.d.ts +6 -0
  54. package/dist/calls/listCalls.js +52 -0
  55. package/dist/calls/runCallManager.d.ts +8 -0
  56. package/dist/calls/runCallManager.js +82 -0
  57. package/dist/calls/trackCall.d.ts +14 -0
  58. package/dist/calls/trackCall.js +64 -0
  59. package/dist/calls/types.d.ts +96 -0
  60. package/dist/calls/types.js +42 -0
  61. package/dist/core/allowList.d.ts +2 -0
  62. package/dist/core/allowList.js +31 -0
  63. package/dist/core/db.d.ts +13 -0
  64. package/dist/core/db.js +29 -0
  65. package/dist/core/filesServer.d.ts +5 -0
  66. package/dist/{ari_proxy.js → core/filesServer.js} +24 -20
  67. package/dist/core/identityConfig.d.ts +21 -0
  68. package/dist/core/identityConfig.js +43 -0
  69. package/dist/core/loadServices.d.ts +8 -0
  70. package/dist/core/loadServices.js +43 -0
  71. package/dist/core/notFoundError.d.ts +6 -0
  72. package/dist/core/notFoundError.js +27 -0
  73. package/dist/core/removeSwaggerNotice.d.ts +2 -0
  74. package/dist/core/removeSwaggerNotice.js +34 -0
  75. package/dist/core/routrConfig.d.ts +5 -0
  76. package/dist/core/routrConfig.js +27 -0
  77. package/dist/core/runServices.d.ts +2 -0
  78. package/dist/core/runServices.js +97 -0
  79. package/dist/core/seed.js +76 -0
  80. package/dist/core/services.d.ts +438 -0
  81. package/dist/core/services.js +53 -0
  82. package/dist/core/upsertDefaultPeer.d.ts +3 -0
  83. package/dist/core/upsertDefaultPeer.js +92 -0
  84. package/dist/envs.d.ts +46 -6
  85. package/dist/envs.js +95 -8
  86. package/dist/events/createInfluxDbPub.d.ts +13 -0
  87. package/dist/events/createInfluxDbPub.js +54 -0
  88. package/dist/events/nats.d.ts +10 -0
  89. package/dist/events/nats.js +85 -0
  90. package/dist/events/types.d.ts +8 -0
  91. package/dist/events/types.js +20 -0
  92. package/dist/index.js +53 -122
  93. package/dist/secrets/buildService.d.ts +37 -0
  94. package/dist/secrets/buildService.js +44 -0
  95. package/dist/secrets/createGetFnUtil.d.ts +16 -0
  96. package/dist/secrets/createGetFnUtil.js +46 -0
  97. package/dist/secrets/createSecret.d.ts +7 -0
  98. package/dist/secrets/createSecret.js +57 -0
  99. package/dist/secrets/deleteSecret.d.ts +8 -0
  100. package/dist/secrets/deleteSecret.js +44 -0
  101. package/dist/secrets/getSecret.d.ts +6 -0
  102. package/dist/secrets/getSecret.js +43 -0
  103. package/dist/secrets/index.d.ts +1 -0
  104. package/dist/secrets/index.js +23 -0
  105. package/dist/secrets/listSecrets.d.ts +7 -0
  106. package/dist/secrets/listSecrets.js +62 -0
  107. package/dist/secrets/types.d.ts +32 -0
  108. package/dist/secrets/types.js +2 -0
  109. package/dist/secrets/updateSecret.d.ts +8 -0
  110. package/dist/secrets/updateSecret.js +53 -0
  111. package/dist/utils/index.d.ts +1 -0
  112. package/dist/utils/index.js +35 -0
  113. package/dist/utils/makeCheckNumberPreconditions.d.ts +6 -0
  114. package/dist/utils/makeCheckNumberPreconditions.js +49 -0
  115. package/dist/voice/ChannelVarNotFoundError.d.ts +5 -0
  116. package/dist/voice/ChannelVarNotFoundError.js +10 -0
  117. package/dist/voice/MethodNotImplementedError.d.ts +4 -0
  118. package/dist/voice/MethodNotImplementedError.js +27 -0
  119. package/dist/voice/VoiceClientImpl.d.ts +42 -0
  120. package/dist/voice/VoiceClientImpl.js +192 -0
  121. package/dist/voice/VoiceDispatcher.d.ts +17 -0
  122. package/dist/voice/VoiceDispatcher.js +99 -0
  123. package/dist/voice/VoiceServiceClientConst.d.ts +3 -0
  124. package/dist/voice/VoiceServiceClientConst.js +53 -0
  125. package/dist/voice/connectToAri.d.ts +2 -0
  126. package/dist/voice/connectToAri.js +80 -0
  127. package/dist/voice/createExternalMediaConfig.d.ts +9 -0
  128. package/dist/voice/createExternalMediaConfig.js +35 -0
  129. package/dist/voice/handlers/Answer.d.ts +5 -0
  130. package/dist/voice/handlers/Answer.js +25 -0
  131. package/dist/voice/handlers/Hangup.d.ts +5 -0
  132. package/dist/voice/handlers/Hangup.js +26 -0
  133. package/dist/voice/handlers/Mute.d.ts +4 -0
  134. package/dist/voice/handlers/Mute.js +28 -0
  135. package/dist/voice/handlers/Play.d.ts +4 -0
  136. package/dist/voice/handlers/Play.js +34 -0
  137. package/dist/voice/handlers/PlayDtmf.d.ts +4 -0
  138. package/dist/voice/handlers/PlayDtmf.js +28 -0
  139. package/dist/voice/handlers/PlaybackControl.d.ts +4 -0
  140. package/dist/voice/handlers/PlaybackControl.js +28 -0
  141. package/dist/voice/handlers/Record.d.ts +4 -0
  142. package/dist/voice/handlers/Record.js +59 -0
  143. package/dist/voice/handlers/Say.d.ts +4 -0
  144. package/dist/voice/handlers/Say.js +46 -0
  145. package/dist/voice/handlers/StasisEnd.d.ts +4 -0
  146. package/dist/voice/handlers/StasisEnd.js +28 -0
  147. package/dist/voice/handlers/Unmute.d.ts +4 -0
  148. package/dist/voice/handlers/Unmute.js +28 -0
  149. package/dist/voice/handlers/awaitForPlaybackFinished.d.ts +3 -0
  150. package/dist/voice/handlers/awaitForPlaybackFinished.js +25 -0
  151. package/dist/voice/handlers/awaitForRecordingFinished.d.ts +5 -0
  152. package/dist/voice/handlers/awaitForRecordingFinished.js +54 -0
  153. package/dist/voice/handlers/dial/Dial.d.ts +5 -0
  154. package/dist/voice/handlers/dial/Dial.js +72 -0
  155. package/dist/voice/handlers/dial/handleChannelLeftBridge.d.ts +6 -0
  156. package/dist/voice/handlers/dial/handleChannelLeftBridge.js +30 -0
  157. package/dist/voice/handlers/dial/handleDialEvents.d.ts +5 -0
  158. package/dist/voice/handlers/dial/handleDialEvents.js +55 -0
  159. package/dist/voice/handlers/dial/handleStasisEnd.d.ts +3 -0
  160. package/dist/voice/handlers/dial/handleStasisEnd.js +20 -0
  161. package/dist/voice/handlers/dial/handleStasisStart.d.ts +9 -0
  162. package/dist/voice/handlers/dial/handleStasisStart.js +54 -0
  163. package/dist/voice/handlers/dial/recordChannel.d.ts +4 -0
  164. package/dist/voice/handlers/dial/recordChannel.js +46 -0
  165. package/dist/voice/handlers/gather/Gather.d.ts +3 -0
  166. package/dist/voice/handlers/gather/Gather.js +73 -0
  167. package/dist/voice/handlers/gather/getTimeoutPromise.d.ts +8 -0
  168. package/dist/voice/handlers/gather/getTimeoutPromise.js +19 -0
  169. package/dist/voice/handlers/withErrorHandling.d.ts +4 -0
  170. package/dist/voice/handlers/withErrorHandling.js +36 -0
  171. package/dist/voice/integrations/ApplicationNotFoundError.d.ts +4 -0
  172. package/dist/voice/integrations/ApplicationNotFoundError.js +28 -0
  173. package/dist/voice/integrations/findIntegrationsCredentials.d.ts +3 -0
  174. package/dist/voice/integrations/findIntegrationsCredentials.js +7 -0
  175. package/dist/voice/integrations/getSttConfig.d.ts +7 -0
  176. package/dist/voice/integrations/getSttConfig.js +10 -0
  177. package/dist/voice/integrations/getTtsConfig.d.ts +7 -0
  178. package/dist/voice/integrations/getTtsConfig.js +11 -0
  179. package/dist/voice/integrations/index.d.ts +1 -0
  180. package/dist/voice/integrations/index.js +35 -0
  181. package/dist/voice/integrations/makeCreateContainer.d.ts +4 -0
  182. package/dist/voice/integrations/makeCreateContainer.js +89 -0
  183. package/dist/voice/integrations/types.d.ts +15 -0
  184. package/dist/voice/integrations/types.js +2 -0
  185. package/dist/voice/makeCreateVoiceClient.d.ts +9 -0
  186. package/dist/voice/makeCreateVoiceClient.js +78 -0
  187. package/dist/voice/makeGetChannelVar.d.ts +4 -0
  188. package/dist/voice/makeGetChannelVar.js +26 -0
  189. package/dist/voice/stt/AbstractSpeechToText.d.ts +15 -0
  190. package/dist/voice/stt/AbstractSpeechToText.js +19 -0
  191. package/dist/voice/stt/Google.d.ts +20 -0
  192. package/dist/voice/stt/Google.js +99 -0
  193. package/dist/voice/stt/SpeechToTextFactory.d.ts +9 -0
  194. package/dist/voice/stt/SpeechToTextFactory.js +41 -0
  195. package/dist/voice/stt/types.d.ts +25 -0
  196. package/dist/voice/stt/types.js +2 -0
  197. package/dist/voice/transcribeOnConnection.d.ts +5 -0
  198. package/dist/voice/transcribeOnConnection.js +27 -0
  199. package/dist/voice/tts/AbstractTextToSpeech.d.ts +18 -0
  200. package/dist/voice/tts/AbstractTextToSpeech.js +82 -0
  201. package/dist/voice/tts/Azure.d.ts +30 -0
  202. package/dist/voice/tts/Azure.js +128 -0
  203. package/dist/voice/tts/Google.d.ts +25 -0
  204. package/dist/voice/tts/Google.js +116 -0
  205. package/dist/voice/tts/TextToSpeechFactory.d.ts +9 -0
  206. package/dist/voice/tts/TextToSpeechFactory.js +43 -0
  207. package/dist/voice/tts/computeFilename.d.ts +7 -0
  208. package/dist/voice/tts/computeFilename.js +39 -0
  209. package/dist/voice/tts/flattenObject.d.ts +2 -0
  210. package/dist/voice/tts/flattenObject.js +39 -0
  211. package/dist/voice/tts/isSsml.d.ts +2 -0
  212. package/dist/voice/tts/isSsml.js +26 -0
  213. package/dist/voice/tts/types.d.ts +7 -0
  214. package/dist/voice/tts/types.js +2 -0
  215. package/dist/voice/types/ari.d.ts +21 -0
  216. package/dist/voice/types/ari.js +43 -0
  217. package/dist/voice/types/index.d.ts +2 -0
  218. package/dist/voice/types/index.js +36 -0
  219. package/dist/voice/types/voice.d.ts +34 -0
  220. package/dist/voice/types/voice.js +2 -0
  221. package/package.json +45 -36
  222. package/dist/upsert_peer.d.ts +0 -1
  223. package/dist/upsert_peer.js +0 -63
  224. /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,7 @@
1
+ declare function computeFilename(params: {
2
+ text: string;
3
+ options: Record<string, unknown>;
4
+ format: "wav" | "sln16";
5
+ cachingFields?: string[];
6
+ }): string;
7
+ export { computeFilename };
@@ -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,2 @@
1
+ declare function flattenObject(obj: any, parentKey?: string, result?: {}): {};
2
+ export { flattenObject };
@@ -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,2 @@
1
+ declare function isSsml(text: string): boolean;
2
+ export { isSsml };
@@ -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,7 @@
1
+ type TtsConfig = {
2
+ pathToFiles: string;
3
+ };
4
+ type SynthOptions = {
5
+ voice: string;
6
+ };
7
+ export { TtsConfig, SynthOptions };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -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,2 @@
1
+ export * from "./ari";
2
+ export * from "./voice";
@@ -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 };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,26 +1,52 @@
1
1
  {
2
2
  "name": "@fonoster/apiserver",
3
- "version": "0.5.5",
4
- "description": "Fonoster API Server",
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
- "nodemonConfig": {
15
- "watch": [
16
- "../"
17
- ],
18
- "ext": "ts",
19
- "exec": "ts-node",
20
- "ignore": "**/*.d.ts"
19
+ "bin": {
20
+ "fonoster": "./dist/index.js"
21
21
  },
22
- "directories": {
23
- "src": "src"
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/http-proxy": "^1.17.14"
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
  }
@@ -1 +0,0 @@
1
- export {};
@@ -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