@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
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SHARED_VALUE_PATHS = exports.fonosterConfigSchema = exports.featuresSchema = 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 common_1 = require("@fonoster/common");
|
|
23
|
+
const identity_1 = require("@fonoster/identity");
|
|
24
|
+
const zod_1 = require("zod");
|
|
25
|
+
/** Product features. Code checks these, never an edition. Community defaults. */
|
|
26
|
+
const featuresSchema = zod_1.z
|
|
27
|
+
.object({
|
|
28
|
+
auth: identity_1.authFeaturesSchema,
|
|
29
|
+
billing: zod_1.z
|
|
30
|
+
.object({
|
|
31
|
+
enabled: zod_1.z.boolean().default(false),
|
|
32
|
+
/** The billing service's Billing API (host:port); defaults to authz.host:50073. */
|
|
33
|
+
address: zod_1.z.string().min(1).optional()
|
|
34
|
+
})
|
|
35
|
+
.default({}),
|
|
36
|
+
costs: zod_1.z
|
|
37
|
+
.object({ display: zod_1.z.enum(["none", "usage", "prices"]).default("usage") })
|
|
38
|
+
.default({}),
|
|
39
|
+
calls: zod_1.z
|
|
40
|
+
.object({
|
|
41
|
+
transcripts: zod_1.z
|
|
42
|
+
.object({
|
|
43
|
+
store: zod_1.z.boolean().default(true),
|
|
44
|
+
retentionDays: zod_1.z.number().int().positive().default(30)
|
|
45
|
+
})
|
|
46
|
+
.default({}),
|
|
47
|
+
recordings: zod_1.z.object({ store: zod_1.z.boolean().default(false) }).default({})
|
|
48
|
+
})
|
|
49
|
+
.default({}),
|
|
50
|
+
/**
|
|
51
|
+
* SIP names (trunk inbound URIs, domains): "domain" requires one DNS label
|
|
52
|
+
* under `sip.<domain>` (carriers and phones reach a wildcard `*.sip.<domain>`);
|
|
53
|
+
* "any" accepts any host or IP, for installs reached by address.
|
|
54
|
+
*/
|
|
55
|
+
sip: zod_1.z
|
|
56
|
+
.object({ names: zod_1.z.enum(["domain", "any"]).default("domain") })
|
|
57
|
+
.default({})
|
|
58
|
+
})
|
|
59
|
+
.default({});
|
|
60
|
+
exports.featuresSchema = featuresSchema;
|
|
61
|
+
/** Where call records live (add-call-record): a directory, or S3-compatible storage. */
|
|
62
|
+
const recordStoreSchema = zod_1.z.union([
|
|
63
|
+
zod_1.z.object({ dir: zod_1.z.string().min(1) }),
|
|
64
|
+
zod_1.z.object({
|
|
65
|
+
s3: zod_1.z.object({
|
|
66
|
+
bucket: zod_1.z.string().min(1),
|
|
67
|
+
prefix: zod_1.z.string().optional(),
|
|
68
|
+
region: zod_1.z.string().optional(),
|
|
69
|
+
endpoint: zod_1.z.string().optional(),
|
|
70
|
+
forcePathStyle: zod_1.z.boolean().optional(),
|
|
71
|
+
credentials: zod_1.z
|
|
72
|
+
.object({
|
|
73
|
+
accessKeyId: zod_1.z.string().min(1),
|
|
74
|
+
secretAccessKey: zod_1.z.string().min(1)
|
|
75
|
+
})
|
|
76
|
+
.optional()
|
|
77
|
+
})
|
|
78
|
+
})
|
|
79
|
+
]);
|
|
80
|
+
/**
|
|
81
|
+
* Call records (add-call-record): the index, the records API (ListCalls and GetCall read the
|
|
82
|
+
* index), and retention. `stores` are the record stores the API reads from (the regions' and
|
|
83
|
+
* any workspace buckets), matched by the location in each index entry.
|
|
84
|
+
*/
|
|
85
|
+
const callRecordsSchema = zod_1.z
|
|
86
|
+
.object({
|
|
87
|
+
enabled: zod_1.z.boolean().default(true),
|
|
88
|
+
stores: zod_1.z.array(recordStoreSchema).default([]),
|
|
89
|
+
retentionIntervalMinutes: zod_1.z.number().int().positive().default(60),
|
|
90
|
+
maintenanceTimeoutMs: zod_1.z.number().int().positive().default(30000)
|
|
91
|
+
})
|
|
92
|
+
.default({});
|
|
93
|
+
/**
|
|
94
|
+
* Session apps (voice-session G2): the hosted Autopilot that Autopilot apps point at, and the
|
|
95
|
+
* secret AppBridge signs their sessions with (the hosted Autopilot verifies one secret for every
|
|
96
|
+
* Autopilot app). Without `signingSecret` each Autopilot app gets its own random secret.
|
|
97
|
+
*/
|
|
98
|
+
const sessionAppsSchema = zod_1.z
|
|
99
|
+
.object({
|
|
100
|
+
autopilotUrl: zod_1.z.string().min(1).default("ws://autopilot:50061"),
|
|
101
|
+
autopilotSigningSecret: zod_1.z.string().min(1).optional(),
|
|
102
|
+
/** Plain http:// webhook endpoints (local testing only). */
|
|
103
|
+
allowInsecureWebhooks: zod_1.z.boolean().default(false),
|
|
104
|
+
/**
|
|
105
|
+
* Private hosts, IPs or CIDRs app and listener URLs may use (self-hosting); default
|
|
106
|
+
* FONOSTER_ALLOWED_DESTINATIONS.
|
|
107
|
+
*/
|
|
108
|
+
allowedDestinations: zod_1.z.array(zod_1.z.string().min(1)).optional()
|
|
109
|
+
})
|
|
110
|
+
.default({});
|
|
111
|
+
/**
|
|
112
|
+
* The provider catalog file (add-self-host-installer D7): applied to the registry tables on
|
|
113
|
+
* every start with `fonoster-registry apply --store database` semantics. Listed entries are added
|
|
114
|
+
* or updated; entries not in the file (operator-added) are kept. Absent: nothing is applied.
|
|
115
|
+
*
|
|
116
|
+
* `files` are applied after `file`, in order (a stack's own catalogs, such as the fakes'
|
|
117
|
+
* mods/conformance/fakes.catalog.yaml in dev and test stacks).
|
|
118
|
+
*/
|
|
119
|
+
const catalogSchema = zod_1.z
|
|
120
|
+
.object({
|
|
121
|
+
file: zod_1.z.string().min(1),
|
|
122
|
+
files: zod_1.z.array(zod_1.z.string().min(1)).optional()
|
|
123
|
+
})
|
|
124
|
+
.optional();
|
|
125
|
+
/**
|
|
126
|
+
* Agent evaluations (EvaluateIntelligence): platform model keys by credentialRef, used when a
|
|
127
|
+
* workspace has no key of its own for the provider. Values take `secret://` references (D8).
|
|
128
|
+
*/
|
|
129
|
+
const evaluationsSchema = zod_1.z
|
|
130
|
+
.object({ credentials: zod_1.z.record(zod_1.z.string().min(1)).default({}) })
|
|
131
|
+
.default({});
|
|
132
|
+
/**
|
|
133
|
+
* Workspace webhooks fan-out (add-workspace-webhooks 2.2): events producers publish on the bus
|
|
134
|
+
* (`webhooks.events`) are delivered from here.
|
|
135
|
+
*/
|
|
136
|
+
const webhooksSchema = zod_1.z
|
|
137
|
+
.object({
|
|
138
|
+
fanout: zod_1.z.boolean().default(true),
|
|
139
|
+
intervalMs: zod_1.z.number().int().positive().default(1000),
|
|
140
|
+
refreshMs: zod_1.z.number().int().positive().default(10000)
|
|
141
|
+
})
|
|
142
|
+
.default({});
|
|
143
|
+
/**
|
|
144
|
+
* Regions (add-private-regions). Public regions come from data (PR-10); private regions need the
|
|
145
|
+
* region-signing key (ES256 PEM) and the region hub (NATS in operator mode, RG-B2), both generated
|
|
146
|
+
* by `fonoster-region-hub-setup`. Without them, workspaces can only pick a public region.
|
|
147
|
+
*/
|
|
148
|
+
const regionsSchema = zod_1.z
|
|
149
|
+
.object({
|
|
150
|
+
public: zod_1.z
|
|
151
|
+
.array(zod_1.z.object({
|
|
152
|
+
id: zod_1.z.string().regex(/^[a-z0-9-]+$/),
|
|
153
|
+
name: zod_1.z.string().min(1),
|
|
154
|
+
default: zod_1.z.boolean().optional(),
|
|
155
|
+
/** Where carriers and softphones reach this region (contract §3a). */
|
|
156
|
+
endpoints: zod_1.z
|
|
157
|
+
.object({
|
|
158
|
+
sip: zod_1.z
|
|
159
|
+
.array(zod_1.z.object({
|
|
160
|
+
host: zod_1.z.string().min(1),
|
|
161
|
+
// coerce: usually "${SIP_PORT}", a string until resolved.
|
|
162
|
+
port: zod_1.z.coerce.number().int().min(1).max(65535),
|
|
163
|
+
transport: zod_1.z.enum(["udp", "tcp", "tls", "ws", "wss"])
|
|
164
|
+
}))
|
|
165
|
+
.default([]),
|
|
166
|
+
signalingAddresses: zod_1.z.array(zod_1.z.string().min(1)).default([]),
|
|
167
|
+
mediaAddresses: zod_1.z.array(zod_1.z.string().min(1)).default([]),
|
|
168
|
+
rtpPorts: zod_1.z
|
|
169
|
+
.object({
|
|
170
|
+
min: zod_1.z.coerce.number().int().min(1).max(65535),
|
|
171
|
+
max: zod_1.z.coerce.number().int().min(1).max(65535)
|
|
172
|
+
})
|
|
173
|
+
.optional()
|
|
174
|
+
})
|
|
175
|
+
.optional()
|
|
176
|
+
}))
|
|
177
|
+
.min(1)
|
|
178
|
+
.default([{ id: "default", name: "Default", default: true }]),
|
|
179
|
+
/**
|
|
180
|
+
* The operator key (PR-19): the only credential of the region admin API (create, list,
|
|
181
|
+
* publish, revoke public regions). `secret://` references are resolved. Absent: admin API off.
|
|
182
|
+
*/
|
|
183
|
+
operatorKey: zod_1.z.string().min(16).optional(),
|
|
184
|
+
/** The flat monthly fee per private region (PR-11), shown when billing is on. */
|
|
185
|
+
privateRegionMonthlyFeeCents: zod_1.z.number().int().nonnegative().optional(),
|
|
186
|
+
/** `cp` in enrollment tokens. Defaults to appUrl. */
|
|
187
|
+
controlPlaneUrl: zod_1.z.string().min(1).optional(),
|
|
188
|
+
/** `leaf` in enrollment tokens. Defaults to tls://<domain>:7422. */
|
|
189
|
+
leafUrl: zod_1.z.string().min(1).optional(),
|
|
190
|
+
/** Allows a plain nats:// leaf URL (local stacks only). */
|
|
191
|
+
allowInsecureLeaf: zod_1.z.boolean().default(false),
|
|
192
|
+
signingKey: zod_1.z
|
|
193
|
+
.object({ file: zod_1.z.string().min(1), kid: zod_1.z.string().min(1).optional() })
|
|
194
|
+
.optional(),
|
|
195
|
+
hub: zod_1.z
|
|
196
|
+
.object({
|
|
197
|
+
url: zod_1.z.string().min(1),
|
|
198
|
+
credentialsFile: zod_1.z.string().min(1),
|
|
199
|
+
systemCredentialsFile: zod_1.z.string().min(1),
|
|
200
|
+
operatorSeedFile: zod_1.z.string().min(1),
|
|
201
|
+
accountSeedFile: zod_1.z.string().min(1)
|
|
202
|
+
})
|
|
203
|
+
.optional(),
|
|
204
|
+
relay: zod_1.z
|
|
205
|
+
.object({
|
|
206
|
+
firstChunkTimeoutMs: zod_1.z.number().int().positive().default(5000),
|
|
207
|
+
idleTimeoutMs: zod_1.z.number().int().positive().default(10000),
|
|
208
|
+
maxBytes: zod_1.z
|
|
209
|
+
.number()
|
|
210
|
+
.int()
|
|
211
|
+
.positive()
|
|
212
|
+
.default(256 * 1024 * 1024),
|
|
213
|
+
/** Relays in flight per region (HTTP 429 beyond). */
|
|
214
|
+
maxConcurrent: zod_1.z.number().int().positive().default(8)
|
|
215
|
+
})
|
|
216
|
+
.default({}),
|
|
217
|
+
/** The release cells are measured against (default: this apiserver's version). */
|
|
218
|
+
currentVersion: zod_1.z.string().optional(),
|
|
219
|
+
configDebounceMs: zod_1.z.number().int().nonnegative().default(500)
|
|
220
|
+
})
|
|
221
|
+
.default({});
|
|
222
|
+
/** fonoster.yaml: everything the API server (and embedded Identity) needs. */
|
|
223
|
+
const fonosterConfigSchema = zod_1.z
|
|
224
|
+
.object({
|
|
225
|
+
/** Public hostname. Sets the defaults for appUrl, signalingServer and the SIP root domain. */
|
|
226
|
+
domain: zod_1.z.string().min(1),
|
|
227
|
+
/** Links in emails. Defaults to https://<domain>. */
|
|
228
|
+
appUrl: zod_1.z.string().min(1).optional(),
|
|
229
|
+
/** Browser test calls: SIP over WebSocket. Defaults to ws(s)://<appUrl host>/sip. */
|
|
230
|
+
signalingServer: zod_1.z.string().min(1).optional(),
|
|
231
|
+
server: zod_1.z
|
|
232
|
+
.object({
|
|
233
|
+
bindAddr: zod_1.z.string().default("0.0.0.0:50051"),
|
|
234
|
+
httpBridgePort: zod_1.z.number().int().positive().default(9876),
|
|
235
|
+
/** How other services reach this one. */
|
|
236
|
+
host: zod_1.z.string().default("apiserver")
|
|
237
|
+
})
|
|
238
|
+
.default({}),
|
|
239
|
+
logs: common_1.logsSchema,
|
|
240
|
+
/** OTLP export (empty = off): `otlpEndpoint: "${OTEL_EXPORTER_OTLP_ENDPOINT:-}"`. */
|
|
241
|
+
telemetry: common_1.telemetrySchema,
|
|
242
|
+
database: zod_1.z.object({ url: zod_1.z.string().min(1) }),
|
|
243
|
+
encryption: zod_1.z.object({ key: identity_1.encryptionKeySchema }),
|
|
244
|
+
smtp: identity_1.smtpSchema.optional(),
|
|
245
|
+
authz: zod_1.z
|
|
246
|
+
.object({
|
|
247
|
+
enabled: zod_1.z.boolean().default(false),
|
|
248
|
+
host: zod_1.z.string().min(1).optional(),
|
|
249
|
+
port: zod_1.z.number().int().positive().default(50071),
|
|
250
|
+
methods: zod_1.z
|
|
251
|
+
.array(zod_1.z.string().min(1))
|
|
252
|
+
.default(["/fonoster.calls.v1beta2.Calls/CreateCall"])
|
|
253
|
+
})
|
|
254
|
+
.default({}),
|
|
255
|
+
features: featuresSchema,
|
|
256
|
+
routr: zod_1.z
|
|
257
|
+
.object({
|
|
258
|
+
apiEndpoint: zod_1.z.string().default("routr:51907"),
|
|
259
|
+
/**
|
|
260
|
+
* host:port of Routr's SIP listener: API-originated calls are dialed through it
|
|
261
|
+
* (CreateCall's to.proxy), as the roomr peer below (to.auth).
|
|
262
|
+
*/
|
|
263
|
+
sipProxy: zod_1.z.string().default("routr:5060"),
|
|
264
|
+
/**
|
|
265
|
+
* The peer Go Roomr nodes register under (least-sessions, add-roomr 4.1). Without a
|
|
266
|
+
* password the apiserver does not create it.
|
|
267
|
+
*/
|
|
268
|
+
roomrPeer: zod_1.z
|
|
269
|
+
.object({
|
|
270
|
+
aor: zod_1.z.string().default("sip:roomr@default"),
|
|
271
|
+
name: zod_1.z.string().default("Roomr nodes"),
|
|
272
|
+
username: zod_1.z.string().default("roomr"),
|
|
273
|
+
password: zod_1.z.string().optional()
|
|
274
|
+
})
|
|
275
|
+
.default({})
|
|
276
|
+
})
|
|
277
|
+
.default({}),
|
|
278
|
+
// user/password: the apiserver's NATS user when the server has per-service users
|
|
279
|
+
// (add-platform 4.1); password is usually a secret:// reference.
|
|
280
|
+
nats: zod_1.z.object({
|
|
281
|
+
url: zod_1.z.string().min(1),
|
|
282
|
+
user: zod_1.z.string().min(1).optional(),
|
|
283
|
+
password: zod_1.z.string().min(1).optional()
|
|
284
|
+
}),
|
|
285
|
+
evaluations: evaluationsSchema,
|
|
286
|
+
templatesDir: zod_1.z.string().optional(),
|
|
287
|
+
twilio: identity_1.twilioSchema.optional(),
|
|
288
|
+
identity: identity_1.identitySectionSchema,
|
|
289
|
+
callRecords: callRecordsSchema,
|
|
290
|
+
apps: sessionAppsSchema,
|
|
291
|
+
webhooks: webhooksSchema,
|
|
292
|
+
catalog: catalogSchema,
|
|
293
|
+
regions: regionsSchema
|
|
294
|
+
})
|
|
295
|
+
.superRefine((config, ctx) => {
|
|
296
|
+
var _a, _b;
|
|
297
|
+
if (config.authz.enabled && !config.authz.host) {
|
|
298
|
+
ctx.addIssue({
|
|
299
|
+
code: "custom",
|
|
300
|
+
path: ["authz", "host"],
|
|
301
|
+
message: "required when authz.enabled is true"
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
if (config.features.billing.enabled && !config.authz.enabled) {
|
|
305
|
+
ctx.addIssue({
|
|
306
|
+
code: "custom",
|
|
307
|
+
path: ["features", "billing", "enabled"],
|
|
308
|
+
message: "billing needs the authorization service (authz.enabled)"
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
if (config.features.auth.methods.includes("github") &&
|
|
312
|
+
!((_a = config.identity.oauth2) === null || _a === void 0 ? void 0 : _a.github)) {
|
|
313
|
+
ctx.addIssue({
|
|
314
|
+
code: "custom",
|
|
315
|
+
path: ["identity", "oauth2", "github"],
|
|
316
|
+
message: "required when features.auth.methods includes github"
|
|
317
|
+
});
|
|
318
|
+
}
|
|
319
|
+
// PR-17: the default public region's id is always `default`.
|
|
320
|
+
const publicRegions = config.regions.public;
|
|
321
|
+
const dflt = (_b = publicRegions.find((r) => r.default)) !== null && _b !== void 0 ? _b : publicRegions[0];
|
|
322
|
+
if (dflt && dflt.id !== "default") {
|
|
323
|
+
ctx.addIssue({
|
|
324
|
+
code: "custom",
|
|
325
|
+
path: ["regions", "public"],
|
|
326
|
+
message: "the default public region's id must be `default` (put the geography in its name)"
|
|
327
|
+
});
|
|
328
|
+
}
|
|
329
|
+
const leaf = config.regions.leafUrl;
|
|
330
|
+
if (leaf &&
|
|
331
|
+
!leaf.startsWith("tls://") &&
|
|
332
|
+
!config.regions.allowInsecureLeaf) {
|
|
333
|
+
ctx.addIssue({
|
|
334
|
+
code: "custom",
|
|
335
|
+
path: ["regions", "leafUrl"],
|
|
336
|
+
message: "must be tls:// unless regions.allowInsecureLeaf is true"
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
const { security } = config.identity;
|
|
340
|
+
if ((security.contactVerificationRequired ||
|
|
341
|
+
security.twoFactorAuthenticationRequired) &&
|
|
342
|
+
!config.twilio) {
|
|
343
|
+
ctx.addIssue({
|
|
344
|
+
code: "custom",
|
|
345
|
+
path: ["twilio"],
|
|
346
|
+
message: "required when contact verification or two-factor authentication is on"
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
});
|
|
350
|
+
exports.fonosterConfigSchema = fonosterConfigSchema;
|
|
351
|
+
/** Paths where ${VAR} may reference a value shared with another container. */
|
|
352
|
+
/**
|
|
353
|
+
* Where `${VAR}` may appear: every key (unify-config-placeholders). Secrets stay in `.env` and
|
|
354
|
+
* reach the container through Compose's env_file.
|
|
355
|
+
*/
|
|
356
|
+
const SHARED_VALUE_PATHS = ["*"];
|
|
357
|
+
exports.SHARED_VALUE_PATHS = SHARED_VALUE_PATHS;
|
package/dist/core/allowList.js
CHANGED
|
@@ -25,6 +25,7 @@ const identity_1 = require("@fonoster/identity");
|
|
|
25
25
|
// non-identity public methods.
|
|
26
26
|
const allowList = [
|
|
27
27
|
...identity_1.identityAllowList,
|
|
28
|
-
"/fonoster.voice.v1beta2.Voice/CreateSession"
|
|
28
|
+
"/fonoster.voice.v1beta2.Voice/CreateSession",
|
|
29
|
+
"/fonoster.capabilities.v1beta2.Capabilities/GetCapabilities"
|
|
29
30
|
];
|
|
30
31
|
exports.allowList = allowList;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Applies the provider catalog file (`catalog.file` in fonoster.yaml) to the registry tables:
|
|
3
|
+
* the same diff `fonoster-registry apply --store database` runs. Listed entries are added or
|
|
4
|
+
* updated; entries not in the file are kept. Equal entries write nothing, so a restart with the
|
|
5
|
+
* same file changes no rows. Returns the change lines (["no changes"] when there are none).
|
|
6
|
+
*/
|
|
7
|
+
declare function applyCatalog(file: string, prisma: any,
|
|
8
|
+
/** The config key that names the file, for errors and the audit log. */
|
|
9
|
+
key?: string): Promise<string[]>;
|
|
10
|
+
export { applyCatalog };
|
|
@@ -42,60 +42,54 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
42
42
|
});
|
|
43
43
|
};
|
|
44
44
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
-
exports.
|
|
45
|
+
exports.applyCatalog = applyCatalog;
|
|
46
|
+
/**
|
|
47
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
48
|
+
* http://github.com/fonoster/fonoster
|
|
49
|
+
*
|
|
50
|
+
* This file is part of Fonoster
|
|
51
|
+
*
|
|
52
|
+
* Licensed under the MIT License (the "License");
|
|
53
|
+
* you may not use this file except in compliance with
|
|
54
|
+
* the License. You may obtain a copy of the License at
|
|
55
|
+
*
|
|
56
|
+
* https://opensource.org/licenses/MIT
|
|
57
|
+
*
|
|
58
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
59
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
60
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
61
|
+
* See the License for the specific language governing permissions and
|
|
62
|
+
* limitations under the License.
|
|
63
|
+
*/
|
|
64
|
+
const fs = __importStar(require("fs"));
|
|
46
65
|
const common_1 = require("@fonoster/common");
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
metadata.add("accessKeyId", this.config.accessKeyId);
|
|
61
|
-
metadata.add("token", this.config.sessionToken);
|
|
62
|
-
this.voice = this.grpcClient.createSession(metadata);
|
|
63
|
-
this.setupEventHandlers();
|
|
64
|
-
// Initialize the session
|
|
65
|
-
this.voice.write({ request: this.config });
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
setupEventHandlers() {
|
|
69
|
-
this.voice.on(common_1.StreamEvent.DATA, (data) => {
|
|
70
|
-
this.verbsStream.emit(data.content, data);
|
|
71
|
-
});
|
|
72
|
-
this.voice.on(common_1.StreamEvent.ERROR, (error) => {
|
|
73
|
-
if (error.code === grpc.status.UNAVAILABLE) {
|
|
74
|
-
logger.error(`voice server not available at "${this.config.endpoint}"`);
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
logger.error(`grpc stream error: ${error.message}`);
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
getVoiceStream() {
|
|
81
|
-
return this.voice;
|
|
82
|
-
}
|
|
83
|
-
sendResponse(response) {
|
|
66
|
+
/**
|
|
67
|
+
* Applies the provider catalog file (`catalog.file` in fonoster.yaml) to the registry tables:
|
|
68
|
+
* the same diff `fonoster-registry apply --store database` runs. Listed entries are added or
|
|
69
|
+
* updated; entries not in the file are kept. Equal entries write nothing, so a restart with the
|
|
70
|
+
* same file changes no rows. Returns the change lines (["no changes"] when there are none).
|
|
71
|
+
*/
|
|
72
|
+
function applyCatalog(file_1, prisma_1) {
|
|
73
|
+
return __awaiter(this, arguments, void 0, function* (file,
|
|
74
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
75
|
+
prisma,
|
|
76
|
+
/** The config key that names the file, for errors and the audit log. */
|
|
77
|
+
key = "catalog.file") {
|
|
78
|
+
let content;
|
|
84
79
|
try {
|
|
85
|
-
|
|
86
|
-
}
|
|
87
|
-
catch (error) {
|
|
88
|
-
logger.error(`error sending response: ${error.message}`);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
close() {
|
|
92
|
-
try {
|
|
93
|
-
this.voice.end();
|
|
94
|
-
this.grpcClient.close();
|
|
80
|
+
content = fs.readFileSync(file, "utf8");
|
|
95
81
|
}
|
|
96
82
|
catch (e) {
|
|
97
|
-
|
|
83
|
+
throw new Error(`${key} ${file} could not be read: ${e.message}`);
|
|
98
84
|
}
|
|
99
|
-
|
|
85
|
+
const store = yield common_1.Registry.PrismaRegistryStore.open(prisma);
|
|
86
|
+
const registry = new common_1.Registry.Registry({
|
|
87
|
+
store,
|
|
88
|
+
actor: "apiserver",
|
|
89
|
+
commandLine: `apiserver ${key} ${file}`
|
|
90
|
+
});
|
|
91
|
+
const lines = registry.apply(content);
|
|
92
|
+
yield store.flush();
|
|
93
|
+
return lines;
|
|
94
|
+
});
|
|
100
95
|
}
|
|
101
|
-
exports.GrpcClientHandler = GrpcClientHandler;
|
package/dist/core/db.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ declare const prisma: import("@prisma/client/runtime/library").DynamicClientExte
|
|
|
3
3
|
model: {};
|
|
4
4
|
query: {};
|
|
5
5
|
client: {};
|
|
6
|
-
}, {}>, import(".prisma/client").Prisma.TypeMapCb<
|
|
6
|
+
}, {}>, import(".prisma/client").Prisma.TypeMapCb<{
|
|
7
|
+
datasourceUrl: string;
|
|
8
|
+
}>, {
|
|
7
9
|
result: {};
|
|
8
10
|
model: {};
|
|
9
11
|
query: {};
|
package/dist/core/db.js
CHANGED
|
@@ -22,8 +22,9 @@ exports.prisma = void 0;
|
|
|
22
22
|
const client_1 = require("@prisma/client");
|
|
23
23
|
const prisma_field_encryption_1 = require("prisma-field-encryption");
|
|
24
24
|
const envs_1 = require("../envs");
|
|
25
|
+
// The URL comes from fonoster.yaml, not the schema's env() reference.
|
|
25
26
|
// We encrypt all fields marked with /// encrypted in the schema
|
|
26
|
-
const prisma = new client_1.PrismaClient().$extends((0, prisma_field_encryption_1.fieldEncryptionExtension)({
|
|
27
|
+
const prisma = new client_1.PrismaClient({ datasourceUrl: envs_1.DATABASE_URL }).$extends((0, prisma_field_encryption_1.fieldEncryptionExtension)({
|
|
27
28
|
encryptionKey: envs_1.CLOAK_ENCRYPTION_KEY
|
|
28
29
|
}));
|
|
29
30
|
exports.prisma = prisma;
|
|
@@ -0,0 +1,41 @@
|
|
|
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 { JsMsg, MsgHdrs, NatsConnection } from "nats";
|
|
20
|
+
/**
|
|
21
|
+
* A JetStream work queue with one durable consumer shared by every apiserver replica (control
|
|
22
|
+
* plane "events on JetStream with queue groups … webhook dispatch as a JetStream consumer", ST-2).
|
|
23
|
+
* Producers keep publishing on the plain subject; the stream captures it. Each message goes to
|
|
24
|
+
* one replica and is acknowledged only after the handler resolved (its result is persisted), so a
|
|
25
|
+
* message taken by a replica that dies is redelivered to another after `ackWaitMs`. Handlers must
|
|
26
|
+
* be idempotent: a message can arrive more than once.
|
|
27
|
+
*/
|
|
28
|
+
export type DurableConsumerOptions = {
|
|
29
|
+
stream: string;
|
|
30
|
+
subject: string;
|
|
31
|
+
durable: string;
|
|
32
|
+
/** How long a taken message may stay unacknowledged before another replica gets it. */
|
|
33
|
+
ackWaitMs?: number;
|
|
34
|
+
/** How long a message the handler failed on waits before it is tried again. */
|
|
35
|
+
retryDelayMs?: number;
|
|
36
|
+
/** Messages nobody consumed are dropped after this long. */
|
|
37
|
+
maxAgeMs?: number;
|
|
38
|
+
/** A message the handler keeps failing on is dropped after this many deliveries. */
|
|
39
|
+
maxDeliver?: number;
|
|
40
|
+
};
|
|
41
|
+
export declare function consumeDurable(nc: NatsConnection, options: DurableConsumerOptions, handle: (data: Uint8Array, headers?: MsgHdrs) => Promise<void>, onError?: (e: Error, m: JsMsg) => void): Promise<() => Promise<void>>;
|
|
@@ -0,0 +1,104 @@
|
|
|
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 __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
12
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
13
|
+
var m = o[Symbol.asyncIterator], i;
|
|
14
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
15
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
16
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
17
|
+
};
|
|
18
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
+
exports.consumeDurable = consumeDurable;
|
|
20
|
+
/**
|
|
21
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
22
|
+
* http://github.com/fonoster/fonoster
|
|
23
|
+
*
|
|
24
|
+
* This file is part of Fonoster
|
|
25
|
+
*
|
|
26
|
+
* Licensed under the MIT License (the "License");
|
|
27
|
+
* you may not use this file except in compliance with
|
|
28
|
+
* the License. You may obtain a copy of the License at
|
|
29
|
+
*
|
|
30
|
+
* https://opensource.org/licenses/MIT
|
|
31
|
+
*
|
|
32
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
33
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
34
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
35
|
+
* See the License for the specific language governing permissions and
|
|
36
|
+
* limitations under the License.
|
|
37
|
+
*/
|
|
38
|
+
const nats_1 = require("nats");
|
|
39
|
+
const notFound = (e) => { var _a; return /not found/i.test((_a = e.message) !== null && _a !== void 0 ? _a : ""); };
|
|
40
|
+
const inUse = (e) => { var _a; return /already in use|already exists/i.test((_a = e.message) !== null && _a !== void 0 ? _a : ""); };
|
|
41
|
+
function consumeDurable(nc_1, options_1, handle_1) {
|
|
42
|
+
return __awaiter(this, arguments, void 0, function* (nc, options, handle, onError = () => undefined) {
|
|
43
|
+
var _a, _b, _c;
|
|
44
|
+
const jsm = yield nc.jetstreamManager();
|
|
45
|
+
try {
|
|
46
|
+
yield jsm.streams.info(options.stream);
|
|
47
|
+
}
|
|
48
|
+
catch (e) {
|
|
49
|
+
if (!notFound(e))
|
|
50
|
+
throw e;
|
|
51
|
+
try {
|
|
52
|
+
yield jsm.streams.add({
|
|
53
|
+
name: options.stream,
|
|
54
|
+
subjects: [options.subject],
|
|
55
|
+
retention: nats_1.RetentionPolicy.Workqueue,
|
|
56
|
+
storage: nats_1.StorageType.File,
|
|
57
|
+
max_age: (0, nats_1.nanos)((_a = options.maxAgeMs) !== null && _a !== void 0 ? _a : 24 * 3600000)
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
catch (e2) {
|
|
61
|
+
// Another replica created it at the same moment.
|
|
62
|
+
if (!inUse(e2))
|
|
63
|
+
throw e2;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
yield jsm.consumers.add(options.stream, {
|
|
67
|
+
durable_name: options.durable,
|
|
68
|
+
ack_policy: nats_1.AckPolicy.Explicit,
|
|
69
|
+
ack_wait: (0, nats_1.nanos)((_b = options.ackWaitMs) !== null && _b !== void 0 ? _b : 30000),
|
|
70
|
+
max_deliver: (_c = options.maxDeliver) !== null && _c !== void 0 ? _c : 100,
|
|
71
|
+
filter_subject: options.subject
|
|
72
|
+
});
|
|
73
|
+
const consumer = yield nc
|
|
74
|
+
.jetstream()
|
|
75
|
+
.consumers.get(options.stream, options.durable);
|
|
76
|
+
const messages = yield consumer.consume({ max_messages: 64 });
|
|
77
|
+
const loop = (() => __awaiter(this, void 0, void 0, function* () {
|
|
78
|
+
var _a, e_1, _b, _c;
|
|
79
|
+
try {
|
|
80
|
+
for (var _d = true, messages_1 = __asyncValues(messages), messages_1_1; messages_1_1 = yield messages_1.next(), _a = messages_1_1.done, !_a; _d = true) {
|
|
81
|
+
_c = messages_1_1.value;
|
|
82
|
+
_d = false;
|
|
83
|
+
const m = _c;
|
|
84
|
+
handle(m.data, m.headers).then(() => m.ack(), (e) => {
|
|
85
|
+
var _a;
|
|
86
|
+
onError(e, m);
|
|
87
|
+
m.nak((_a = options.retryDelayMs) !== null && _a !== void 0 ? _a : 5000);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
92
|
+
finally {
|
|
93
|
+
try {
|
|
94
|
+
if (!_d && !_a && (_b = messages_1.return)) yield _b.call(messages_1);
|
|
95
|
+
}
|
|
96
|
+
finally { if (e_1) throw e_1.error; }
|
|
97
|
+
}
|
|
98
|
+
}))();
|
|
99
|
+
return () => __awaiter(this, void 0, void 0, function* () {
|
|
100
|
+
yield messages.close();
|
|
101
|
+
yield loop.catch(() => undefined);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
104
|
+
}
|