@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,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.RecordMaintenanceError = void 0;
|
|
13
|
+
exports.natsMaintenanceClient = natsMaintenanceClient;
|
|
14
|
+
exports.writeAudit = writeAudit;
|
|
15
|
+
exports.createRecordMaintenance = createRecordMaintenance;
|
|
16
|
+
exports.runRetention = runRetention;
|
|
17
|
+
/**
|
|
18
|
+
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
19
|
+
* http://github.com/fonoster/fonoster
|
|
20
|
+
*
|
|
21
|
+
* This file is part of Fonoster
|
|
22
|
+
*
|
|
23
|
+
* Licensed under the MIT License (the "License");
|
|
24
|
+
* you may not use this file except in compliance with
|
|
25
|
+
* the License. You may obtain a copy of the License at
|
|
26
|
+
*
|
|
27
|
+
* https://opensource.org/licenses/MIT
|
|
28
|
+
*
|
|
29
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
30
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
31
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
32
|
+
* See the License for the specific language governing permissions and
|
|
33
|
+
* limitations under the License.
|
|
34
|
+
*/
|
|
35
|
+
const callrecord_1 = require("@fonoster/callrecord");
|
|
36
|
+
const logger_1 = require("@fonoster/logger");
|
|
37
|
+
const nats_1 = require("nats");
|
|
38
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
39
|
+
const sc = (0, nats_1.StringCodec)();
|
|
40
|
+
/**
|
|
41
|
+
* Retention and erasure run in the record's region (it holds the files and the signing key);
|
|
42
|
+
* the control plane asks over NATS (`callrecord.<region>.maintenance`, served by the AppBridge replicas).
|
|
43
|
+
*/
|
|
44
|
+
function natsMaintenanceClient(nc, timeoutMs = 30000) {
|
|
45
|
+
return (region, request) => __awaiter(this, void 0, void 0, function* () {
|
|
46
|
+
const msg = yield nc.request(`callrecord.${region}.maintenance`, sc.encode(JSON.stringify(request)), { timeout: timeoutMs });
|
|
47
|
+
return JSON.parse(sc.decode(msg.data));
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/** Writes audit entries (call-record: what was deleted, when, why and by whom). */
|
|
51
|
+
function writeAudit(db, audit) {
|
|
52
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
53
|
+
if (!audit.length)
|
|
54
|
+
return;
|
|
55
|
+
yield db.callRecordAudit.createMany({
|
|
56
|
+
data: audit.map((a) => ({
|
|
57
|
+
callRef: a.callRef,
|
|
58
|
+
accessKeyId: a.workspaceRef,
|
|
59
|
+
action: a.action,
|
|
60
|
+
part: a.part,
|
|
61
|
+
reason: a.reason,
|
|
62
|
+
actor: a.actor,
|
|
63
|
+
version: a.version,
|
|
64
|
+
at: new Date(a.at)
|
|
65
|
+
}))
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
class RecordMaintenanceError extends Error {
|
|
70
|
+
constructor(code, message) {
|
|
71
|
+
super(message);
|
|
72
|
+
this.code = code;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.RecordMaintenanceError = RecordMaintenanceError;
|
|
76
|
+
/** Deletes parts of a record or erases it, then audits and updates the index. */
|
|
77
|
+
function createRecordMaintenance(db, maintenance) {
|
|
78
|
+
return (request) => __awaiter(this, void 0, void 0, function* () {
|
|
79
|
+
var _a, _b;
|
|
80
|
+
const row = yield db.callRecord.findUnique({
|
|
81
|
+
where: { callRef: request.callRef }
|
|
82
|
+
});
|
|
83
|
+
if (!row || row.accessKeyId !== request.accessKeyId)
|
|
84
|
+
throw new RecordMaintenanceError("not_found", "record not found");
|
|
85
|
+
if (row.erasedAt)
|
|
86
|
+
throw new RecordMaintenanceError("gone", "the record was erased");
|
|
87
|
+
const parts = ((_a = request.parts) !== null && _a !== void 0 ? _a : []).filter((p) => callrecord_1.RECORD_PARTS.includes(p));
|
|
88
|
+
if (request.op === "delete_parts" && !parts.length)
|
|
89
|
+
throw new RecordMaintenanceError("bad_request", `parts must be some of ${callrecord_1.RECORD_PARTS.join(", ")}`);
|
|
90
|
+
const reply = yield maintenance(row.region, {
|
|
91
|
+
op: request.op,
|
|
92
|
+
callRef: request.callRef,
|
|
93
|
+
workspaceRef: request.accessKeyId,
|
|
94
|
+
location: row.location,
|
|
95
|
+
parts,
|
|
96
|
+
reason: request.reason,
|
|
97
|
+
actor: request.actor
|
|
98
|
+
});
|
|
99
|
+
if (reply.type !== "ack")
|
|
100
|
+
throw new RecordMaintenanceError(reply.code, (_b = reply.message) !== null && _b !== void 0 ? _b : `${request.op} failed`);
|
|
101
|
+
yield writeAudit(db, reply.audit);
|
|
102
|
+
// The region also publishes the new version's index entry; this makes the change visible
|
|
103
|
+
// at once (and is harmless when that entry arrives).
|
|
104
|
+
yield db.callRecord.update({
|
|
105
|
+
where: { callRef: request.callRef },
|
|
106
|
+
data: request.op === "erase"
|
|
107
|
+
? {
|
|
108
|
+
version: reply.version,
|
|
109
|
+
status: "erased",
|
|
110
|
+
erasedAt: new Date(),
|
|
111
|
+
fromNumber: null,
|
|
112
|
+
toNumber: null,
|
|
113
|
+
parts: []
|
|
114
|
+
}
|
|
115
|
+
: {
|
|
116
|
+
version: reply.version,
|
|
117
|
+
// The region may delete more than asked (the transcript takes the messages).
|
|
118
|
+
parts: row.parts.filter((p) => !parts.includes(p) &&
|
|
119
|
+
!reply.audit.some((a) => a.part === p))
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
logger.info(`call record ${request.callRef}: ${request.op} done`, {
|
|
123
|
+
actor: request.actor
|
|
124
|
+
});
|
|
125
|
+
return { version: reply.version, audit: reply.audit };
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Applies every workspace's retention policies once (task 4.3): records older than a policy's
|
|
130
|
+
* days lose that part, with the policy named as the reason. Without a policy nothing is deleted.
|
|
131
|
+
*/
|
|
132
|
+
function runRetention(db_1, maintenance_1) {
|
|
133
|
+
return __awaiter(this, arguments, void 0, function* (db, maintenance, now = Date.now()) {
|
|
134
|
+
const maintain = createRecordMaintenance(db, maintenance);
|
|
135
|
+
const done = [];
|
|
136
|
+
for (const policy of yield db.callRecordRetention.findMany()) {
|
|
137
|
+
const cutoff = new Date(now - policy.days * 24 * 3600 * 1000);
|
|
138
|
+
const rows = yield db.callRecord.findMany({
|
|
139
|
+
where: {
|
|
140
|
+
accessKeyId: policy.accessKeyId,
|
|
141
|
+
erasedAt: null,
|
|
142
|
+
startedAt: { lt: cutoff },
|
|
143
|
+
parts: { has: policy.part }
|
|
144
|
+
},
|
|
145
|
+
take: 500
|
|
146
|
+
});
|
|
147
|
+
for (const row of rows) {
|
|
148
|
+
try {
|
|
149
|
+
yield maintain({
|
|
150
|
+
op: "delete_parts",
|
|
151
|
+
callRef: row.callRef,
|
|
152
|
+
accessKeyId: policy.accessKeyId,
|
|
153
|
+
parts: [policy.part],
|
|
154
|
+
reason: `retention policy: ${policy.part} after ${policy.days} days`,
|
|
155
|
+
actor: "system:retention"
|
|
156
|
+
});
|
|
157
|
+
done.push({ callRef: row.callRef, part: policy.part });
|
|
158
|
+
}
|
|
159
|
+
catch (e) {
|
|
160
|
+
logger.warn(`retention for ${row.callRef} failed: ${e.message}`);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return done;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
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 { ObjectStoreConfig } from "@fonoster/callrecord";
|
|
20
|
+
import { NatsTarget } from "@fonoster/common";
|
|
21
|
+
import { Router } from "express";
|
|
22
|
+
import { IndexUsageDeps } from "./createIndexRecord";
|
|
23
|
+
import { RecordsRouterDeps } from "./createRecordsRouter";
|
|
24
|
+
import { RecordsDb } from "./types";
|
|
25
|
+
export type CallRecordsConfig = {
|
|
26
|
+
enabled: boolean;
|
|
27
|
+
stores: ObjectStoreConfig[];
|
|
28
|
+
retentionIntervalMinutes: number;
|
|
29
|
+
maintenanceTimeoutMs: number;
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Starts the control plane's side of call records: the index consumer, the retention job and the
|
|
33
|
+
* records API router (mounted on the HTTP bridge at /api/records).
|
|
34
|
+
*/
|
|
35
|
+
export declare function runCallRecords(config: CallRecordsConfig, deps: {
|
|
36
|
+
natsUrl: NatsTarget;
|
|
37
|
+
identityPublicKey: string;
|
|
38
|
+
identityTokenOptions?: RecordsRouterDeps["identityTokenOptions"];
|
|
39
|
+
db: RecordsDb;
|
|
40
|
+
relay?: RecordsRouterDeps["relay"];
|
|
41
|
+
onConfigChange?: (accessKeyId: string) => void;
|
|
42
|
+
usage?: IndexUsageDeps;
|
|
43
|
+
}): Promise<{
|
|
44
|
+
routers: {
|
|
45
|
+
path: string;
|
|
46
|
+
router: Router;
|
|
47
|
+
}[];
|
|
48
|
+
}>;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.runCallRecords = runCallRecords;
|
|
13
|
+
const common_1 = require("@fonoster/common");
|
|
14
|
+
const logger_1 = require("@fonoster/logger");
|
|
15
|
+
const nats_1 = require("nats");
|
|
16
|
+
const createIndexRecord_1 = require("./createIndexRecord");
|
|
17
|
+
const createRecordsRouter_1 = require("./createRecordsRouter");
|
|
18
|
+
const maintenance_1 = require("./maintenance");
|
|
19
|
+
const stores_1 = require("./stores");
|
|
20
|
+
const logger = (0, logger_1.getLogger)({ service: "apiserver", filePath: __filename });
|
|
21
|
+
/**
|
|
22
|
+
* Starts the control plane's side of call records: the index consumer, the retention job and the
|
|
23
|
+
* records API router (mounted on the HTTP bridge at /api/records).
|
|
24
|
+
*/
|
|
25
|
+
function runCallRecords(config, deps) {
|
|
26
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
+
if (!config.enabled)
|
|
28
|
+
return { routers: [] };
|
|
29
|
+
const nc = yield (0, nats_1.connect)(Object.assign(Object.assign({}, (0, common_1.natsConnectOptions)(deps.natsUrl)), { maxReconnectAttempts: -1 }));
|
|
30
|
+
yield (0, createIndexRecord_1.subscribeRecordIndex)(nc, deps.db, { usage: deps.usage });
|
|
31
|
+
const maintenance = (0, maintenance_1.natsMaintenanceClient)(nc, config.maintenanceTimeoutMs);
|
|
32
|
+
const retention = setInterval(() => void (0, maintenance_1.runRetention)(deps.db, maintenance)
|
|
33
|
+
.then((done) => done.length &&
|
|
34
|
+
logger.info(`retention deleted ${done.length} record parts`))
|
|
35
|
+
.catch((e) => logger.error(`retention failed: ${e.message}`)), config.retentionIntervalMinutes * 60000);
|
|
36
|
+
retention.unref();
|
|
37
|
+
const router = (0, createRecordsRouter_1.createRecordsRouter)({
|
|
38
|
+
db: deps.db,
|
|
39
|
+
identityPublicKey: deps.identityPublicKey,
|
|
40
|
+
identityTokenOptions: deps.identityTokenOptions,
|
|
41
|
+
stores: (0, stores_1.createStoreResolver)(config.stores),
|
|
42
|
+
maintenance,
|
|
43
|
+
relay: deps.relay,
|
|
44
|
+
onConfigChange: deps.onConfigChange
|
|
45
|
+
});
|
|
46
|
+
logger.info("call records: index, retention and /api/records are on");
|
|
47
|
+
return { routers: [{ path: "/api/records", router }] };
|
|
48
|
+
});
|
|
49
|
+
}
|
|
@@ -16,12 +16,9 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
+
import { ObjectStoreConfig, RecordStore } from "@fonoster/callrecord";
|
|
19
20
|
/**
|
|
20
|
-
*
|
|
21
|
-
*
|
|
21
|
+
* Opens the store an index entry points at (its `location`). The control plane reads records
|
|
22
|
+
* through the region's store (or a workspace bucket) configured here; it never copies them.
|
|
22
23
|
*/
|
|
23
|
-
declare function
|
|
24
|
-
get(key: string): T | undefined;
|
|
25
|
-
set(key: string, value: T): void;
|
|
26
|
-
};
|
|
27
|
-
export { createPerCallCache };
|
|
24
|
+
export declare function createStoreResolver(stores: ObjectStoreConfig[]): (location: string) => RecordStore | undefined;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.createStoreResolver = createStoreResolver;
|
|
4
4
|
/**
|
|
5
5
|
* Copyright (C) 2025 by Fonoster Inc (https://fonoster.com)
|
|
6
6
|
* http://github.com/fonoster/fonoster
|
|
@@ -19,6 +19,12 @@ exports.isDtmf = isDtmf;
|
|
|
19
19
|
* See the License for the specific language governing permissions and
|
|
20
20
|
* limitations under the License.
|
|
21
21
|
*/
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
const callrecord_1 = require("@fonoster/callrecord");
|
|
23
|
+
/**
|
|
24
|
+
* Opens the store an index entry points at (its `location`). The control plane reads records
|
|
25
|
+
* through the region's store (or a workspace bucket) configured here; it never copies them.
|
|
26
|
+
*/
|
|
27
|
+
function createStoreResolver(stores) {
|
|
28
|
+
const opened = stores.map((c) => new callrecord_1.RecordStore((0, callrecord_1.openObjectStore)(c)));
|
|
29
|
+
return (location) => opened.find((s) => s.location === location);
|
|
24
30
|
}
|
|
@@ -0,0 +1,104 @@
|
|
|
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 type { AuditEntry, RecordIndexEntry } from "@fonoster/callrecord";
|
|
20
|
+
export type CallRecordRow = {
|
|
21
|
+
callRef: string;
|
|
22
|
+
accessKeyId: string | null;
|
|
23
|
+
appRef: string | null;
|
|
24
|
+
fromNumber: string | null;
|
|
25
|
+
toNumber: string | null;
|
|
26
|
+
direction: string | null;
|
|
27
|
+
status: string;
|
|
28
|
+
endReason: string | null;
|
|
29
|
+
failureReason: string | null;
|
|
30
|
+
sipStatus: number | null;
|
|
31
|
+
/** Who answered, by AMD (human, voicemail, ivr, machine, unknown); null when it didn't run. */
|
|
32
|
+
amdStatus?: string | null;
|
|
33
|
+
startedAt: Date;
|
|
34
|
+
endedAt: Date | null;
|
|
35
|
+
durationSeconds: number;
|
|
36
|
+
region: string;
|
|
37
|
+
location: string;
|
|
38
|
+
version: number;
|
|
39
|
+
size: bigint | number;
|
|
40
|
+
parts: string[];
|
|
41
|
+
erasedAt: Date | null;
|
|
42
|
+
};
|
|
43
|
+
export type RetentionRow = {
|
|
44
|
+
accessKeyId: string;
|
|
45
|
+
part: string;
|
|
46
|
+
days: number;
|
|
47
|
+
};
|
|
48
|
+
export type AuditRow = {
|
|
49
|
+
callRef: string;
|
|
50
|
+
accessKeyId: string | null;
|
|
51
|
+
action: string;
|
|
52
|
+
part: string;
|
|
53
|
+
reason: string;
|
|
54
|
+
actor: string;
|
|
55
|
+
version: number;
|
|
56
|
+
at: Date;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* The slice of the Prisma client these functions use. Typed here, not from the generated client,
|
|
60
|
+
* so the records code compiles before the client is regenerated with the new models.
|
|
61
|
+
*/
|
|
62
|
+
export interface RecordsDb {
|
|
63
|
+
callRecord: {
|
|
64
|
+
findUnique(args: {
|
|
65
|
+
where: {
|
|
66
|
+
callRef: string;
|
|
67
|
+
};
|
|
68
|
+
}): Promise<CallRecordRow | null>;
|
|
69
|
+
findMany(args: Record<string, unknown>): Promise<CallRecordRow[]>;
|
|
70
|
+
upsert(args: Record<string, unknown>): Promise<unknown>;
|
|
71
|
+
update(args: Record<string, unknown>): Promise<unknown>;
|
|
72
|
+
};
|
|
73
|
+
callRecordAudit: {
|
|
74
|
+
createMany(args: {
|
|
75
|
+
data: AuditRow[];
|
|
76
|
+
}): Promise<unknown>;
|
|
77
|
+
findMany(args: Record<string, unknown>): Promise<AuditRow[]>;
|
|
78
|
+
};
|
|
79
|
+
callRecordRetention: {
|
|
80
|
+
findMany(args?: Record<string, unknown>): Promise<RetentionRow[]>;
|
|
81
|
+
upsert(args: Record<string, unknown>): Promise<unknown>;
|
|
82
|
+
deleteMany(args: Record<string, unknown>): Promise<unknown>;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/** Sends retention and erasure requests to the region that holds the record. */
|
|
86
|
+
export type MaintenanceClient = (region: string, request: {
|
|
87
|
+
op: "delete_parts" | "erase";
|
|
88
|
+
callRef: string;
|
|
89
|
+
workspaceRef?: string | null;
|
|
90
|
+
/** Where the record is stored (the index's location): the region store or a workspace bucket. */
|
|
91
|
+
location?: string;
|
|
92
|
+
parts?: string[];
|
|
93
|
+
reason: string;
|
|
94
|
+
actor: string;
|
|
95
|
+
}) => Promise<{
|
|
96
|
+
type: "ack";
|
|
97
|
+
version: number;
|
|
98
|
+
audit: AuditEntry[];
|
|
99
|
+
} | {
|
|
100
|
+
type: "error";
|
|
101
|
+
code: string;
|
|
102
|
+
message?: string;
|
|
103
|
+
}>;
|
|
104
|
+
export type { AuditEntry, RecordIndexEntry };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { LinkPublisher, RegionService } from "./service";
|
|
2
|
+
import { RegionRow, RegionsDb } from "./types";
|
|
3
|
+
/** What a private cell runs on (PR-7); central config is authoritative. */
|
|
4
|
+
export type ConfigKinds = {
|
|
5
|
+
numbers: unknown[];
|
|
6
|
+
apps: Record<string, unknown>[];
|
|
7
|
+
agents: {
|
|
8
|
+
appRef: string;
|
|
9
|
+
productRef?: string;
|
|
10
|
+
config: unknown;
|
|
11
|
+
}[];
|
|
12
|
+
routr: {
|
|
13
|
+
domains: unknown[];
|
|
14
|
+
agents: unknown[];
|
|
15
|
+
trunks: unknown[];
|
|
16
|
+
acls: unknown[];
|
|
17
|
+
};
|
|
18
|
+
catalog: Record<string, unknown>[];
|
|
19
|
+
webhooks: unknown[];
|
|
20
|
+
recordingPolicy: Record<string, unknown>;
|
|
21
|
+
};
|
|
22
|
+
/** Where a snapshot's parts come from (Prisma and the Routr-backed services in production). */
|
|
23
|
+
export type SnapshotSources = {
|
|
24
|
+
apps(accessKeyId: string): Promise<{
|
|
25
|
+
apps: Record<string, unknown>[];
|
|
26
|
+
agents: ConfigKinds["agents"];
|
|
27
|
+
}>;
|
|
28
|
+
numbers(accessKeyId: string): Promise<unknown[]>;
|
|
29
|
+
routr(accessKeyId: string): Promise<ConfigKinds["routr"]>;
|
|
30
|
+
/** Catalog entries (providers, models, voices) for the given catalog ids and providers. */
|
|
31
|
+
catalog(ids: string[], providers: string[]): Promise<Record<string, unknown>[]>;
|
|
32
|
+
webhooks(accessKeyId: string): Promise<unknown[]>;
|
|
33
|
+
recordingPolicy(accessKeyId: string): Promise<Record<string, unknown>>;
|
|
34
|
+
};
|
|
35
|
+
/** AppBridge's defaults when an app names no voice or STT model. */
|
|
36
|
+
export declare const DEFAULT_SPEECH: {
|
|
37
|
+
voice: string;
|
|
38
|
+
sttModel: string;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* The catalog ids each app and agent uses, and the secret names (provider ids) they need,
|
|
42
|
+
* with who needs them (PR-4: names only, never values).
|
|
43
|
+
*/
|
|
44
|
+
export declare function catalogUse(apps: Record<string, unknown>[], agents: ConfigKinds["agents"]): {
|
|
45
|
+
ids: string[];
|
|
46
|
+
secrets: {
|
|
47
|
+
name: string;
|
|
48
|
+
usedBy: string[];
|
|
49
|
+
}[];
|
|
50
|
+
};
|
|
51
|
+
/** One workspace's part of a snapshot (contract §3). */
|
|
52
|
+
export type WorkspaceConfig = {
|
|
53
|
+
ref: string;
|
|
54
|
+
name: string;
|
|
55
|
+
/** The workspace's first SIP domain as the region writes it (PR-16). */
|
|
56
|
+
domain: string | null;
|
|
57
|
+
kinds: Omit<ConfigKinds, "catalog">;
|
|
58
|
+
};
|
|
59
|
+
export type ConfigMessage = {
|
|
60
|
+
type: "region.config";
|
|
61
|
+
configVersion: number;
|
|
62
|
+
full: true;
|
|
63
|
+
region: {
|
|
64
|
+
ref: string;
|
|
65
|
+
id: string;
|
|
66
|
+
kind: string;
|
|
67
|
+
sipDomain: string | null;
|
|
68
|
+
rootDomain: string;
|
|
69
|
+
};
|
|
70
|
+
catalog: Record<string, unknown>[];
|
|
71
|
+
workspaces: Record<string, WorkspaceConfig>;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* A cloud domain as the region writes it (PR-16): `<label>.<rootDomain>` becomes
|
|
75
|
+
* `<label>.<sipDomain>`; another name keeps its first label; no sipDomain leaves it unchanged.
|
|
76
|
+
*/
|
|
77
|
+
export declare function regionDomainUri(uri: string, rootDomain: string, sipDomain?: string | null): string;
|
|
78
|
+
/**
|
|
79
|
+
* Config sync to regions (task 2.4, PR-14): one full snapshot per region holding every workspace
|
|
80
|
+
* bound to it (keyed by workspace), with an increasing configVersion, published on change
|
|
81
|
+
* (debounced) and on request; paused while the region is `unsupported`.
|
|
82
|
+
*/
|
|
83
|
+
export declare function createConfigSync(deps: {
|
|
84
|
+
db: RegionsDb;
|
|
85
|
+
service: RegionService;
|
|
86
|
+
sources: SnapshotSources;
|
|
87
|
+
publish: LinkPublisher;
|
|
88
|
+
debounceMs?: number;
|
|
89
|
+
/**
|
|
90
|
+
* How often this replica looks for changes whose debounced publish never happened (the replica
|
|
91
|
+
* that took the change died inside the window, ST-3). 0 turns the sweep off.
|
|
92
|
+
*/
|
|
93
|
+
sweepMs?: number;
|
|
94
|
+
/** The cloud's SIP root domain (workspace domains end with it). */
|
|
95
|
+
rootDomain?: () => string;
|
|
96
|
+
}): {
|
|
97
|
+
snapshot: (row: RegionRow) => Promise<Omit<ConfigMessage, "type" | "configVersion" | "full">>;
|
|
98
|
+
secretsNeeded: (row: RegionRow, only?: string) => Promise<{
|
|
99
|
+
secrets: {
|
|
100
|
+
name: string;
|
|
101
|
+
usedBy: string[];
|
|
102
|
+
}[];
|
|
103
|
+
perWorkspace: Record<string, string[]>;
|
|
104
|
+
}>;
|
|
105
|
+
publishNow: (row: RegionRow) => Promise<ConfigMessage>;
|
|
106
|
+
sweep: (now?: number) => Promise<string[]>;
|
|
107
|
+
/**
|
|
108
|
+
* A workspace's config changed: mark its region changed now and publish it soon (several
|
|
109
|
+
* changes make one version). Resolves once the mark is stored.
|
|
110
|
+
*/
|
|
111
|
+
onChange(accessKeyId: string): Promise<any>;
|
|
112
|
+
/** A workspace joined or left a region (created or deleted): publish that region soon. */
|
|
113
|
+
onRegionChange(regionKeyValue: string): Promise<any>;
|
|
114
|
+
/** The answer to `region.R.config.request` (contract §3). */
|
|
115
|
+
answer(row: RegionRow, haveVersion: number): Promise<ConfigMessage | {
|
|
116
|
+
type: string;
|
|
117
|
+
reason: string;
|
|
118
|
+
requiredVersion: string;
|
|
119
|
+
configVersion?: undefined;
|
|
120
|
+
} | {
|
|
121
|
+
type: string;
|
|
122
|
+
configVersion: number;
|
|
123
|
+
reason?: undefined;
|
|
124
|
+
requiredVersion?: undefined;
|
|
125
|
+
}>;
|
|
126
|
+
/** After a heartbeat: a supported cell behind the current version gets the snapshot again. */
|
|
127
|
+
afterHeartbeat(row: RegionRow): Promise<void>;
|
|
128
|
+
stop(): void;
|
|
129
|
+
};
|
|
130
|
+
export type ConfigSync = ReturnType<typeof createConfigSync>;
|