@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
@@ -3,8 +3,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.filesServer = void 0;
6
7
  /*
7
- * Copyright (C) 2023 by Fonoster Inc (https://fonoster.com)
8
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
8
9
  * http://github.com/fonoster/fonoster
9
10
  *
10
11
  * This file is part of Fonoster
@@ -21,26 +22,29 @@ Object.defineProperty(exports, "__esModule", { value: true });
21
22
  * See the License for the specific language governing permissions and
22
23
  * limitations under the License.
23
24
  */
25
+ const fs_1 = __importDefault(require("fs"));
26
+ const path_1 = require("path");
24
27
  const logger_1 = require("@fonoster/logger");
25
- const envs_1 = require("./envs");
26
- const btoa_1 = __importDefault(require("btoa"));
27
28
  const express_1 = __importDefault(require("express"));
28
- const http_proxy_1 = __importDefault(require("http-proxy"));
29
29
  const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
30
- const PORT = 4000;
31
- const proxy = http_proxy_1.default.createProxyServer({});
32
- const app = (0, express_1.default)();
33
- proxy.on("proxyReq", (proxyReq) => {
34
- const encodedCredentials = (0, btoa_1.default)(`${envs_1.APISERVER_ASTERISK_ARI_USERNAME}:${envs_1.APISERVER_ASTERISK_ARI_SECRET}`);
35
- proxyReq.setHeader("Authorization", `Basic ${encodedCredentials}`);
36
- });
37
- app.use("/", (req, res) => {
38
- logger.verbose("proxying request to target server", {
39
- targetServer: envs_1.APISERVER_ASTERISK_ARI_INTERNAL_URL,
40
- url: req.url
30
+ const CONTENT_TYPE = "audio/L16;rate=16000;channels=1";
31
+ function filesServer(params) {
32
+ const { pathToFiles, port } = params;
33
+ const app = (0, express_1.default)();
34
+ app.get("/sounds/:file", (req, res) => {
35
+ fs_1.default.readFile((0, path_1.join)(pathToFiles, req.params.file), function (err, data) {
36
+ if (err) {
37
+ res.status(404).send("file not found!");
38
+ }
39
+ else {
40
+ res.setHeader("content-type", CONTENT_TYPE);
41
+ res.send(data);
42
+ }
43
+ res.end();
44
+ });
41
45
  });
42
- proxy.web(req, res, { target: envs_1.APISERVER_ASTERISK_ARI_INTERNAL_URL });
43
- });
44
- app.listen(PORT, () => {
45
- logger.info(`ARI proxy server is running on http://localhost:${PORT}`);
46
- });
46
+ app.listen(port, () => {
47
+ logger.info(`files server is running on port ${port}`);
48
+ });
49
+ }
50
+ exports.filesServer = filesServer;
@@ -0,0 +1,21 @@
1
+ declare const identityConfig: {
2
+ issuer: string;
3
+ audience: string;
4
+ privateKey: string;
5
+ publicKey: string;
6
+ encryptionKey: string;
7
+ accessTokenExpiresIn: string;
8
+ refreshTokenExpiresIn: string;
9
+ idTokenExpiresIn: string;
10
+ smtpConfig: {
11
+ host: string;
12
+ port: number;
13
+ secure: boolean;
14
+ sender: string;
15
+ auth: {
16
+ user: string;
17
+ pass: string;
18
+ };
19
+ };
20
+ };
21
+ export { identityConfig };
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.identityConfig = 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 envs_1 = require("../envs");
23
+ const identityConfig = {
24
+ issuer: envs_1.IDENTITY_ISSUER,
25
+ audience: envs_1.IDENTITY_AUDIENCE,
26
+ privateKey: envs_1.IDENTITY_PRIVATE_KEY,
27
+ publicKey: envs_1.IDENTITY_PUBLIC_KEY,
28
+ encryptionKey: envs_1.CLOAK_ENCRYPTION_KEY,
29
+ accessTokenExpiresIn: envs_1.IDENTITY_ACCESS_TOKEN_EXPIRES_IN,
30
+ refreshTokenExpiresIn: envs_1.IDENTITY_REFRESH_TOKEN_EXPIRES_IN,
31
+ idTokenExpiresIn: envs_1.IDENTITY_ID_TOKEN_EXPIRES_IN,
32
+ smtpConfig: {
33
+ host: envs_1.SMTP_HOST,
34
+ port: envs_1.SMTP_PORT,
35
+ secure: envs_1.SMTP_SECURE,
36
+ sender: envs_1.SMTP_SENDER,
37
+ auth: {
38
+ user: envs_1.SMTP_AUTH_USER,
39
+ pass: envs_1.SMTP_AUTH_PASS
40
+ }
41
+ }
42
+ };
43
+ exports.identityConfig = identityConfig;
@@ -0,0 +1,8 @@
1
+ import { ServiceDefinitionParams } from "@fonoster/common";
2
+ import * as grpc from "@grpc/grpc-js";
3
+ type FonosterService = {
4
+ definition: ServiceDefinitionParams;
5
+ handlers: grpc.UntypedServiceImplementation;
6
+ };
7
+ declare function loadServices(server: grpc.Server, services: FonosterService[]): Promise<void>;
8
+ export default loadServices;
@@ -0,0 +1,43 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /*
13
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
14
+ * http://github.com/fonoster/fonoster
15
+ *
16
+ * This file is part of Fonoster
17
+ *
18
+ * Licensed under the MIT License (the "License");
19
+ * you may not use this file except in compliance with
20
+ * the License. You may obtain a copy of the License at
21
+ *
22
+ * https://opensource.org/licenses/MIT
23
+ *
24
+ * Unless required by applicable law or agreed to in writing, software
25
+ * distributed under the License is distributed on an "AS IS" BASIS,
26
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
+ * See the License for the specific language governing permissions and
28
+ * limitations under the License.
29
+ */
30
+ const common_1 = require("@fonoster/common");
31
+ const logger_1 = require("@fonoster/logger");
32
+ const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
33
+ function loadServices(server, services) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ services.forEach((service) => {
36
+ const serviceDefinition = (0, common_1.createServiceDefinition)(service.definition);
37
+ const { serviceName, pckg, version } = service.definition;
38
+ server.addService(serviceDefinition, service.handlers);
39
+ logger.info("loaded service", { serviceName, pckg, version });
40
+ });
41
+ });
42
+ }
43
+ exports.default = loadServices;
@@ -0,0 +1,6 @@
1
+ import { status } from "@grpc/grpc-js";
2
+ declare const notFoundError: (message: string) => {
3
+ code: status;
4
+ message: string;
5
+ };
6
+ export { notFoundError };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.notFoundError = 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 grpc_js_1 = require("@grpc/grpc-js");
23
+ const notFoundError = (message) => ({
24
+ code: grpc_js_1.status.NOT_FOUND,
25
+ message
26
+ });
27
+ exports.notFoundError = notFoundError;
@@ -0,0 +1,2 @@
1
+ declare const _default: {};
2
+ export default _default;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /*
4
+ * Copyright (C) 2024 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
+ // eslint-disable-next-line no-console
22
+ const originalLog = console.log;
23
+ const containsDeprecationWarning = (str) => {
24
+ const deprecationWarning = "This API is using a deprecated version of Swagger! Please see http://github.com/wordnik/swagger-core/wiki for more info";
25
+ return str.includes(deprecationWarning);
26
+ };
27
+ // eslint-disable-next-line no-console
28
+ console.log = (...args) => {
29
+ const logString = args.join(" ");
30
+ if (!containsDeprecationWarning(logString)) {
31
+ originalLog(...args);
32
+ }
33
+ };
34
+ exports.default = {};
@@ -0,0 +1,5 @@
1
+ declare const routrConfig: {
2
+ endpoint: string;
3
+ insecure: boolean;
4
+ };
5
+ export { routrConfig };
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.routrConfig = 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 envs_1 = require("../envs");
23
+ const routrConfig = {
24
+ endpoint: envs_1.ROUTR_API_ENDPOINT,
25
+ insecure: true
26
+ };
27
+ exports.routrConfig = routrConfig;
@@ -0,0 +1,2 @@
1
+ declare function runServices(): Promise<void>;
2
+ export default runServices;
@@ -0,0 +1,97 @@
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
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ /*
39
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
40
+ * http://github.com/fonoster/fonoster
41
+ *
42
+ * This file is part of Fonoster
43
+ *
44
+ * Licensed under the MIT License (the "License");
45
+ * you may not use this file except in compliance with
46
+ * the License. You may obtain a copy of the License at
47
+ *
48
+ * https://opensource.org/licenses/MIT
49
+ *
50
+ * Unless required by applicable law or agreed to in writing, software
51
+ * distributed under the License is distributed on an "AS IS" BASIS,
52
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
53
+ * See the License for the specific language governing permissions and
54
+ * limitations under the License.
55
+ */
56
+ const common_1 = require("@fonoster/common");
57
+ const identity_1 = require("@fonoster/identity");
58
+ const logger_1 = require("@fonoster/logger");
59
+ const grpc = __importStar(require("@grpc/grpc-js"));
60
+ const grpc_health_check_1 = require("grpc-health-check");
61
+ const allowList_1 = require("./allowList");
62
+ const filesServer_1 = require("./filesServer");
63
+ const loadServices_1 = __importDefault(require("./loadServices"));
64
+ const services_1 = __importDefault(require("./services"));
65
+ const runCallManager_1 = require("../calls/runCallManager");
66
+ const envs_1 = require("../envs");
67
+ const connectToAri_1 = require("../voice/connectToAri");
68
+ const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
69
+ const authorization = (0, identity_1.createAuthInterceptor)(envs_1.IDENTITY_PUBLIC_KEY, allowList_1.allowList);
70
+ function runServices() {
71
+ return __awaiter(this, void 0, void 0, function* () {
72
+ const healthImpl = new grpc_health_check_1.HealthImplementation(common_1.statusMap);
73
+ const credentials = yield (0, common_1.getServerCredentials)({});
74
+ const server = new grpc.Server({
75
+ interceptors: [authorization]
76
+ });
77
+ // Add the health check service to the server
78
+ healthImpl.addToServer(server);
79
+ // Load the remaining services
80
+ (0, loadServices_1.default)(server, yield services_1.default);
81
+ // Connecting to Asterisk ARI
82
+ yield (0, connectToAri_1.connectToAri)();
83
+ // Additional Call Managers subscriber may be added here to handle call events
84
+ yield (0, runCallManager_1.createCreateCallSubscriber)({
85
+ natsUrl: envs_1.NATS_URL,
86
+ ariProxyUrl: envs_1.ASTERISK_ARI_PROXY_URL,
87
+ ariUsername: envs_1.ASTERISK_ARI_USERNAME,
88
+ ariPassword: envs_1.ASTERISK_ARI_SECRET
89
+ });
90
+ (0, filesServer_1.filesServer)({ pathToFiles: envs_1.TTS_PATH_TO_FILES, port: envs_1.FILES_SERVER_PORT });
91
+ server.bindAsync(envs_1.APISERVER_BIND_ADDR, credentials, () => __awaiter(this, void 0, void 0, function* () {
92
+ healthImpl.setStatus("", common_1.GRPC_SERVING_STATUS);
93
+ logger.info(`apiserver running at ${envs_1.APISERVER_BIND_ADDR}`);
94
+ }));
95
+ });
96
+ }
97
+ exports.default = runServices;
@@ -0,0 +1,76 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ /*
13
+ * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
14
+ * http://github.com/fonoster/fonoster
15
+ *
16
+ * This file is part of Fonoster
17
+ *
18
+ * Licensed under the MIT License (the "License");
19
+ * you may not use this file except in compliance with
20
+ * the License. You may obtain a copy of the License at
21
+ *
22
+ * https://opensource.org/licenses/MIT
23
+ *
24
+ * Unless required by applicable law or agreed to in writing, software
25
+ * distributed under the License is distributed on an "AS IS" BASIS,
26
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
+ * See the License for the specific language governing permissions and
28
+ * limitations under the License.
29
+ */
30
+ const logger_1 = require("@fonoster/logger");
31
+ const client_1 = require("@prisma/client");
32
+ const prisma = new client_1.PrismaClient();
33
+ const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
34
+ function main() {
35
+ return __awaiter(this, void 0, void 0, function* () {
36
+ yield prisma.product.upsert({
37
+ where: { ref: "tts.google" },
38
+ update: {},
39
+ create: {
40
+ ref: "tts.google",
41
+ name: "Google Text-to-Speech",
42
+ vendor: "GOOGLE",
43
+ type: "TTS"
44
+ }
45
+ });
46
+ yield prisma.product.upsert({
47
+ where: { ref: "stt.google" },
48
+ update: {},
49
+ create: {
50
+ ref: "stt.google",
51
+ name: "Google Speech-to-Text",
52
+ vendor: "GOOGLE",
53
+ type: "STT"
54
+ }
55
+ });
56
+ yield prisma.product.upsert({
57
+ where: { ref: "nlu.dialogflowcx" },
58
+ update: {},
59
+ create: {
60
+ ref: "nlu.dialogflowcx",
61
+ name: "Dialogflow CX",
62
+ vendor: "GOOGLE",
63
+ type: "NLU"
64
+ }
65
+ });
66
+ });
67
+ }
68
+ main()
69
+ .then(() => __awaiter(void 0, void 0, void 0, function* () {
70
+ yield prisma.$disconnect();
71
+ }))
72
+ .catch((e) => __awaiter(void 0, void 0, void 0, function* () {
73
+ logger.error(e);
74
+ yield prisma.$disconnect();
75
+ process.exit(1);
76
+ }));