@deepgram/sdk 5.0.0-beta.2 → 5.0.0-beta.4
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/README.md +50 -9
- package/dist/browser/index.global.js +304 -451
- package/dist/cjs/BaseClient.js +2 -2
- package/dist/cjs/CustomClient.js +131 -0
- package/dist/cjs/api/resources/agent/resources/v1/client/Client.d.ts +2 -0
- package/dist/cjs/api/resources/agent/resources/v1/client/Client.js +2 -2
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1ConversationText.d.ts +1 -1
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1Settings.d.ts +5 -65
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.ts +1 -1
- package/dist/cjs/api/resources/agent/resources/v1/types/AgentV1UpdateSpeak.d.ts +1 -26
- package/dist/cjs/api/resources/agent/resources/v1/types/index.d.ts +0 -4
- package/dist/cjs/api/resources/agent/resources/v1/types/index.js +0 -4
- package/dist/cjs/api/resources/listen/resources/v1/client/Client.d.ts +3 -0
- package/dist/cjs/api/resources/listen/resources/v1/client/Client.js +3 -2
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestCallbackMethod.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestCustomIntentMode.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestCustomTopicMode.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestEncoding.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestModel.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestSummarize.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestVersion.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/types/ListenV1CloseStream.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/types/ListenV1Finalize.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/types/ListenV1KeepAlive.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v1/types/ListenV1Results.d.ts +19 -0
- package/dist/cjs/api/resources/listen/resources/v2/client/Client.d.ts +2 -0
- package/dist/cjs/api/resources/listen/resources/v2/client/Client.js +2 -2
- package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2CloseStream.d.ts +1 -1
- package/dist/cjs/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/types/BreakdownListRequestDeployment.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/types/BreakdownListRequestGroupingItem.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/keys/types/KeysListRequestStatus.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/requests/client/Client.js +2 -2
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/requests/types/RequestsListRequestDeployment.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/requests/types/RequestsListRequestEndpoint.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/requests/types/RequestsListRequestMethod.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/requests/types/RequestsListRequestStatus.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/types/BreakdownGetRequestDeployment.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/types/BreakdownGetRequestEndpoint.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/types/BreakdownGetRequestGrouping.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/types/BreakdownGetRequestMethod.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/types/UsageGetRequestDeployment.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/types/UsageGetRequestEndpoint.d.ts +1 -1
- package/dist/cjs/api/resources/manage/resources/v1/resources/projects/resources/usage/types/UsageGetRequestMethod.d.ts +1 -1
- package/dist/cjs/api/resources/read/resources/v1/resources/text/types/TextAnalyzeRequestCallbackMethod.d.ts +1 -1
- package/dist/cjs/api/resources/read/resources/v1/resources/text/types/TextAnalyzeRequestCustomIntentMode.d.ts +1 -1
- package/dist/cjs/api/resources/read/resources/v1/resources/text/types/TextAnalyzeRequestCustomTopicMode.d.ts +1 -1
- package/dist/cjs/api/resources/read/resources/v1/resources/text/types/TextAnalyzeRequestSummarize.d.ts +1 -1
- package/dist/cjs/api/resources/selfHosted/resources/v1/resources/distributionCredentials/types/DistributionCredentialsCreateRequestScopesItem.d.ts +1 -1
- package/dist/cjs/api/resources/speak/resources/v1/client/Client.d.ts +2 -0
- package/dist/cjs/api/resources/speak/resources/v1/client/Client.js +2 -2
- package/dist/cjs/api/resources/speak/resources/v1/resources/audio/types/AudioGenerateRequestCallbackMethod.d.ts +1 -1
- package/dist/cjs/api/resources/speak/resources/v1/resources/audio/types/AudioGenerateRequestContainer.d.ts +1 -1
- package/dist/cjs/api/resources/speak/resources/v1/resources/audio/types/AudioGenerateRequestEncoding.d.ts +1 -1
- package/dist/cjs/api/resources/speak/resources/v1/resources/audio/types/AudioGenerateRequestModel.d.ts +1 -1
- package/dist/cjs/api/resources/speak/resources/v1/types/SpeakV1Clear.d.ts +1 -1
- package/dist/cjs/api/resources/speak/resources/v1/types/SpeakV1Cleared.d.ts +1 -1
- package/dist/cjs/api/resources/speak/resources/v1/types/SpeakV1Close.d.ts +1 -1
- package/dist/cjs/api/resources/speak/resources/v1/types/SpeakV1Flush.d.ts +1 -1
- package/dist/cjs/api/resources/speak/resources/v1/types/SpeakV1Flushed.d.ts +1 -1
- package/dist/cjs/api/types/AgentThinkModelsV1Response.d.ts +3 -3
- package/dist/cjs/api/types/Anthropic.d.ts +17 -0
- package/dist/cjs/api/types/Anthropic.js +12 -0
- package/dist/cjs/api/types/AwsBedrockThinkProvider.d.ts +40 -0
- package/dist/cjs/api/types/AwsBedrockThinkProvider.js +20 -0
- package/dist/cjs/api/types/AwsPollySpeakProvider.d.ts +47 -0
- package/dist/cjs/api/types/AwsPollySpeakProvider.js +31 -0
- package/dist/cjs/api/types/Cartesia.d.ts +24 -0
- package/dist/cjs/api/types/Cartesia.js +12 -0
- package/dist/cjs/api/types/Deepgram.d.ts +76 -0
- package/dist/cjs/api/types/Deepgram.js +73 -0
- package/dist/cjs/api/types/ElevenLabsSpeakProvider.d.ts +20 -0
- package/dist/cjs/api/types/ElevenLabsSpeakProvider.js +13 -0
- package/dist/cjs/api/types/Google.d.ts +18 -0
- package/dist/cjs/api/types/Google.js +13 -0
- package/dist/cjs/api/types/Groq.d.ts +9 -0
- package/dist/cjs/api/types/Groq.js +3 -0
- package/dist/cjs/api/types/ListBillingFieldsV1Response.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1CallbackMethod.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1DetectEntities.d.ts +6 -0
- package/dist/cjs/api/types/ListenV1DetectEntities.js +9 -0
- package/dist/cjs/api/types/ListenV1Diarize.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1Dictation.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1Encoding.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1InterimResults.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1Model.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1Multichannel.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1Numerals.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1ProfanityFilter.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1Punctuate.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1Redact.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1ResponseResultsChannelsItem.d.ts +12 -0
- package/dist/cjs/api/types/ListenV1SmartFormat.d.ts +1 -1
- package/dist/cjs/api/types/ListenV1VadEvents.d.ts +1 -1
- package/dist/cjs/api/types/ListenV2Encoding.d.ts +1 -1
- package/dist/cjs/api/types/OpenAi.d.ts +27 -0
- package/dist/cjs/api/types/OpenAi.js +21 -0
- package/dist/cjs/api/types/OpenAiSpeakProvider.d.ts +27 -0
- package/dist/cjs/api/types/OpenAiSpeakProvider.js +21 -0
- package/dist/cjs/api/types/OpenAiThinkProvider.d.ts +23 -0
- package/dist/cjs/api/types/OpenAiThinkProvider.js +18 -0
- package/dist/cjs/api/types/SpeakSettingsV1.d.ts +20 -0
- package/dist/cjs/api/types/SpeakSettingsV1.js +3 -0
- package/dist/cjs/api/types/SpeakSettingsV1Provider.d.ts +19 -0
- package/dist/cjs/api/types/SpeakSettingsV1Provider.js +3 -0
- package/dist/cjs/api/types/SpeakV1Encoding.d.ts +1 -1
- package/dist/cjs/api/types/SpeakV1Model.d.ts +1 -1
- package/dist/cjs/api/types/SpeakV1SampleRate.d.ts +1 -1
- package/dist/cjs/api/types/ThinkSettingsV1.d.ts +50 -0
- package/dist/cjs/api/types/ThinkSettingsV1.js +3 -0
- package/dist/cjs/api/types/ThinkSettingsV1Provider.d.ts +19 -0
- package/dist/cjs/api/types/ThinkSettingsV1Provider.js +3 -0
- package/dist/cjs/api/types/index.d.ts +15 -0
- package/dist/cjs/api/types/index.js +15 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/middleware/adapters/express.d.ts +103 -0
- package/dist/cjs/middleware/adapters/express.js +141 -0
- package/dist/cjs/middleware/adapters/fastify.d.ts +32 -0
- package/dist/cjs/middleware/adapters/fastify.js +194 -0
- package/dist/cjs/middleware/adapters/http.d.ts +153 -0
- package/dist/cjs/middleware/adapters/http.js +192 -0
- package/dist/cjs/middleware/core/ProxyHandler.d.ts +35 -0
- package/dist/cjs/middleware/core/ProxyHandler.js +225 -0
- package/dist/cjs/middleware/core/TokenManager.d.ts +29 -0
- package/dist/cjs/middleware/core/TokenManager.js +110 -0
- package/dist/cjs/middleware/core/WebSocketProxy.d.ts +32 -0
- package/dist/cjs/middleware/core/WebSocketProxy.js +169 -0
- package/dist/cjs/middleware/core/jwt.d.ts +71 -0
- package/dist/cjs/middleware/core/jwt.js +136 -0
- package/dist/cjs/middleware/core/types.d.ts +37 -0
- package/dist/cjs/middleware/core/types.js +2 -0
- package/dist/cjs/middleware/index.d.ts +55 -0
- package/dist/cjs/middleware/index.js +75 -0
- package/dist/cjs/tests/manual/test-custom-baseurl.js +124 -0
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.mjs +2 -2
- package/dist/esm/CustomClient.mjs +131 -0
- package/dist/esm/api/resources/agent/resources/v1/client/Client.d.mts +2 -0
- package/dist/esm/api/resources/agent/resources/v1/client/Client.mjs +2 -2
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1ConversationText.d.mts +1 -1
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1Settings.d.mts +5 -65
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1SettingsAgentListenProvider.d.mts +1 -1
- package/dist/esm/api/resources/agent/resources/v1/types/AgentV1UpdateSpeak.d.mts +1 -26
- package/dist/esm/api/resources/agent/resources/v1/types/index.d.mts +0 -4
- package/dist/esm/api/resources/agent/resources/v1/types/index.mjs +0 -4
- package/dist/esm/api/resources/listen/resources/v1/client/Client.d.mts +3 -0
- package/dist/esm/api/resources/listen/resources/v1/client/Client.mjs +3 -2
- package/dist/esm/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestCallbackMethod.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestCustomIntentMode.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestCustomTopicMode.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestEncoding.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestModel.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestSummarize.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/resources/media/types/MediaTranscribeRequestVersion.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/types/ListenV1CloseStream.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/types/ListenV1Finalize.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/types/ListenV1KeepAlive.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v1/types/ListenV1Results.d.mts +19 -0
- package/dist/esm/api/resources/listen/resources/v2/client/Client.d.mts +2 -0
- package/dist/esm/api/resources/listen/resources/v2/client/Client.mjs +2 -2
- package/dist/esm/api/resources/listen/resources/v2/types/ListenV2CloseStream.d.mts +1 -1
- package/dist/esm/api/resources/listen/resources/v2/types/ListenV2TurnInfo.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/types/BreakdownListRequestDeployment.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/billing/resources/breakdown/types/BreakdownListRequestGroupingItem.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/keys/types/KeysListRequestStatus.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/requests/client/Client.mjs +2 -2
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/requests/types/RequestsListRequestDeployment.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/requests/types/RequestsListRequestEndpoint.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/requests/types/RequestsListRequestMethod.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/requests/types/RequestsListRequestStatus.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/types/BreakdownGetRequestDeployment.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/types/BreakdownGetRequestEndpoint.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/types/BreakdownGetRequestGrouping.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/resources/breakdown/types/BreakdownGetRequestMethod.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/types/UsageGetRequestDeployment.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/types/UsageGetRequestEndpoint.d.mts +1 -1
- package/dist/esm/api/resources/manage/resources/v1/resources/projects/resources/usage/types/UsageGetRequestMethod.d.mts +1 -1
- package/dist/esm/api/resources/read/resources/v1/resources/text/types/TextAnalyzeRequestCallbackMethod.d.mts +1 -1
- package/dist/esm/api/resources/read/resources/v1/resources/text/types/TextAnalyzeRequestCustomIntentMode.d.mts +1 -1
- package/dist/esm/api/resources/read/resources/v1/resources/text/types/TextAnalyzeRequestCustomTopicMode.d.mts +1 -1
- package/dist/esm/api/resources/read/resources/v1/resources/text/types/TextAnalyzeRequestSummarize.d.mts +1 -1
- package/dist/esm/api/resources/selfHosted/resources/v1/resources/distributionCredentials/types/DistributionCredentialsCreateRequestScopesItem.d.mts +1 -1
- package/dist/esm/api/resources/speak/resources/v1/client/Client.d.mts +2 -0
- package/dist/esm/api/resources/speak/resources/v1/client/Client.mjs +2 -2
- package/dist/esm/api/resources/speak/resources/v1/resources/audio/types/AudioGenerateRequestCallbackMethod.d.mts +1 -1
- package/dist/esm/api/resources/speak/resources/v1/resources/audio/types/AudioGenerateRequestContainer.d.mts +1 -1
- package/dist/esm/api/resources/speak/resources/v1/resources/audio/types/AudioGenerateRequestEncoding.d.mts +1 -1
- package/dist/esm/api/resources/speak/resources/v1/resources/audio/types/AudioGenerateRequestModel.d.mts +1 -1
- package/dist/esm/api/resources/speak/resources/v1/types/SpeakV1Clear.d.mts +1 -1
- package/dist/esm/api/resources/speak/resources/v1/types/SpeakV1Cleared.d.mts +1 -1
- package/dist/esm/api/resources/speak/resources/v1/types/SpeakV1Close.d.mts +1 -1
- package/dist/esm/api/resources/speak/resources/v1/types/SpeakV1Flush.d.mts +1 -1
- package/dist/esm/api/resources/speak/resources/v1/types/SpeakV1Flushed.d.mts +1 -1
- package/dist/esm/api/types/AgentThinkModelsV1Response.d.mts +3 -3
- package/dist/esm/api/types/Anthropic.d.mts +17 -0
- package/dist/esm/api/types/Anthropic.mjs +9 -0
- package/dist/esm/api/types/AwsBedrockThinkProvider.d.mts +40 -0
- package/dist/esm/api/types/AwsBedrockThinkProvider.mjs +17 -0
- package/dist/esm/api/types/AwsPollySpeakProvider.d.mts +47 -0
- package/dist/esm/api/types/AwsPollySpeakProvider.mjs +28 -0
- package/dist/esm/api/types/Cartesia.d.mts +24 -0
- package/dist/esm/api/types/Cartesia.mjs +9 -0
- package/dist/esm/api/types/Deepgram.d.mts +76 -0
- package/dist/esm/api/types/Deepgram.mjs +70 -0
- package/dist/esm/api/types/ElevenLabsSpeakProvider.d.mts +20 -0
- package/dist/esm/api/types/ElevenLabsSpeakProvider.mjs +10 -0
- package/dist/esm/api/types/Google.d.mts +18 -0
- package/dist/esm/api/types/Google.mjs +10 -0
- package/dist/esm/api/types/Groq.d.mts +9 -0
- package/dist/esm/api/types/Groq.mjs +2 -0
- package/dist/esm/api/types/ListBillingFieldsV1Response.d.mts +1 -1
- package/dist/esm/api/types/ListenV1CallbackMethod.d.mts +1 -1
- package/dist/esm/api/types/ListenV1DetectEntities.d.mts +6 -0
- package/dist/esm/api/types/ListenV1DetectEntities.mjs +6 -0
- package/dist/esm/api/types/ListenV1Diarize.d.mts +1 -1
- package/dist/esm/api/types/ListenV1Dictation.d.mts +1 -1
- package/dist/esm/api/types/ListenV1Encoding.d.mts +1 -1
- package/dist/esm/api/types/ListenV1InterimResults.d.mts +1 -1
- package/dist/esm/api/types/ListenV1Model.d.mts +1 -1
- package/dist/esm/api/types/ListenV1Multichannel.d.mts +1 -1
- package/dist/esm/api/types/ListenV1Numerals.d.mts +1 -1
- package/dist/esm/api/types/ListenV1ProfanityFilter.d.mts +1 -1
- package/dist/esm/api/types/ListenV1Punctuate.d.mts +1 -1
- package/dist/esm/api/types/ListenV1Redact.d.mts +1 -1
- package/dist/esm/api/types/ListenV1ResponseResultsChannelsItem.d.mts +12 -0
- package/dist/esm/api/types/ListenV1SmartFormat.d.mts +1 -1
- package/dist/esm/api/types/ListenV1VadEvents.d.mts +1 -1
- package/dist/esm/api/types/ListenV2Encoding.d.mts +1 -1
- package/dist/esm/api/types/OpenAi.d.mts +27 -0
- package/dist/esm/api/types/OpenAi.mjs +18 -0
- package/dist/esm/api/types/OpenAiSpeakProvider.d.mts +27 -0
- package/dist/esm/api/types/OpenAiSpeakProvider.mjs +18 -0
- package/dist/esm/api/types/OpenAiThinkProvider.d.mts +23 -0
- package/dist/esm/api/types/OpenAiThinkProvider.mjs +15 -0
- package/dist/esm/api/types/SpeakSettingsV1.d.mts +20 -0
- package/dist/esm/api/types/SpeakSettingsV1.mjs +2 -0
- package/dist/esm/api/types/SpeakSettingsV1Provider.d.mts +19 -0
- package/dist/esm/api/types/SpeakSettingsV1Provider.mjs +2 -0
- package/dist/esm/api/types/SpeakV1Encoding.d.mts +1 -1
- package/dist/esm/api/types/SpeakV1Model.d.mts +1 -1
- package/dist/esm/api/types/SpeakV1SampleRate.d.mts +1 -1
- package/dist/esm/api/types/ThinkSettingsV1.d.mts +50 -0
- package/dist/esm/api/types/ThinkSettingsV1.mjs +2 -0
- package/dist/esm/api/types/ThinkSettingsV1Provider.d.mts +19 -0
- package/dist/esm/api/types/ThinkSettingsV1Provider.mjs +2 -0
- package/dist/esm/api/types/index.d.mts +15 -0
- package/dist/esm/api/types/index.mjs +15 -0
- package/dist/esm/index.d.mts +2 -0
- package/dist/esm/index.mjs +6 -0
- package/dist/esm/middleware/adapters/express.d.mts +103 -0
- package/dist/esm/middleware/adapters/express.mjs +136 -0
- package/dist/esm/middleware/adapters/fastify.d.mts +32 -0
- package/dist/esm/middleware/adapters/fastify.mjs +157 -0
- package/dist/esm/middleware/adapters/http.d.mts +153 -0
- package/dist/esm/middleware/adapters/http.mjs +187 -0
- package/dist/esm/middleware/core/ProxyHandler.d.mts +35 -0
- package/dist/esm/middleware/core/ProxyHandler.mjs +218 -0
- package/dist/esm/middleware/core/TokenManager.d.mts +29 -0
- package/dist/esm/middleware/core/TokenManager.mjs +106 -0
- package/dist/esm/middleware/core/WebSocketProxy.d.mts +32 -0
- package/dist/esm/middleware/core/WebSocketProxy.mjs +162 -0
- package/dist/esm/middleware/core/jwt.d.mts +71 -0
- package/dist/esm/middleware/core/jwt.mjs +99 -0
- package/dist/esm/middleware/core/types.d.mts +37 -0
- package/dist/esm/middleware/core/types.mjs +1 -0
- package/dist/esm/middleware/index.d.mts +55 -0
- package/dist/esm/middleware/index.mjs +59 -0
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +2 -2
|
@@ -15,15 +15,21 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./AgentThinkModelsV1Response.js"), exports);
|
|
18
|
+
__exportStar(require("./Anthropic.js"), exports);
|
|
19
|
+
__exportStar(require("./AwsBedrockThinkProvider.js"), exports);
|
|
20
|
+
__exportStar(require("./AwsPollySpeakProvider.js"), exports);
|
|
18
21
|
__exportStar(require("./BillingBreakdownV1Response.js"), exports);
|
|
22
|
+
__exportStar(require("./Cartesia.js"), exports);
|
|
19
23
|
__exportStar(require("./CreateKeyV1RequestOne.js"), exports);
|
|
20
24
|
__exportStar(require("./CreateKeyV1Response.js"), exports);
|
|
21
25
|
__exportStar(require("./CreateProjectDistributionCredentialsV1Response.js"), exports);
|
|
22
26
|
__exportStar(require("./CreateProjectInviteV1Response.js"), exports);
|
|
27
|
+
__exportStar(require("./Deepgram.js"), exports);
|
|
23
28
|
__exportStar(require("./DeleteProjectInviteV1Response.js"), exports);
|
|
24
29
|
__exportStar(require("./DeleteProjectKeyV1Response.js"), exports);
|
|
25
30
|
__exportStar(require("./DeleteProjectMemberV1Response.js"), exports);
|
|
26
31
|
__exportStar(require("./DeleteProjectV1Response.js"), exports);
|
|
32
|
+
__exportStar(require("./ElevenLabsSpeakProvider.js"), exports);
|
|
27
33
|
__exportStar(require("./ErrorResponse.js"), exports);
|
|
28
34
|
__exportStar(require("./ErrorResponseLegacyError.js"), exports);
|
|
29
35
|
__exportStar(require("./ErrorResponseModernError.js"), exports);
|
|
@@ -34,13 +40,16 @@ __exportStar(require("./GetProjectDistributionCredentialsV1Response.js"), export
|
|
|
34
40
|
__exportStar(require("./GetProjectKeyV1Response.js"), exports);
|
|
35
41
|
__exportStar(require("./GetProjectRequestV1Response.js"), exports);
|
|
36
42
|
__exportStar(require("./GetProjectV1Response.js"), exports);
|
|
43
|
+
__exportStar(require("./Google.js"), exports);
|
|
37
44
|
__exportStar(require("./GrantV1Response.js"), exports);
|
|
45
|
+
__exportStar(require("./Groq.js"), exports);
|
|
38
46
|
__exportStar(require("./LeaveProjectV1Response.js"), exports);
|
|
39
47
|
__exportStar(require("./ListBillingFieldsV1Response.js"), exports);
|
|
40
48
|
__exportStar(require("./ListenV1AcceptedResponse.js"), exports);
|
|
41
49
|
__exportStar(require("./ListenV1Callback.js"), exports);
|
|
42
50
|
__exportStar(require("./ListenV1CallbackMethod.js"), exports);
|
|
43
51
|
__exportStar(require("./ListenV1Channels.js"), exports);
|
|
52
|
+
__exportStar(require("./ListenV1DetectEntities.js"), exports);
|
|
44
53
|
__exportStar(require("./ListenV1Diarize.js"), exports);
|
|
45
54
|
__exportStar(require("./ListenV1Dictation.js"), exports);
|
|
46
55
|
__exportStar(require("./ListenV1Encoding.js"), exports);
|
|
@@ -95,6 +104,8 @@ __exportStar(require("./ListProjectMembersV1Response.js"), exports);
|
|
|
95
104
|
__exportStar(require("./ListProjectPurchasesV1Response.js"), exports);
|
|
96
105
|
__exportStar(require("./ListProjectRequestsV1Response.js"), exports);
|
|
97
106
|
__exportStar(require("./ListProjectsV1Response.js"), exports);
|
|
107
|
+
__exportStar(require("./OpenAiSpeakProvider.js"), exports);
|
|
108
|
+
__exportStar(require("./OpenAiThinkProvider.js"), exports);
|
|
98
109
|
__exportStar(require("./ProjectRequestResponse.js"), exports);
|
|
99
110
|
__exportStar(require("./ReadV1Request.js"), exports);
|
|
100
111
|
__exportStar(require("./ReadV1RequestText.js"), exports);
|
|
@@ -106,11 +117,15 @@ __exportStar(require("./ReadV1ResponseResultsSummary.js"), exports);
|
|
|
106
117
|
__exportStar(require("./SharedIntents.js"), exports);
|
|
107
118
|
__exportStar(require("./SharedSentiments.js"), exports);
|
|
108
119
|
__exportStar(require("./SharedTopics.js"), exports);
|
|
120
|
+
__exportStar(require("./SpeakSettingsV1.js"), exports);
|
|
121
|
+
__exportStar(require("./SpeakSettingsV1Provider.js"), exports);
|
|
109
122
|
__exportStar(require("./SpeakV1Encoding.js"), exports);
|
|
110
123
|
__exportStar(require("./SpeakV1MipOptOut.js"), exports);
|
|
111
124
|
__exportStar(require("./SpeakV1Model.js"), exports);
|
|
112
125
|
__exportStar(require("./SpeakV1Response.js"), exports);
|
|
113
126
|
__exportStar(require("./SpeakV1SampleRate.js"), exports);
|
|
127
|
+
__exportStar(require("./ThinkSettingsV1.js"), exports);
|
|
128
|
+
__exportStar(require("./ThinkSettingsV1Provider.js"), exports);
|
|
114
129
|
__exportStar(require("./UpdateProjectMemberScopesV1Response.js"), exports);
|
|
115
130
|
__exportStar(require("./UpdateProjectV1Response.js"), exports);
|
|
116
131
|
__exportStar(require("./UsageBreakdownV1Response.js"), exports);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * as Deepgram from "./api/index.js";
|
|
2
|
+
export * from "./api/types/index.js";
|
|
3
|
+
export * from "./api/resources/index.js";
|
|
2
4
|
export type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
3
5
|
export { DeepgramClient as DefaultDeepgramClient } from "./Client.js";
|
|
4
6
|
export { CustomDeepgramClient as DeepgramClient } from "./CustomClient.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -37,7 +37,13 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.DeepgramTimeoutError = exports.DeepgramError = exports.DeepgramEnvironment = exports.DeepgramClient = exports.DefaultDeepgramClient = exports.Deepgram = void 0;
|
|
40
|
+
// Export everything under Deepgram namespace for backwards compatibility
|
|
40
41
|
exports.Deepgram = __importStar(require("./api/index.js"));
|
|
42
|
+
// ALSO export all types directly for better discoverability and IDE autocomplete
|
|
43
|
+
// This allows: import { ListenV1Response } from "@deepgram/sdk"
|
|
44
|
+
// While still supporting: import { Deepgram } from "@deepgram/sdk"; type Response = Deepgram.ListenV1Response;
|
|
45
|
+
__exportStar(require("./api/types/index.js"), exports);
|
|
46
|
+
__exportStar(require("./api/resources/index.js"), exports);
|
|
41
47
|
var Client_js_1 = require("./Client.js");
|
|
42
48
|
Object.defineProperty(exports, "DefaultDeepgramClient", { enumerable: true, get: function () { return Client_js_1.DeepgramClient; } });
|
|
43
49
|
var CustomClient_js_1 = require("./CustomClient.js");
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Express middleware for proxying Deepgram API requests.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*
|
|
6
|
+
* **Peer Dependencies Required:**
|
|
7
|
+
* ```bash
|
|
8
|
+
* npm install express
|
|
9
|
+
* # or
|
|
10
|
+
* pnpm add express
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* This module provides Express-compatible middleware for proxying requests to the
|
|
14
|
+
* Deepgram API, including REST endpoints and WebSocket connections.
|
|
15
|
+
*/
|
|
16
|
+
import type { IncomingMessage, Server, ServerResponse } from "node:http";
|
|
17
|
+
import type { Duplex } from "node:stream";
|
|
18
|
+
import type { MiddlewareOptions } from "../core/types.js";
|
|
19
|
+
/**
|
|
20
|
+
* Express middleware type
|
|
21
|
+
*/
|
|
22
|
+
export type ExpressMiddleware = (req: IncomingMessage, res: ServerResponse, next: (error?: Error) => void) => void | Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* WebSocket upgrade handler type
|
|
25
|
+
*/
|
|
26
|
+
export type UpgradeHandler = (req: IncomingMessage, socket: Duplex, head: Buffer) => void;
|
|
27
|
+
/**
|
|
28
|
+
* Create Express middleware for proxying Deepgram API requests
|
|
29
|
+
*
|
|
30
|
+
* @param options - Middleware configuration options
|
|
31
|
+
* @returns Express middleware function
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* ```typescript
|
|
35
|
+
* import express from 'express';
|
|
36
|
+
* import { createDeepgramProxy, createWebSocketHandler } from '@deepgram/sdk';
|
|
37
|
+
*
|
|
38
|
+
* const app = express();
|
|
39
|
+
* const proxyOptions = {
|
|
40
|
+
* apiKey: process.env.DEEPGRAM_API_KEY!,
|
|
41
|
+
* enableTokenAuth: true
|
|
42
|
+
* };
|
|
43
|
+
*
|
|
44
|
+
* // REST API proxy
|
|
45
|
+
* app.use('/api/deepgram', createDeepgramProxy(proxyOptions));
|
|
46
|
+
*
|
|
47
|
+
* // WebSocket upgrade handler
|
|
48
|
+
* const server = app.listen(3000);
|
|
49
|
+
* server.on('upgrade', createWebSocketHandler(proxyOptions));
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
export declare function createDeepgramProxy(options: MiddlewareOptions): ExpressMiddleware;
|
|
53
|
+
/**
|
|
54
|
+
* Create WebSocket upgrade handler for Express
|
|
55
|
+
*
|
|
56
|
+
* This must be registered on the HTTP server, not the Express app.
|
|
57
|
+
*
|
|
58
|
+
* @param options - Middleware configuration options
|
|
59
|
+
* @returns Upgrade handler function
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```typescript
|
|
63
|
+
* import express from 'express';
|
|
64
|
+
* import { createWebSocketHandler } from '@deepgram/sdk';
|
|
65
|
+
*
|
|
66
|
+
* const app = express();
|
|
67
|
+
* const server = app.listen(3000);
|
|
68
|
+
*
|
|
69
|
+
* // Register WebSocket handler on the server
|
|
70
|
+
* server.on('upgrade', createWebSocketHandler({
|
|
71
|
+
* apiKey: process.env.DEEPGRAM_API_KEY!
|
|
72
|
+
* }));
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
export declare function createWebSocketHandler(options: MiddlewareOptions): UpgradeHandler;
|
|
76
|
+
/**
|
|
77
|
+
* Combined helper that returns both middleware and upgrade handler
|
|
78
|
+
*
|
|
79
|
+
* @param options - Middleware configuration options
|
|
80
|
+
* @returns Object with middleware and upgrade handler
|
|
81
|
+
*
|
|
82
|
+
* @example
|
|
83
|
+
* ```typescript
|
|
84
|
+
* import express from 'express';
|
|
85
|
+
* import { createDeepgramMiddleware } from '@deepgram/sdk';
|
|
86
|
+
*
|
|
87
|
+
* const app = express();
|
|
88
|
+
* const { middleware, upgradeHandler } = createDeepgramMiddleware({
|
|
89
|
+
* apiKey: process.env.DEEPGRAM_API_KEY!,
|
|
90
|
+
* enableTokenAuth: true
|
|
91
|
+
* });
|
|
92
|
+
*
|
|
93
|
+
* app.use('/api/deepgram', middleware);
|
|
94
|
+
*
|
|
95
|
+
* const server = app.listen(3000);
|
|
96
|
+
* server.on('upgrade', upgradeHandler);
|
|
97
|
+
* ```
|
|
98
|
+
*/
|
|
99
|
+
export declare function createDeepgramMiddleware(options: MiddlewareOptions): {
|
|
100
|
+
middleware: ExpressMiddleware;
|
|
101
|
+
upgradeHandler: UpgradeHandler;
|
|
102
|
+
server: (httpServer: Server) => void;
|
|
103
|
+
};
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Express middleware for proxying Deepgram API requests.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*
|
|
7
|
+
* **Peer Dependencies Required:**
|
|
8
|
+
* ```bash
|
|
9
|
+
* npm install express
|
|
10
|
+
* # or
|
|
11
|
+
* pnpm add express
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* This module provides Express-compatible middleware for proxying requests to the
|
|
15
|
+
* Deepgram API, including REST endpoints and WebSocket connections.
|
|
16
|
+
*/
|
|
17
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
+
exports.createDeepgramProxy = createDeepgramProxy;
|
|
28
|
+
exports.createWebSocketHandler = createWebSocketHandler;
|
|
29
|
+
exports.createDeepgramMiddleware = createDeepgramMiddleware;
|
|
30
|
+
const ProxyHandler_js_1 = require("../core/ProxyHandler.js");
|
|
31
|
+
const TokenManager_js_1 = require("../core/TokenManager.js");
|
|
32
|
+
const WebSocketProxy_js_1 = require("../core/WebSocketProxy.js");
|
|
33
|
+
/**
|
|
34
|
+
* Create Express middleware for proxying Deepgram API requests
|
|
35
|
+
*
|
|
36
|
+
* @param options - Middleware configuration options
|
|
37
|
+
* @returns Express middleware function
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```typescript
|
|
41
|
+
* import express from 'express';
|
|
42
|
+
* import { createDeepgramProxy, createWebSocketHandler } from '@deepgram/sdk';
|
|
43
|
+
*
|
|
44
|
+
* const app = express();
|
|
45
|
+
* const proxyOptions = {
|
|
46
|
+
* apiKey: process.env.DEEPGRAM_API_KEY!,
|
|
47
|
+
* enableTokenAuth: true
|
|
48
|
+
* };
|
|
49
|
+
*
|
|
50
|
+
* // REST API proxy
|
|
51
|
+
* app.use('/api/deepgram', createDeepgramProxy(proxyOptions));
|
|
52
|
+
*
|
|
53
|
+
* // WebSocket upgrade handler
|
|
54
|
+
* const server = app.listen(3000);
|
|
55
|
+
* server.on('upgrade', createWebSocketHandler(proxyOptions));
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
function createDeepgramProxy(options) {
|
|
59
|
+
const proxyHandler = new ProxyHandler_js_1.ProxyHandler(options);
|
|
60
|
+
const tokenManager = options.enableTokenAuth
|
|
61
|
+
? new TokenManager_js_1.TokenManager(options)
|
|
62
|
+
: null;
|
|
63
|
+
return (req, res, next) => __awaiter(this, void 0, void 0, function* () {
|
|
64
|
+
try {
|
|
65
|
+
// Handle token generation requests
|
|
66
|
+
if (options.enableTokenAuth &&
|
|
67
|
+
req.url === "/token" &&
|
|
68
|
+
req.method === "GET") {
|
|
69
|
+
yield tokenManager.handleTokenRequest(req, res);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
// Handle all other requests (proxy to Deepgram)
|
|
73
|
+
yield proxyHandler.handleRequest(req, res);
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
next(error instanceof Error ? error : new Error(String(error)));
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Create WebSocket upgrade handler for Express
|
|
82
|
+
*
|
|
83
|
+
* This must be registered on the HTTP server, not the Express app.
|
|
84
|
+
*
|
|
85
|
+
* @param options - Middleware configuration options
|
|
86
|
+
* @returns Upgrade handler function
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* import express from 'express';
|
|
91
|
+
* import { createWebSocketHandler } from '@deepgram/sdk';
|
|
92
|
+
*
|
|
93
|
+
* const app = express();
|
|
94
|
+
* const server = app.listen(3000);
|
|
95
|
+
*
|
|
96
|
+
* // Register WebSocket handler on the server
|
|
97
|
+
* server.on('upgrade', createWebSocketHandler({
|
|
98
|
+
* apiKey: process.env.DEEPGRAM_API_KEY!
|
|
99
|
+
* }));
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
102
|
+
function createWebSocketHandler(options) {
|
|
103
|
+
const wsProxy = new WebSocketProxy_js_1.WebSocketProxy(options);
|
|
104
|
+
return (req, socket, head) => {
|
|
105
|
+
wsProxy.handleUpgrade(req, socket, head);
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Combined helper that returns both middleware and upgrade handler
|
|
110
|
+
*
|
|
111
|
+
* @param options - Middleware configuration options
|
|
112
|
+
* @returns Object with middleware and upgrade handler
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* import express from 'express';
|
|
117
|
+
* import { createDeepgramMiddleware } from '@deepgram/sdk';
|
|
118
|
+
*
|
|
119
|
+
* const app = express();
|
|
120
|
+
* const { middleware, upgradeHandler } = createDeepgramMiddleware({
|
|
121
|
+
* apiKey: process.env.DEEPGRAM_API_KEY!,
|
|
122
|
+
* enableTokenAuth: true
|
|
123
|
+
* });
|
|
124
|
+
*
|
|
125
|
+
* app.use('/api/deepgram', middleware);
|
|
126
|
+
*
|
|
127
|
+
* const server = app.listen(3000);
|
|
128
|
+
* server.on('upgrade', upgradeHandler);
|
|
129
|
+
* ```
|
|
130
|
+
*/
|
|
131
|
+
function createDeepgramMiddleware(options) {
|
|
132
|
+
const middleware = createDeepgramProxy(options);
|
|
133
|
+
const upgradeHandler = createWebSocketHandler(options);
|
|
134
|
+
return {
|
|
135
|
+
middleware,
|
|
136
|
+
upgradeHandler,
|
|
137
|
+
server: (httpServer) => {
|
|
138
|
+
httpServer.on("upgrade", upgradeHandler);
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fastify plugin for proxying Deepgram API requests.
|
|
3
|
+
*
|
|
4
|
+
* @packageDocumentation
|
|
5
|
+
*
|
|
6
|
+
* **Peer Dependencies Required:**
|
|
7
|
+
* ```bash
|
|
8
|
+
* npm install fastify fastify-plugin
|
|
9
|
+
* # or
|
|
10
|
+
* pnpm add fastify fastify-plugin
|
|
11
|
+
* ```
|
|
12
|
+
*
|
|
13
|
+
* This module provides a Fastify plugin for proxying requests to the Deepgram API,
|
|
14
|
+
* including REST endpoints and WebSocket connections.
|
|
15
|
+
*/
|
|
16
|
+
import type { FastifyPluginAsync, FastifyPluginOptions } from "fastify";
|
|
17
|
+
import type { MiddlewareOptions } from "../core/types.js";
|
|
18
|
+
/**
|
|
19
|
+
* Fastify plugin options
|
|
20
|
+
*/
|
|
21
|
+
export interface FastifyDeepgramProxyOptions extends MiddlewareOptions, FastifyPluginOptions {
|
|
22
|
+
/** URL prefix for the proxy routes (default: "") */
|
|
23
|
+
prefix?: string;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Export as Fastify plugin with proper typing
|
|
27
|
+
*/
|
|
28
|
+
export declare const fastifyDeepgramProxy: FastifyPluginAsync<FastifyDeepgramProxyOptions>;
|
|
29
|
+
/**
|
|
30
|
+
* Alternative export for direct usage (without fastify-plugin wrapper)
|
|
31
|
+
*/
|
|
32
|
+
export declare const deepgramProxyPlugin: FastifyPluginAsync<FastifyDeepgramProxyOptions>;
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Fastify plugin for proxying Deepgram API requests.
|
|
4
|
+
*
|
|
5
|
+
* @packageDocumentation
|
|
6
|
+
*
|
|
7
|
+
* **Peer Dependencies Required:**
|
|
8
|
+
* ```bash
|
|
9
|
+
* npm install fastify fastify-plugin
|
|
10
|
+
* # or
|
|
11
|
+
* pnpm add fastify fastify-plugin
|
|
12
|
+
* ```
|
|
13
|
+
*
|
|
14
|
+
* This module provides a Fastify plugin for proxying requests to the Deepgram API,
|
|
15
|
+
* including REST endpoints and WebSocket connections.
|
|
16
|
+
*/
|
|
17
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
34
|
+
var ownKeys = function(o) {
|
|
35
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
36
|
+
var ar = [];
|
|
37
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
38
|
+
return ar;
|
|
39
|
+
};
|
|
40
|
+
return ownKeys(o);
|
|
41
|
+
};
|
|
42
|
+
return function (mod) {
|
|
43
|
+
if (mod && mod.__esModule) return mod;
|
|
44
|
+
var result = {};
|
|
45
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
46
|
+
__setModuleDefault(result, mod);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
})();
|
|
50
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
51
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
52
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
53
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
54
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
55
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
56
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
57
|
+
});
|
|
58
|
+
};
|
|
59
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
|
+
exports.deepgramProxyPlugin = exports.fastifyDeepgramProxy = void 0;
|
|
61
|
+
const ProxyHandler_js_1 = require("../core/ProxyHandler.js");
|
|
62
|
+
const TokenManager_js_1 = require("../core/TokenManager.js");
|
|
63
|
+
const WebSocketProxy_js_1 = require("../core/WebSocketProxy.js");
|
|
64
|
+
// Lazy-load fastify-plugin
|
|
65
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Dynamic loading
|
|
66
|
+
let fp = null;
|
|
67
|
+
function loadFastifyPlugin() {
|
|
68
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
69
|
+
if (fp) {
|
|
70
|
+
return fp;
|
|
71
|
+
}
|
|
72
|
+
try {
|
|
73
|
+
const module = yield Promise.resolve().then(() => __importStar(require("fastify-plugin")));
|
|
74
|
+
fp = module.default || module;
|
|
75
|
+
return fp;
|
|
76
|
+
}
|
|
77
|
+
catch (_a) {
|
|
78
|
+
throw new Error("fastify-plugin is required for Fastify middleware. Install it with: npm install fastify-plugin");
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Fastify plugin for proxying Deepgram API requests
|
|
84
|
+
*
|
|
85
|
+
* @param fastify - Fastify instance
|
|
86
|
+
* @param options - Plugin configuration options
|
|
87
|
+
*
|
|
88
|
+
* @example
|
|
89
|
+
* ```typescript
|
|
90
|
+
* import Fastify from 'fastify';
|
|
91
|
+
* import { fastifyDeepgramProxy } from '@deepgram/sdk';
|
|
92
|
+
*
|
|
93
|
+
* const fastify = Fastify();
|
|
94
|
+
*
|
|
95
|
+
* fastify.register(fastifyDeepgramProxy, {
|
|
96
|
+
* prefix: '/api/deepgram',
|
|
97
|
+
* apiKey: process.env.DEEPGRAM_API_KEY!,
|
|
98
|
+
* enableTokenAuth: true
|
|
99
|
+
* });
|
|
100
|
+
*
|
|
101
|
+
* fastify.listen({ port: 3000 });
|
|
102
|
+
* ```
|
|
103
|
+
*/
|
|
104
|
+
const fastifyDeepgramProxyPlugin = (fastify, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
105
|
+
var _a;
|
|
106
|
+
const proxyHandler = new ProxyHandler_js_1.ProxyHandler(options);
|
|
107
|
+
const tokenManager = options.enableTokenAuth
|
|
108
|
+
? new TokenManager_js_1.TokenManager(options)
|
|
109
|
+
: null;
|
|
110
|
+
const wsProxy = new WebSocketProxy_js_1.WebSocketProxy(options);
|
|
111
|
+
// NOTE: We do NOT add a custom content type parser here because:
|
|
112
|
+
// 1. fastify-plugin breaks encapsulation, so it would affect ALL routes
|
|
113
|
+
// 2. We handle body reconstruction in our route handlers instead
|
|
114
|
+
// This allows users to use their own body parsers for their routes
|
|
115
|
+
// Register token endpoint if token auth is enabled
|
|
116
|
+
if (tokenManager) {
|
|
117
|
+
fastify.get("/token", (request, reply) => {
|
|
118
|
+
reply.hijack();
|
|
119
|
+
tokenManager.handleTokenRequest(request.raw, reply.raw).catch((error) => {
|
|
120
|
+
console.error("Token generation error:", error);
|
|
121
|
+
});
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
// Register wildcard route to catch ALL paths
|
|
125
|
+
// This must match any path depth: /, /v1, /v1/listen, /v1/listen/more/paths
|
|
126
|
+
fastify.all("/*", (request, reply) => {
|
|
127
|
+
reply.hijack();
|
|
128
|
+
// Fastify has already consumed the request body stream, so we need to
|
|
129
|
+
// write the parsed body back to the raw request
|
|
130
|
+
if (request.body && (request.method === 'POST' || request.method === 'PUT' || request.method === 'PATCH')) {
|
|
131
|
+
const bodyString = typeof request.body === 'string' ? request.body : JSON.stringify(request.body);
|
|
132
|
+
// Write the body to the raw request stream
|
|
133
|
+
process.nextTick(() => {
|
|
134
|
+
request.raw.emit('data', Buffer.from(bodyString));
|
|
135
|
+
request.raw.emit('end');
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
proxyHandler.handleRequest(request.raw, reply.raw).catch((error) => {
|
|
139
|
+
console.error("[Fastify] Proxy error:", error);
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
// Also catch root path explicitly
|
|
143
|
+
fastify.all("/", (request, reply) => {
|
|
144
|
+
reply.hijack();
|
|
145
|
+
// Reconstruct body if needed
|
|
146
|
+
if (request.body && (request.method === 'POST' || request.method === 'PUT' || request.method === 'PATCH')) {
|
|
147
|
+
const bodyString = typeof request.body === 'string' ? request.body : JSON.stringify(request.body);
|
|
148
|
+
process.nextTick(() => {
|
|
149
|
+
request.raw.emit('data', Buffer.from(bodyString));
|
|
150
|
+
request.raw.emit('end');
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
proxyHandler.handleRequest(request.raw, reply.raw).catch((error) => {
|
|
154
|
+
console.error("[Fastify] Root proxy error:", error);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
// Register WebSocket upgrade handler
|
|
158
|
+
if (fastify.server) {
|
|
159
|
+
const prefix = (_a = options.prefix) !== null && _a !== void 0 ? _a : "";
|
|
160
|
+
fastify.server.on("upgrade", (req, socket, head) => {
|
|
161
|
+
var _a;
|
|
162
|
+
// Only handle requests matching our prefix
|
|
163
|
+
if ((_a = req.url) === null || _a === void 0 ? void 0 : _a.startsWith(prefix)) {
|
|
164
|
+
// Remove prefix from URL before proxying
|
|
165
|
+
const originalUrl = req.url;
|
|
166
|
+
req.url = originalUrl.slice(prefix.length);
|
|
167
|
+
wsProxy.handleUpgrade(req, socket, head);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
/**
|
|
173
|
+
* Lazy-loaded Fastify plugin (only loads fastify-plugin when called)
|
|
174
|
+
*/
|
|
175
|
+
let _fastifyDeepgramProxy = null;
|
|
176
|
+
/**
|
|
177
|
+
* Export as Fastify plugin with proper typing
|
|
178
|
+
*/
|
|
179
|
+
const fastifyDeepgramProxy = (fastify, options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
180
|
+
if (!_fastifyDeepgramProxy) {
|
|
181
|
+
const pluginWrapper = yield loadFastifyPlugin();
|
|
182
|
+
_fastifyDeepgramProxy = pluginWrapper(fastifyDeepgramProxyPlugin, {
|
|
183
|
+
fastify: ">=4.0.0",
|
|
184
|
+
name: "@deepgram/sdk-middleware",
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion -- Guaranteed to be set above
|
|
188
|
+
return _fastifyDeepgramProxy(fastify, options);
|
|
189
|
+
});
|
|
190
|
+
exports.fastifyDeepgramProxy = fastifyDeepgramProxy;
|
|
191
|
+
/**
|
|
192
|
+
* Alternative export for direct usage (without fastify-plugin wrapper)
|
|
193
|
+
*/
|
|
194
|
+
exports.deepgramProxyPlugin = fastifyDeepgramProxyPlugin;
|