@fonoster/apiserver 0.27.0 → 0.31.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 (376) hide show
  1. package/dist/applications/buildService.d.ts +5 -1
  2. package/dist/applications/buildService.js +10 -7
  3. package/dist/applications/createCreateApplication.d.ts +6 -2
  4. package/dist/applications/createCreateApplication.js +24 -16
  5. package/dist/applications/createCreateTestToken.d.ts +3 -1
  6. package/dist/applications/createCreateTestToken.js +18 -13
  7. package/dist/applications/createGetApplication.js +2 -2
  8. package/dist/applications/createGetFnUtil.d.ts +22 -18
  9. package/dist/applications/createGetFnUtil.js +3 -5
  10. package/dist/applications/createListApplications.js +3 -4
  11. package/dist/applications/createRotateSigningSecret.d.ts +9 -0
  12. package/dist/{calls/createFetchSingleCall.js → applications/createRotateSigningSecret.js} +23 -20
  13. package/dist/applications/createUpdateApplication.d.ts +6 -2
  14. package/dist/applications/createUpdateApplication.js +35 -36
  15. package/dist/applications/evalKeys.d.ts +9 -0
  16. package/dist/{voice/handlers/dial/recordChannel.js → applications/evalKeys.js} +17 -12
  17. package/dist/applications/session/appModel.d.ts +225 -0
  18. package/dist/applications/session/appModel.js +331 -0
  19. package/dist/applications/types.d.ts +1 -27
  20. package/dist/billing/buildService.d.ts +24 -0
  21. package/dist/billing/buildService.js +116 -0
  22. package/dist/bin/entrypoint.d.ts +1 -0
  23. package/dist/bin/entrypoint.js +180 -0
  24. package/dist/bin/healthcheck.d.ts +2 -0
  25. package/dist/{voice/utils/VoiceServiceClientConstructor.js → bin/healthcheck.js} +24 -9
  26. package/dist/bin/regionHubSetup.d.ts +2 -0
  27. package/dist/bin/regionHubSetup.js +67 -0
  28. package/dist/bin/usage.d.ts +2 -0
  29. package/dist/bin/usage.js +119 -0
  30. package/dist/calls/buildService.d.ts +1 -20
  31. package/dist/calls/buildService.js +59 -6
  32. package/dist/calls/createCall.d.ts +17 -2
  33. package/dist/calls/createCall.js +64 -11
  34. package/dist/calls/createCallPublisher.d.ts +40 -2
  35. package/dist/calls/createCallPublisher.js +43 -9
  36. package/dist/calls/createIsWorkspaceNumber.d.ts +41 -0
  37. package/dist/calls/createIsWorkspaceNumber.js +39 -0
  38. package/dist/calls/createTrackCall.d.ts +55 -2
  39. package/dist/calls/createTrackCall.js +230 -16
  40. package/dist/calls/getCall.d.ts +4 -2
  41. package/dist/calls/getCall.js +2 -3
  42. package/dist/calls/listCalls.d.ts +4 -2
  43. package/dist/calls/listCalls.js +2 -3
  44. package/dist/calls/types.d.ts +11 -2
  45. package/dist/calls/types.js +10 -0
  46. package/dist/{core/buildWelcomeDemoService.d.ts → capabilities/buildService.d.ts} +8 -8
  47. package/dist/capabilities/buildService.js +17 -0
  48. package/dist/capabilities/createGetCapabilities.d.ts +78 -0
  49. package/dist/capabilities/createGetCapabilities.js +98 -0
  50. package/dist/{voice/handlers/utils → capabilities}/index.d.ts +2 -3
  51. package/dist/{voice/handlers/utils → capabilities}/index.js +4 -3
  52. package/dist/config/index.d.ts +23 -0
  53. package/dist/config/index.js +102 -0
  54. package/dist/config/schema.d.ts +1919 -0
  55. package/dist/config/schema.js +357 -0
  56. package/dist/core/allowList.js +2 -1
  57. package/dist/core/applyCatalog.d.ts +10 -0
  58. package/dist/{voice/client/GrpcClientHandler.js → core/applyCatalog.js} +45 -51
  59. package/dist/core/db.d.ts +3 -1
  60. package/dist/core/db.js +2 -1
  61. package/dist/core/durableConsumer.d.ts +41 -0
  62. package/dist/core/durableConsumer.js +104 -0
  63. package/dist/core/httpBridge.d.ts +24 -6
  64. package/dist/core/httpBridge.js +3 -25
  65. package/dist/core/identityConfig.d.ts +2 -35
  66. package/dist/core/identityConfig.js +3 -36
  67. package/dist/core/regionHooks.d.ts +15 -0
  68. package/dist/{calls/influxdb.js → core/regionHooks.js} +4 -8
  69. package/dist/core/runServices.js +98 -15
  70. package/dist/core/services.d.ts +96 -6
  71. package/dist/core/services.js +49 -10
  72. package/dist/{voice/errors/index.d.ts → core/telemetry.d.ts} +2 -2
  73. package/dist/core/telemetry.js +42 -0
  74. package/dist/{applications/utils/convertToApplicationData.d.ts → core/telemetryInterceptor.d.ts} +10 -4
  75. package/dist/core/telemetryInterceptor.js +57 -0
  76. package/dist/core/testTokenConfig.js +4 -1
  77. package/dist/core/upsertRoomrPeer.d.ts +6 -0
  78. package/dist/core/{upsertDefaultPeer.js → upsertRoomrPeer.js} +31 -30
  79. package/dist/envs.d.ts +136 -23
  80. package/dist/envs.js +108 -143
  81. package/dist/index.js +39 -21
  82. package/dist/outbound/createNodeDirectory.d.ts +86 -0
  83. package/dist/outbound/createNodeDirectory.js +140 -0
  84. package/dist/{voice/integrations → outbound}/index.d.ts +4 -1
  85. package/dist/{voice/errors → outbound}/index.js +4 -2
  86. package/dist/outbound/placeOutboundCall.d.ts +96 -0
  87. package/dist/outbound/placeOutboundCall.js +172 -0
  88. package/dist/outbound/placementSweep.d.ts +56 -0
  89. package/dist/outbound/placementSweep.js +127 -0
  90. package/dist/outbound/runOutboundCalls.d.ts +52 -0
  91. package/dist/outbound/runOutboundCalls.js +171 -0
  92. package/dist/providers/createProvidersHandlers.d.ts +39 -0
  93. package/dist/providers/createProvidersHandlers.js +229 -0
  94. package/dist/providers/index.d.ts +47 -0
  95. package/dist/{voice/client → providers}/index.js +15 -6
  96. package/dist/providers/registryUsage.d.ts +48 -0
  97. package/dist/providers/registryUsage.js +236 -0
  98. package/dist/records/createIndexRecord.d.ts +42 -0
  99. package/dist/records/createIndexRecord.js +185 -0
  100. package/dist/records/createRecordsRouter.d.ts +61 -0
  101. package/dist/records/createRecordsRouter.js +330 -0
  102. package/dist/records/createSearchRecords.d.ts +51 -0
  103. package/dist/records/createSearchRecords.js +134 -0
  104. package/dist/{voice/filters → records}/index.d.ts +6 -6
  105. package/dist/{voice/filters → records}/index.js +6 -6
  106. package/dist/records/maintenance.d.ts +33 -0
  107. package/dist/records/maintenance.js +166 -0
  108. package/dist/records/runCallRecords.d.ts +48 -0
  109. package/dist/records/runCallRecords.js +49 -0
  110. package/dist/{events/createPerCallCache.d.ts → records/stores.d.ts} +4 -7
  111. package/dist/{voice/handlers/utils/isDtmf.js → records/stores.js} +9 -3
  112. package/dist/records/types.d.ts +104 -0
  113. package/dist/regions/configSync.d.ts +130 -0
  114. package/dist/regions/configSync.js +316 -0
  115. package/dist/regions/createRegionsRouter.d.ts +151 -0
  116. package/dist/regions/createRegionsRouter.js +391 -0
  117. package/dist/regions/endpoints.d.ts +41 -0
  118. package/dist/regions/endpoints.js +90 -0
  119. package/dist/regions/enrollmentToken.d.ts +41 -0
  120. package/dist/regions/enrollmentToken.js +94 -0
  121. package/dist/regions/httpAuth.d.ts +39 -0
  122. package/dist/regions/httpAuth.js +78 -0
  123. package/dist/regions/ids.d.ts +15 -0
  124. package/dist/regions/ids.js +81 -0
  125. package/dist/{voice/client → regions}/index.d.ts +17 -6
  126. package/dist/regions/index.js +51 -0
  127. package/dist/regions/link.d.ts +17 -0
  128. package/dist/regions/link.js +170 -0
  129. package/dist/regions/natsAuth.d.ts +41 -0
  130. package/dist/regions/natsAuth.js +64 -0
  131. package/dist/regions/natsJwt.d.ts +23 -0
  132. package/dist/regions/natsJwt.js +26 -0
  133. package/dist/regions/relay.d.ts +45 -0
  134. package/dist/regions/relay.js +203 -0
  135. package/dist/regions/relayHttp.d.ts +7 -0
  136. package/dist/regions/relayHttp.js +107 -0
  137. package/dist/regions/relaySlots.d.ts +18 -0
  138. package/dist/regions/relaySlots.js +118 -0
  139. package/dist/regions/runRegions.d.ts +111 -0
  140. package/dist/regions/runRegions.js +235 -0
  141. package/dist/regions/service.d.ts +129 -0
  142. package/dist/regions/service.js +558 -0
  143. package/dist/regions/sources.d.ts +20 -0
  144. package/dist/regions/sources.js +191 -0
  145. package/dist/regions/status.d.ts +35 -0
  146. package/dist/regions/status.js +63 -0
  147. package/dist/regions/types.d.ts +123 -0
  148. package/dist/regions/types.js +41 -0
  149. package/dist/{voice/integrations/getSttConfig.d.ts → regions/withConfigChangeHook.d.ts} +13 -7
  150. package/dist/regions/withConfigChangeHook.js +44 -0
  151. package/dist/secrets/createGetFnUtil.d.ts +2 -2
  152. package/dist/session/createSessionRouter.d.ts +49 -0
  153. package/dist/session/createSessionRouter.js +206 -0
  154. package/dist/{voice/handlers/dial → session}/index.d.ts +1 -1
  155. package/dist/{voice/handlers/dial → session}/index.js +1 -1
  156. package/dist/usage/buildService.d.ts +16 -0
  157. package/dist/{voice/integrations/getTtsConfig.js → usage/buildService.js} +13 -7
  158. package/dist/{voice/tts/utils/convertUlawToPCM16.d.ts → usage/createGetUsage.d.ts} +7 -6
  159. package/dist/usage/createGetUsage.js +118 -0
  160. package/dist/usage/ingestUsage.d.ts +7 -0
  161. package/dist/usage/ingestUsage.js +87 -0
  162. package/dist/usage/publishRecordedUsage.d.ts +52 -0
  163. package/dist/usage/publishRecordedUsage.js +103 -0
  164. package/dist/{utils/createHandleDialEventsWithNats.d.ts → usage/publishUsage.d.ts} +10 -4
  165. package/dist/usage/publishUsage.js +50 -0
  166. package/dist/usage/rebuildUsage.d.ts +48 -0
  167. package/dist/usage/rebuildUsage.js +104 -0
  168. package/dist/usage/runUsageConsumer.d.ts +22 -0
  169. package/dist/usage/runUsageConsumer.js +78 -0
  170. package/dist/usage/snapshotStorage.d.ts +14 -0
  171. package/dist/usage/snapshotStorage.js +95 -0
  172. package/dist/{voice/integrations/getTtsConfig.d.ts → usage/types.d.ts} +17 -6
  173. package/dist/utils/createCheckNumberPreconditions.js +4 -0
  174. package/dist/utils/index.d.ts +0 -2
  175. package/dist/utils/index.js +0 -2
  176. package/dist/voice/stt/Deepgram.d.ts +4 -57
  177. package/dist/voice/stt/Deepgram.js +15 -286
  178. package/dist/voice/stt/Google.d.ts +4 -15
  179. package/dist/voice/stt/Google.js +7 -103
  180. package/dist/voice/stt/types.d.ts +2 -38
  181. package/dist/voice/stt/types.js +25 -3
  182. package/dist/voice/tts/Azure.d.ts +4 -34
  183. package/dist/voice/tts/Azure.js +25 -105
  184. package/dist/voice/tts/Deepgram.d.ts +4 -38
  185. package/dist/voice/tts/Deepgram.js +25 -82
  186. package/dist/voice/tts/ElevenLabs.d.ts +4 -18
  187. package/dist/voice/tts/ElevenLabs.js +6 -97
  188. package/dist/voice/tts/Google.d.ts +4 -38
  189. package/dist/voice/tts/Google.js +25 -91
  190. package/dist/webhooks/createWebhooksHandlers.d.ts +37 -0
  191. package/dist/webhooks/createWebhooksHandlers.js +217 -0
  192. package/dist/webhooks/index.d.ts +37 -0
  193. package/dist/webhooks/index.js +51 -0
  194. package/dist/webhooks/lostCalls.d.ts +49 -0
  195. package/dist/webhooks/lostCalls.js +147 -0
  196. package/dist/webhooks/nodeCallEvents.d.ts +73 -0
  197. package/dist/webhooks/nodeCallEvents.js +177 -0
  198. package/dist/webhooks/runWebhookFanout.d.ts +44 -0
  199. package/dist/webhooks/runWebhookFanout.js +202 -0
  200. package/package.json +21 -31
  201. package/dist/applications/utils/applicationWithEncodedStruct.d.ts +0 -3
  202. package/dist/applications/utils/applicationWithEncodedStruct.js +0 -50
  203. package/dist/applications/utils/convertToApplicationData.js +0 -37
  204. package/dist/applications/validation/assistantWithoutApiKeySchema.d.ts +0 -786
  205. package/dist/applications/validation/assistantWithoutApiKeySchema.js +0 -35
  206. package/dist/applications/validation/createValidationSchema.d.ts +0 -1474
  207. package/dist/applications/validation/createValidationSchema.js +0 -67
  208. package/dist/applications/validation/prepareForValidation.d.ts +0 -21
  209. package/dist/applications/validation/prepareForValidation.js +0 -35
  210. package/dist/applications/validation/speechValidators.d.ts +0 -47
  211. package/dist/applications/validation/speechValidators.js +0 -50
  212. package/dist/applications/validation/validOrThrow.d.ts +0 -21
  213. package/dist/applications/validation/validOrThrow.js +0 -15
  214. package/dist/calls/createFetchCalls.d.ts +0 -22
  215. package/dist/calls/createFetchCalls.js +0 -88
  216. package/dist/calls/createFetchSingleCall.d.ts +0 -22
  217. package/dist/calls/influxdb.d.ts +0 -2
  218. package/dist/calls/runCallManager.d.ts +0 -8
  219. package/dist/calls/runCallManager.js +0 -75
  220. package/dist/core/buildWelcomeDemoService.js +0 -97
  221. package/dist/core/upsertDefaultPeer.d.ts +0 -2
  222. package/dist/events/amdResultCache.d.ts +0 -23
  223. package/dist/events/amdResultCache.js +0 -35
  224. package/dist/events/createInfluxDbPub.d.ts +0 -13
  225. package/dist/events/createInfluxDbPub.js +0 -89
  226. package/dist/events/createPerCallCache.js +0 -46
  227. package/dist/events/mapCallDirectionToEnum.d.ts +0 -21
  228. package/dist/events/mapCallDirectionToEnum.js +0 -37
  229. package/dist/events/nats.d.ts +0 -10
  230. package/dist/events/nats.js +0 -82
  231. package/dist/events/transformEvent.d.ts +0 -2
  232. package/dist/events/transformEvent.js +0 -87
  233. package/dist/events/types.d.ts +0 -26
  234. package/dist/utils/createHandleDialEventsWithNats.js +0 -24
  235. package/dist/utils/createHandleDialEventsWithVoiceClient.d.ts +0 -23
  236. package/dist/utils/createHandleDialEventsWithVoiceClient.js +0 -27
  237. package/dist/utils/getIntegrationsFromFile.d.ts +0 -2
  238. package/dist/utils/getIntegrationsFromFile.js +0 -49
  239. package/dist/utils/mapDialStatus.d.ts +0 -21
  240. package/dist/utils/mapDialStatus.js +0 -38
  241. package/dist/voice/VoiceDispatcher.d.ts +0 -21
  242. package/dist/voice/VoiceDispatcher.js +0 -122
  243. package/dist/voice/amd/mapAsteriskAmd.d.ts +0 -38
  244. package/dist/voice/amd/mapAsteriskAmd.js +0 -68
  245. package/dist/voice/client/AudioSocketHandler.d.ts +0 -38
  246. package/dist/voice/client/AudioSocketHandler.js +0 -70
  247. package/dist/voice/client/AuthorizationHandler.d.ts +0 -13
  248. package/dist/voice/client/AuthorizationHandler.js +0 -78
  249. package/dist/voice/client/ExternalMediaHandler.d.ts +0 -32
  250. package/dist/voice/client/ExternalMediaHandler.js +0 -59
  251. package/dist/voice/client/GrpcClientHandler.d.ts +0 -36
  252. package/dist/voice/client/SpeechHandler.d.ts +0 -60
  253. package/dist/voice/client/SpeechHandler.js +0 -120
  254. package/dist/voice/client/VoiceClientImpl.d.ts +0 -79
  255. package/dist/voice/client/VoiceClientImpl.js +0 -198
  256. package/dist/voice/connectToAri.d.ts +0 -2
  257. package/dist/voice/connectToAri.js +0 -81
  258. package/dist/voice/createCreateVoiceClient.d.ts +0 -9
  259. package/dist/voice/createCreateVoiceClient.js +0 -97
  260. package/dist/voice/errors/ChannelVarNotFoundError.d.ts +0 -23
  261. package/dist/voice/errors/ChannelVarNotFoundError.js +0 -10
  262. package/dist/voice/errors/MethodNotImplementedError.d.ts +0 -22
  263. package/dist/voice/errors/MethodNotImplementedError.js +0 -27
  264. package/dist/voice/filters/AudioFilterFactory.d.ts +0 -35
  265. package/dist/voice/filters/AudioFilterFactory.js +0 -94
  266. package/dist/voice/filters/aiCoustics/createAiCousticsFilter.d.ts +0 -64
  267. package/dist/voice/filters/aiCoustics/createAiCousticsFilter.js +0 -252
  268. package/dist/voice/filters/aiCoustics/types.d.ts +0 -45
  269. package/dist/voice/filters/aiCoustics/types.js +0 -29
  270. package/dist/voice/filters/createAudioFilterChain.d.ts +0 -9
  271. package/dist/voice/filters/createAudioFilterChain.js +0 -171
  272. package/dist/voice/filters/createAudioFilterSession.d.ts +0 -15
  273. package/dist/voice/filters/createAudioFilterSession.js +0 -114
  274. package/dist/voice/filters/pcm.d.ts +0 -21
  275. package/dist/voice/filters/pcm.js +0 -37
  276. package/dist/voice/filters/types.d.ts +0 -61
  277. package/dist/voice/filters/types.js +0 -26
  278. package/dist/voice/handlers/createAnswerHandler.d.ts +0 -23
  279. package/dist/voice/handlers/createAnswerHandler.js +0 -24
  280. package/dist/voice/handlers/createHangupHandler.d.ts +0 -23
  281. package/dist/voice/handlers/createHangupHandler.js +0 -28
  282. package/dist/voice/handlers/createMuteHandler.d.ts +0 -4
  283. package/dist/voice/handlers/createMuteHandler.js +0 -27
  284. package/dist/voice/handlers/createPlayDtmfHandler.d.ts +0 -4
  285. package/dist/voice/handlers/createPlayDtmfHandler.js +0 -27
  286. package/dist/voice/handlers/createPlayHandler.d.ts +0 -4
  287. package/dist/voice/handlers/createPlayHandler.js +0 -33
  288. package/dist/voice/handlers/createPlaybackControlHandler.d.ts +0 -4
  289. package/dist/voice/handlers/createPlaybackControlHandler.js +0 -62
  290. package/dist/voice/handlers/createRecordHandler.d.ts +0 -4
  291. package/dist/voice/handlers/createRecordHandler.js +0 -58
  292. package/dist/voice/handlers/createSayHandler.d.ts +0 -4
  293. package/dist/voice/handlers/createSayHandler.js +0 -31
  294. package/dist/voice/handlers/createSetAudioFiltersHandler.d.ts +0 -11
  295. package/dist/voice/handlers/createSetAudioFiltersHandler.js +0 -74
  296. package/dist/voice/handlers/createStopSayHandler.d.ts +0 -3
  297. package/dist/voice/handlers/createStopSayHandler.js +0 -34
  298. package/dist/voice/handlers/createStreamGatherHandler.d.ts +0 -3
  299. package/dist/voice/handlers/createStreamGatherHandler.js +0 -74
  300. package/dist/voice/handlers/createStreamHandler.d.ts +0 -3
  301. package/dist/voice/handlers/createStreamHandler.js +0 -70
  302. package/dist/voice/handlers/createUnmuteHandler.d.ts +0 -4
  303. package/dist/voice/handlers/createUnmuteHandler.js +0 -27
  304. package/dist/voice/handlers/dial/createDialHandler.d.ts +0 -23
  305. package/dist/voice/handlers/dial/createDialHandler.js +0 -78
  306. package/dist/voice/handlers/dial/handleChannelLeftBridge.d.ts +0 -24
  307. package/dist/voice/handlers/dial/handleChannelLeftBridge.js +0 -29
  308. package/dist/voice/handlers/dial/handleStasisEnd.d.ts +0 -21
  309. package/dist/voice/handlers/dial/handleStasisEnd.js +0 -19
  310. package/dist/voice/handlers/dial/handleStasisStart.d.ts +0 -27
  311. package/dist/voice/handlers/dial/handleStasisStart.js +0 -52
  312. package/dist/voice/handlers/dial/recordChannel.d.ts +0 -22
  313. package/dist/voice/handlers/gather/createGatherHandler.d.ts +0 -3
  314. package/dist/voice/handlers/gather/createGatherHandler.js +0 -86
  315. package/dist/voice/handlers/gather/getTimeoutPromise.d.ts +0 -26
  316. package/dist/voice/handlers/gather/getTimeoutPromise.js +0 -18
  317. package/dist/voice/handlers/index.d.ts +0 -33
  318. package/dist/voice/handlers/index.js +0 -49
  319. package/dist/voice/handlers/utils/awaitForPlaybackFinished.d.ts +0 -21
  320. package/dist/voice/handlers/utils/awaitForPlaybackFinished.js +0 -25
  321. package/dist/voice/handlers/utils/awaitForRecordingFinished.d.ts +0 -5
  322. package/dist/voice/handlers/utils/awaitForRecordingFinished.js +0 -53
  323. package/dist/voice/handlers/utils/isDtmf.d.ts +0 -20
  324. package/dist/voice/handlers/utils/textChunksByClause.d.ts +0 -2
  325. package/dist/voice/handlers/utils/textChunksByClause.js +0 -41
  326. package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.d.ts +0 -2
  327. package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.js +0 -34
  328. package/dist/voice/handlers/utils/withErrorHandling.d.ts +0 -22
  329. package/dist/voice/handlers/utils/withErrorHandling.js +0 -38
  330. package/dist/voice/integrations/ApplicationNotFoundError.d.ts +0 -22
  331. package/dist/voice/integrations/ApplicationNotFoundError.js +0 -28
  332. package/dist/voice/integrations/createCreateContainer.d.ts +0 -4
  333. package/dist/voice/integrations/createCreateContainer.js +0 -76
  334. package/dist/voice/integrations/getSttConfig.js +0 -30
  335. package/dist/voice/integrations/index.js +0 -35
  336. package/dist/voice/integrations/types.d.ts +0 -29
  337. package/dist/voice/stt/AbstractSpeechToText.d.ts +0 -33
  338. package/dist/voice/stt/AbstractSpeechToText.js +0 -19
  339. package/dist/voice/stt/SpeechToTextFactory.d.ts +0 -9
  340. package/dist/voice/stt/SpeechToTextFactory.js +0 -43
  341. package/dist/voice/transcribeOnConnection.d.ts +0 -35
  342. package/dist/voice/transcribeOnConnection.js +0 -91
  343. package/dist/voice/tts/AbstractTextToSpeech.d.ts +0 -40
  344. package/dist/voice/tts/AbstractTextToSpeech.js +0 -50
  345. package/dist/voice/tts/TextToSpeechFactory.d.ts +0 -8
  346. package/dist/voice/tts/TextToSpeechFactory.js +0 -47
  347. package/dist/voice/tts/types.d.ts +0 -48
  348. package/dist/voice/tts/types.js +0 -2
  349. package/dist/voice/tts/utils/convertUlawToPCM16.js +0 -40
  350. package/dist/voice/tts/utils/createChunkedSynthesisStream.d.ts +0 -28
  351. package/dist/voice/tts/utils/createChunkedSynthesisStream.js +0 -78
  352. package/dist/voice/tts/utils/createErrorStream.d.ts +0 -21
  353. package/dist/voice/tts/utils/createErrorStream.js +0 -28
  354. package/dist/voice/tts/utils/index.d.ts +0 -23
  355. package/dist/voice/tts/utils/index.js +0 -39
  356. package/dist/voice/tts/utils/isSsml.d.ts +0 -20
  357. package/dist/voice/tts/utils/isSsml.js +0 -25
  358. package/dist/voice/tts/utils/streamToBuffer.d.ts +0 -20
  359. package/dist/voice/tts/utils/streamToBuffer.js +0 -60
  360. package/dist/voice/types/ari.d.ts +0 -43
  361. package/dist/voice/types/ari.js +0 -48
  362. package/dist/voice/types/index.d.ts +0 -20
  363. package/dist/voice/types/index.js +0 -36
  364. package/dist/voice/types/voice.d.ts +0 -67
  365. package/dist/voice/types/voice.js +0 -2
  366. package/dist/voice/utils/VoiceServiceClientConstructor.d.ts +0 -3
  367. package/dist/voice/utils/createExternalMediaConfig.d.ts +0 -12
  368. package/dist/voice/utils/createExternalMediaConfig.js +0 -37
  369. package/dist/voice/utils/createGetChannelVar.d.ts +0 -22
  370. package/dist/voice/utils/createGetChannelVar.js +0 -27
  371. package/dist/voice/utils/createGetChannelVarWithoutThrow.d.ts +0 -22
  372. package/dist/voice/utils/createGetChannelVarWithoutThrow.js +0 -26
  373. package/dist/voice/utils/index.d.ts +0 -22
  374. package/dist/voice/utils/index.js +0 -38
  375. /package/dist/{events → records}/types.js +0 -0
  376. /package/dist/{voice/integrations → usage}/types.js +0 -0
@@ -1,67 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createValidationSchema = createValidationSchema;
4
- /**
5
- * Copyright (C) 2025 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");
23
- const client_1 = require("@prisma/client");
24
- const zod_1 = require("zod");
25
- const assistantWithoutApiKeySchema_1 = require("./assistantWithoutApiKeySchema");
26
- const speechValidators_1 = require("./speechValidators");
27
- const MAX_NAME_MESSAGE = "Name must contain at most 255 characters";
28
- function createValidationSchema(request) {
29
- const { applicationType, ttsEngineName, sttEngineName } = request;
30
- return zod_1.z.object({
31
- name: zod_1.z.string().max(255, MAX_NAME_MESSAGE),
32
- type: zod_1.z.nativeEnum(client_1.ApplicationType, {
33
- message: "Invalid application type"
34
- }),
35
- endpoint: common_1.hostOrHostPortSchema,
36
- textToSpeech: ttsEngineName
37
- ? zod_1.z.object({
38
- productRef: zod_1.z.string(),
39
- config: speechValidators_1.speechValidators.ttsConfigValidators[ttsEngineName]()
40
- })
41
- : zod_1.z.undefined(),
42
- speechToText: sttEngineName
43
- ? zod_1.z.object({
44
- productRef: zod_1.z.string(),
45
- config: speechValidators_1.speechValidators.sttConfigValidators[sttEngineName]()
46
- })
47
- : zod_1.z.undefined(),
48
- intelligence: applicationType === client_1.ApplicationType.AUTOPILOT
49
- ? zod_1.z
50
- .object({
51
- productRef: zod_1.z.string(),
52
- config: assistantWithoutApiKeySchema_1.assistantWithoutApiKeySchema
53
- })
54
- .superRefine((data, ctx) => {
55
- const vendor = data.productRef.split(".")[1];
56
- const languageModelProvider = data.config.languageModel.provider;
57
- if (vendor !== languageModelProvider) {
58
- ctx.addIssue({
59
- code: zod_1.z.ZodIssueCode.custom,
60
- message: `intelligence.productRef (${data.productRef}) must match languageModel.provider (${languageModelProvider}).`,
61
- path: ["productRef"]
62
- });
63
- }
64
- })
65
- : zod_1.z.undefined()
66
- });
67
- }
@@ -1,21 +0,0 @@
1
- /**
2
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
- * http://github.com/fonoster/fonoster
4
- *
5
- * This file is part of Fonoster
6
- *
7
- * Licensed under the MIT License (the "License");
8
- * you may not use this file except in compliance with
9
- * the License. You may obtain a copy of the License at
10
- *
11
- * https://opensource.org/licenses/MIT
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- import { Application, CreateApplicationRequest, UpdateApplicationRequest } from "@fonoster/types";
20
- declare function prepareForValidation(request: CreateApplicationRequest | UpdateApplicationRequest): Application;
21
- export { prepareForValidation };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.prepareForValidation = prepareForValidation;
4
- const client_1 = require("@prisma/client");
5
- const pb_util_1 = require("pb-util");
6
- function prepareForValidation(request) {
7
- const type = request.type || client_1.ApplicationType.EXTERNAL;
8
- const result = {
9
- ref: request.ref, // Only for UpdateApplicationRequest
10
- name: request.name,
11
- type,
12
- endpoint: request.endpoint
13
- };
14
- const createProperty = (property) => {
15
- return property
16
- ? {
17
- productRef: property.productRef,
18
- credentials: property.credentials
19
- ? pb_util_1.struct.decode(property.credentials)
20
- : undefined,
21
- config: property.config ? pb_util_1.struct.decode(property.config) : null
22
- }
23
- : undefined;
24
- };
25
- if (request.textToSpeech) {
26
- result.textToSpeech = createProperty(request.textToSpeech);
27
- }
28
- if (request.speechToText) {
29
- result.speechToText = createProperty(request.speechToText);
30
- }
31
- if (request.intelligence) {
32
- result.intelligence = createProperty(request.intelligence);
33
- }
34
- return result;
35
- }
@@ -1,47 +0,0 @@
1
- /**
2
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
- * http://github.com/fonoster/fonoster
4
- *
5
- * This file is part of Fonoster
6
- *
7
- * Licensed under the MIT License (the "License");
8
- * you may not use this file except in compliance with
9
- * the License. You may obtain a copy of the License at
10
- *
11
- * https://opensource.org/licenses/MIT
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- import { Deepgram as DeepgramStt } from "../../voice/stt/Deepgram";
20
- import { Google as GoogleStt } from "../../voice/stt/Google";
21
- import { Azure as AzureTts } from "../../voice/tts/Azure";
22
- import { Deepgram as DeepgramTts } from "../../voice/tts/Deepgram";
23
- import { ElevenLabs as ElevenLabsTts } from "../../voice/tts/ElevenLabs";
24
- import { Google as GoogleTts } from "../../voice/tts/Google";
25
- declare const speechValidators: {
26
- ttsConfigValidators: {
27
- "tts.google": typeof GoogleTts.getConfigValidationSchema;
28
- "tts.azure": typeof AzureTts.getConfigValidationSchema;
29
- "tts.deepgram": typeof DeepgramTts.getConfigValidationSchema;
30
- "tts.elevenlabs": typeof ElevenLabsTts.getConfigValidationSchema;
31
- };
32
- ttsCredentialsValidators: {
33
- "tts.google": typeof GoogleTts.getCredentialsValidationSchema;
34
- "tts.azure": typeof AzureTts.getCredentialsValidationSchema;
35
- "tts.deepgram": typeof DeepgramTts.getCredentialsValidationSchema;
36
- "tts.elevenlabs": typeof ElevenLabsTts.getCredentialsValidationSchema;
37
- };
38
- sttConfigValidators: {
39
- "stt.google": typeof GoogleStt.getConfigValidationSchema;
40
- "stt.deepgram": typeof DeepgramStt.getConfigValidationSchema;
41
- };
42
- sttCredentialsValidators: {
43
- "stt.google": typeof GoogleStt.getCredentialsValidationSchema;
44
- "stt.deepgram": typeof DeepgramStt.getCredentialsValidationSchema;
45
- };
46
- };
47
- export { speechValidators };
@@ -1,50 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.speechValidators = void 0;
4
- /**
5
- * Copyright (C) 2025 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 Deepgram_1 = require("../../voice/stt/Deepgram");
23
- const Google_1 = require("../../voice/stt/Google");
24
- const Azure_1 = require("../../voice/tts/Azure");
25
- const Deepgram_2 = require("../../voice/tts/Deepgram");
26
- const ElevenLabs_1 = require("../../voice/tts/ElevenLabs");
27
- const Google_2 = require("../../voice/tts/Google");
28
- const speechValidators = {
29
- ttsConfigValidators: {
30
- "tts.google": Google_2.Google.getConfigValidationSchema,
31
- "tts.azure": Azure_1.Azure.getConfigValidationSchema,
32
- "tts.deepgram": Deepgram_2.Deepgram.getConfigValidationSchema,
33
- "tts.elevenlabs": ElevenLabs_1.ElevenLabs.getConfigValidationSchema
34
- },
35
- ttsCredentialsValidators: {
36
- "tts.google": Google_2.Google.getCredentialsValidationSchema,
37
- "tts.azure": Azure_1.Azure.getCredentialsValidationSchema,
38
- "tts.deepgram": Deepgram_2.Deepgram.getCredentialsValidationSchema,
39
- "tts.elevenlabs": ElevenLabs_1.ElevenLabs.getCredentialsValidationSchema
40
- },
41
- sttConfigValidators: {
42
- "stt.google": Google_1.Google.getConfigValidationSchema,
43
- "stt.deepgram": Deepgram_1.Deepgram.getConfigValidationSchema
44
- },
45
- sttCredentialsValidators: {
46
- "stt.google": Google_1.Google.getCredentialsValidationSchema,
47
- "stt.deepgram": Deepgram_1.Deepgram.getCredentialsValidationSchema
48
- }
49
- };
50
- exports.speechValidators = speechValidators;
@@ -1,21 +0,0 @@
1
- /**
2
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
- * http://github.com/fonoster/fonoster
4
- *
5
- * This file is part of Fonoster
6
- *
7
- * Licensed under the MIT License (the "License");
8
- * you may not use this file except in compliance with
9
- * the License. You may obtain a copy of the License at
10
- *
11
- * https://opensource.org/licenses/MIT
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- import { CreateApplicationRequest, UpdateApplicationRequest } from "@fonoster/types";
20
- declare function validOrThrow(request: CreateApplicationRequest | UpdateApplicationRequest): void;
21
- export { validOrThrow };
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.validOrThrow = validOrThrow;
4
- const createValidationSchema_1 = require("./createValidationSchema");
5
- const prepareForValidation_1 = require("./prepareForValidation");
6
- function validOrThrow(request) {
7
- var _a, _b;
8
- const data = (0, prepareForValidation_1.prepareForValidation)(request);
9
- const schema = (0, createValidationSchema_1.createValidationSchema)({
10
- applicationType: request.type,
11
- ttsEngineName: (_a = request.textToSpeech) === null || _a === void 0 ? void 0 : _a.productRef,
12
- sttEngineName: (_b = request.speechToText) === null || _b === void 0 ? void 0 : _b.productRef
13
- });
14
- schema.parse(data);
15
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
- * http://github.com/fonoster/fonoster
4
- *
5
- * This file is part of Fonoster
6
- *
7
- * Licensed under the MIT License (the "License");
8
- * you may not use this file except in compliance with
9
- * the License. You may obtain a copy of the License at
10
- *
11
- * https://opensource.org/licenses/MIT
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- import { InfluxDBClient } from "@fonoster/common";
20
- import { ListCallsRequest, ListCallsResponse } from "@fonoster/types";
21
- declare function createFetchCalls(influxdb: InfluxDBClient): (accessKeyId: string, request: ListCallsRequest) => Promise<ListCallsResponse>;
22
- export { createFetchCalls };
@@ -1,88 +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.createFetchCalls = createFetchCalls;
13
- /**
14
- * Copyright (C) 2025 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 logger_1 = require("@fonoster/logger");
33
- const influxdb_client_1 = require("@influxdata/influxdb-client");
34
- const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
35
- function createFetchCalls(influxdb) {
36
- return (accessKeyId, request) => __awaiter(this, void 0, void 0, function* () {
37
- const { after, before, type, from, to, status, pageSize, pageToken } = request;
38
- const accessKeyIdFilter = accessKeyId
39
- ? (0, influxdb_client_1.flux) `and r.accessKeyId == "${accessKeyId}"`
40
- : (0, influxdb_client_1.flux) ``;
41
- const typeFilter = type ? (0, influxdb_client_1.flux) `and r.type == "${type}"` : (0, influxdb_client_1.flux) ``;
42
- const fromFilter = from ? (0, influxdb_client_1.flux) `and r.from == "${from}"` : (0, influxdb_client_1.flux) ``;
43
- const toFilter = to ? (0, influxdb_client_1.flux) `and r.to == "${to}"` : (0, influxdb_client_1.flux) ``;
44
- const statusFilter = status ? (0, influxdb_client_1.flux) `and r.status == "${status}"` : (0, influxdb_client_1.flux) ``;
45
- const pageTokenFilter = pageToken
46
- ? (0, influxdb_client_1.flux) `|> filter(fn: (r) => r.startedAtParsed < int(v: ${pageToken}))`
47
- : (0, influxdb_client_1.flux) ``;
48
- const limit = (0, influxdb_client_1.flux) `|> limit(n: ${pageSize || 50})`;
49
- const parsedAfter = after
50
- ? Math.trunc(new Date(after).getTime() / 1000)
51
- : (0, influxdb_client_1.flux) `-30d`;
52
- const parsedBefore = before
53
- ? new Date(before).getTime() / 1000
54
- : new Date().getTime() / 1000;
55
- const query = (0, influxdb_client_1.flux) `from(bucket: "${common_1.INFLUXDB_CALLS_BUCKET}")
56
- |> range(start: ${parsedAfter})
57
- |> pivot(rowKey: ["callId"], columnKey: ["_field"], valueColumn: "_value")
58
- |> map(fn: (r) => ({
59
- r with
60
- duration: int(v: r.endedAt) - int(v: r.startedAt),
61
- startedAtParsed: int(v: r.startedAt) / 1000,
62
- }))
63
- |> filter(fn: (r) =>
64
- r._measurement == "${common_1.CALL_DETAIL_RECORD_MEASUREMENT}"
65
- and r.startedAtParsed < ${parsedBefore}
66
- ${accessKeyIdFilter}
67
- ${typeFilter}
68
- ${fromFilter}
69
- ${toFilter}
70
- ${statusFilter})
71
- |> group()
72
- |> sort(columns: ["startedAtParsed"], desc: true)
73
- ${pageTokenFilter}
74
- ${limit}`;
75
- logger.verbose("list calls request", {
76
- accessKeyId,
77
- after,
78
- before,
79
- query: query.toString()
80
- });
81
- const items = (yield influxdb.collectRows(query));
82
- const nextPageToken = items.length > 0 ? items[items.length - 1].startedAt : "";
83
- return {
84
- nextPageToken: nextPageToken + "",
85
- items
86
- };
87
- });
88
- }
@@ -1,22 +0,0 @@
1
- /**
2
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
3
- * http://github.com/fonoster/fonoster
4
- *
5
- * This file is part of Fonoster
6
- *
7
- * Licensed under the MIT License (the "License");
8
- * you may not use this file except in compliance with
9
- * the License. You may obtain a copy of the License at
10
- *
11
- * https://opensource.org/licenses/MIT
12
- *
13
- * Unless required by applicable law or agreed to in writing, software
14
- * distributed under the License is distributed on an "AS IS" BASIS,
15
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- * See the License for the specific language governing permissions and
17
- * limitations under the License.
18
- */
19
- import { InfluxDBClient } from "@fonoster/common";
20
- import { CallDetailRecord } from "@fonoster/types";
21
- declare function createFetchSingleCall(influxdb: InfluxDBClient): (accessKeyId: string, ref: string) => Promise<CallDetailRecord>;
22
- export { createFetchSingleCall };
@@ -1,2 +0,0 @@
1
- declare const influxdb: import("@influxdata/influxdb-client").QueryApi;
2
- export { influxdb };
@@ -1,8 +0,0 @@
1
- type CallManagerConfig = {
2
- natsUrl: string;
3
- ariProxyUrl: string;
4
- ariUsername: string;
5
- ariPassword: string;
6
- };
7
- declare function createCreateCallSubscriber(config: CallManagerConfig): Promise<void>;
8
- export { createCreateCallSubscriber };
@@ -1,75 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.createCreateCallSubscriber = createCreateCallSubscriber;
16
- /**
17
- * Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
18
- * http://github.com/fonoster/fonoster
19
- *
20
- * This file is part of Fonoster
21
- *
22
- * Licensed under the MIT License (the "License");
23
- * you may not use this file except in compliance with
24
- * the License. You may obtain a copy of the License at
25
- *
26
- * https://opensource.org/licenses/MIT
27
- *
28
- * Unless required by applicable law or agreed to in writing, software
29
- * distributed under the License is distributed on an "AS IS" BASIS,
30
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
31
- * See the License for the specific language governing permissions and
32
- * limitations under the License.
33
- */
34
- const common_1 = require("@fonoster/common");
35
- const logger_1 = require("@fonoster/logger");
36
- const ari_client_1 = __importDefault(require("ari-client"));
37
- const nats_1 = require("nats");
38
- const envs_1 = require("../envs");
39
- const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
40
- function createCreateCallSubscriber(config) {
41
- return __awaiter(this, void 0, void 0, function* () {
42
- const { natsUrl, ariProxyUrl, ariUsername, ariPassword } = config;
43
- try {
44
- logger.verbose("connecting to nats", { natsUrl });
45
- const nc = yield (0, nats_1.connect)({ servers: natsUrl, maxReconnectAttempts: -1 });
46
- logger.verbose("subscribing to call create subject", {
47
- subject: envs_1.CALLS_CREATE_SUBJECT
48
- });
49
- const subscription = nc.subscribe(envs_1.CALLS_CREATE_SUBJECT, {
50
- queue: envs_1.DEFAULT_NATS_QUEUE_GROUP
51
- });
52
- logger.verbose("connecting to ari", { ariProxyUrl });
53
- const ariConn = yield ari_client_1.default.connect(ariProxyUrl, ariUsername, ariPassword);
54
- subscription.callback = (err, msg) => __awaiter(this, void 0, void 0, function* () {
55
- if (err) {
56
- logger.error(err);
57
- }
58
- const { ref, from, to, appRef, accessKeyId, timeout, metadata } = msg.json();
59
- logger.verbose("received a new call request", Object.assign({}, msg.json()));
60
- yield ariConn.channels.originate({
61
- context: common_1.CALL_CONTEXT,
62
- extension: common_1.CALL_EXTENSION,
63
- endpoint: `PJSIP/${envs_1.ASTERISK_TRUNK}/sip:${to}@${envs_1.ASTERISK_SYSTEM_DOMAIN}`,
64
- timeout,
65
- variables: Object.assign(Object.assign(Object.assign({ "PJSIP_HEADER(add,X-Call-Ref)": ref, "PJSIP_HEADER(add,X-Dod-Number)": from, "PJSIP_HEADER(add,X-Access-Key-Id)": accessKeyId, "PJSIP_HEADER(add,X-Is-Api-Originated-Type)": "true", CALL_DIRECTION: "peer-to-pstn", INGRESS_NUMBER: from, APP_REF: appRef, METADATA: JSON.stringify(metadata), CALL_REF: ref }, (envs_1.AMD_ENABLED ? { AMD_ENABLED: "true" } : {})), (envs_1.AMD_ENABLED && envs_1.AMD_ENGINE === "ml" ? { AMD_ENGINE: "ml" } : {})), (envs_1.AMD_ENABLED && envs_1.AMD_ENGINE === "ml" && envs_1.AMD_MODE === "full"
66
- ? { AMD_MODE: "full" }
67
- : {}))
68
- });
69
- });
70
- }
71
- catch (e) {
72
- logger.error("error connecting to ari", e);
73
- }
74
- });
75
- }
@@ -1,97 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.buildWelcomeDemoService = buildWelcomeDemoService;
4
- /**
5
- * Copyright (C) 2025 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");
23
- const logger_1 = require("@fonoster/logger");
24
- const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
25
- const SERVICE_DEFINITION = {
26
- serviceName: "Voice",
27
- pckg: "voice",
28
- version: "v1beta2",
29
- proto: "voice.proto"
30
- };
31
- function buildWelcomeDemoService() {
32
- return {
33
- definition: SERVICE_DEFINITION,
34
- handlers: {
35
- createSession: (voice) => {
36
- let mediaSessionRef;
37
- voice.on(common_1.StreamEvent.DATA, (params) => {
38
- try {
39
- const { request, sayResponse } = params;
40
- if (request) {
41
- const { callerNumber } = request;
42
- mediaSessionRef = request.mediaSessionRef;
43
- logger.verbose("welcome demo session started", {
44
- mediaSessionRef,
45
- callerNumber
46
- });
47
- voice.write({
48
- answerRequest: {
49
- mediaSessionRef: request.mediaSessionRef
50
- }
51
- });
52
- voice.write({
53
- sayRequest: {
54
- text: "Welcome to Fonoster! Your system is configured correctly and ready for voice application development. Goodbye!",
55
- mediaSessionRef: request.mediaSessionRef
56
- }
57
- });
58
- }
59
- if (sayResponse && mediaSessionRef) {
60
- logger.verbose("hanging up welcome demo session", {
61
- mediaSessionRef
62
- });
63
- voice.write({
64
- hangupRequest: {
65
- mediaSessionRef
66
- }
67
- });
68
- }
69
- }
70
- catch (error) {
71
- logger.error("error in welcome demo session", {
72
- mediaSessionRef,
73
- error
74
- });
75
- if (mediaSessionRef) {
76
- voice.write({
77
- hangupRequest: { mediaSessionRef }
78
- });
79
- }
80
- voice.end();
81
- }
82
- });
83
- voice.once(common_1.StreamEvent.END, () => {
84
- voice.end();
85
- logger.verbose("welcome demo session ended", { mediaSessionRef });
86
- });
87
- voice.on(common_1.StreamEvent.ERROR, (error) => {
88
- logger.error("stream error in welcome demo session", {
89
- mediaSessionRef,
90
- error
91
- });
92
- voice.end();
93
- });
94
- }
95
- }
96
- };
97
- }
@@ -1,2 +0,0 @@
1
- declare function upsertDefaultPeer(): Promise<void>;
2
- export { upsertDefaultPeer };
@@ -1,23 +0,0 @@
1
- type CachedAmdResult = {
2
- status: string;
3
- confidence: number;
4
- detector: string;
5
- latencyMs: number;
6
- cause: string;
7
- };
8
- /**
9
- * Process-local bridge between the voice path and the CDR writer.
10
- * createCreateVoiceClient stores the AMD verdict here keyed by `callRef` as it
11
- * reads it off the channel; createInfluxDbPub reads it while building the call's
12
- * CDR points so the verdict is persisted alongside the rest of the record for
13
- * later analysis.
14
- *
15
- * For API-originated (outbound) calls `callRef` equals the CDR `ref` tag, so the
16
- * lookup is direct. SIP-originated inbound calls mint independent refs on each
17
- * side and are not correlated here — AMD only runs on outbound calls.
18
- */
19
- declare const amdResultCache: {
20
- get(key: string): CachedAmdResult;
21
- set(key: string, value: CachedAmdResult): void;
22
- };
23
- export { amdResultCache, CachedAmdResult };
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.amdResultCache = void 0;
4
- /**
5
- * Copyright (C) 2025 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 createPerCallCache_1 = require("./createPerCallCache");
23
- /**
24
- * Process-local bridge between the voice path and the CDR writer.
25
- * createCreateVoiceClient stores the AMD verdict here keyed by `callRef` as it
26
- * reads it off the channel; createInfluxDbPub reads it while building the call's
27
- * CDR points so the verdict is persisted alongside the rest of the record for
28
- * later analysis.
29
- *
30
- * For API-originated (outbound) calls `callRef` equals the CDR `ref` tag, so the
31
- * lookup is direct. SIP-originated inbound calls mint independent refs on each
32
- * side and are not correlated here — AMD only runs on outbound calls.
33
- */
34
- const amdResultCache = (0, createPerCallCache_1.createPerCallCache)(24 * 60 * 60 * 1000);
35
- exports.amdResultCache = amdResultCache;
@@ -1,13 +0,0 @@
1
- type InfluxDbPub = {
2
- url: string;
3
- token: string;
4
- org: string;
5
- bucket: string;
6
- };
7
- type FonosterEvent = {
8
- name: "cdr" | "error";
9
- tag: string;
10
- data: Record<string, string>;
11
- };
12
- declare function createInfluxDbPub(config: any): (event: any) => void;
13
- export { FonosterEvent, InfluxDbPub, createInfluxDbPub };