@fonoster/apiserver 0.8.25 → 0.8.27

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 (120) hide show
  1. package/dist/applications/buildService.js +10 -10
  2. package/dist/applications/{createApplication.d.ts → createCreateApplication.d.ts} +2 -2
  3. package/dist/applications/{createApplication.js → createCreateApplication.js} +14 -7
  4. package/dist/applications/{getApplication.d.ts → createDeleteApplication.d.ts} +2 -2
  5. package/dist/applications/{deleteApplication.js → createDeleteApplication.js} +4 -4
  6. package/dist/applications/{updateApplication.d.ts → createGetApplication.d.ts} +2 -2
  7. package/dist/applications/{getApplication.js → createGetApplication.js} +4 -4
  8. package/dist/applications/createGetFnUtil.d.ts +2 -0
  9. package/dist/applications/{listApplications.d.ts → createListApplications.d.ts} +2 -2
  10. package/dist/applications/{listApplications.js → createListApplications.js} +5 -6
  11. package/dist/applications/{deleteApplication.d.ts → createUpdateApplication.d.ts} +2 -2
  12. package/dist/applications/{updateApplication.js → createUpdateApplication.js} +7 -7
  13. package/dist/applications/utils/applicationWithEncodedStruct.js +2 -0
  14. package/dist/applications/utils/convertToApplicationData.d.ts +2 -2
  15. package/dist/applications/validation/assistantWithoutApiKeySchema.d.ts +671 -0
  16. package/dist/applications/validation/assistantWithoutApiKeySchema.js +35 -0
  17. package/dist/applications/validation/createValidationSchema.d.ts +1107 -0
  18. package/dist/applications/validation/createValidationSchema.js +67 -0
  19. package/dist/applications/validation/speechValidators.d.ts +29 -0
  20. package/dist/applications/{utils/getApplicationValidationSchema.js → validation/speechValidators.js} +3 -28
  21. package/dist/applications/{utils → validation}/validOrThrow.js +3 -2
  22. package/dist/calls/buildService.js +2 -2
  23. package/dist/calls/createCall.js +1 -2
  24. package/dist/calls/{makeTrackCall.d.ts → createTrackCall.d.ts} +2 -2
  25. package/dist/calls/{makeTrackCall.js → createTrackCall.js} +4 -4
  26. package/dist/calls/getCall.js +1 -2
  27. package/dist/calls/listCalls.js +1 -2
  28. package/dist/core/httpBridge.js +1 -1
  29. package/dist/core/runServices.js +2 -3
  30. package/dist/core/seed.js +11 -1
  31. package/dist/core/services.js +1 -1
  32. package/dist/envs.d.ts +1 -0
  33. package/dist/envs.js +3 -2
  34. package/dist/secrets/createGetFnUtil.js +12 -10
  35. package/dist/secrets/createSecret.js +1 -2
  36. package/dist/secrets/listSecrets.js +1 -2
  37. package/dist/secrets/updateSecret.js +1 -2
  38. package/dist/utils/createCheckNumberPreconditions.d.ts +6 -0
  39. package/dist/utils/{makeCheckNumberPreconditions.js → createCheckNumberPreconditions.js} +4 -4
  40. package/dist/utils/createHandleDialEventsWithNats.d.ts +5 -0
  41. package/dist/utils/{makeHandleDialEventsWithNats.js → createHandleDialEventsWithNats.js} +10 -8
  42. package/dist/utils/createHandleDialEventsWithVoiceClient.d.ts +5 -0
  43. package/dist/utils/{makeHandleDialEventsWithVoiceClient.js → createHandleDialEventsWithVoiceClient.js} +13 -11
  44. package/dist/utils/index.d.ts +3 -3
  45. package/dist/utils/index.js +3 -3
  46. package/dist/voice/VoiceClientImpl.js +13 -7
  47. package/dist/voice/VoiceDispatcher.js +16 -17
  48. package/dist/voice/connectToAri.js +3 -3
  49. package/dist/voice/{makeCreateVoiceClient.d.ts → createCreateVoiceClient.d.ts} +2 -2
  50. package/dist/voice/createCreateVoiceClient.js +76 -0
  51. package/dist/voice/handlers/createAnswerHandler.d.ts +5 -0
  52. package/dist/voice/handlers/{Answer.js → createAnswerHandler.js} +2 -2
  53. package/dist/voice/handlers/createHangupHandler.d.ts +5 -0
  54. package/dist/voice/handlers/{Hangup.js → createHangupHandler.js} +2 -2
  55. package/dist/voice/handlers/createMuteHandler.d.ts +4 -0
  56. package/dist/voice/handlers/{Mute.js → createMuteHandler.js} +2 -2
  57. package/dist/voice/handlers/createPlayDtmfHandler.d.ts +4 -0
  58. package/dist/voice/handlers/{PlayDtmf.js → createPlayDtmfHandler.js} +2 -2
  59. package/dist/voice/handlers/createPlayHandler.d.ts +4 -0
  60. package/dist/voice/handlers/{Play.js → createPlayHandler.js} +2 -2
  61. package/dist/voice/handlers/createPlaybackControlHandler.d.ts +4 -0
  62. package/dist/voice/handlers/{PlaybackControl.js → createPlaybackControlHandler.js} +2 -2
  63. package/dist/voice/handlers/createRecordHandler.d.ts +4 -0
  64. package/dist/voice/handlers/{Record.js → createRecordHandler.js} +2 -2
  65. package/dist/voice/handlers/createSayHandler.d.ts +4 -0
  66. package/dist/voice/handlers/{Say.js → createSayHandler.js} +2 -2
  67. package/dist/voice/handlers/createStreamGatherHandler.d.ts +3 -0
  68. package/dist/voice/handlers/{StreamGather.js → createStreamGatherHandler.js} +2 -2
  69. package/dist/voice/handlers/{StreamGather.d.ts → createStreamHandler.d.ts} +2 -2
  70. package/dist/voice/handlers/{Stream.js → createStreamHandler.js} +2 -2
  71. package/dist/voice/handlers/createUnmuteHandler.d.ts +4 -0
  72. package/dist/voice/handlers/{Unmute.js → createUnmuteHandler.js} +2 -2
  73. package/dist/voice/handlers/dial/createDialHandler.d.ts +5 -0
  74. package/dist/voice/handlers/dial/createDialHandler.js +78 -0
  75. package/dist/voice/handlers/dial/index.d.ts +1 -0
  76. package/dist/voice/handlers/dial/index.js +35 -0
  77. package/dist/voice/handlers/gather/createGatherHandler.d.ts +3 -0
  78. package/dist/voice/handlers/gather/{Gather.js → createGatherHandler.js} +2 -2
  79. package/dist/voice/handlers/index.d.ts +13 -12
  80. package/dist/voice/handlers/index.js +13 -12
  81. package/dist/voice/integrations/createCreateContainer.d.ts +4 -0
  82. package/dist/voice/integrations/{makeCreateContainer.js → createCreateContainer.js} +28 -26
  83. package/dist/voice/integrations/getSttConfig.js +20 -2
  84. package/dist/voice/integrations/getTtsConfig.js +2 -2
  85. package/dist/voice/integrations/index.d.ts +1 -1
  86. package/dist/voice/integrations/index.js +1 -1
  87. package/dist/voice/stt/types.d.ts +1 -1
  88. package/dist/voice/utils/createGetChannelVar.d.ts +4 -0
  89. package/dist/voice/utils/{makeGetChannelVar.js → createGetChannelVar.js} +14 -12
  90. package/dist/voice/utils/createGetChannelVarWithoutThrow.d.ts +4 -0
  91. package/dist/voice/utils/{makeGetChannelVarWithoutThrow.js → createGetChannelVarWithoutThrow.js} +14 -12
  92. package/dist/voice/utils/index.d.ts +2 -2
  93. package/dist/voice/utils/index.js +2 -2
  94. package/package.json +9 -9
  95. package/dist/applications/utils/getApplicationValidationSchema.d.ts +0 -64
  96. package/dist/utils/makeCheckNumberPreconditions.d.ts +0 -6
  97. package/dist/utils/makeHandleDialEventsWithNats.d.ts +0 -5
  98. package/dist/utils/makeHandleDialEventsWithVoiceClient.d.ts +0 -5
  99. package/dist/voice/handlers/Answer.d.ts +0 -5
  100. package/dist/voice/handlers/Hangup.d.ts +0 -5
  101. package/dist/voice/handlers/Mute.d.ts +0 -4
  102. package/dist/voice/handlers/Play.d.ts +0 -4
  103. package/dist/voice/handlers/PlayDtmf.d.ts +0 -4
  104. package/dist/voice/handlers/PlaybackControl.d.ts +0 -4
  105. package/dist/voice/handlers/Record.d.ts +0 -4
  106. package/dist/voice/handlers/Say.d.ts +0 -4
  107. package/dist/voice/handlers/Stream.d.ts +0 -3
  108. package/dist/voice/handlers/Unmute.d.ts +0 -4
  109. package/dist/voice/handlers/dial/Dial.d.ts +0 -5
  110. package/dist/voice/handlers/dial/Dial.js +0 -76
  111. package/dist/voice/handlers/gather/Gather.d.ts +0 -3
  112. package/dist/voice/integrations/findIntegrationsCredentials.d.ts +0 -3
  113. package/dist/voice/integrations/findIntegrationsCredentials.js +0 -7
  114. package/dist/voice/integrations/makeCreateContainer.d.ts +0 -4
  115. package/dist/voice/makeCreateVoiceClient.js +0 -74
  116. package/dist/voice/utils/makeGetChannelVar.d.ts +0 -4
  117. package/dist/voice/utils/makeGetChannelVarWithoutThrow.d.ts +0 -4
  118. /package/dist/applications/{utils → validation}/prepareForValidation.d.ts +0 -0
  119. /package/dist/applications/{utils → validation}/prepareForValidation.js +0 -0
  120. /package/dist/applications/{utils → validation}/validOrThrow.d.ts +0 -0
@@ -32,15 +32,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
32
32
  * See the License for the specific language governing permissions and
33
33
  * limitations under the License.
34
34
  */
35
- __exportStar(require("./Answer"), exports);
36
- __exportStar(require("./Hangup"), exports);
37
- __exportStar(require("./Mute"), exports);
38
- __exportStar(require("./Play"), exports);
39
- __exportStar(require("./PlayDtmf"), exports);
40
- __exportStar(require("./PlaybackControl"), exports);
41
- __exportStar(require("./Record"), exports);
42
- __exportStar(require("./Say"), exports);
43
- __exportStar(require("./StreamGather"), exports);
44
- __exportStar(require("./Unmute"), exports);
45
- __exportStar(require("./dial/Dial"), exports);
46
- __exportStar(require("./gather/Gather"), exports);
35
+ __exportStar(require("./createAnswerHandler"), exports);
36
+ __exportStar(require("./createHangupHandler"), exports);
37
+ __exportStar(require("./createMuteHandler"), exports);
38
+ __exportStar(require("./createStreamHandler"), exports);
39
+ __exportStar(require("./createPlayHandler"), exports);
40
+ __exportStar(require("./createPlayDtmfHandler"), exports);
41
+ __exportStar(require("./createPlaybackControlHandler"), exports);
42
+ __exportStar(require("./createRecordHandler"), exports);
43
+ __exportStar(require("./createSayHandler"), exports);
44
+ __exportStar(require("./createStreamGatherHandler"), exports);
45
+ __exportStar(require("./createUnmuteHandler"), exports);
46
+ __exportStar(require("./dial/createDialHandler"), exports);
47
+ __exportStar(require("./gather/createGatherHandler"), exports);
@@ -0,0 +1,4 @@
1
+ import { IntegrationsContainer } from "./types";
2
+ import { Prisma } from "../../core/db";
3
+ declare function createCreateContainer(prisma: Prisma, pathToIntegrations: string): (appRef: string) => Promise<IntegrationsContainer>;
4
+ export { createCreateContainer };
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.makeCreateContainer = makeCreateContainer;
15
+ exports.createCreateContainer = createCreateContainer;
16
16
  /*
17
17
  * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
18
18
  * http://github.com/fonoster/fonoster
@@ -44,10 +44,10 @@ const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filen
44
44
  const integrationsConfigSchema = zod_1.z.array(zod_1.z.object({
45
45
  name: zod_1.z.string(),
46
46
  productRef: zod_1.z.string(),
47
- type: zod_1.z.enum(["tts", "stt"]),
47
+ type: zod_1.z.enum(["tts", "stt", "llm"]),
48
48
  credentials: zod_1.z.record(zod_1.z.unknown())
49
49
  }));
50
- function makeCreateContainer(prisma, pathToIntegrations) {
50
+ function createCreateContainer(prisma, pathToIntegrations) {
51
51
  logger.verbose("loading integrations config", { pathToIntegrations });
52
52
  const integrationsFile = fs_1.default.readFileSync(pathToIntegrations, "utf8");
53
53
  const integrations = JSON.parse(integrationsFile);
@@ -60,29 +60,31 @@ function makeCreateContainer(prisma, pathToIntegrations) {
60
60
  logger.error("integrations config is invalid", { message });
61
61
  process.exit(1);
62
62
  }
63
- return (appRef) => __awaiter(this, void 0, void 0, function* () {
64
- logger.verbose("creating integrations container", { appRef });
65
- const app = yield prisma.application.findUnique({
66
- where: { ref: appRef },
67
- include: {
68
- textToSpeech: true,
69
- speechToText: true,
70
- intelligence: true
63
+ return function createContainer(appRef) {
64
+ return __awaiter(this, void 0, void 0, function* () {
65
+ logger.verbose("creating integrations container", { appRef });
66
+ const app = yield prisma.application.findUnique({
67
+ where: { ref: appRef },
68
+ include: {
69
+ textToSpeech: true,
70
+ speechToText: true,
71
+ intelligence: true
72
+ }
73
+ });
74
+ if (!app) {
75
+ throw new ApplicationNotFoundError_1.ApplicationNotFoundError(appRef);
71
76
  }
77
+ const ttsConfig = (0, getTtsConfig_1.getTtsConfig)(integrations, app);
78
+ const sttConfig = (0, getSttConfig_1.getSttConfig)(integrations, app);
79
+ const tts = TextToSpeechFactory_1.TextToSpeechFactory.getEngine(app.textToSpeech.productRef, ttsConfig);
80
+ const stt = SpeechToTextFactory_1.SpeechToTextFactory.getEngine(app.speechToText.productRef, sttConfig);
81
+ return {
82
+ ref: appRef,
83
+ accessKeyId: app.accessKeyId,
84
+ endpoint: app.endpoint,
85
+ tts,
86
+ stt
87
+ };
72
88
  });
73
- if (!app) {
74
- throw new ApplicationNotFoundError_1.ApplicationNotFoundError(appRef);
75
- }
76
- const ttsConfig = (0, getTtsConfig_1.getTtsConfig)(integrations, app);
77
- const sttConfig = (0, getSttConfig_1.getSttConfig)(integrations, app);
78
- const tts = TextToSpeechFactory_1.TextToSpeechFactory.getEngine(app.textToSpeech.productRef, ttsConfig);
79
- const stt = SpeechToTextFactory_1.SpeechToTextFactory.getEngine(app.speechToText.productRef, sttConfig);
80
- return {
81
- ref: appRef,
82
- accessKeyId: app.accessKeyId,
83
- endpoint: app.endpoint,
84
- tts,
85
- stt
86
- };
87
- });
89
+ };
88
90
  }
@@ -1,10 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getSttConfig = getSttConfig;
4
- const findIntegrationsCredentials_1 = require("./findIntegrationsCredentials");
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 common_1 = require("@fonoster/common");
5
23
  function getSttConfig(integrations, app) {
6
24
  const config = app.speechToText.config;
7
- const credentials = (0, findIntegrationsCredentials_1.findIntegrationsCredentials)(integrations, app.speechToText.productRef);
25
+ const credentials = (0, common_1.findIntegrationsCredentials)(integrations, app.speechToText.productRef);
8
26
  return {
9
27
  config,
10
28
  credentials
@@ -1,10 +1,10 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getTtsConfig = getTtsConfig;
4
- const findIntegrationsCredentials_1 = require("./findIntegrationsCredentials");
4
+ const common_1 = require("@fonoster/common");
5
5
  function getTtsConfig(integrations, app) {
6
6
  const config = app.textToSpeech.config;
7
- const credentials = (0, findIntegrationsCredentials_1.findIntegrationsCredentials)(integrations, app.textToSpeech.productRef);
7
+ const credentials = (0, common_1.findIntegrationsCredentials)(integrations, app.textToSpeech.productRef);
8
8
  return {
9
9
  config,
10
10
  credentials
@@ -1 +1 @@
1
- export * from "./makeCreateContainer";
1
+ export * from "./createCreateContainer";
@@ -32,4 +32,4 @@ Object.defineProperty(exports, "__esModule", { value: true });
32
32
  * See the License for the specific language governing permissions and
33
33
  * limitations under the License.
34
34
  */
35
- __exportStar(require("./makeCreateContainer"), exports);
35
+ __exportStar(require("./createCreateContainer"), exports);
@@ -1,4 +1,4 @@
1
- import { VoiceLanguage } from "@fonoster/common/src/tts/types";
1
+ import { VoiceLanguage } from "@fonoster/common";
2
2
  type SpeechResult = {
3
3
  speech: string;
4
4
  isFinal: boolean;
@@ -0,0 +1,4 @@
1
+ import { Channel } from "ari-client";
2
+ import { ChannelVar } from "../types";
3
+ declare function createGetChannelVar(channel: Channel): (variable: ChannelVar) => Promise<import("ari-client").Variable>;
4
+ export { createGetChannelVar };
@@ -9,17 +9,19 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.makeGetChannelVar = makeGetChannelVar;
12
+ exports.createGetChannelVar = createGetChannelVar;
13
13
  const ChannelVarNotFoundError_1 = require("../errors/ChannelVarNotFoundError");
14
- function makeGetChannelVar(channel) {
15
- return (variable) => __awaiter(this, void 0, void 0, function* () {
16
- try {
17
- return yield channel.getChannelVar({
18
- variable
19
- });
20
- }
21
- catch (e) {
22
- throw new ChannelVarNotFoundError_1.ChannelVarNotFoundError(variable);
23
- }
24
- });
14
+ function createGetChannelVar(channel) {
15
+ return function getChannelVar(variable) {
16
+ return __awaiter(this, void 0, void 0, function* () {
17
+ try {
18
+ return yield channel.getChannelVar({
19
+ variable
20
+ });
21
+ }
22
+ catch (e) {
23
+ throw new ChannelVarNotFoundError_1.ChannelVarNotFoundError(variable);
24
+ }
25
+ });
26
+ };
25
27
  }
@@ -0,0 +1,4 @@
1
+ import { Channel } from "ari-client";
2
+ import { ChannelVar } from "../types";
3
+ declare function createGetChannelVarWithoutThrow(channel: Channel): (variable: ChannelVar) => Promise<import("ari-client").Variable>;
4
+ export { createGetChannelVarWithoutThrow };
@@ -9,16 +9,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.makeGetChannelVarWithoutThrow = makeGetChannelVarWithoutThrow;
13
- function makeGetChannelVarWithoutThrow(channel) {
14
- return (variable) => __awaiter(this, void 0, void 0, function* () {
15
- try {
16
- return yield channel.getChannelVar({
17
- variable
18
- });
19
- }
20
- catch (e) {
21
- return null;
22
- }
23
- });
12
+ exports.createGetChannelVarWithoutThrow = createGetChannelVarWithoutThrow;
13
+ function createGetChannelVarWithoutThrow(channel) {
14
+ return function getChannelVarWithoutThrow(variable) {
15
+ return __awaiter(this, void 0, void 0, function* () {
16
+ try {
17
+ return yield channel.getChannelVar({
18
+ variable
19
+ });
20
+ }
21
+ catch (e) {
22
+ return null;
23
+ }
24
+ });
25
+ };
24
26
  }
@@ -1,4 +1,4 @@
1
1
  export * from "./VoiceServiceClientConstructor";
2
2
  export * from "./createExternalMediaConfig";
3
- export * from "./makeGetChannelVar";
4
- export * from "./makeGetChannelVarWithoutThrow";
3
+ export * from "./createGetChannelVar";
4
+ export * from "./createGetChannelVarWithoutThrow";
@@ -34,5 +34,5 @@ Object.defineProperty(exports, "__esModule", { value: true });
34
34
  */
35
35
  __exportStar(require("./VoiceServiceClientConstructor"), exports);
36
36
  __exportStar(require("./createExternalMediaConfig"), exports);
37
- __exportStar(require("./makeGetChannelVar"), exports);
38
- __exportStar(require("./makeGetChannelVarWithoutThrow"), exports);
37
+ __exportStar(require("./createGetChannelVar"), exports);
38
+ __exportStar(require("./createGetChannelVarWithoutThrow"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/apiserver",
3
- "version": "0.8.25",
3
+ "version": "0.8.27",
4
4
  "description": "APIServer for Fonoster",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -21,13 +21,13 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@deepgram/sdk": "^3.5.1",
24
- "@fonoster/authz": "^0.8.25",
25
- "@fonoster/common": "^0.8.25",
26
- "@fonoster/identity": "^0.8.25",
27
- "@fonoster/logger": "^0.8.24",
28
- "@fonoster/sipnet": "^0.8.25",
29
- "@fonoster/streams": "^0.8.24",
30
- "@fonoster/types": "^0.8.24",
24
+ "@fonoster/authz": "^0.8.27",
25
+ "@fonoster/common": "^0.8.27",
26
+ "@fonoster/identity": "^0.8.27",
27
+ "@fonoster/logger": "^0.8.27",
28
+ "@fonoster/sipnet": "^0.8.27",
29
+ "@fonoster/streams": "^0.8.27",
30
+ "@fonoster/types": "^0.8.27",
31
31
  "@google-cloud/speech": "^6.6.0",
32
32
  "@google-cloud/text-to-speech": "^5.3.0",
33
33
  "@grpc/grpc-js": "~1.10.6",
@@ -73,5 +73,5 @@
73
73
  "@types/uuid": "^10.0.0",
74
74
  "@types/validator": "^13.12.0"
75
75
  },
76
- "gitHead": "159876a77dc3f30e2d155a2d4f39d1a73919f2af"
76
+ "gitHead": "3c50badbc1b7043d1525603ad3386b9f70d53b28"
77
77
  }
@@ -1,64 +0,0 @@
1
- import { z } from "zod";
2
- declare function getApplicationValidationSchema(request: {
3
- ttsEngineName: string;
4
- sttEngineName: string;
5
- }): z.ZodObject<{
6
- name: z.ZodString;
7
- type: z.ZodNativeEnum<{
8
- EXTERNAL: "EXTERNAL";
9
- }>;
10
- endpoint: z.ZodEffects<z.ZodOptional<z.ZodString>, string, string>;
11
- textToSpeech: z.ZodObject<{
12
- productRef: z.ZodString;
13
- config: any;
14
- }, "strip", z.ZodTypeAny, {
15
- [x: string]: any;
16
- productRef?: unknown;
17
- config?: unknown;
18
- }, {
19
- [x: string]: any;
20
- productRef?: unknown;
21
- config?: unknown;
22
- }> | z.ZodUndefined;
23
- speechToText: z.ZodUndefined | z.ZodObject<{
24
- productRef: z.ZodString;
25
- config: any;
26
- }, "strip", z.ZodTypeAny, {
27
- [x: string]: any;
28
- productRef?: unknown;
29
- config?: unknown;
30
- }, {
31
- [x: string]: any;
32
- productRef?: unknown;
33
- config?: unknown;
34
- }>;
35
- }, "strip", z.ZodTypeAny, {
36
- textToSpeech?: {
37
- [x: string]: any;
38
- productRef?: unknown;
39
- config?: unknown;
40
- };
41
- speechToText?: {
42
- [x: string]: any;
43
- productRef?: unknown;
44
- config?: unknown;
45
- };
46
- name?: string;
47
- type?: "EXTERNAL";
48
- endpoint?: string;
49
- }, {
50
- textToSpeech?: {
51
- [x: string]: any;
52
- productRef?: unknown;
53
- config?: unknown;
54
- };
55
- speechToText?: {
56
- [x: string]: any;
57
- productRef?: unknown;
58
- config?: unknown;
59
- };
60
- name?: string;
61
- type?: "EXTERNAL";
62
- endpoint?: string;
63
- }>;
64
- export { getApplicationValidationSchema };
@@ -1,6 +0,0 @@
1
- import { Prisma } from "../core/db";
2
- declare function makeCheckNumberPreconditions(prisma: Prisma): ({ appRef, accessKeyId }: {
3
- appRef: any;
4
- accessKeyId: any;
5
- }) => Promise<void>;
6
- export { makeCheckNumberPreconditions };
@@ -1,5 +0,0 @@
1
- import { NatsConnection } from "nats";
2
- declare function makeHandleDialEventsWithNats(nc: NatsConnection): (callRef: string, event: {
3
- dialstatus: string;
4
- }) => Promise<void>;
5
- export { makeHandleDialEventsWithNats };
@@ -1,5 +0,0 @@
1
- import { VoiceClient } from "../voice/types";
2
- declare function makeHandleDialEventsWithVoiceClient(voiceClient: VoiceClient): (event: {
3
- dialstatus: string;
4
- }) => Promise<void>;
5
- export { makeHandleDialEventsWithVoiceClient };
@@ -1,5 +0,0 @@
1
- import { VerbRequest } from "@fonoster/common";
2
- import { Client } from "ari-client";
3
- import { VoiceClient } from "../types";
4
- declare function answerHandler(ari: Client, voiceClient: VoiceClient): (request: VerbRequest) => Promise<void>;
5
- export { answerHandler };
@@ -1,5 +0,0 @@
1
- import { VerbRequest } from "@fonoster/common";
2
- import { Client } from "ari-client";
3
- import { VoiceClient } from "../types";
4
- declare function hangupHandler(ari: Client, voiceClient: VoiceClient): (request: VerbRequest) => Promise<void>;
5
- export { hangupHandler };
@@ -1,4 +0,0 @@
1
- import { Client } from "ari-client";
2
- import { VoiceClient } from "../types";
3
- declare function muteHandler(ari: Client, voiceClient: VoiceClient): (request: import("@fonoster/common").VerbRequest) => Promise<void>;
4
- export { muteHandler };
@@ -1,4 +0,0 @@
1
- import { Client } from "ari-client";
2
- import { VoiceClient } from "../types";
3
- declare function playHandler(ari: Client, voiceClient: VoiceClient): (request: import("@fonoster/common").VerbRequest) => Promise<void>;
4
- export { playHandler };
@@ -1,4 +0,0 @@
1
- import { Client } from "ari-client";
2
- import { VoiceClient } from "../types";
3
- declare function playDtmfHandler(ari: Client, voiceClient: VoiceClient): (request: import("@fonoster/common").VerbRequest) => Promise<void>;
4
- export { playDtmfHandler };
@@ -1,4 +0,0 @@
1
- import { Client } from "ari-client";
2
- import { VoiceClient } from "../types";
3
- declare function playbackControlHandler(ari: Client, voiceClient: VoiceClient): (request: import("@fonoster/common").VerbRequest) => Promise<void>;
4
- export { playbackControlHandler };
@@ -1,4 +0,0 @@
1
- import { Client } from "ari-client";
2
- import { VoiceClient } from "../types";
3
- declare function recordHandler(ari: Client, voiceClient: VoiceClient): (request: import("@fonoster/common").VerbRequest) => Promise<void>;
4
- export { recordHandler };
@@ -1,4 +0,0 @@
1
- import { Client } from "ari-client";
2
- import { VoiceClient } from "../types";
3
- declare function sayHandler(ari: Client, voiceClient: VoiceClient): (request: import("@fonoster/common").VerbRequest) => Promise<void>;
4
- export { sayHandler };
@@ -1,3 +0,0 @@
1
- import { VoiceClient } from "../types";
2
- declare function streamHandler(voiceClient: VoiceClient): (request: import("@fonoster/common").VerbRequest) => Promise<void>;
3
- export { streamHandler };
@@ -1,4 +0,0 @@
1
- import { Client } from "ari-client";
2
- import { VoiceClient } from "../types";
3
- declare function unmuteHandler(ari: Client, voiceClient: VoiceClient): (request: import("@fonoster/common").VerbRequest) => Promise<void>;
4
- export { unmuteHandler };
@@ -1,5 +0,0 @@
1
- import { DialRequest } from "@fonoster/common";
2
- import { Client } from "ari-client";
3
- import { VoiceClient } from "../../types";
4
- declare function dialHandler(ari: Client, voiceClient: VoiceClient): (request: DialRequest) => Promise<void>;
5
- export { dialHandler };
@@ -1,76 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.dialHandler = dialHandler;
13
- /*
14
- * Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
15
- * http://github.com/fonoster/fonoster
16
- *
17
- * This file is part of Fonoster
18
- *
19
- * Licensed under the MIT License (the "License");
20
- * you may not use this file except in compliance with
21
- * the License. You may obtain a copy of the License at
22
- *
23
- * https://opensource.org/licenses/MIT
24
- *
25
- * Unless required by applicable law or agreed to in writing, software
26
- * distributed under the License is distributed on an "AS IS" BASIS,
27
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
28
- * See the License for the specific language governing permissions and
29
- * limitations under the License.
30
- */
31
- const common_1 = require("@fonoster/common");
32
- const uuid_1 = require("uuid");
33
- const handleChannelLeftBridge_1 = require("./handleChannelLeftBridge");
34
- const handleStasisEnd_1 = require("./handleStasisEnd");
35
- const handleStasisStart_1 = require("./handleStasisStart");
36
- const envs_1 = require("../../../envs");
37
- const utils_1 = require("../../../utils");
38
- const types_1 = require("../../types");
39
- const makeGetChannelVar_1 = require("../../utils/makeGetChannelVar");
40
- // TODO: Needs request validation
41
- function dialHandler(ari, voiceClient) {
42
- return (request) => __awaiter(this, void 0, void 0, function* () {
43
- const { sessionRef: channelId, destination, timeout } = request;
44
- const bridge = yield ari.bridges.create({
45
- type: "mixing"
46
- });
47
- // eslint-disable-next-line new-cap
48
- const dialed = ari.Channel();
49
- yield bridge.addChannel({ channel: channelId });
50
- const callerChannel = yield ari.channels.get({ channelId });
51
- const getChannelVar = (0, makeGetChannelVar_1.makeGetChannelVar)(callerChannel);
52
- const ingressNumber = (yield getChannelVar(types_1.ChannelVar.INGRESS_NUMBER))
53
- .value;
54
- const ref = (0, uuid_1.v4)();
55
- yield dialed.originate({
56
- app: common_1.STASIS_APP_NAME,
57
- endpoint: `PJSIP/${envs_1.ASTERISK_TRUNK}/sip:${destination}@${envs_1.ASTERISK_SYSTEM_DOMAIN}`,
58
- timeout,
59
- variables: {
60
- "PJSIP_HEADER(add,X-Call-Ref)": ref,
61
- "PJSIP_HEADER(add,X-Dod-Number)": ingressNumber,
62
- "PJSIP_HEADER(add,X-Is-Api-Originated-Type)": "true"
63
- }
64
- });
65
- yield ari.channels.ring({ channelId });
66
- dialed.once(types_1.AriEvent.STASIS_START, (0, handleStasisStart_1.handleStasisStart)({ ari, request, bridge, dialed }));
67
- dialed.once(types_1.AriEvent.CHANNEL_LEFT_BRIDGE, (0, handleChannelLeftBridge_1.handleChannelLeftBridge)({ bridge, dialed }));
68
- dialed.once(types_1.AriEvent.STASIS_END, (0, handleStasisEnd_1.handleStasisEnd)(request));
69
- dialed.on(types_1.AriEvent.DIAL, (0, utils_1.makeHandleDialEventsWithVoiceClient)(voiceClient));
70
- voiceClient.sendResponse({
71
- dialResponse: {
72
- status: common_1.DialStatus.TRYING
73
- }
74
- });
75
- });
76
- }
@@ -1,3 +0,0 @@
1
- import { VoiceClient } from "../../types";
2
- declare function gatherHandler(voiceClient: VoiceClient): (request: import("@fonoster/common").VerbRequest) => Promise<void>;
3
- export { gatherHandler };
@@ -1,3 +0,0 @@
1
- import { IntegrationConfig } from "./types";
2
- declare function findIntegrationsCredentials(integrations: IntegrationConfig[], engine: string): Record<string, unknown>;
3
- export { findIntegrationsCredentials };
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.findIntegrationsCredentials = findIntegrationsCredentials;
4
- function findIntegrationsCredentials(integrations, engine) {
5
- var _a;
6
- return (_a = integrations.find((i) => i.productRef === engine)) === null || _a === void 0 ? void 0 : _a.credentials;
7
- }
@@ -1,4 +0,0 @@
1
- import { IntegrationsContainer } from "./types";
2
- import { Prisma } from "../../core/db";
3
- declare function makeCreateContainer(prisma: Prisma, pathToIntegrations: string): (appRef: string) => Promise<IntegrationsContainer>;
4
- export { makeCreateContainer };