@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
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Prisma } from "../core/db";
|
|
2
|
+
import { SessionAppsConfig } from "./session/appModel";
|
|
2
3
|
import { TestTokenConfiguration } from "./types";
|
|
3
|
-
declare function buildService(prisma: Prisma, testTokenConfig: TestTokenConfiguration): {
|
|
4
|
+
declare function buildService(prisma: Prisma, testTokenConfig: TestTokenConfiguration, config?: SessionAppsConfig, findCallerEmail?: (userRef: string) => Promise<string | undefined>): {
|
|
4
5
|
definition: {
|
|
5
6
|
serviceName: string;
|
|
6
7
|
pckg: string;
|
|
@@ -23,6 +24,9 @@ declare function buildService(prisma: Prisma, testTokenConfig: TestTokenConfigur
|
|
|
23
24
|
updateApplication: (call: {
|
|
24
25
|
request: unknown;
|
|
25
26
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
27
|
+
rotateSigningSecret: (call: {
|
|
28
|
+
request: unknown;
|
|
29
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
26
30
|
evaluateIntelligence: (call: {
|
|
27
31
|
request: import("@fonoster/autopilot").EvaluateIntelligenceRequest;
|
|
28
32
|
write: (chunk: Record<string, unknown>) => void;
|
|
@@ -21,15 +21,17 @@ exports.buildService = buildService;
|
|
|
21
21
|
*/
|
|
22
22
|
const autopilot_1 = require("@fonoster/autopilot");
|
|
23
23
|
const envs_1 = require("../envs");
|
|
24
|
-
const
|
|
24
|
+
const publishUsage_1 = require("../usage/publishUsage");
|
|
25
25
|
const createCreateApplication_1 = require("./createCreateApplication");
|
|
26
26
|
const createCreateTestToken_1 = require("./createCreateTestToken");
|
|
27
27
|
const createDeleteApplication_1 = require("./createDeleteApplication");
|
|
28
28
|
const createGetApplication_1 = require("./createGetApplication");
|
|
29
29
|
const createListApplications_1 = require("./createListApplications");
|
|
30
|
+
const createRotateSigningSecret_1 = require("./createRotateSigningSecret");
|
|
30
31
|
const createUpdateApplication_1 = require("./createUpdateApplication");
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
const evalKeys_1 = require("./evalKeys");
|
|
33
|
+
function buildService(prisma, testTokenConfig, config = envs_1.SESSION_APPS, findCallerEmail) {
|
|
34
|
+
const evaluateIntelligence = (0, autopilot_1.createEvaluateIntelligence)((0, evalKeys_1.createEvalKeys)(prisma, envs_1.EVALUATIONS.credentials), publishUsage_1.reportEvalUsage);
|
|
33
35
|
return {
|
|
34
36
|
definition: {
|
|
35
37
|
serviceName: "Applications",
|
|
@@ -38,13 +40,14 @@ function buildService(prisma, testTokenConfig) {
|
|
|
38
40
|
proto: "applications.proto"
|
|
39
41
|
},
|
|
40
42
|
handlers: {
|
|
41
|
-
createApplication: (0, createCreateApplication_1.createCreateApplication)(prisma),
|
|
43
|
+
createApplication: (0, createCreateApplication_1.createCreateApplication)(prisma, config),
|
|
42
44
|
getApplication: (0, createGetApplication_1.createGetApplication)(prisma),
|
|
43
45
|
listApplications: (0, createListApplications_1.createListApplications)(prisma),
|
|
44
46
|
deleteApplication: (0, createDeleteApplication_1.createDeleteApplication)(prisma),
|
|
45
|
-
updateApplication: (0, createUpdateApplication_1.createUpdateApplication)(prisma),
|
|
46
|
-
|
|
47
|
-
|
|
47
|
+
updateApplication: (0, createUpdateApplication_1.createUpdateApplication)(prisma, config),
|
|
48
|
+
rotateSigningSecret: (0, createRotateSigningSecret_1.createRotateSigningSecret)(prisma, config),
|
|
49
|
+
evaluateIntelligence,
|
|
50
|
+
createTestToken: (0, createCreateTestToken_1.createCreateTestToken)(testTokenConfig, findCallerEmail)
|
|
48
51
|
}
|
|
49
52
|
};
|
|
50
53
|
}
|
|
@@ -17,8 +17,12 @@
|
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
19
|
import { GrpcErrorMessage } from "@fonoster/common";
|
|
20
|
-
import {
|
|
21
|
-
|
|
20
|
+
import { AppsDb, SessionAppsConfig } from "./session/appModel";
|
|
21
|
+
/**
|
|
22
|
+
* Creates an application (a stream or an Autopilot agent). The response carries the signing secret, the only time it is shown.
|
|
23
|
+
* Autopilot apps share the configured Autopilot secret when one is set (CP-B3).
|
|
24
|
+
*/
|
|
25
|
+
declare function createCreateApplication(prisma: AppsDb, config: SessionAppsConfig): (call: {
|
|
22
26
|
request: unknown;
|
|
23
27
|
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
24
28
|
export { createCreateApplication };
|
|
@@ -30,30 +30,38 @@ exports.createCreateApplication = createCreateApplication;
|
|
|
30
30
|
*/
|
|
31
31
|
const common_1 = require("@fonoster/common");
|
|
32
32
|
const logger_1 = require("@fonoster/logger");
|
|
33
|
-
const
|
|
34
|
-
const convertToApplicationData_1 = require("./utils/convertToApplicationData");
|
|
35
|
-
const validOrThrow_1 = require("./validation/validOrThrow");
|
|
33
|
+
const appModel_1 = require("./session/appModel");
|
|
36
34
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
37
|
-
|
|
35
|
+
/**
|
|
36
|
+
* Creates an application (a stream or an Autopilot agent). The response carries the signing secret, the only time it is shown.
|
|
37
|
+
* Autopilot apps share the configured Autopilot secret when one is set (CP-B3).
|
|
38
|
+
*/
|
|
39
|
+
function createCreateApplication(prisma, config) {
|
|
38
40
|
const createApplication = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
-
const { request } = call;
|
|
40
|
-
const { type } = request;
|
|
41
41
|
const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
|
|
42
|
+
const request = call.request;
|
|
42
43
|
logger.verbose("call to createApplication", {
|
|
43
44
|
accessKeyId,
|
|
44
|
-
type
|
|
45
|
+
type: request.type
|
|
45
46
|
});
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const { columns, agent, autopilot } = yield (0, appModel_1.toAppColumns)(prisma, request, {
|
|
48
|
+
accessKeyId,
|
|
49
|
+
config
|
|
50
|
+
});
|
|
51
|
+
const shared = autopilot ? config.autopilotSigningSecret : undefined;
|
|
52
|
+
const signingSecret = shared !== null && shared !== void 0 ? shared : (0, appModel_1.newSigningSecret)();
|
|
53
|
+
const intelligence = agent
|
|
54
|
+
? { create: yield (0, appModel_1.agentRow)(prisma, agent) }
|
|
55
|
+
: undefined;
|
|
53
56
|
const result = yield prisma.application.create({
|
|
54
|
-
data: Object.assign(Object.assign({},
|
|
57
|
+
data: Object.assign(Object.assign({}, columns), { signingSecret, accessKeyId, intelligence })
|
|
58
|
+
});
|
|
59
|
+
callback(null, {
|
|
60
|
+
ref: result.ref,
|
|
61
|
+
// A shared Autopilot secret is the operator's, not the app's to show.
|
|
62
|
+
signingSecret: shared ? "" : signingSecret,
|
|
63
|
+
signingSecretHint: (0, appModel_1.secretHint)(signingSecret)
|
|
55
64
|
});
|
|
56
|
-
callback(null, { ref: result.ref });
|
|
57
65
|
});
|
|
58
66
|
return (0, common_1.withErrorHandling)(createApplication);
|
|
59
67
|
}
|
|
@@ -18,7 +18,9 @@
|
|
|
18
18
|
*/
|
|
19
19
|
import { GrpcErrorMessage } from "@fonoster/common";
|
|
20
20
|
import { TestTokenConfiguration } from "./types";
|
|
21
|
-
|
|
21
|
+
/** The email of the user a ref names, for the token's `caller` (#1060). */
|
|
22
|
+
type FindCallerEmail = (userRef: string) => Promise<string | undefined>;
|
|
23
|
+
declare function createCreateTestToken(config: TestTokenConfiguration, findCallerEmail?: FindCallerEmail): (call: {
|
|
22
24
|
request: unknown;
|
|
23
25
|
}, callback: (error?: GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
24
26
|
export { createCreateTestToken };
|
|
@@ -38,25 +38,30 @@ const jsonwebtoken_1 = __importDefault(require("jsonwebtoken"));
|
|
|
38
38
|
const uuid_1 = require("uuid");
|
|
39
39
|
const envs_1 = require("../envs");
|
|
40
40
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
41
|
-
function createCreateTestToken(config) {
|
|
41
|
+
function createCreateTestToken(config, findCallerEmail) {
|
|
42
42
|
const createApplication = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
43
43
|
const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
|
|
44
44
|
logger.verbose("call to createTestToken", {
|
|
45
45
|
accessKeyId
|
|
46
46
|
});
|
|
47
|
+
// Who is testing: the signed-in user behind the access token, recorded as the call's
|
|
48
|
+
// caller instead of the SIP leg's internal name. A lookup failure only leaves it out.
|
|
49
|
+
let caller;
|
|
50
|
+
try {
|
|
51
|
+
const token = (0, common_1.getTokenFromCall)(call);
|
|
52
|
+
const sub = token
|
|
53
|
+
? (0, common_1.decodeToken)(token).sub
|
|
54
|
+
: undefined;
|
|
55
|
+
caller =
|
|
56
|
+
typeof sub === "string" && findCallerEmail
|
|
57
|
+
? yield findCallerEmail(sub)
|
|
58
|
+
: undefined;
|
|
59
|
+
}
|
|
60
|
+
catch (err) {
|
|
61
|
+
logger.verbose("test token without a caller", { error: err });
|
|
62
|
+
}
|
|
47
63
|
// Build payload
|
|
48
|
-
const payload = {
|
|
49
|
-
ref: (0, uuid_1.v4)(),
|
|
50
|
-
domain: config.domain,
|
|
51
|
-
displayName: config.displayName,
|
|
52
|
-
signalingServer: config.signalingServer,
|
|
53
|
-
targetAor: config.targetAor,
|
|
54
|
-
username: config.username,
|
|
55
|
-
accessKeyId,
|
|
56
|
-
aorLink: config.targetAor,
|
|
57
|
-
privacy: "NONE",
|
|
58
|
-
allowedMethods: ["INVITE"]
|
|
59
|
-
};
|
|
64
|
+
const payload = Object.assign(Object.assign({}, (caller ? { caller } : {})), { ref: (0, uuid_1.v4)(), domain: config.domain, displayName: config.displayName, signalingServer: config.signalingServer, targetAor: config.targetAor, username: config.username, accessKeyId, aorLink: config.targetAor, privacy: "NONE", allowedMethods: ["INVITE"] });
|
|
60
65
|
// Sign JWT
|
|
61
66
|
let token;
|
|
62
67
|
try {
|
|
@@ -32,7 +32,7 @@ const common_1 = require("@fonoster/common");
|
|
|
32
32
|
const logger_1 = require("@fonoster/logger");
|
|
33
33
|
const withErrorHandlingAndValidationAndAccess_1 = require("../utils/withErrorHandlingAndValidationAndAccess");
|
|
34
34
|
const createGetFnUtil_1 = require("./createGetFnUtil");
|
|
35
|
-
const
|
|
35
|
+
const appModel_1 = require("./session/appModel");
|
|
36
36
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
37
37
|
function createGetApplication(prisma) {
|
|
38
38
|
const getFn = (0, createGetFnUtil_1.createGetFnUtil)(prisma);
|
|
@@ -40,7 +40,7 @@ function createGetApplication(prisma) {
|
|
|
40
40
|
const { ref } = call.request;
|
|
41
41
|
logger.verbose("call to getApplication", { ref });
|
|
42
42
|
const result = yield getFn(ref);
|
|
43
|
-
return result ? (0,
|
|
43
|
+
return result ? (0, appModel_1.rowToApplication)(result) : null;
|
|
44
44
|
});
|
|
45
45
|
return (0, withErrorHandlingAndValidationAndAccess_1.withErrorHandlingAndValidationAndAccess)(getApplication, (ref) => getFn(ref), common_1.Validators.emptySchema);
|
|
46
46
|
}
|
|
@@ -3,33 +3,37 @@ declare function createGetFnUtil(prisma: Prisma): (ref: string) => Promise<{
|
|
|
3
3
|
extended: {
|
|
4
4
|
accessKeyId: string;
|
|
5
5
|
};
|
|
6
|
-
textToSpeech: {
|
|
7
|
-
ref: string;
|
|
8
|
-
config: import("@prisma/client/runtime/library").JsonValue;
|
|
9
|
-
credentials: string | null;
|
|
10
|
-
productRef: string;
|
|
11
|
-
applicationRef: string;
|
|
12
|
-
};
|
|
13
|
-
speechToText: {
|
|
14
|
-
ref: string;
|
|
15
|
-
config: import("@prisma/client/runtime/library").JsonValue;
|
|
16
|
-
credentials: string | null;
|
|
17
|
-
productRef: string;
|
|
18
|
-
applicationRef: string;
|
|
19
|
-
};
|
|
20
6
|
intelligence: {
|
|
7
|
+
credentials: string | null;
|
|
21
8
|
ref: string;
|
|
22
9
|
config: import("@prisma/client/runtime/library").JsonValue;
|
|
23
|
-
credentials: string | null;
|
|
24
10
|
productRef: string;
|
|
25
11
|
applicationRef: string;
|
|
26
12
|
};
|
|
27
|
-
ref: string;
|
|
28
|
-
accessKeyId: string;
|
|
29
13
|
type: import(".prisma/client").$Enums.ApplicationType;
|
|
30
|
-
name: string;
|
|
31
14
|
endpoint: string;
|
|
15
|
+
accessKeyId: string;
|
|
16
|
+
name: string;
|
|
17
|
+
url: string | null;
|
|
18
|
+
ref: string;
|
|
19
|
+
speechVoice: string | null;
|
|
20
|
+
speechTtsModel: string | null;
|
|
21
|
+
speechSttModel: string | null;
|
|
32
22
|
createdAt: Date;
|
|
33
23
|
updatedAt: Date;
|
|
24
|
+
recording: string | null;
|
|
25
|
+
silenceTimeoutMs: number | null;
|
|
26
|
+
patience: string | null;
|
|
27
|
+
protocol: string | null;
|
|
28
|
+
audio: import("@prisma/client/runtime/library").JsonValue | null;
|
|
29
|
+
fallbackAppRef: string | null;
|
|
30
|
+
fallbackMessage: string | null;
|
|
31
|
+
listeners: import("@prisma/client/runtime/library").JsonValue | null;
|
|
32
|
+
amd: boolean;
|
|
33
|
+
filters: import("@prisma/client/runtime/library").JsonValue | null;
|
|
34
|
+
signingSecret: string | null;
|
|
35
|
+
speechLanguage: string | null;
|
|
36
|
+
amdWindowMs: number | null;
|
|
37
|
+
speechSettings: import("@prisma/client/runtime/library").JsonValue | null;
|
|
34
38
|
}>;
|
|
35
39
|
export { createGetFnUtil };
|
|
@@ -37,11 +37,9 @@ function createGetFnUtil(prisma) {
|
|
|
37
37
|
}
|
|
38
38
|
const response = yield prisma.application.findUnique({
|
|
39
39
|
where: { ref },
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
intelligence: true
|
|
44
|
-
}
|
|
40
|
+
// The legacy TextToSpeech/SpeechToText rows (and their credentials) are not read any more
|
|
41
|
+
// (add-provider-registry 5.2): speech defaults are columns on the app.
|
|
42
|
+
include: { intelligence: true }
|
|
45
43
|
});
|
|
46
44
|
if (!response) {
|
|
47
45
|
throw (0, notFoundError_1.notFoundError)("Application not found");
|
|
@@ -30,7 +30,7 @@ exports.createListApplications = createListApplications;
|
|
|
30
30
|
*/
|
|
31
31
|
const common_1 = require("@fonoster/common");
|
|
32
32
|
const logger_1 = require("@fonoster/logger");
|
|
33
|
-
const
|
|
33
|
+
const appModel_1 = require("./session/appModel");
|
|
34
34
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
35
35
|
function createListApplications(prisma) {
|
|
36
36
|
const listApplications = (call, callback) => __awaiter(this, void 0, void 0, function* () {
|
|
@@ -45,15 +45,14 @@ function createListApplications(prisma) {
|
|
|
45
45
|
const result = yield prisma.application.findMany({
|
|
46
46
|
where: { accessKeyId },
|
|
47
47
|
include: {
|
|
48
|
-
textToSpeech: true,
|
|
49
|
-
speechToText: true,
|
|
50
48
|
intelligence: true
|
|
51
49
|
},
|
|
50
|
+
orderBy: [{ createdAt: "desc" }, { ref: "asc" }],
|
|
52
51
|
take: pageSize,
|
|
53
52
|
skip: pageToken ? 1 : 0,
|
|
54
53
|
cursor: pageToken ? { ref: pageToken } : undefined
|
|
55
54
|
});
|
|
56
|
-
const items = result.map(
|
|
55
|
+
const items = result.map((row) => (0, appModel_1.rowToApplication)(row));
|
|
57
56
|
callback(null, {
|
|
58
57
|
items,
|
|
59
58
|
nextPageToken: items.length < pageSize ? "" : (_a = result[result.length - 1]) === null || _a === void 0 ? void 0 : _a.ref
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AppsDb, SessionAppsConfig } from "./session/appModel";
|
|
2
|
+
/**
|
|
3
|
+
* New signing secret for an app. It takes effect at once: the old one stops working with no
|
|
4
|
+
* overlap window (owner ruling B25), so the app must redeploy in step.
|
|
5
|
+
*/
|
|
6
|
+
declare function createRotateSigningSecret(prisma: AppsDb, config: SessionAppsConfig): (call: {
|
|
7
|
+
request: unknown;
|
|
8
|
+
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
9
|
+
export { createRotateSigningSecret };
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.createRotateSigningSecret = createRotateSigningSecret;
|
|
13
13
|
/**
|
|
14
14
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
15
15
|
* http://github.com/fonoster/fonoster
|
|
@@ -29,26 +29,29 @@ exports.createFetchSingleCall = createFetchSingleCall;
|
|
|
29
29
|
* limitations under the License.
|
|
30
30
|
*/
|
|
31
31
|
const common_1 = require("@fonoster/common");
|
|
32
|
+
const identity_1 = require("@fonoster/identity");
|
|
32
33
|
const logger_1 = require("@fonoster/logger");
|
|
33
|
-
const
|
|
34
|
+
const createGetFnUtil_1 = require("./createGetFnUtil");
|
|
35
|
+
const appModel_1 = require("./session/appModel");
|
|
34
36
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
return
|
|
37
|
+
/**
|
|
38
|
+
* New signing secret for an app. It takes effect at once: the old one stops working with no
|
|
39
|
+
* overlap window (owner ruling B25), so the app must redeploy in step.
|
|
40
|
+
*/
|
|
41
|
+
function createRotateSigningSecret(prisma, config) {
|
|
42
|
+
const getFn = (0, createGetFnUtil_1.createGetFnUtil)(prisma);
|
|
43
|
+
const rotateSigningSecret = (call) => __awaiter(this, void 0, void 0, function* () {
|
|
44
|
+
const { ref } = call.request;
|
|
45
|
+
const app = yield getFn(ref);
|
|
46
|
+
if (app.type === "AUTOPILOT" && config.autopilotSigningSecret)
|
|
47
|
+
throw (0, appModel_1.invalid)("Autopilot apps use the platform's Autopilot secret; it is rotated by the operator");
|
|
48
|
+
const signingSecret = (0, appModel_1.newSigningSecret)();
|
|
49
|
+
yield prisma.application.update({
|
|
50
|
+
where: { ref },
|
|
51
|
+
data: { signingSecret, updatedAt: new Date() }
|
|
52
|
+
});
|
|
53
|
+
logger.verbose("rotated the signing secret", { ref });
|
|
54
|
+
return { ref, signingSecret, signingSecretHint: (0, appModel_1.secretHint)(signingSecret) };
|
|
53
55
|
});
|
|
56
|
+
return (0, common_1.withErrorHandling)((0, identity_1.withAccess)(rotateSigningSecret, (ref) => getFn(ref)));
|
|
54
57
|
}
|
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { AppsDb, SessionAppsConfig } from "./session/appModel";
|
|
2
|
+
/**
|
|
3
|
+
* Replaces an app's settings (PUT semantics, CP-B2): fields left out go back to their defaults.
|
|
4
|
+
* The signing secret is kept; rotate it with RotateSigningSecret.
|
|
5
|
+
*/
|
|
6
|
+
declare function createUpdateApplication(prisma: AppsDb, config: SessionAppsConfig): (call: {
|
|
3
7
|
request: unknown;
|
|
4
8
|
}, callback: (error?: import("@fonoster/common").GrpcErrorMessage, response?: unknown) => void) => Promise<void>;
|
|
5
9
|
export { createUpdateApplication };
|
|
@@ -31,53 +31,52 @@ exports.createUpdateApplication = createUpdateApplication;
|
|
|
31
31
|
const common_1 = require("@fonoster/common");
|
|
32
32
|
const identity_1 = require("@fonoster/identity");
|
|
33
33
|
const logger_1 = require("@fonoster/logger");
|
|
34
|
-
const types_1 = require("@fonoster/types");
|
|
35
34
|
const createGetFnUtil_1 = require("./createGetFnUtil");
|
|
36
|
-
const
|
|
37
|
-
const validOrThrow_1 = require("./validation/validOrThrow");
|
|
35
|
+
const appModel_1 = require("./session/appModel");
|
|
38
36
|
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
39
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Replaces an app's settings (PUT semantics, CP-B2): fields left out go back to their defaults.
|
|
39
|
+
* The signing secret is kept; rotate it with RotateSigningSecret.
|
|
40
|
+
*/
|
|
41
|
+
function createUpdateApplication(prisma, config) {
|
|
40
42
|
const getFn = (0, createGetFnUtil_1.createGetFnUtil)(prisma);
|
|
41
43
|
const updateApplication = (call) => __awaiter(this, void 0, void 0, function* () {
|
|
42
|
-
const {
|
|
43
|
-
const { type, ref: applicationRef } = request;
|
|
44
|
+
const { ref } = call.request;
|
|
44
45
|
const accessKeyId = (0, common_1.getAccessKeyIdFromCall)(call);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
request.endpoint = common_1.AUTOPILOT_SPECIAL_LOCAL_ADDRESS;
|
|
50
|
-
}
|
|
51
|
-
(0, validOrThrow_1.validOrThrow)(request);
|
|
52
|
-
logger.verbose("call to updateApplication", {
|
|
46
|
+
const existing = (yield getFn(ref));
|
|
47
|
+
const request = Object.assign(Object.assign({}, call.request), { name: call.request.name || existing.name, type: call.request.type || existing.type });
|
|
48
|
+
logger.verbose("call to updateApplication", { accessKeyId, ref });
|
|
49
|
+
const { columns, agent, autopilot } = yield (0, appModel_1.toAppColumns)(prisma, request, {
|
|
53
50
|
accessKeyId,
|
|
54
|
-
|
|
51
|
+
ref,
|
|
52
|
+
config
|
|
55
53
|
});
|
|
54
|
+
const intelligence = agent ? yield (0, appModel_1.agentRow)(prisma, agent) : undefined;
|
|
55
|
+
// An app that became an Autopilot app takes the shared secret; one that stopped being one
|
|
56
|
+
// needs its own.
|
|
57
|
+
let signingSecret;
|
|
58
|
+
if (autopilot && config.autopilotSigningSecret)
|
|
59
|
+
signingSecret = config.autopilotSigningSecret;
|
|
60
|
+
else if (!existing.signingSecret ||
|
|
61
|
+
existing.signingSecret === config.autopilotSigningSecret)
|
|
62
|
+
signingSecret = (0, appModel_1.newSigningSecret)();
|
|
56
63
|
yield prisma.$transaction([
|
|
57
|
-
prisma.
|
|
58
|
-
where: {
|
|
59
|
-
applicationRef
|
|
60
|
-
}
|
|
61
|
-
}),
|
|
62
|
-
prisma.speechToText.deleteMany({
|
|
63
|
-
where: {
|
|
64
|
-
applicationRef
|
|
65
|
-
}
|
|
66
|
-
}),
|
|
67
|
-
prisma.intelligence.deleteMany({
|
|
68
|
-
where: {
|
|
69
|
-
applicationRef
|
|
70
|
-
}
|
|
71
|
-
}),
|
|
64
|
+
prisma.intelligence.deleteMany({ where: { applicationRef: ref } }),
|
|
72
65
|
prisma.application.update({
|
|
73
|
-
where: {
|
|
74
|
-
|
|
75
|
-
accessKeyId
|
|
76
|
-
},
|
|
77
|
-
data: (0, convertToApplicationData_1.convertToApplicationData)(request)
|
|
66
|
+
where: { ref, accessKeyId },
|
|
67
|
+
data: Object.assign(Object.assign(Object.assign(Object.assign({}, columns), (signingSecret ? { signingSecret } : {})), { updatedAt: new Date() }), (intelligence ? { intelligence: { create: intelligence } } : {}))
|
|
78
68
|
})
|
|
79
69
|
]);
|
|
80
|
-
|
|
70
|
+
// A secret generated here is returned once, like on create; the shared Autopilot secret
|
|
71
|
+
// never is (CP review).
|
|
72
|
+
const generated = signingSecret && signingSecret !== config.autopilotSigningSecret
|
|
73
|
+
? signingSecret
|
|
74
|
+
: undefined;
|
|
75
|
+
return {
|
|
76
|
+
ref,
|
|
77
|
+
signingSecret: generated !== null && generated !== void 0 ? generated : "",
|
|
78
|
+
signingSecretHint: generated ? (0, appModel_1.secretHint)(generated) : ""
|
|
79
|
+
};
|
|
81
80
|
});
|
|
82
81
|
return (0, common_1.withErrorHandling)((0, identity_1.withAccess)(updateApplication, (ref) => getFn(ref)));
|
|
83
82
|
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type EvalDb = any;
|
|
2
|
+
export declare function createEvalKeys(db: EvalDb, platform: Record<string, string>): (providerId: string, workspaceRef: string) => Promise<{
|
|
3
|
+
key: string;
|
|
4
|
+
source: "workspace";
|
|
5
|
+
} | {
|
|
6
|
+
key: string;
|
|
7
|
+
source: "platform";
|
|
8
|
+
}>;
|
|
9
|
+
export {};
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.createEvalKeys = createEvalKeys;
|
|
13
13
|
/**
|
|
14
14
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
15
15
|
* http://github.com/fonoster/fonoster
|
|
@@ -29,18 +29,23 @@ exports.recordChannel = recordChannel;
|
|
|
29
29
|
* limitations under the License.
|
|
30
30
|
*/
|
|
31
31
|
const common_1 = require("@fonoster/common");
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
function createEvalKeys(db, platform) {
|
|
33
|
+
const workspaceKeys = new common_1.Registry.PrismaWorkspaceKeys(db);
|
|
34
|
+
return (providerId, workspaceRef) => __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
var _a;
|
|
36
|
+
// An unreadable key never falls back to the platform's (remove-platform-key-fallback).
|
|
37
|
+
const own = yield workspaceKeys
|
|
38
|
+
.get(workspaceRef, providerId)
|
|
39
|
+
.catch((e) => {
|
|
40
|
+
throw new Error(`key_unavailable: the workspace's ${providerId} key could not be read (${e.message})`);
|
|
39
41
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if (own)
|
|
43
|
+
return { key: own, source: "workspace" };
|
|
44
|
+
const provider = yield db.registryProvider.findUnique({
|
|
45
|
+
where: { id: providerId }
|
|
44
46
|
});
|
|
47
|
+
const ref = (_a = provider === null || provider === void 0 ? void 0 : provider.credentialRef) !== null && _a !== void 0 ? _a : `${providerId}-default`;
|
|
48
|
+
const key = platform[ref];
|
|
49
|
+
return key ? { key, source: "platform" } : undefined;
|
|
45
50
|
});
|
|
46
51
|
}
|