@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.
- package/dist/applications/buildService.d.ts +5 -1
- package/dist/applications/buildService.js +10 -7
- package/dist/applications/createCreateApplication.d.ts +6 -2
- package/dist/applications/createCreateApplication.js +24 -16
- package/dist/applications/createCreateTestToken.d.ts +3 -1
- package/dist/applications/createCreateTestToken.js +18 -13
- package/dist/applications/createGetApplication.js +2 -2
- package/dist/applications/createGetFnUtil.d.ts +22 -18
- package/dist/applications/createGetFnUtil.js +3 -5
- package/dist/applications/createListApplications.js +3 -4
- package/dist/applications/createRotateSigningSecret.d.ts +9 -0
- package/dist/{calls/createFetchSingleCall.js → applications/createRotateSigningSecret.js} +23 -20
- package/dist/applications/createUpdateApplication.d.ts +6 -2
- package/dist/applications/createUpdateApplication.js +35 -36
- package/dist/applications/evalKeys.d.ts +9 -0
- package/dist/{voice/handlers/dial/recordChannel.js → applications/evalKeys.js} +17 -12
- package/dist/applications/session/appModel.d.ts +225 -0
- package/dist/applications/session/appModel.js +331 -0
- package/dist/applications/types.d.ts +1 -27
- package/dist/billing/buildService.d.ts +24 -0
- package/dist/billing/buildService.js +116 -0
- package/dist/bin/entrypoint.d.ts +1 -0
- package/dist/bin/entrypoint.js +180 -0
- package/dist/bin/healthcheck.d.ts +2 -0
- package/dist/{voice/utils/VoiceServiceClientConstructor.js → bin/healthcheck.js} +24 -9
- package/dist/bin/regionHubSetup.d.ts +2 -0
- package/dist/bin/regionHubSetup.js +67 -0
- package/dist/bin/usage.d.ts +2 -0
- package/dist/bin/usage.js +119 -0
- package/dist/calls/buildService.d.ts +1 -20
- package/dist/calls/buildService.js +59 -6
- package/dist/calls/createCall.d.ts +17 -2
- package/dist/calls/createCall.js +64 -11
- package/dist/calls/createCallPublisher.d.ts +40 -2
- package/dist/calls/createCallPublisher.js +43 -9
- package/dist/calls/createIsWorkspaceNumber.d.ts +41 -0
- package/dist/calls/createIsWorkspaceNumber.js +39 -0
- package/dist/calls/createTrackCall.d.ts +55 -2
- package/dist/calls/createTrackCall.js +230 -16
- package/dist/calls/getCall.d.ts +4 -2
- package/dist/calls/getCall.js +2 -3
- package/dist/calls/listCalls.d.ts +4 -2
- package/dist/calls/listCalls.js +2 -3
- package/dist/calls/types.d.ts +11 -2
- package/dist/calls/types.js +10 -0
- package/dist/{core/buildWelcomeDemoService.d.ts → capabilities/buildService.d.ts} +8 -8
- package/dist/capabilities/buildService.js +17 -0
- package/dist/capabilities/createGetCapabilities.d.ts +78 -0
- package/dist/capabilities/createGetCapabilities.js +98 -0
- package/dist/{voice/handlers/utils → capabilities}/index.d.ts +2 -3
- package/dist/{voice/handlers/utils → capabilities}/index.js +4 -3
- package/dist/config/index.d.ts +23 -0
- package/dist/config/index.js +102 -0
- package/dist/config/schema.d.ts +1919 -0
- package/dist/config/schema.js +357 -0
- package/dist/core/allowList.js +2 -1
- package/dist/core/applyCatalog.d.ts +10 -0
- package/dist/{voice/client/GrpcClientHandler.js → core/applyCatalog.js} +45 -51
- package/dist/core/db.d.ts +3 -1
- package/dist/core/db.js +2 -1
- package/dist/core/durableConsumer.d.ts +41 -0
- package/dist/core/durableConsumer.js +104 -0
- package/dist/core/httpBridge.d.ts +24 -6
- package/dist/core/httpBridge.js +3 -25
- package/dist/core/identityConfig.d.ts +2 -35
- package/dist/core/identityConfig.js +3 -36
- package/dist/core/regionHooks.d.ts +15 -0
- package/dist/{calls/influxdb.js → core/regionHooks.js} +4 -8
- package/dist/core/runServices.js +98 -15
- package/dist/core/services.d.ts +96 -6
- package/dist/core/services.js +49 -10
- package/dist/{voice/errors/index.d.ts → core/telemetry.d.ts} +2 -2
- package/dist/core/telemetry.js +42 -0
- package/dist/{applications/utils/convertToApplicationData.d.ts → core/telemetryInterceptor.d.ts} +10 -4
- package/dist/core/telemetryInterceptor.js +57 -0
- package/dist/core/testTokenConfig.js +4 -1
- package/dist/core/upsertRoomrPeer.d.ts +6 -0
- package/dist/core/{upsertDefaultPeer.js → upsertRoomrPeer.js} +31 -30
- package/dist/envs.d.ts +136 -23
- package/dist/envs.js +108 -143
- package/dist/index.js +39 -21
- package/dist/outbound/createNodeDirectory.d.ts +86 -0
- package/dist/outbound/createNodeDirectory.js +140 -0
- package/dist/{voice/integrations → outbound}/index.d.ts +4 -1
- package/dist/{voice/errors → outbound}/index.js +4 -2
- package/dist/outbound/placeOutboundCall.d.ts +96 -0
- package/dist/outbound/placeOutboundCall.js +172 -0
- package/dist/outbound/placementSweep.d.ts +56 -0
- package/dist/outbound/placementSweep.js +127 -0
- package/dist/outbound/runOutboundCalls.d.ts +52 -0
- package/dist/outbound/runOutboundCalls.js +171 -0
- package/dist/providers/createProvidersHandlers.d.ts +39 -0
- package/dist/providers/createProvidersHandlers.js +229 -0
- package/dist/providers/index.d.ts +47 -0
- package/dist/{voice/client → providers}/index.js +15 -6
- package/dist/providers/registryUsage.d.ts +48 -0
- package/dist/providers/registryUsage.js +236 -0
- package/dist/records/createIndexRecord.d.ts +42 -0
- package/dist/records/createIndexRecord.js +185 -0
- package/dist/records/createRecordsRouter.d.ts +61 -0
- package/dist/records/createRecordsRouter.js +330 -0
- package/dist/records/createSearchRecords.d.ts +51 -0
- package/dist/records/createSearchRecords.js +134 -0
- package/dist/{voice/filters → records}/index.d.ts +6 -6
- package/dist/{voice/filters → records}/index.js +6 -6
- package/dist/records/maintenance.d.ts +33 -0
- package/dist/records/maintenance.js +166 -0
- package/dist/records/runCallRecords.d.ts +48 -0
- package/dist/records/runCallRecords.js +49 -0
- package/dist/{events/createPerCallCache.d.ts → records/stores.d.ts} +4 -7
- package/dist/{voice/handlers/utils/isDtmf.js → records/stores.js} +9 -3
- package/dist/records/types.d.ts +104 -0
- package/dist/regions/configSync.d.ts +130 -0
- package/dist/regions/configSync.js +316 -0
- package/dist/regions/createRegionsRouter.d.ts +151 -0
- package/dist/regions/createRegionsRouter.js +391 -0
- package/dist/regions/endpoints.d.ts +41 -0
- package/dist/regions/endpoints.js +90 -0
- package/dist/regions/enrollmentToken.d.ts +41 -0
- package/dist/regions/enrollmentToken.js +94 -0
- package/dist/regions/httpAuth.d.ts +39 -0
- package/dist/regions/httpAuth.js +78 -0
- package/dist/regions/ids.d.ts +15 -0
- package/dist/regions/ids.js +81 -0
- package/dist/{voice/client → regions}/index.d.ts +17 -6
- package/dist/regions/index.js +51 -0
- package/dist/regions/link.d.ts +17 -0
- package/dist/regions/link.js +170 -0
- package/dist/regions/natsAuth.d.ts +41 -0
- package/dist/regions/natsAuth.js +64 -0
- package/dist/regions/natsJwt.d.ts +23 -0
- package/dist/regions/natsJwt.js +26 -0
- package/dist/regions/relay.d.ts +45 -0
- package/dist/regions/relay.js +203 -0
- package/dist/regions/relayHttp.d.ts +7 -0
- package/dist/regions/relayHttp.js +107 -0
- package/dist/regions/relaySlots.d.ts +18 -0
- package/dist/regions/relaySlots.js +118 -0
- package/dist/regions/runRegions.d.ts +111 -0
- package/dist/regions/runRegions.js +235 -0
- package/dist/regions/service.d.ts +129 -0
- package/dist/regions/service.js +558 -0
- package/dist/regions/sources.d.ts +20 -0
- package/dist/regions/sources.js +191 -0
- package/dist/regions/status.d.ts +35 -0
- package/dist/regions/status.js +63 -0
- package/dist/regions/types.d.ts +123 -0
- package/dist/regions/types.js +41 -0
- package/dist/{voice/integrations/getSttConfig.d.ts → regions/withConfigChangeHook.d.ts} +13 -7
- package/dist/regions/withConfigChangeHook.js +44 -0
- package/dist/secrets/createGetFnUtil.d.ts +2 -2
- package/dist/session/createSessionRouter.d.ts +49 -0
- package/dist/session/createSessionRouter.js +206 -0
- package/dist/{voice/handlers/dial → session}/index.d.ts +1 -1
- package/dist/{voice/handlers/dial → session}/index.js +1 -1
- package/dist/usage/buildService.d.ts +16 -0
- package/dist/{voice/integrations/getTtsConfig.js → usage/buildService.js} +13 -7
- package/dist/{voice/tts/utils/convertUlawToPCM16.d.ts → usage/createGetUsage.d.ts} +7 -6
- package/dist/usage/createGetUsage.js +118 -0
- package/dist/usage/ingestUsage.d.ts +7 -0
- package/dist/usage/ingestUsage.js +87 -0
- package/dist/usage/publishRecordedUsage.d.ts +52 -0
- package/dist/usage/publishRecordedUsage.js +103 -0
- package/dist/{utils/createHandleDialEventsWithNats.d.ts → usage/publishUsage.d.ts} +10 -4
- package/dist/usage/publishUsage.js +50 -0
- package/dist/usage/rebuildUsage.d.ts +48 -0
- package/dist/usage/rebuildUsage.js +104 -0
- package/dist/usage/runUsageConsumer.d.ts +22 -0
- package/dist/usage/runUsageConsumer.js +78 -0
- package/dist/usage/snapshotStorage.d.ts +14 -0
- package/dist/usage/snapshotStorage.js +95 -0
- package/dist/{voice/integrations/getTtsConfig.d.ts → usage/types.d.ts} +17 -6
- package/dist/utils/createCheckNumberPreconditions.js +4 -0
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.js +0 -2
- package/dist/voice/stt/Deepgram.d.ts +4 -57
- package/dist/voice/stt/Deepgram.js +15 -286
- package/dist/voice/stt/Google.d.ts +4 -15
- package/dist/voice/stt/Google.js +7 -103
- package/dist/voice/stt/types.d.ts +2 -38
- package/dist/voice/stt/types.js +25 -3
- package/dist/voice/tts/Azure.d.ts +4 -34
- package/dist/voice/tts/Azure.js +25 -105
- package/dist/voice/tts/Deepgram.d.ts +4 -38
- package/dist/voice/tts/Deepgram.js +25 -82
- package/dist/voice/tts/ElevenLabs.d.ts +4 -18
- package/dist/voice/tts/ElevenLabs.js +6 -97
- package/dist/voice/tts/Google.d.ts +4 -38
- package/dist/voice/tts/Google.js +25 -91
- package/dist/webhooks/createWebhooksHandlers.d.ts +37 -0
- package/dist/webhooks/createWebhooksHandlers.js +217 -0
- package/dist/webhooks/index.d.ts +37 -0
- package/dist/webhooks/index.js +51 -0
- package/dist/webhooks/lostCalls.d.ts +49 -0
- package/dist/webhooks/lostCalls.js +147 -0
- package/dist/webhooks/nodeCallEvents.d.ts +73 -0
- package/dist/webhooks/nodeCallEvents.js +177 -0
- package/dist/webhooks/runWebhookFanout.d.ts +44 -0
- package/dist/webhooks/runWebhookFanout.js +202 -0
- package/package.json +21 -31
- package/dist/applications/utils/applicationWithEncodedStruct.d.ts +0 -3
- package/dist/applications/utils/applicationWithEncodedStruct.js +0 -50
- package/dist/applications/utils/convertToApplicationData.js +0 -37
- package/dist/applications/validation/assistantWithoutApiKeySchema.d.ts +0 -786
- package/dist/applications/validation/assistantWithoutApiKeySchema.js +0 -35
- package/dist/applications/validation/createValidationSchema.d.ts +0 -1474
- package/dist/applications/validation/createValidationSchema.js +0 -67
- package/dist/applications/validation/prepareForValidation.d.ts +0 -21
- package/dist/applications/validation/prepareForValidation.js +0 -35
- package/dist/applications/validation/speechValidators.d.ts +0 -47
- package/dist/applications/validation/speechValidators.js +0 -50
- package/dist/applications/validation/validOrThrow.d.ts +0 -21
- package/dist/applications/validation/validOrThrow.js +0 -15
- package/dist/calls/createFetchCalls.d.ts +0 -22
- package/dist/calls/createFetchCalls.js +0 -88
- package/dist/calls/createFetchSingleCall.d.ts +0 -22
- package/dist/calls/influxdb.d.ts +0 -2
- package/dist/calls/runCallManager.d.ts +0 -8
- package/dist/calls/runCallManager.js +0 -75
- package/dist/core/buildWelcomeDemoService.js +0 -97
- package/dist/core/upsertDefaultPeer.d.ts +0 -2
- package/dist/events/amdResultCache.d.ts +0 -23
- package/dist/events/amdResultCache.js +0 -35
- package/dist/events/createInfluxDbPub.d.ts +0 -13
- package/dist/events/createInfluxDbPub.js +0 -89
- package/dist/events/createPerCallCache.js +0 -46
- package/dist/events/mapCallDirectionToEnum.d.ts +0 -21
- package/dist/events/mapCallDirectionToEnum.js +0 -37
- package/dist/events/nats.d.ts +0 -10
- package/dist/events/nats.js +0 -82
- package/dist/events/transformEvent.d.ts +0 -2
- package/dist/events/transformEvent.js +0 -87
- package/dist/events/types.d.ts +0 -26
- package/dist/utils/createHandleDialEventsWithNats.js +0 -24
- package/dist/utils/createHandleDialEventsWithVoiceClient.d.ts +0 -23
- package/dist/utils/createHandleDialEventsWithVoiceClient.js +0 -27
- package/dist/utils/getIntegrationsFromFile.d.ts +0 -2
- package/dist/utils/getIntegrationsFromFile.js +0 -49
- package/dist/utils/mapDialStatus.d.ts +0 -21
- package/dist/utils/mapDialStatus.js +0 -38
- package/dist/voice/VoiceDispatcher.d.ts +0 -21
- package/dist/voice/VoiceDispatcher.js +0 -122
- package/dist/voice/amd/mapAsteriskAmd.d.ts +0 -38
- package/dist/voice/amd/mapAsteriskAmd.js +0 -68
- package/dist/voice/client/AudioSocketHandler.d.ts +0 -38
- package/dist/voice/client/AudioSocketHandler.js +0 -70
- package/dist/voice/client/AuthorizationHandler.d.ts +0 -13
- package/dist/voice/client/AuthorizationHandler.js +0 -78
- package/dist/voice/client/ExternalMediaHandler.d.ts +0 -32
- package/dist/voice/client/ExternalMediaHandler.js +0 -59
- package/dist/voice/client/GrpcClientHandler.d.ts +0 -36
- package/dist/voice/client/SpeechHandler.d.ts +0 -60
- package/dist/voice/client/SpeechHandler.js +0 -120
- package/dist/voice/client/VoiceClientImpl.d.ts +0 -79
- package/dist/voice/client/VoiceClientImpl.js +0 -198
- package/dist/voice/connectToAri.d.ts +0 -2
- package/dist/voice/connectToAri.js +0 -81
- package/dist/voice/createCreateVoiceClient.d.ts +0 -9
- package/dist/voice/createCreateVoiceClient.js +0 -97
- package/dist/voice/errors/ChannelVarNotFoundError.d.ts +0 -23
- package/dist/voice/errors/ChannelVarNotFoundError.js +0 -10
- package/dist/voice/errors/MethodNotImplementedError.d.ts +0 -22
- package/dist/voice/errors/MethodNotImplementedError.js +0 -27
- package/dist/voice/filters/AudioFilterFactory.d.ts +0 -35
- package/dist/voice/filters/AudioFilterFactory.js +0 -94
- package/dist/voice/filters/aiCoustics/createAiCousticsFilter.d.ts +0 -64
- package/dist/voice/filters/aiCoustics/createAiCousticsFilter.js +0 -252
- package/dist/voice/filters/aiCoustics/types.d.ts +0 -45
- package/dist/voice/filters/aiCoustics/types.js +0 -29
- package/dist/voice/filters/createAudioFilterChain.d.ts +0 -9
- package/dist/voice/filters/createAudioFilterChain.js +0 -171
- package/dist/voice/filters/createAudioFilterSession.d.ts +0 -15
- package/dist/voice/filters/createAudioFilterSession.js +0 -114
- package/dist/voice/filters/pcm.d.ts +0 -21
- package/dist/voice/filters/pcm.js +0 -37
- package/dist/voice/filters/types.d.ts +0 -61
- package/dist/voice/filters/types.js +0 -26
- package/dist/voice/handlers/createAnswerHandler.d.ts +0 -23
- package/dist/voice/handlers/createAnswerHandler.js +0 -24
- package/dist/voice/handlers/createHangupHandler.d.ts +0 -23
- package/dist/voice/handlers/createHangupHandler.js +0 -28
- package/dist/voice/handlers/createMuteHandler.d.ts +0 -4
- package/dist/voice/handlers/createMuteHandler.js +0 -27
- package/dist/voice/handlers/createPlayDtmfHandler.d.ts +0 -4
- package/dist/voice/handlers/createPlayDtmfHandler.js +0 -27
- package/dist/voice/handlers/createPlayHandler.d.ts +0 -4
- package/dist/voice/handlers/createPlayHandler.js +0 -33
- package/dist/voice/handlers/createPlaybackControlHandler.d.ts +0 -4
- package/dist/voice/handlers/createPlaybackControlHandler.js +0 -62
- package/dist/voice/handlers/createRecordHandler.d.ts +0 -4
- package/dist/voice/handlers/createRecordHandler.js +0 -58
- package/dist/voice/handlers/createSayHandler.d.ts +0 -4
- package/dist/voice/handlers/createSayHandler.js +0 -31
- package/dist/voice/handlers/createSetAudioFiltersHandler.d.ts +0 -11
- package/dist/voice/handlers/createSetAudioFiltersHandler.js +0 -74
- package/dist/voice/handlers/createStopSayHandler.d.ts +0 -3
- package/dist/voice/handlers/createStopSayHandler.js +0 -34
- package/dist/voice/handlers/createStreamGatherHandler.d.ts +0 -3
- package/dist/voice/handlers/createStreamGatherHandler.js +0 -74
- package/dist/voice/handlers/createStreamHandler.d.ts +0 -3
- package/dist/voice/handlers/createStreamHandler.js +0 -70
- package/dist/voice/handlers/createUnmuteHandler.d.ts +0 -4
- package/dist/voice/handlers/createUnmuteHandler.js +0 -27
- package/dist/voice/handlers/dial/createDialHandler.d.ts +0 -23
- package/dist/voice/handlers/dial/createDialHandler.js +0 -78
- package/dist/voice/handlers/dial/handleChannelLeftBridge.d.ts +0 -24
- package/dist/voice/handlers/dial/handleChannelLeftBridge.js +0 -29
- package/dist/voice/handlers/dial/handleStasisEnd.d.ts +0 -21
- package/dist/voice/handlers/dial/handleStasisEnd.js +0 -19
- package/dist/voice/handlers/dial/handleStasisStart.d.ts +0 -27
- package/dist/voice/handlers/dial/handleStasisStart.js +0 -52
- package/dist/voice/handlers/dial/recordChannel.d.ts +0 -22
- package/dist/voice/handlers/gather/createGatherHandler.d.ts +0 -3
- package/dist/voice/handlers/gather/createGatherHandler.js +0 -86
- package/dist/voice/handlers/gather/getTimeoutPromise.d.ts +0 -26
- package/dist/voice/handlers/gather/getTimeoutPromise.js +0 -18
- package/dist/voice/handlers/index.d.ts +0 -33
- package/dist/voice/handlers/index.js +0 -49
- package/dist/voice/handlers/utils/awaitForPlaybackFinished.d.ts +0 -21
- package/dist/voice/handlers/utils/awaitForPlaybackFinished.js +0 -25
- package/dist/voice/handlers/utils/awaitForRecordingFinished.d.ts +0 -5
- package/dist/voice/handlers/utils/awaitForRecordingFinished.js +0 -53
- package/dist/voice/handlers/utils/isDtmf.d.ts +0 -20
- package/dist/voice/handlers/utils/textChunksByClause.d.ts +0 -2
- package/dist/voice/handlers/utils/textChunksByClause.js +0 -41
- package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.d.ts +0 -2
- package/dist/voice/handlers/utils/textChunksByFirstNaturalPause.js +0 -34
- package/dist/voice/handlers/utils/withErrorHandling.d.ts +0 -22
- package/dist/voice/handlers/utils/withErrorHandling.js +0 -38
- package/dist/voice/integrations/ApplicationNotFoundError.d.ts +0 -22
- package/dist/voice/integrations/ApplicationNotFoundError.js +0 -28
- package/dist/voice/integrations/createCreateContainer.d.ts +0 -4
- package/dist/voice/integrations/createCreateContainer.js +0 -76
- package/dist/voice/integrations/getSttConfig.js +0 -30
- package/dist/voice/integrations/index.js +0 -35
- package/dist/voice/integrations/types.d.ts +0 -29
- package/dist/voice/stt/AbstractSpeechToText.d.ts +0 -33
- package/dist/voice/stt/AbstractSpeechToText.js +0 -19
- package/dist/voice/stt/SpeechToTextFactory.d.ts +0 -9
- package/dist/voice/stt/SpeechToTextFactory.js +0 -43
- package/dist/voice/transcribeOnConnection.d.ts +0 -35
- package/dist/voice/transcribeOnConnection.js +0 -91
- package/dist/voice/tts/AbstractTextToSpeech.d.ts +0 -40
- package/dist/voice/tts/AbstractTextToSpeech.js +0 -50
- package/dist/voice/tts/TextToSpeechFactory.d.ts +0 -8
- package/dist/voice/tts/TextToSpeechFactory.js +0 -47
- package/dist/voice/tts/types.d.ts +0 -48
- package/dist/voice/tts/types.js +0 -2
- package/dist/voice/tts/utils/convertUlawToPCM16.js +0 -40
- package/dist/voice/tts/utils/createChunkedSynthesisStream.d.ts +0 -28
- package/dist/voice/tts/utils/createChunkedSynthesisStream.js +0 -78
- package/dist/voice/tts/utils/createErrorStream.d.ts +0 -21
- package/dist/voice/tts/utils/createErrorStream.js +0 -28
- package/dist/voice/tts/utils/index.d.ts +0 -23
- package/dist/voice/tts/utils/index.js +0 -39
- package/dist/voice/tts/utils/isSsml.d.ts +0 -20
- package/dist/voice/tts/utils/isSsml.js +0 -25
- package/dist/voice/tts/utils/streamToBuffer.d.ts +0 -20
- package/dist/voice/tts/utils/streamToBuffer.js +0 -60
- package/dist/voice/types/ari.d.ts +0 -43
- package/dist/voice/types/ari.js +0 -48
- package/dist/voice/types/index.d.ts +0 -20
- package/dist/voice/types/index.js +0 -36
- package/dist/voice/types/voice.d.ts +0 -67
- package/dist/voice/types/voice.js +0 -2
- package/dist/voice/utils/VoiceServiceClientConstructor.d.ts +0 -3
- package/dist/voice/utils/createExternalMediaConfig.d.ts +0 -12
- package/dist/voice/utils/createExternalMediaConfig.js +0 -37
- package/dist/voice/utils/createGetChannelVar.d.ts +0 -22
- package/dist/voice/utils/createGetChannelVar.js +0 -27
- package/dist/voice/utils/createGetChannelVarWithoutThrow.d.ts +0 -22
- package/dist/voice/utils/createGetChannelVarWithoutThrow.js +0 -26
- package/dist/voice/utils/index.d.ts +0 -22
- package/dist/voice/utils/index.js +0 -38
- /package/dist/{events → records}/types.js +0 -0
- /package/dist/{voice/integrations → usage}/types.js +0 -0
package/dist/envs.js
CHANGED
|
@@ -1,11 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
var _a;
|
|
2
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
6
3
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.
|
|
8
|
-
exports.
|
|
4
|
+
exports.SMTP_PORT = exports.SMTP_HOST = exports.SMTP_AUTH_USER = exports.SMTP_AUTH_PASS = exports.ROUTR_SIP_PROXY = exports.ROUTR_ROOMR_PEER = exports.ROUTR_API_ENDPOINT = exports.OWNER_PASSWORD = exports.OWNER_NAME = exports.OWNER_EMAIL = exports.NATS = exports.NATS_CONNECTION = exports.NATS_URL = exports.EVALUATIONS = exports.AUTHZ_SERVICE_METHODS = exports.AUTHZ_SERVICE_PORT = exports.AUTHZ_SERVICE_HOST = exports.AUTHZ_SERVICE_ENABLED = exports.BILLING_ADDRESS = exports.BILLING_ENABLED = exports.IDENTITY_DATABASE_URL = exports.IDENTITY_WORKSPACE_INVITE_URL = exports.IDENTITY_WORKSPACE_INVITE_EXPIRATION = exports.IDENTITY_WORKSPACE_INVITE_FAIL_URL = exports.IDENTITY_REFRESH_TOKEN_EXPIRES_IN = exports.IDENTITY_PUBLIC_KEY = exports.IDENTITY_PRIVATE_KEY = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET = exports.IDENTITY_OAUTH2_GITHUB_CLIENT_ID = exports.IDENTITY_OAUTH2_GITHUB_ENABLED = exports.IDENTITY_TWO_FACTOR_AUTHENTICATION_REQUIRED = exports.IDENTITY_CONTACT_VERIFICATION_REQUIRED = exports.IDENTITY_ISSUER = exports.IDENTITY_ID_TOKEN_EXPIRES_IN = exports.IDENTITY_AUDIENCE = exports.IDENTITY_ACCESS_TOKEN_EXPIRES_IN = exports.HTTP_BRIDGE_PORT = exports.DEFAULT_NATS_QUEUE_GROUP = exports.DATABASE_URL = exports.CLOAK_ENCRYPTION_KEY = exports.NODE_HEARTBEAT_WILDCARD = exports.MEDIA_CALL_EVENTS_WILDCARD = exports.mediaCallEventsSubject = exports.CALL_EVENTS_WILDCARD = exports.callEventsSubject = exports.CALLS_CREATE_SUBJECT = exports.APP_URL = exports.APISERVER_SIGNALING_SERVER = exports.APISERVER_HOST = exports.APISERVER_BIND_ADDR = void 0;
|
|
5
|
+
exports.DOMAIN_NAMES_ROOT = exports.TRUNK_NAMES_ROOT = exports.SIP_ROOT = exports.PSTN_ROOT = exports.DOMAIN = exports.REGIONS = exports.WEBHOOKS = exports.SESSION_APPS = exports.CALL_RECORDS = exports.TWILIO_PHONE_NUMBER = exports.TWILIO_AUTH_TOKEN = exports.TWILIO_ACCOUNT_SID = exports.TEMPLATES_DIR = exports.SMTP_SENDER = exports.SMTP_SECURE = void 0;
|
|
9
6
|
/**
|
|
10
7
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
11
8
|
* http://github.com/fonoster/fonoster
|
|
@@ -24,148 +21,116 @@ exports.TWILIO_PHONE_NUMBER = exports.TWILIO_AUTH_TOKEN = exports.TWILIO_ACCOUNT
|
|
|
24
21
|
* See the License for the specific language governing permissions and
|
|
25
22
|
* limitations under the License.
|
|
26
23
|
*/
|
|
27
|
-
|
|
28
|
-
|
|
24
|
+
/**
|
|
25
|
+
* The API server's settings, as constants. They come from fonoster.yaml (see
|
|
26
|
+
* ./config), loaded once on first import; the names are kept from the
|
|
27
|
+
* env-var era so modules that import them didn't change.
|
|
28
|
+
*/
|
|
29
29
|
const common_1 = require("@fonoster/common");
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
(0,
|
|
36
|
-
"APISERVER_APP_URL",
|
|
37
|
-
"APISERVER_SIGNALING_SERVER",
|
|
38
|
-
"APISERVER_ASTERISK_ARI_PROXY_URL",
|
|
39
|
-
"APISERVER_ASTERISK_ARI_USERNAME",
|
|
40
|
-
"APISERVER_ASTERISK_ARI_SECRET",
|
|
41
|
-
"APISERVER_CLOAK_ENCRYPTION_KEY",
|
|
42
|
-
"APISERVER_SMTP_HOST",
|
|
43
|
-
"APISERVER_SMTP_SENDER",
|
|
44
|
-
"APISERVER_SMTP_AUTH_USER",
|
|
45
|
-
"APISERVER_SMTP_AUTH_PASS",
|
|
46
|
-
"APISERVER_IDENTITY_ISSUER",
|
|
47
|
-
"APISERVER_IDENTITY_DATABASE_URL",
|
|
48
|
-
"APISERVER_IDENTITY_WORKSPACE_INVITE_URL",
|
|
49
|
-
"APISERVER_IDENTITY_WORKSPACE_INVITE_FAIL_URL",
|
|
50
|
-
"APISERVER_DATABASE_URL",
|
|
51
|
-
"APISERVER_INFLUXDB_URL",
|
|
52
|
-
"APISERVER_INFLUXDB_INIT_USERNAME",
|
|
53
|
-
"APISERVER_INFLUXDB_INIT_PASSWORD",
|
|
54
|
-
"APISERVER_INFLUXDB_INIT_ORG",
|
|
55
|
-
"APISERVER_INFLUXDB_INIT_TOKEN",
|
|
56
|
-
"APISERVER_NATS_URL"
|
|
57
|
-
]);
|
|
58
|
-
const IDENTITY_PRIVATE_KEY_PATH = e.APISERVER_IDENTITY_PRIVATE_KEY_PATH || "/opt/fonoster/keys/private.pem";
|
|
59
|
-
const IDENTITY_PUBLIC_KEY_PATH = e.APISERVER_IDENTITY_PUBLIC_KEY_PATH || "/opt/fonoster/keys/public.pem";
|
|
60
|
-
exports.APISERVER_BIND_ADDR = e.APISERVER_BIND_ADDR || "0.0.0.0:50051";
|
|
61
|
-
exports.APISERVER_HOST = e.APISERVER_HOST || "apiserver";
|
|
62
|
-
exports.APISERVER_SIGNALING_SERVER = e.APISERVER_SIGNALING_SERVER;
|
|
30
|
+
const config_1 = require("./config");
|
|
31
|
+
const config = (0, config_1.getConfig)();
|
|
32
|
+
const identity = (0, config_1.getIdentityConfig)();
|
|
33
|
+
exports.APISERVER_BIND_ADDR = config.server.bindAddr;
|
|
34
|
+
exports.APISERVER_HOST = config.server.host;
|
|
35
|
+
exports.APISERVER_SIGNALING_SERVER = (0, config_1.getSignalingServer)(config);
|
|
63
36
|
// Frontend configurations
|
|
64
|
-
exports.APP_URL =
|
|
65
|
-
exports.ASTERISK_ARI_PROXY_URL = e.APISERVER_ASTERISK_ARI_PROXY_URL;
|
|
66
|
-
exports.ASTERISK_ARI_SECRET = e.APISERVER_ASTERISK_ARI_SECRET;
|
|
67
|
-
exports.ASTERISK_ARI_USERNAME = e.APISERVER_ASTERISK_ARI_USERNAME;
|
|
68
|
-
exports.ASTERISK_SYSTEM_DOMAIN = e.APISERVER_ASTERISK_SYSTEM_DOMAIN || "sip.invalid";
|
|
69
|
-
exports.ASTERISK_TRUNK = "routr";
|
|
37
|
+
exports.APP_URL = (0, config_1.getAppUrl)(config);
|
|
70
38
|
exports.CALLS_CREATE_SUBJECT = "calls.create";
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
exports.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// AMDLATENCYMS and the classifier's own five-way status (HUMAN/MACHINE/
|
|
91
|
-
// VOICEMAIL/IVR/UNKNOWN) — a consumer must opt into "full" to see those.
|
|
92
|
-
exports.AMD_MODE = e.APISERVER_AMD_MODE === "full" ? "full" : "compact";
|
|
39
|
+
/**
|
|
40
|
+
* The control plane's own status of a call it places (TRYING, the node that took it, FAILED),
|
|
41
|
+
* keyed by the call, so TrackCall on any replica sees it.
|
|
42
|
+
*/
|
|
43
|
+
const callEventsSubject = (ref) => `calls.${ref}.events`;
|
|
44
|
+
exports.callEventsSubject = callEventsSubject;
|
|
45
|
+
/** Every call's control-plane status (TrackCall's subscription). */
|
|
46
|
+
exports.CALL_EVENTS_WILDCARD = "calls.*.events";
|
|
47
|
+
/**
|
|
48
|
+
* A call's events from its Roomr node (media-control "Events on NATS are keyed by call"):
|
|
49
|
+
* call.started, call.ringing, call.answered, call.ended and the call's participant and operation
|
|
50
|
+
* events, each with node_ref, seq and metadata.
|
|
51
|
+
*/
|
|
52
|
+
const mediaCallEventsSubject = (ref) => `roomr.events.${ref}`;
|
|
53
|
+
exports.mediaCallEventsSubject = mediaCallEventsSubject;
|
|
54
|
+
/** Every call's media events (TrackCall's subscription; room events are roomr.events.room.*). */
|
|
55
|
+
exports.MEDIA_CALL_EVENTS_WILDCARD = "roomr.events.*";
|
|
56
|
+
/** Every Roomr node's heartbeat and node.down (TrackCall ends the calls of a lost node). */
|
|
57
|
+
exports.NODE_HEARTBEAT_WILDCARD = "roomr.nodes.*.heartbeat";
|
|
93
58
|
// Other configurations
|
|
94
|
-
exports.CLOAK_ENCRYPTION_KEY =
|
|
59
|
+
exports.CLOAK_ENCRYPTION_KEY = config.encryption.key;
|
|
60
|
+
exports.DATABASE_URL = config.database.url;
|
|
95
61
|
exports.DEFAULT_NATS_QUEUE_GROUP = "apiserver";
|
|
96
|
-
exports.HTTP_BRIDGE_PORT =
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
exports.
|
|
101
|
-
exports.
|
|
102
|
-
exports.
|
|
103
|
-
exports.
|
|
104
|
-
exports.
|
|
105
|
-
exports.
|
|
106
|
-
exports.
|
|
107
|
-
exports.
|
|
108
|
-
exports.
|
|
109
|
-
exports.
|
|
110
|
-
exports.
|
|
111
|
-
exports.
|
|
112
|
-
exports.
|
|
113
|
-
exports.
|
|
114
|
-
|
|
115
|
-
exports.
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
"APISERVER_IDENTITY_OAUTH2_GITHUB_CLIENT_ID",
|
|
119
|
-
"APISERVER_IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET"
|
|
120
|
-
]);
|
|
121
|
-
}
|
|
122
|
-
if (exports.IDENTITY_CONTACT_VERIFICATION_REQUIRED ||
|
|
123
|
-
exports.IDENTITY_TWO_FACTOR_AUTHENTICATION_REQUIRED) {
|
|
124
|
-
(0, common_1.assertEnvsAreSet)([
|
|
125
|
-
"APISERVER_TWILIO_ACCOUNT_SID",
|
|
126
|
-
"APISERVER_TWILIO_AUTH_TOKEN",
|
|
127
|
-
"APISERVER_TWILIO_PHONE_NUMBER"
|
|
128
|
-
]);
|
|
129
|
-
}
|
|
130
|
-
if (e.APISERVER_AUTHZ_SERVICE_ENABLED === "true") {
|
|
131
|
-
(0, common_1.assertEnvsAreSet)(["APISERVER_AUTHZ_SERVICE_HOST"]);
|
|
132
|
-
}
|
|
62
|
+
exports.HTTP_BRIDGE_PORT = config.server.httpBridgePort;
|
|
63
|
+
// Identity configurations (from the identity: section)
|
|
64
|
+
exports.IDENTITY_ACCESS_TOKEN_EXPIRES_IN = identity.accessTokenExpiresIn;
|
|
65
|
+
exports.IDENTITY_AUDIENCE = identity.audience;
|
|
66
|
+
exports.IDENTITY_ID_TOKEN_EXPIRES_IN = identity.idTokenExpiresIn;
|
|
67
|
+
exports.IDENTITY_ISSUER = identity.issuer;
|
|
68
|
+
exports.IDENTITY_CONTACT_VERIFICATION_REQUIRED = identity.contactVerificationRequired;
|
|
69
|
+
exports.IDENTITY_TWO_FACTOR_AUTHENTICATION_REQUIRED = identity.twoFactorAuthenticationRequired;
|
|
70
|
+
exports.IDENTITY_OAUTH2_GITHUB_ENABLED = config.features.auth.methods.includes("github");
|
|
71
|
+
exports.IDENTITY_OAUTH2_GITHUB_CLIENT_ID = (_a = identity.githubOauth2Config) === null || _a === void 0 ? void 0 : _a.clientId;
|
|
72
|
+
exports.IDENTITY_OAUTH2_GITHUB_CLIENT_SECRET = (_b = identity.githubOauth2Config) === null || _b === void 0 ? void 0 : _b.clientSecret;
|
|
73
|
+
exports.IDENTITY_PRIVATE_KEY = identity.privateKey;
|
|
74
|
+
exports.IDENTITY_PUBLIC_KEY = identity.publicKey;
|
|
75
|
+
exports.IDENTITY_REFRESH_TOKEN_EXPIRES_IN = identity.refreshTokenExpiresIn;
|
|
76
|
+
exports.IDENTITY_WORKSPACE_INVITE_FAIL_URL = identity.workspaceInviteFailUrl;
|
|
77
|
+
exports.IDENTITY_WORKSPACE_INVITE_EXPIRATION = identity.workspaceInviteExpiration;
|
|
78
|
+
exports.IDENTITY_WORKSPACE_INVITE_URL = identity.workspaceInviteUrl;
|
|
79
|
+
exports.IDENTITY_DATABASE_URL = identity.dbUrl;
|
|
80
|
+
/** Billing is on (Cloud): stored usage is published for the billing service (add-billing-service D2). */
|
|
81
|
+
exports.BILLING_ENABLED = config.features.billing.enabled;
|
|
82
|
+
/** Where the Billing API is served (the billing service). */
|
|
83
|
+
exports.BILLING_ADDRESS = (_c = config.features.billing.address) !== null && _c !== void 0 ? _c : `${config.authz.host}:50073`;
|
|
133
84
|
// Authz configurations
|
|
134
|
-
exports.AUTHZ_SERVICE_ENABLED =
|
|
135
|
-
exports.AUTHZ_SERVICE_HOST =
|
|
136
|
-
exports.AUTHZ_SERVICE_PORT =
|
|
137
|
-
exports.AUTHZ_SERVICE_METHODS =
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
exports.
|
|
143
|
-
|
|
144
|
-
exports.
|
|
145
|
-
|
|
146
|
-
exports.
|
|
147
|
-
exports.
|
|
148
|
-
exports.
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
exports.
|
|
152
|
-
|
|
153
|
-
exports.
|
|
154
|
-
|
|
155
|
-
exports.
|
|
156
|
-
exports.
|
|
157
|
-
exports.
|
|
158
|
-
exports.
|
|
159
|
-
|
|
160
|
-
exports.
|
|
161
|
-
exports.SMTP_PORT = e.APISERVER_SMTP_PORT
|
|
162
|
-
? parseInt(e.APISERVER_SMTP_PORT)
|
|
163
|
-
: 587;
|
|
164
|
-
exports.SMTP_SECURE = ((_a = e.APISERVER_SMTP_SECURE) === null || _a === void 0 ? void 0 : _a.toLowerCase()) === "true";
|
|
165
|
-
exports.SMTP_SENDER = e.APISERVER_SMTP_SENDER;
|
|
85
|
+
exports.AUTHZ_SERVICE_ENABLED = config.authz.enabled;
|
|
86
|
+
exports.AUTHZ_SERVICE_HOST = config.authz.host;
|
|
87
|
+
exports.AUTHZ_SERVICE_PORT = config.authz.port;
|
|
88
|
+
exports.AUTHZ_SERVICE_METHODS = config.authz.methods;
|
|
89
|
+
// Platform model keys for agent evaluations, by credentialRef (rework-autopilot 8.2).
|
|
90
|
+
exports.EVALUATIONS = config.evaluations;
|
|
91
|
+
exports.NATS_URL = config.nats.url;
|
|
92
|
+
/** The `nats` setting itself (URL, user, password), for helpers that take a NatsTarget. */
|
|
93
|
+
exports.NATS_CONNECTION = config.nats;
|
|
94
|
+
/** nats.js connect options: the URL plus the apiserver's NATS user, when set (add-platform 4.1). */
|
|
95
|
+
exports.NATS = (0, common_1.natsConnectOptions)(config.nats);
|
|
96
|
+
// Default owner (if identity.owner is set, the system creates a user and a workspace)
|
|
97
|
+
exports.OWNER_EMAIL = (_d = config.identity.owner) === null || _d === void 0 ? void 0 : _d.email;
|
|
98
|
+
exports.OWNER_NAME = (_f = (_e = config.identity.owner) === null || _e === void 0 ? void 0 : _e.name) !== null && _f !== void 0 ? _f : "Admin";
|
|
99
|
+
exports.OWNER_PASSWORD = (_g = config.identity.owner) === null || _g === void 0 ? void 0 : _g.password;
|
|
100
|
+
exports.ROUTR_API_ENDPOINT = config.routr.apiEndpoint;
|
|
101
|
+
// The roomr peer every app-linked number points at (add-roomr 4.1)
|
|
102
|
+
exports.ROUTR_ROOMR_PEER = config.routr.roomrPeer;
|
|
103
|
+
/** Routr's SIP address: API-originated calls are dialed through it (Roomr CreateCall). */
|
|
104
|
+
exports.ROUTR_SIP_PROXY = config.routr.sipProxy;
|
|
105
|
+
// SMTP configurations (optional; email features fail clearly without it)
|
|
106
|
+
exports.SMTP_AUTH_PASS = (_h = config.smtp) === null || _h === void 0 ? void 0 : _h.password;
|
|
107
|
+
exports.SMTP_AUTH_USER = (_j = config.smtp) === null || _j === void 0 ? void 0 : _j.user;
|
|
108
|
+
exports.SMTP_HOST = (_k = config.smtp) === null || _k === void 0 ? void 0 : _k.host;
|
|
109
|
+
exports.SMTP_PORT = (_m = (_l = config.smtp) === null || _l === void 0 ? void 0 : _l.port) !== null && _m !== void 0 ? _m : 587;
|
|
110
|
+
exports.SMTP_SECURE = (_p = (_o = config.smtp) === null || _o === void 0 ? void 0 : _o.secure) !== null && _p !== void 0 ? _p : false;
|
|
111
|
+
exports.SMTP_SENDER = (_q = config.smtp) === null || _q === void 0 ? void 0 : _q.sender;
|
|
166
112
|
// Custom templates
|
|
167
|
-
exports.TEMPLATES_DIR =
|
|
113
|
+
exports.TEMPLATES_DIR = config.templatesDir;
|
|
168
114
|
// Twilio configurations
|
|
169
|
-
exports.TWILIO_ACCOUNT_SID =
|
|
170
|
-
exports.TWILIO_AUTH_TOKEN =
|
|
171
|
-
exports.TWILIO_PHONE_NUMBER =
|
|
115
|
+
exports.TWILIO_ACCOUNT_SID = (_r = config.twilio) === null || _r === void 0 ? void 0 : _r.accountSid;
|
|
116
|
+
exports.TWILIO_AUTH_TOKEN = (_s = config.twilio) === null || _s === void 0 ? void 0 : _s.authToken;
|
|
117
|
+
exports.TWILIO_PHONE_NUMBER = (_t = config.twilio) === null || _t === void 0 ? void 0 : _t.phoneNumber;
|
|
118
|
+
// Call records (add-call-record): index, records API, retention, ListCalls from the index.
|
|
119
|
+
exports.CALL_RECORDS = config.callRecords;
|
|
120
|
+
// Session apps (rebuild: control): hosted Autopilot URL and signing secret, webhook URL policy
|
|
121
|
+
exports.SESSION_APPS = config.apps;
|
|
122
|
+
exports.WEBHOOKS = config.webhooks;
|
|
123
|
+
// Regions (add-private-regions): public regions, the region-signing key and the region hub
|
|
124
|
+
exports.REGIONS = config.regions;
|
|
125
|
+
exports.DOMAIN = config.domain;
|
|
126
|
+
/**
|
|
127
|
+
* The install's SIP roots, split as Twilio does: carriers reach trunks at
|
|
128
|
+
* `<label>.pstn.<domain>`, phones register on domains at `<label>.sip.<domain>`.
|
|
129
|
+
*/
|
|
130
|
+
exports.PSTN_ROOT = `pstn.${config.domain}`;
|
|
131
|
+
exports.SIP_ROOT = `sip.${config.domain}`;
|
|
132
|
+
const strictNames = config.features.sip.names === "domain";
|
|
133
|
+
/** Where trunk inbound URIs must live, or undefined when features.sip.names is "any". */
|
|
134
|
+
exports.TRUNK_NAMES_ROOT = strictNames ? exports.PSTN_ROOT : undefined;
|
|
135
|
+
/** Where domains must live, or undefined when features.sip.names is "any". */
|
|
136
|
+
exports.DOMAIN_NAMES_ROOT = strictNames ? exports.SIP_ROOT : undefined;
|
package/dist/index.js
CHANGED
|
@@ -48,16 +48,23 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
48
48
|
const common_1 = require("@fonoster/common");
|
|
49
49
|
const identity_1 = require("@fonoster/identity");
|
|
50
50
|
const logger_1 = require("@fonoster/logger");
|
|
51
|
+
const config_1 = require("./config");
|
|
52
|
+
const applyCatalog_1 = require("./core/applyCatalog");
|
|
53
|
+
const db_1 = require("./core/db");
|
|
51
54
|
const identityConfig_1 = require("./core/identityConfig");
|
|
52
55
|
const runServices_1 = __importDefault(require("./core/runServices"));
|
|
53
|
-
const
|
|
56
|
+
const upsertRoomrPeer_1 = require("./core/upsertRoomrPeer");
|
|
54
57
|
const envs_1 = require("./envs");
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
const
|
|
58
|
+
// Apply fonoster.yaml to the shared modules before serving. Loggers created
|
|
59
|
+
// while the imports above ran switch to the file's settings here.
|
|
60
|
+
const config = (0, config_1.getConfig)();
|
|
61
|
+
(0, logger_1.configureLogger)(config.logs);
|
|
62
|
+
(0, common_1.setRootDomain)(config.domain);
|
|
58
63
|
Promise.resolve().then(() => __importStar(require("./core/removeSwaggerNotice")));
|
|
59
64
|
function main() {
|
|
60
65
|
return __awaiter(this, void 0, void 0, function* () {
|
|
66
|
+
var _a;
|
|
67
|
+
yield (0, identity_1.migratePasswordStorage)(identityConfig_1.identityConfig);
|
|
61
68
|
if (envs_1.OWNER_EMAIL) {
|
|
62
69
|
const user = {
|
|
63
70
|
name: envs_1.OWNER_NAME,
|
|
@@ -66,26 +73,37 @@ function main() {
|
|
|
66
73
|
};
|
|
67
74
|
yield (0, identity_1.upsertDefaultUser)(identityConfig_1.identityConfig, user);
|
|
68
75
|
}
|
|
69
|
-
//
|
|
70
|
-
|
|
76
|
+
// The provider catalog (add-self-host-installer D7): applied on every start, idempotent. A
|
|
77
|
+
// configured file that can't be read or applied stops the server (IC-B2).
|
|
78
|
+
if (config.catalog) {
|
|
79
|
+
// `file`, then each of `files` (a stack's own catalogs, e.g. the fakes in dev and tests).
|
|
80
|
+
const files = [
|
|
81
|
+
{ file: config.catalog.file, key: "catalog.file" },
|
|
82
|
+
...((_a = config.catalog.files) !== null && _a !== void 0 ? _a : []).map((file, i) => ({
|
|
83
|
+
file,
|
|
84
|
+
key: `catalog.files[${i}]`
|
|
85
|
+
}))
|
|
86
|
+
];
|
|
87
|
+
for (const { file, key } of files) {
|
|
88
|
+
try {
|
|
89
|
+
const lines = yield (0, applyCatalog_1.applyCatalog)(file, db_1.prisma, key);
|
|
90
|
+
logger.info(lines[0] === "no changes"
|
|
91
|
+
? "catalog: no changes"
|
|
92
|
+
: `catalog: ${lines.length} entries added or changed`, { file });
|
|
93
|
+
}
|
|
94
|
+
catch (e) {
|
|
95
|
+
logger.error(`catalog: ${e.message}`);
|
|
96
|
+
process.exit(1);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
// The roomr peer every app-linked number points at (add-roomr 4.1). Runs in the
|
|
101
|
+
// background: it waits for Routr, which may start after the API server.
|
|
102
|
+
(0, upsertRoomrPeer_1.upsertRoomrPeer)().catch(logger.error);
|
|
71
103
|
// Start the gRPC server
|
|
72
104
|
(0, runServices_1.default)().catch(logger.error);
|
|
73
|
-
const pubToInfluxDb = (0, createInfluxDbPub_1.createInfluxDbPub)({
|
|
74
|
-
url: envs_1.INFLUXDB_URL,
|
|
75
|
-
token: envs_1.INFLUXDB_TOKEN,
|
|
76
|
-
org: envs_1.INFLUXDB_ORG,
|
|
77
|
-
bucket: common_1.INFLUXDB_CALLS_BUCKET
|
|
78
|
-
});
|
|
79
|
-
// Subscribe to NATs events
|
|
80
|
-
(0, nats_1.watchNats)(envs_1.NATS_URL, (event) => {
|
|
81
|
-
logger.verbose("received nats event", Object.assign({}, event));
|
|
82
|
-
pubToInfluxDb({
|
|
83
|
-
name: common_1.CALL_DETAIL_RECORD_MEASUREMENT,
|
|
84
|
-
tag: event.callId,
|
|
85
|
-
data: (0, transformEvent_1.transformEvent)(event)
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
105
|
});
|
|
89
106
|
}
|
|
90
107
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
108
|
+
(0, common_1.logUnhandledRejections)(logger);
|
|
91
109
|
main().catch(logger.error);
|
|
@@ -0,0 +1,86 @@
|
|
|
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
|
+
/** One Roomr node as its heartbeats describe it (media-control, node.heartbeat). */
|
|
20
|
+
export type RoomrStatus = {
|
|
21
|
+
/** The heartbeat's node_ref. */
|
|
22
|
+
nodeId: string;
|
|
23
|
+
rooms: number;
|
|
24
|
+
/** The node's room limit (max_rooms); unset for nodes that report none. */
|
|
25
|
+
maxRooms?: number;
|
|
26
|
+
/** The node's region; unset for nodes that report none. */
|
|
27
|
+
region?: string;
|
|
28
|
+
/**
|
|
29
|
+
* The node said `node.down` (it is draining or exiting) and has not sent a heartbeat since: it
|
|
30
|
+
* takes no new calls, but its live calls are not failed for it (see `live`).
|
|
31
|
+
*/
|
|
32
|
+
down: boolean;
|
|
33
|
+
/** Where the node serves Roomr (the heartbeat's control_addr); unset: no calls placed on it. */
|
|
34
|
+
controlAddr?: string;
|
|
35
|
+
seenAt: number;
|
|
36
|
+
};
|
|
37
|
+
/** The room limit assumed for a node that reports none (the Roomr node's default). */
|
|
38
|
+
export declare const DEFAULT_MAX_ROOMS = 200;
|
|
39
|
+
/** Heartbeats are every 2 s; a node silent for three of them is not offered new calls. */
|
|
40
|
+
export declare const NODE_STALE_MS = 6000;
|
|
41
|
+
/**
|
|
42
|
+
* A node silent this long is forgotten. A crashed or replaced node sends no `node.down` and its
|
|
43
|
+
* registry lease expires without a delete event, so silence is the only sign it is gone.
|
|
44
|
+
*/
|
|
45
|
+
export declare const NODE_FORGET_MS = 60000;
|
|
46
|
+
/**
|
|
47
|
+
* The Roomr nodes this replica knows, for placing outbound calls (add-roomr 3.3): fed by
|
|
48
|
+
* the `node.heartbeat` / `node.down` events on `roomr.nodes.<node_ref>.heartbeat` (core NATS;
|
|
49
|
+
* nodes write nothing else). `node.down` only takes the node out of placement: a draining node
|
|
50
|
+
* keeps its live rooms and sends no heartbeats, so it is "gone" only after it stays silent for
|
|
51
|
+
* `staleMs` past its `node.down`.
|
|
52
|
+
*/
|
|
53
|
+
export declare function createNodeDirectory(options?: {
|
|
54
|
+
staleMs?: number;
|
|
55
|
+
forgetMs?: number;
|
|
56
|
+
now?: () => number;
|
|
57
|
+
}): {
|
|
58
|
+
/**
|
|
59
|
+
* Feeds one `node.heartbeat` or `node.down` event; `seenAt` (ms) is when it was written, for
|
|
60
|
+
* registry entries read after the fact (default now).
|
|
61
|
+
*/
|
|
62
|
+
note(event: Record<string, unknown>, seenAt?: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* The eligible node with the most room to spare (control-plane): live, not down, below
|
|
65
|
+
* its room limit, with a control address and, when the call names a region, in that region; scored
|
|
66
|
+
* `1 - rooms / max_rooms`, highest wins. Skips the nodes in `exclude` (already tried for
|
|
67
|
+
* this call); undefined when there is none.
|
|
68
|
+
*/
|
|
69
|
+
pick(exclude?: ReadonlySet<string>, region?: string): string | undefined;
|
|
70
|
+
/**
|
|
71
|
+
* A node refused a room because it is full or unavailable: no new call goes to it until
|
|
72
|
+
* its next heartbeat says otherwise.
|
|
73
|
+
*/
|
|
74
|
+
refused(nodeId: string, code: string): void;
|
|
75
|
+
/**
|
|
76
|
+
* Whether the node is still there: a heartbeat, or its `node.down`, is fresh. A node that
|
|
77
|
+
* said `node.down` stays live for `staleMs` more; after that, silence means it exited.
|
|
78
|
+
*/
|
|
79
|
+
live(nodeId: string): boolean;
|
|
80
|
+
/** The node's Roomr address (control_addr), if known. */
|
|
81
|
+
addressOf(nodeId: string): string | undefined;
|
|
82
|
+
/** Counts a room placed on a node before its next heartbeat reports it. */
|
|
83
|
+
placed(nodeId: string): void;
|
|
84
|
+
list(): RoomrStatus[];
|
|
85
|
+
};
|
|
86
|
+
export type NodeDirectory = ReturnType<typeof createNodeDirectory>;
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NODE_FORGET_MS = exports.NODE_STALE_MS = exports.DEFAULT_MAX_ROOMS = void 0;
|
|
4
|
+
exports.createNodeDirectory = createNodeDirectory;
|
|
5
|
+
/** The room limit assumed for a node that reports none (the Roomr node's default). */
|
|
6
|
+
exports.DEFAULT_MAX_ROOMS = 200;
|
|
7
|
+
/** Heartbeats are every 2 s; a node silent for three of them is not offered new calls. */
|
|
8
|
+
exports.NODE_STALE_MS = 6000;
|
|
9
|
+
/**
|
|
10
|
+
* A node silent this long is forgotten. A crashed or replaced node sends no `node.down` and its
|
|
11
|
+
* registry lease expires without a delete event, so silence is the only sign it is gone.
|
|
12
|
+
*/
|
|
13
|
+
exports.NODE_FORGET_MS = 60000;
|
|
14
|
+
/**
|
|
15
|
+
* The Roomr nodes this replica knows, for placing outbound calls (add-roomr 3.3): fed by
|
|
16
|
+
* the `node.heartbeat` / `node.down` events on `roomr.nodes.<node_ref>.heartbeat` (core NATS;
|
|
17
|
+
* nodes write nothing else). `node.down` only takes the node out of placement: a draining node
|
|
18
|
+
* keeps its live rooms and sends no heartbeats, so it is "gone" only after it stays silent for
|
|
19
|
+
* `staleMs` past its `node.down`.
|
|
20
|
+
*/
|
|
21
|
+
function createNodeDirectory(options = {}) {
|
|
22
|
+
var _a, _b, _c;
|
|
23
|
+
const staleMs = (_a = options.staleMs) !== null && _a !== void 0 ? _a : exports.NODE_STALE_MS;
|
|
24
|
+
const forgetMs = Math.max((_b = options.forgetMs) !== null && _b !== void 0 ? _b : exports.NODE_FORGET_MS, staleMs);
|
|
25
|
+
const now = (_c = options.now) !== null && _c !== void 0 ? _c : Date.now;
|
|
26
|
+
const nodes = new Map();
|
|
27
|
+
let sweptAt = now();
|
|
28
|
+
/** Drops the nodes silent for `forgetMs` (at most once per `staleMs`). */
|
|
29
|
+
const forget = () => {
|
|
30
|
+
const t = now();
|
|
31
|
+
if (t - sweptAt < staleMs)
|
|
32
|
+
return;
|
|
33
|
+
sweptAt = t;
|
|
34
|
+
for (const [id, n] of nodes)
|
|
35
|
+
if (t - n.seenAt > forgetMs)
|
|
36
|
+
nodes.delete(id);
|
|
37
|
+
};
|
|
38
|
+
return {
|
|
39
|
+
/**
|
|
40
|
+
* Feeds one `node.heartbeat` or `node.down` event; `seenAt` (ms) is when it was written, for
|
|
41
|
+
* registry entries read after the fact (default now).
|
|
42
|
+
*/
|
|
43
|
+
note(event, seenAt) {
|
|
44
|
+
var _a;
|
|
45
|
+
const nodeId = typeof event.node_ref === "string" ? event.node_ref : "";
|
|
46
|
+
if (!nodeId)
|
|
47
|
+
return;
|
|
48
|
+
if (event.type === "node.down") {
|
|
49
|
+
const known = nodes.get(nodeId);
|
|
50
|
+
if (known) {
|
|
51
|
+
known.down = true;
|
|
52
|
+
known.seenAt = seenAt !== null && seenAt !== void 0 ? seenAt : now();
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
else if (event.type === "node.heartbeat") {
|
|
56
|
+
const at = seenAt !== null && seenAt !== void 0 ? seenAt : now();
|
|
57
|
+
const known = nodes.get(nodeId);
|
|
58
|
+
// An older registry entry never replaces a fresher heartbeat.
|
|
59
|
+
if (known && known.seenAt > at)
|
|
60
|
+
return;
|
|
61
|
+
const maxRooms = Number(event.max_rooms);
|
|
62
|
+
nodes.set(nodeId, {
|
|
63
|
+
nodeId,
|
|
64
|
+
rooms: Number((_a = event.rooms) !== null && _a !== void 0 ? _a : 0),
|
|
65
|
+
maxRooms: Number.isFinite(maxRooms) && maxRooms > 0 ? maxRooms : undefined,
|
|
66
|
+
region: typeof event.region === "string" && event.region
|
|
67
|
+
? event.region
|
|
68
|
+
: undefined,
|
|
69
|
+
down: false,
|
|
70
|
+
controlAddr: typeof event.control_addr === "string" && event.control_addr
|
|
71
|
+
? event.control_addr
|
|
72
|
+
: undefined,
|
|
73
|
+
seenAt: at
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
forget();
|
|
77
|
+
},
|
|
78
|
+
/**
|
|
79
|
+
* The eligible node with the most room to spare (control-plane): live, not down, below
|
|
80
|
+
* its room limit, with a control address and, when the call names a region, in that region; scored
|
|
81
|
+
* `1 - rooms / max_rooms`, highest wins. Skips the nodes in `exclude` (already tried for
|
|
82
|
+
* this call); undefined when there is none.
|
|
83
|
+
*/
|
|
84
|
+
pick(exclude = new Set(), region) {
|
|
85
|
+
var _a;
|
|
86
|
+
let best;
|
|
87
|
+
for (const n of nodes.values()) {
|
|
88
|
+
if (exclude.has(n.nodeId) || n.down || !n.controlAddr)
|
|
89
|
+
continue;
|
|
90
|
+
if (now() - n.seenAt > staleMs)
|
|
91
|
+
continue;
|
|
92
|
+
if (region && n.region !== region)
|
|
93
|
+
continue;
|
|
94
|
+
const limit = (_a = n.maxRooms) !== null && _a !== void 0 ? _a : exports.DEFAULT_MAX_ROOMS;
|
|
95
|
+
if (n.rooms >= limit)
|
|
96
|
+
continue;
|
|
97
|
+
const score = 1 - n.rooms / limit;
|
|
98
|
+
if (!best || score > best.score)
|
|
99
|
+
best = { node: n, score };
|
|
100
|
+
}
|
|
101
|
+
return best === null || best === void 0 ? void 0 : best.node.nodeId;
|
|
102
|
+
},
|
|
103
|
+
/**
|
|
104
|
+
* A node refused a room because it is full or unavailable: no new call goes to it until
|
|
105
|
+
* its next heartbeat says otherwise.
|
|
106
|
+
*/
|
|
107
|
+
refused(nodeId, code) {
|
|
108
|
+
var _a;
|
|
109
|
+
const n = nodes.get(nodeId);
|
|
110
|
+
if (!n)
|
|
111
|
+
return;
|
|
112
|
+
if (code === "unavailable")
|
|
113
|
+
n.down = true;
|
|
114
|
+
else
|
|
115
|
+
n.maxRooms = Math.min((_a = n.maxRooms) !== null && _a !== void 0 ? _a : n.rooms, n.rooms);
|
|
116
|
+
},
|
|
117
|
+
/**
|
|
118
|
+
* Whether the node is still there: a heartbeat, or its `node.down`, is fresh. A node that
|
|
119
|
+
* said `node.down` stays live for `staleMs` more; after that, silence means it exited.
|
|
120
|
+
*/
|
|
121
|
+
live(nodeId) {
|
|
122
|
+
const n = nodes.get(nodeId);
|
|
123
|
+
return !!n && now() - n.seenAt <= staleMs;
|
|
124
|
+
},
|
|
125
|
+
/** The node's Roomr address (control_addr), if known. */
|
|
126
|
+
addressOf(nodeId) {
|
|
127
|
+
var _a;
|
|
128
|
+
return (_a = nodes.get(nodeId)) === null || _a === void 0 ? void 0 : _a.controlAddr;
|
|
129
|
+
},
|
|
130
|
+
/** Counts a room placed on a node before its next heartbeat reports it. */
|
|
131
|
+
placed(nodeId) {
|
|
132
|
+
const n = nodes.get(nodeId);
|
|
133
|
+
if (n)
|
|
134
|
+
n.rooms += 1;
|
|
135
|
+
},
|
|
136
|
+
list() {
|
|
137
|
+
return [...nodes.values()];
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
}
|
|
@@ -16,4 +16,7 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
export * from "./
|
|
19
|
+
export * from "./createNodeDirectory";
|
|
20
|
+
export * from "./placeOutboundCall";
|
|
21
|
+
export * from "./placementSweep";
|
|
22
|
+
export * from "./runOutboundCalls";
|
|
@@ -32,5 +32,7 @@ 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("./
|
|
36
|
-
__exportStar(require("./
|
|
35
|
+
__exportStar(require("./createNodeDirectory"), exports);
|
|
36
|
+
__exportStar(require("./placeOutboundCall"), exports);
|
|
37
|
+
__exportStar(require("./placementSweep"), exports);
|
|
38
|
+
__exportStar(require("./runOutboundCalls"), exports);
|