voice-router-dev 0.8.1 → 0.8.3

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.
@@ -1,7 +1,237 @@
1
- import { fo as TranscriptionStatus, fl as Speaker, fm as Word, fn as Utterance, Q as CallbackTranscriptionSuccessPayload, J as CallbackTranscriptionErrorPayload, cf as TranscriptWebhookNotification, d2 as ListenV1Response } from './transcriptWebhookNotification-BJk1CEF5.js';
2
- import { T as TranscriptionProvider } from './provider-metadata-DbsSGAO7.js';
1
+ import { gH as TranscriptionStatus, gE as Speaker, gF as Word, gG as Utterance, Q as CallbackTranscriptionSuccessPayload, J as CallbackTranscriptionErrorPayload, cf as TranscriptWebhookNotification, d2 as ListenV1Response, eR as RetrieveTranscriptResponse, fr as SpeechToTextChunkResponseModel } from './speechToTextChunkResponseModel-DjL2ncnf.js';
2
+ import { T as TranscriptionProvider } from './provider-metadata-_gUWlRXS.js';
3
3
  import './constants.js';
4
4
 
5
+ /**
6
+ * Base webhook handler interface
7
+ * All provider-specific webhook handlers must implement this
8
+ */
9
+
10
+ /**
11
+ * Abstract base class for webhook handlers
12
+ *
13
+ * Each provider implements this to parse and normalize their webhook payloads
14
+ */
15
+ declare abstract class BaseWebhookHandler {
16
+ /** Provider name */
17
+ abstract readonly provider: TranscriptionProvider;
18
+ /**
19
+ * Check if this payload matches this provider's webhook format
20
+ *
21
+ * Used for auto-detection of webhook provider
22
+ *
23
+ * @param payload - Raw webhook payload
24
+ * @param options - Optional context (query params, headers, etc.)
25
+ * @returns true if this handler can process the payload
26
+ *
27
+ * @example
28
+ * ```typescript
29
+ * matches(payload, options) {
30
+ * return typeof payload === 'object' &&
31
+ * 'event' in payload &&
32
+ * 'payload' in payload
33
+ * }
34
+ * ```
35
+ */
36
+ abstract matches(payload: unknown, options?: {
37
+ queryParams?: Record<string, string>;
38
+ userAgent?: string;
39
+ }): boolean;
40
+ /**
41
+ * Parse and normalize webhook payload
42
+ *
43
+ * Converts provider-specific webhook format to UnifiedWebhookEvent
44
+ *
45
+ * @param payload - Raw webhook payload
46
+ * @param options - Optional context (query params, headers, etc.)
47
+ * @returns Normalized webhook event
48
+ * @throws Error if payload cannot be parsed
49
+ *
50
+ * @example
51
+ * ```typescript
52
+ * parse(payload, options) {
53
+ * const typed = payload as ProviderWebhookPayload
54
+ * return {
55
+ * success: true,
56
+ * provider: this.provider,
57
+ * eventType: 'transcription.completed',
58
+ * data: { id: typed.job_id, ... },
59
+ * timestamp: new Date().toISOString(),
60
+ * raw: payload
61
+ * }
62
+ * }
63
+ * ```
64
+ */
65
+ abstract parse(payload: unknown, options?: {
66
+ queryParams?: Record<string, string>;
67
+ }): UnifiedWebhookEvent;
68
+ /**
69
+ * Verify webhook signature (if provider supports it)
70
+ *
71
+ * Optional method - implement if provider supports webhook signature verification
72
+ *
73
+ * @param payload - Raw webhook payload
74
+ * @param options - Verification options (signature, secret, etc.)
75
+ * @returns true if signature is valid
76
+ *
77
+ * @example
78
+ * ```typescript
79
+ * verify(payload, options) {
80
+ * if (!options.signature || !options.secret) return false
81
+ *
82
+ * const computed = crypto
83
+ * .createHmac('sha256', options.secret)
84
+ * .update(JSON.stringify(payload))
85
+ * .digest('hex')
86
+ *
87
+ * return computed === options.signature
88
+ * }
89
+ * ```
90
+ */
91
+ verify?(payload: unknown, options: WebhookVerificationOptions): boolean;
92
+ /**
93
+ * Validate webhook payload structure
94
+ *
95
+ * Checks if payload has required fields and correct types
96
+ *
97
+ * @param payload - Raw webhook payload
98
+ * @param options - Optional context (query params, headers, etc.)
99
+ * @returns Validation result with details
100
+ */
101
+ validate(payload: unknown, options?: {
102
+ queryParams?: Record<string, string>;
103
+ userAgent?: string;
104
+ }): WebhookValidation;
105
+ /**
106
+ * Helper method to create error response
107
+ */
108
+ protected createErrorEvent(payload: unknown, errorMessage: string): UnifiedWebhookEvent;
109
+ }
110
+
111
+ /**
112
+ * Azure Speech-to-Text webhook handler
113
+ * Parses and normalizes Azure STT webhook callbacks
114
+ */
115
+
116
+ /**
117
+ * Azure webhook event payload structure
118
+ * Based on Azure Speech Services v3.1 webhook format
119
+ */
120
+ interface AzureWebhookPayload {
121
+ /** Event action (e.g., "TranscriptionCreated", "TranscriptionSucceeded", "TranscriptionFailed") */
122
+ action: string;
123
+ /** Timestamp of the event */
124
+ timestamp: string;
125
+ /** Self-link to the resource */
126
+ self?: string;
127
+ /** Additional properties */
128
+ properties?: Record<string, unknown>;
129
+ /** Error details (for failed events) */
130
+ error?: {
131
+ code: string;
132
+ message: string;
133
+ };
134
+ }
135
+ /**
136
+ * Azure webhook handler
137
+ *
138
+ * Handles webhook callbacks from Azure Speech Services API:
139
+ * - TranscriptionCreated - Transcription job created
140
+ * - TranscriptionRunning - Transcription is processing
141
+ * - TranscriptionSucceeded - Transcription completed successfully
142
+ * - TranscriptionFailed - Transcription failed with error
143
+ *
144
+ * Azure supports optional webhook signature verification using a shared secret.
145
+ *
146
+ * @example Basic usage
147
+ * ```typescript
148
+ * import { AzureWebhookHandler } from '@meeting-baas/sdk';
149
+ *
150
+ * const handler = new AzureWebhookHandler();
151
+ *
152
+ * // Validate webhook
153
+ * const validation = handler.validate(req.body);
154
+ * if (!validation.valid) {
155
+ * return res.status(400).json({ error: validation.error });
156
+ * }
157
+ *
158
+ * // Parse webhook
159
+ * const event = handler.parse(req.body);
160
+ * console.log('Event type:', event.eventType);
161
+ * console.log('Action:', event.raw.action);
162
+ * ```
163
+ *
164
+ * @example With signature verification
165
+ * ```typescript
166
+ * // Verify webhook signature (if configured in Azure)
167
+ * const isValid = handler.verify(req.body, {
168
+ * signature: req.headers['x-azure-signature'],
169
+ * secret: process.env.AZURE_WEBHOOK_SECRET,
170
+ * rawBody: req.rawBody
171
+ * });
172
+ *
173
+ * if (!isValid) {
174
+ * return res.status(401).json({ error: 'Invalid signature' });
175
+ * }
176
+ * ```
177
+ *
178
+ * @example Processing completed transcription
179
+ * ```typescript
180
+ * const event = handler.parse(req.body);
181
+ *
182
+ * if (event.eventType === 'transcription.completed') {
183
+ * // Extract transcription ID from self link
184
+ * const transcriptionId = event.data?.id;
185
+ *
186
+ * // Fetch full transcript using AzureAdapter.getTranscript(transcriptionId)
187
+ * console.log('Transcription completed:', transcriptionId);
188
+ * }
189
+ * ```
190
+ */
191
+ declare class AzureWebhookHandler extends BaseWebhookHandler {
192
+ readonly provider: TranscriptionProvider;
193
+ /**
194
+ * Check if payload matches Azure webhook format
195
+ */
196
+ matches(payload: unknown, _options?: {
197
+ queryParams?: Record<string, string>;
198
+ userAgent?: string;
199
+ }): boolean;
200
+ /**
201
+ * Parse Azure webhook payload to unified format
202
+ */
203
+ parse(payload: unknown, _options?: {
204
+ queryParams?: Record<string, string>;
205
+ }): UnifiedWebhookEvent;
206
+ /**
207
+ * Verify Azure webhook signature
208
+ *
209
+ * Azure can optionally sign webhooks using HMAC-SHA256.
210
+ * The signature is sent in the X-Azure-Signature header.
211
+ *
212
+ * Note: Signature verification is optional in Azure and must be
213
+ * configured when creating the webhook.
214
+ *
215
+ * @param payload - Webhook payload
216
+ * @param options - Verification options with signature and secret
217
+ * @returns true if signature is valid or no signature provided
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * const isValid = handler.verify(req.body, {
222
+ * signature: req.headers['x-azure-signature'],
223
+ * secret: process.env.AZURE_WEBHOOK_SECRET,
224
+ * rawBody: req.rawBody
225
+ * });
226
+ * ```
227
+ */
228
+ verify(payload: unknown, options: WebhookVerificationOptions): boolean;
229
+ }
230
+ /**
231
+ * Factory function to create an Azure webhook handler
232
+ */
233
+ declare function createAzureWebhookHandler(): AzureWebhookHandler;
234
+
5
235
  /**
6
236
  * Unified webhook types for transcription providers
7
237
  * Normalizes webhook callbacks from different providers to a common format
@@ -18,9 +248,10 @@ type ProviderWebhookPayloadMap = {
18
248
  gladia: GladiaWebhookPayload;
19
249
  assemblyai: TranscriptWebhookNotification;
20
250
  deepgram: ListenV1Response;
21
- "azure-stt": unknown;
251
+ "azure-stt": AzureWebhookPayload;
22
252
  "openai-whisper": never;
23
- speechmatics: unknown;
253
+ speechmatics: RetrieveTranscriptResponse;
254
+ elevenlabs: SpeechToTextChunkResponseModel;
24
255
  };
25
256
  /**
26
257
  * Unified webhook event types
@@ -122,112 +353,6 @@ interface WebhookVerificationOptions {
122
353
  headers?: Record<string, string>;
123
354
  }
124
355
 
125
- /**
126
- * Base webhook handler interface
127
- * All provider-specific webhook handlers must implement this
128
- */
129
-
130
- /**
131
- * Abstract base class for webhook handlers
132
- *
133
- * Each provider implements this to parse and normalize their webhook payloads
134
- */
135
- declare abstract class BaseWebhookHandler {
136
- /** Provider name */
137
- abstract readonly provider: TranscriptionProvider;
138
- /**
139
- * Check if this payload matches this provider's webhook format
140
- *
141
- * Used for auto-detection of webhook provider
142
- *
143
- * @param payload - Raw webhook payload
144
- * @param options - Optional context (query params, headers, etc.)
145
- * @returns true if this handler can process the payload
146
- *
147
- * @example
148
- * ```typescript
149
- * matches(payload, options) {
150
- * return typeof payload === 'object' &&
151
- * 'event' in payload &&
152
- * 'payload' in payload
153
- * }
154
- * ```
155
- */
156
- abstract matches(payload: unknown, options?: {
157
- queryParams?: Record<string, string>;
158
- userAgent?: string;
159
- }): boolean;
160
- /**
161
- * Parse and normalize webhook payload
162
- *
163
- * Converts provider-specific webhook format to UnifiedWebhookEvent
164
- *
165
- * @param payload - Raw webhook payload
166
- * @param options - Optional context (query params, headers, etc.)
167
- * @returns Normalized webhook event
168
- * @throws Error if payload cannot be parsed
169
- *
170
- * @example
171
- * ```typescript
172
- * parse(payload, options) {
173
- * const typed = payload as ProviderWebhookPayload
174
- * return {
175
- * success: true,
176
- * provider: this.provider,
177
- * eventType: 'transcription.completed',
178
- * data: { id: typed.job_id, ... },
179
- * timestamp: new Date().toISOString(),
180
- * raw: payload
181
- * }
182
- * }
183
- * ```
184
- */
185
- abstract parse(payload: unknown, options?: {
186
- queryParams?: Record<string, string>;
187
- }): UnifiedWebhookEvent;
188
- /**
189
- * Verify webhook signature (if provider supports it)
190
- *
191
- * Optional method - implement if provider supports webhook signature verification
192
- *
193
- * @param payload - Raw webhook payload
194
- * @param options - Verification options (signature, secret, etc.)
195
- * @returns true if signature is valid
196
- *
197
- * @example
198
- * ```typescript
199
- * verify(payload, options) {
200
- * if (!options.signature || !options.secret) return false
201
- *
202
- * const computed = crypto
203
- * .createHmac('sha256', options.secret)
204
- * .update(JSON.stringify(payload))
205
- * .digest('hex')
206
- *
207
- * return computed === options.signature
208
- * }
209
- * ```
210
- */
211
- verify?(payload: unknown, options: WebhookVerificationOptions): boolean;
212
- /**
213
- * Validate webhook payload structure
214
- *
215
- * Checks if payload has required fields and correct types
216
- *
217
- * @param payload - Raw webhook payload
218
- * @param options - Optional context (query params, headers, etc.)
219
- * @returns Validation result with details
220
- */
221
- validate(payload: unknown, options?: {
222
- queryParams?: Record<string, string>;
223
- userAgent?: string;
224
- }): WebhookValidation;
225
- /**
226
- * Helper method to create error response
227
- */
228
- protected createErrorEvent(payload: unknown, errorMessage: string): UnifiedWebhookEvent;
229
- }
230
-
231
356
  /**
232
357
  * Gladia webhook handler
233
358
  * Parses and normalizes Gladia webhook callbacks
@@ -513,111 +638,6 @@ declare class DeepgramWebhookHandler extends BaseWebhookHandler {
513
638
  */
514
639
  declare function createDeepgramWebhookHandler(): DeepgramWebhookHandler;
515
640
 
516
- /**
517
- * Azure Speech-to-Text webhook handler
518
- * Parses and normalizes Azure STT webhook callbacks
519
- */
520
-
521
- /**
522
- * Azure webhook handler
523
- *
524
- * Handles webhook callbacks from Azure Speech Services API:
525
- * - TranscriptionCreated - Transcription job created
526
- * - TranscriptionRunning - Transcription is processing
527
- * - TranscriptionSucceeded - Transcription completed successfully
528
- * - TranscriptionFailed - Transcription failed with error
529
- *
530
- * Azure supports optional webhook signature verification using a shared secret.
531
- *
532
- * @example Basic usage
533
- * ```typescript
534
- * import { AzureWebhookHandler } from '@meeting-baas/sdk';
535
- *
536
- * const handler = new AzureWebhookHandler();
537
- *
538
- * // Validate webhook
539
- * const validation = handler.validate(req.body);
540
- * if (!validation.valid) {
541
- * return res.status(400).json({ error: validation.error });
542
- * }
543
- *
544
- * // Parse webhook
545
- * const event = handler.parse(req.body);
546
- * console.log('Event type:', event.eventType);
547
- * console.log('Action:', event.raw.action);
548
- * ```
549
- *
550
- * @example With signature verification
551
- * ```typescript
552
- * // Verify webhook signature (if configured in Azure)
553
- * const isValid = handler.verify(req.body, {
554
- * signature: req.headers['x-azure-signature'],
555
- * secret: process.env.AZURE_WEBHOOK_SECRET,
556
- * rawBody: req.rawBody
557
- * });
558
- *
559
- * if (!isValid) {
560
- * return res.status(401).json({ error: 'Invalid signature' });
561
- * }
562
- * ```
563
- *
564
- * @example Processing completed transcription
565
- * ```typescript
566
- * const event = handler.parse(req.body);
567
- *
568
- * if (event.eventType === 'transcription.completed') {
569
- * // Extract transcription ID from self link
570
- * const transcriptionId = event.data?.id;
571
- *
572
- * // Fetch full transcript using AzureAdapter.getTranscript(transcriptionId)
573
- * console.log('Transcription completed:', transcriptionId);
574
- * }
575
- * ```
576
- */
577
- declare class AzureWebhookHandler extends BaseWebhookHandler {
578
- readonly provider: TranscriptionProvider;
579
- /**
580
- * Check if payload matches Azure webhook format
581
- */
582
- matches(payload: unknown, _options?: {
583
- queryParams?: Record<string, string>;
584
- userAgent?: string;
585
- }): boolean;
586
- /**
587
- * Parse Azure webhook payload to unified format
588
- */
589
- parse(payload: unknown, _options?: {
590
- queryParams?: Record<string, string>;
591
- }): UnifiedWebhookEvent;
592
- /**
593
- * Verify Azure webhook signature
594
- *
595
- * Azure can optionally sign webhooks using HMAC-SHA256.
596
- * The signature is sent in the X-Azure-Signature header.
597
- *
598
- * Note: Signature verification is optional in Azure and must be
599
- * configured when creating the webhook.
600
- *
601
- * @param payload - Webhook payload
602
- * @param options - Verification options with signature and secret
603
- * @returns true if signature is valid or no signature provided
604
- *
605
- * @example
606
- * ```typescript
607
- * const isValid = handler.verify(req.body, {
608
- * signature: req.headers['x-azure-signature'],
609
- * secret: process.env.AZURE_WEBHOOK_SECRET,
610
- * rawBody: req.rawBody
611
- * });
612
- * ```
613
- */
614
- verify(payload: unknown, options: WebhookVerificationOptions): boolean;
615
- }
616
- /**
617
- * Factory function to create an Azure webhook handler
618
- */
619
- declare function createAzureWebhookHandler(): AzureWebhookHandler;
620
-
621
641
  /**
622
642
  * Speechmatics webhook handler
623
643
  * Parses and normalizes Speechmatics webhook callbacks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "voice-router-dev",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "Universal speech-to-text router for Gladia, AssemblyAI, Deepgram, Azure, OpenAI Whisper, Speechmatics, Soniox, and ElevenLabs",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -197,7 +197,7 @@
197
197
  "openapi:diagram": "node scripts/generate-pipeline-diagram.js",
198
198
  "openapi:rebuild": "pnpm openapi:sync && pnpm openapi:generate && pnpm build",
199
199
  "docs:clean": "rm -rf docs/generated",
200
- "docs:generate": "pnpm docs:clean && pnpm docs:generate:router && pnpm docs:generate:webhooks && pnpm docs:generate:gladia && pnpm docs:generate:assemblyai && pnpm docs:generate:deepgram && pnpm docs:generate:azure && pnpm docs:generate:openai && pnpm docs:generate:speechmatics && pnpm docs:field-equivalences",
200
+ "docs:generate": "pnpm docs:clean && pnpm docs:generate:router && pnpm docs:generate:webhooks && pnpm docs:generate:gladia && pnpm docs:generate:assemblyai && pnpm docs:generate:deepgram && pnpm docs:generate:azure && pnpm docs:generate:openai && pnpm docs:generate:speechmatics && pnpm docs:generate:soniox && pnpm docs:generate:elevenlabs && pnpm docs:field-equivalences",
201
201
  "docs:generate:router": "typedoc --options typedoc.router.config.mjs",
202
202
  "docs:generate:webhooks": "typedoc --options typedoc.webhooks.config.mjs",
203
203
  "docs:generate:gladia": "typedoc --options typedoc.gladia.config.mjs",
@@ -206,6 +206,8 @@
206
206
  "docs:generate:azure": "typedoc --options typedoc.azure.config.mjs",
207
207
  "docs:generate:openai": "typedoc --options typedoc.openai.config.mjs",
208
208
  "docs:generate:speechmatics": "typedoc --options typedoc.speechmatics.config.mjs",
209
+ "docs:generate:soniox": "typedoc --options typedoc.soniox.config.mjs",
210
+ "docs:generate:elevenlabs": "typedoc --options typedoc.elevenlabs.config.mjs",
209
211
  "docs:field-equivalences": "node scripts/generate-field-equivalences.js",
210
212
  "prebuild": "pnpm openapi:fix-specs && pnpm openapi:fix && pnpm openapi:sync-soniox-languages && pnpm openapi:sync-soniox-models && pnpm openapi:sync-speechmatics-languages && pnpm openapi:sync-azure-locales && pnpm openapi:sync-deepgram-languages && pnpm openapi:sync-deepgram-models && pnpm openapi:sync-openai-models && pnpm openapi:sync-elevenlabs-languages && pnpm openapi:sync-elevenlabs-models"
211
213
  }