telnyx 6.71.0 → 6.73.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.
Files changed (122) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/client.d.mts +14 -8
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +14 -8
  5. package/client.d.ts.map +1 -1
  6. package/client.js +12 -6
  7. package/client.js.map +1 -1
  8. package/client.mjs +12 -6
  9. package/client.mjs.map +1 -1
  10. package/package.json +1 -1
  11. package/resources/ai/ai.d.mts +1 -1
  12. package/resources/ai/ai.d.mts.map +1 -1
  13. package/resources/ai/ai.d.ts +1 -1
  14. package/resources/ai/ai.d.ts.map +1 -1
  15. package/resources/ai/ai.js +2 -2
  16. package/resources/ai/ai.js.map +1 -1
  17. package/resources/ai/ai.mjs +2 -2
  18. package/resources/ai/ai.mjs.map +1 -1
  19. package/resources/index.d.mts +3 -2
  20. package/resources/index.d.mts.map +1 -1
  21. package/resources/index.d.ts +3 -2
  22. package/resources/index.d.ts.map +1 -1
  23. package/resources/index.js +4 -2
  24. package/resources/index.js.map +1 -1
  25. package/resources/index.mjs +1 -0
  26. package/resources/index.mjs.map +1 -1
  27. package/resources/sip-registration-status.d.mts +91 -0
  28. package/resources/sip-registration-status.d.mts.map +1 -0
  29. package/resources/sip-registration-status.d.ts +91 -0
  30. package/resources/sip-registration-status.d.ts.map +1 -0
  31. package/resources/sip-registration-status.js +20 -0
  32. package/resources/sip-registration-status.js.map +1 -0
  33. package/resources/sip-registration-status.mjs +16 -0
  34. package/resources/sip-registration-status.mjs.map +1 -0
  35. package/resources/speech-to-text/index.d.mts +3 -3
  36. package/resources/speech-to-text/index.d.mts.map +1 -1
  37. package/resources/speech-to-text/index.d.ts +3 -3
  38. package/resources/speech-to-text/index.d.ts.map +1 -1
  39. package/resources/speech-to-text/index.js +1 -5
  40. package/resources/speech-to-text/index.js.map +1 -1
  41. package/resources/speech-to-text/index.mjs +0 -2
  42. package/resources/speech-to-text/index.mjs.map +1 -1
  43. package/resources/speech-to-text/internal-base.d.mts +42 -11
  44. package/resources/speech-to-text/internal-base.d.mts.map +1 -1
  45. package/resources/speech-to-text/internal-base.d.ts +42 -11
  46. package/resources/speech-to-text/internal-base.d.ts.map +1 -1
  47. package/resources/speech-to-text/internal-base.js +5 -9
  48. package/resources/speech-to-text/internal-base.js.map +1 -1
  49. package/resources/speech-to-text/internal-base.mjs +5 -9
  50. package/resources/speech-to-text/internal-base.mjs.map +1 -1
  51. package/resources/speech-to-text/speech-to-text.d.mts +79 -100
  52. package/resources/speech-to-text/speech-to-text.d.mts.map +1 -1
  53. package/resources/speech-to-text/speech-to-text.d.ts +79 -100
  54. package/resources/speech-to-text/speech-to-text.d.ts.map +1 -1
  55. package/resources/speech-to-text/speech-to-text.js +16 -19
  56. package/resources/speech-to-text/speech-to-text.js.map +1 -1
  57. package/resources/speech-to-text/speech-to-text.mjs +16 -19
  58. package/resources/speech-to-text/speech-to-text.mjs.map +1 -1
  59. package/resources/speech-to-text/ws-base.d.mts +106 -0
  60. package/resources/speech-to-text/ws-base.d.mts.map +1 -0
  61. package/resources/speech-to-text/ws-base.d.ts +106 -0
  62. package/resources/speech-to-text/ws-base.d.ts.map +1 -0
  63. package/resources/speech-to-text/ws-base.js +476 -0
  64. package/resources/speech-to-text/ws-base.js.map +1 -0
  65. package/resources/speech-to-text/ws-base.mjs +472 -0
  66. package/resources/speech-to-text/ws-base.mjs.map +1 -0
  67. package/resources/speech-to-text/ws.d.mts +9 -28
  68. package/resources/speech-to-text/ws.d.mts.map +1 -1
  69. package/resources/speech-to-text/ws.d.ts +9 -28
  70. package/resources/speech-to-text/ws.d.ts.map +1 -1
  71. package/resources/speech-to-text/ws.js +17 -97
  72. package/resources/speech-to-text/ws.js.map +1 -1
  73. package/resources/speech-to-text/ws.mjs +17 -97
  74. package/resources/speech-to-text/ws.mjs.map +1 -1
  75. package/resources/speech-to-text.d.mts +1 -80
  76. package/resources/speech-to-text.d.mts.map +1 -1
  77. package/resources/speech-to-text.d.ts +1 -80
  78. package/resources/speech-to-text.d.ts.map +1 -1
  79. package/resources/speech-to-text.js +2 -32
  80. package/resources/speech-to-text.js.map +1 -1
  81. package/resources/speech-to-text.mjs +1 -30
  82. package/resources/speech-to-text.mjs.map +1 -1
  83. package/resources/texml/accounts/calls/calls.d.mts +31 -465
  84. package/resources/texml/accounts/calls/calls.d.mts.map +1 -1
  85. package/resources/texml/accounts/calls/calls.d.ts +31 -465
  86. package/resources/texml/accounts/calls/calls.d.ts.map +1 -1
  87. package/resources/texml/accounts/calls/calls.js +7 -1
  88. package/resources/texml/accounts/calls/calls.js.map +1 -1
  89. package/resources/texml/accounts/calls/calls.mjs +7 -1
  90. package/resources/texml/accounts/calls/calls.mjs.map +1 -1
  91. package/resources/text-to-speech/index.d.mts +1 -1
  92. package/resources/text-to-speech/index.d.mts.map +1 -1
  93. package/resources/text-to-speech/index.d.ts +1 -1
  94. package/resources/text-to-speech/index.d.ts.map +1 -1
  95. package/resources/text-to-speech/index.js.map +1 -1
  96. package/resources/text-to-speech/index.mjs.map +1 -1
  97. package/resources/text-to-speech/text-to-speech.d.mts +79 -13
  98. package/resources/text-to-speech/text-to-speech.d.mts.map +1 -1
  99. package/resources/text-to-speech/text-to-speech.d.ts +79 -13
  100. package/resources/text-to-speech/text-to-speech.d.ts.map +1 -1
  101. package/resources/text-to-speech/text-to-speech.js +33 -1
  102. package/resources/text-to-speech/text-to-speech.js.map +1 -1
  103. package/resources/text-to-speech/text-to-speech.mjs +33 -1
  104. package/resources/text-to-speech/text-to-speech.mjs.map +1 -1
  105. package/src/client.ts +42 -20
  106. package/src/resources/ai/ai.ts +3 -3
  107. package/src/resources/index.ts +10 -2
  108. package/src/resources/sip-registration-status.ts +123 -0
  109. package/src/resources/speech-to-text/index.ts +6 -9
  110. package/src/resources/speech-to-text/internal-base.ts +49 -22
  111. package/src/resources/speech-to-text/speech-to-text.ts +102 -128
  112. package/src/resources/speech-to-text/ws-base.ts +619 -0
  113. package/src/resources/speech-to-text/ws.ts +26 -111
  114. package/src/resources/speech-to-text.ts +1 -112
  115. package/src/resources/texml/accounts/calls/calls.ts +36 -564
  116. package/src/resources/text-to-speech/index.ts +3 -2
  117. package/src/resources/text-to-speech/text-to-speech.ts +100 -16
  118. package/src/version.ts +1 -1
  119. package/version.d.mts +1 -1
  120. package/version.d.ts +1 -1
  121. package/version.js +1 -1
  122. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -811,6 +811,11 @@ import {
811
811
  SimCardOrders,
812
812
  SimCardOrdersDefaultFlatPagination,
813
813
  } from './resources/sim-card-orders';
814
+ import {
815
+ SipRegistrationStatus,
816
+ SipRegistrationStatusRetrieveParams,
817
+ SipRegistrationStatusRetrieveResponse,
818
+ } from './resources/sip-registration-status';
814
819
  import {
815
820
  SiprecConnectorCreateParams,
816
821
  SiprecConnectorCreateResponse,
@@ -819,11 +824,6 @@ import {
819
824
  SiprecConnectorUpdateResponse,
820
825
  SiprecConnectors,
821
826
  } from './resources/siprec-connectors';
822
- import {
823
- SpeechToText,
824
- SpeechToTextListProvidersParams,
825
- SpeechToTextListProvidersResponse,
826
- } from './resources/speech-to-text';
827
827
  import {
828
828
  SubNumberOrder,
829
829
  SubNumberOrderCancelResponse,
@@ -1536,6 +1536,13 @@ import {
1536
1536
  SimCardUpdateResponse,
1537
1537
  SimCards,
1538
1538
  } from './resources/sim-cards/sim-cards';
1539
+ import {
1540
+ SpeechToText,
1541
+ SpeechToTextListProvidersParams,
1542
+ SpeechToTextListProvidersResponse,
1543
+ TranscribeClientEvent,
1544
+ TranscribeServerEvent,
1545
+ } from './resources/speech-to-text/speech-to-text';
1539
1546
  import { Storage, StorageListMigrationSourceCoverageResponse } from './resources/storage/storage';
1540
1547
  import { TermsOfService } from './resources/terms-of-service/terms-of-service';
1541
1548
  import {
@@ -1549,8 +1556,9 @@ import {
1549
1556
  StreamClientEvent,
1550
1557
  StreamServerEvent,
1551
1558
  TextToSpeech,
1552
- TextToSpeechGenerateParams,
1553
- TextToSpeechGenerateResponse,
1559
+ TextToSpeechCreateSpeechParams,
1560
+ TextToSpeechCreateSpeechResponse,
1561
+ TextToSpeechGenerateSpeechParams,
1554
1562
  TextToSpeechListVoicesParams,
1555
1563
  TextToSpeechListVoicesResponse,
1556
1564
  } from './resources/text-to-speech/text-to-speech';
@@ -2791,6 +2799,10 @@ export class Telnyx {
2791
2799
  */
2792
2800
  regulatoryRequirements: API.RegulatoryRequirements = new API.RegulatoryRequirements(this);
2793
2801
  reports: API.Reports = new API.Reports(this);
2802
+ /**
2803
+ * Discover available speech-to-text providers, models, and supported languages.
2804
+ */
2805
+ speechToText: API.SpeechToText = new API.SpeechToText(this);
2794
2806
  /**
2795
2807
  * Requirement Groups
2796
2808
  */
@@ -2984,14 +2996,14 @@ export class Telnyx {
2984
2996
  * UAC connection operations
2985
2997
  */
2986
2998
  uacConnections: API.UacConnections = new API.UacConnections(this);
2987
- /**
2988
- * Discover available speech-to-text providers, models, and supported languages.
2989
- */
2990
- speechToText: API.SpeechToText = new API.SpeechToText(this);
2991
2999
  /**
2992
3000
  * Retrieve raw Voice SDK call report stats payloads for WebRTC call troubleshooting.
2993
3001
  */
2994
3002
  voiceSDKCallReports: API.VoiceSDKCallReports = new API.VoiceSDKCallReports(this);
3003
+ /**
3004
+ * Look up SIP registration status across credential types
3005
+ */
3006
+ sipRegistrationStatus: API.SipRegistrationStatus = new API.SipRegistrationStatus(this);
2995
3007
  }
2996
3008
 
2997
3009
  Telnyx.Legacy = Legacy;
@@ -3102,6 +3114,7 @@ Telnyx.Recordings = Recordings;
3102
3114
  Telnyx.Regions = Regions;
3103
3115
  Telnyx.RegulatoryRequirements = RegulatoryRequirements;
3104
3116
  Telnyx.Reports = Reports;
3117
+ Telnyx.SpeechToText = SpeechToText;
3105
3118
  Telnyx.RequirementGroups = RequirementGroups;
3106
3119
  Telnyx.RequirementTypes = RequirementTypes;
3107
3120
  Telnyx.Requirements = Requirements;
@@ -3158,8 +3171,8 @@ Telnyx.Reputation = Reputation;
3158
3171
  Telnyx.TermsOfService = TermsOfService;
3159
3172
  Telnyx.PronunciationDicts = PronunciationDicts;
3160
3173
  Telnyx.UacConnections = UacConnections;
3161
- Telnyx.SpeechToText = SpeechToText;
3162
3174
  Telnyx.VoiceSDKCallReports = VoiceSDKCallReports;
3175
+ Telnyx.SipRegistrationStatus = SipRegistrationStatus;
3163
3176
 
3164
3177
  export declare namespace Telnyx {
3165
3178
  export type RequestOptions = Opts.RequestOptions;
@@ -4397,6 +4410,14 @@ export declare namespace Telnyx {
4397
4410
  type ReportListWdrsParams as ReportListWdrsParams,
4398
4411
  };
4399
4412
 
4413
+ export {
4414
+ SpeechToText as SpeechToText,
4415
+ type SpeechToTextListProvidersResponse as SpeechToTextListProvidersResponse,
4416
+ type TranscribeClientEvent as TranscribeClientEvent,
4417
+ type TranscribeServerEvent as TranscribeServerEvent,
4418
+ type SpeechToTextListProvidersParams as SpeechToTextListProvidersParams,
4419
+ };
4420
+
4400
4421
  export {
4401
4422
  RequirementGroups as RequirementGroups,
4402
4423
  type RequirementGroup as RequirementGroup,
@@ -4615,11 +4636,12 @@ export declare namespace Telnyx {
4615
4636
 
4616
4637
  export {
4617
4638
  TextToSpeech as TextToSpeech,
4618
- type TextToSpeechGenerateResponse as TextToSpeechGenerateResponse,
4639
+ type TextToSpeechCreateSpeechResponse as TextToSpeechCreateSpeechResponse,
4619
4640
  type TextToSpeechListVoicesResponse as TextToSpeechListVoicesResponse,
4620
4641
  type StreamClientEvent as StreamClientEvent,
4621
4642
  type StreamServerEvent as StreamServerEvent,
4622
- type TextToSpeechGenerateParams as TextToSpeechGenerateParams,
4643
+ type TextToSpeechCreateSpeechParams as TextToSpeechCreateSpeechParams,
4644
+ type TextToSpeechGenerateSpeechParams as TextToSpeechGenerateSpeechParams,
4623
4645
  type TextToSpeechListVoicesParams as TextToSpeechListVoicesParams,
4624
4646
  };
4625
4647
 
@@ -4942,12 +4964,6 @@ export declare namespace Telnyx {
4942
4964
  type UacConnectionListParams as UacConnectionListParams,
4943
4965
  };
4944
4966
 
4945
- export {
4946
- SpeechToText as SpeechToText,
4947
- type SpeechToTextListProvidersResponse as SpeechToTextListProvidersResponse,
4948
- type SpeechToTextListProvidersParams as SpeechToTextListProvidersParams,
4949
- };
4950
-
4951
4967
  export {
4952
4968
  VoiceSDKCallReports as VoiceSDKCallReports,
4953
4969
  type VoiceSDKCallReportLogEntry as VoiceSDKCallReportLogEntry,
@@ -4957,6 +4973,12 @@ export declare namespace Telnyx {
4957
4973
  type VoiceSDKCallReportListParams as VoiceSDKCallReportListParams,
4958
4974
  };
4959
4975
 
4976
+ export {
4977
+ SipRegistrationStatus as SipRegistrationStatus,
4978
+ type SipRegistrationStatusRetrieveResponse as SipRegistrationStatusRetrieveResponse,
4979
+ type SipRegistrationStatusRetrieveParams as SipRegistrationStatusRetrieveParams,
4980
+ };
4981
+
4960
4982
  export type APIError = API.APIError;
4961
4983
  export type AvailablePhoneNumbersMetadata = API.AvailablePhoneNumbersMetadata;
4962
4984
  export type AzureVoiceSettings = API.AzureVoiceSettings;
@@ -180,8 +180,8 @@ export class AI extends APIResource {
180
180
  params: AICreateResponseParams,
181
181
  options?: RequestOptions,
182
182
  ): APIPromise<AICreateResponseResponse> {
183
- const { body } = params;
184
- return this._client.post('/ai/responses', { body: body, ...options });
183
+ const { input } = params;
184
+ return this._client.post('/ai/responses', { body: input, ...options });
185
185
  }
186
186
 
187
187
  /**
@@ -374,7 +374,7 @@ export namespace AISummarizeResponse {
374
374
  }
375
375
 
376
376
  export interface AICreateResponseParams {
377
- body: { [key: string]: unknown };
377
+ input: { [key: string]: unknown };
378
378
  }
379
379
 
380
380
  export interface AISummarizeParams {
@@ -1163,6 +1163,11 @@ export {
1163
1163
  type SimCardListWirelessConnectivityLogsParams,
1164
1164
  type SimCardListWirelessConnectivityLogsResponsesDefaultFlatPagination,
1165
1165
  } from './sim-cards/sim-cards';
1166
+ export {
1167
+ SipRegistrationStatus,
1168
+ type SipRegistrationStatusRetrieveResponse,
1169
+ type SipRegistrationStatusRetrieveParams,
1170
+ } from './sip-registration-status';
1166
1171
  export {
1167
1172
  SiprecConnectors,
1168
1173
  type SiprecConnectorCreateResponse,
@@ -1174,6 +1179,8 @@ export {
1174
1179
  export {
1175
1180
  SpeechToText,
1176
1181
  type SpeechToTextListProvidersResponse,
1182
+ type TranscribeClientEvent,
1183
+ type TranscribeServerEvent,
1177
1184
  type SpeechToTextListProvidersParams,
1178
1185
  } from './speech-to-text';
1179
1186
  export { Storage, type StorageListMigrationSourceCoverageResponse } from './storage/storage';
@@ -1234,11 +1241,12 @@ export {
1234
1241
  } from './texml-applications';
1235
1242
  export {
1236
1243
  TextToSpeech,
1237
- type TextToSpeechGenerateResponse,
1244
+ type TextToSpeechCreateSpeechResponse,
1238
1245
  type TextToSpeechListVoicesResponse,
1239
1246
  type StreamClientEvent,
1240
1247
  type StreamServerEvent,
1241
- type TextToSpeechGenerateParams,
1248
+ type TextToSpeechCreateSpeechParams,
1249
+ type TextToSpeechGenerateSpeechParams,
1242
1250
  type TextToSpeechListVoicesParams,
1243
1251
  type TextToSpeechStreamParams,
1244
1252
  } from './text-to-speech';
@@ -0,0 +1,123 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../core/resource';
4
+ import { APIPromise } from '../core/api-promise';
5
+ import { RequestOptions } from '../internal/request-options';
6
+
7
+ /**
8
+ * Look up SIP registration status across credential types
9
+ */
10
+ export class SipRegistrationStatus extends APIResource {
11
+ /**
12
+ * Returns the live SIP registration state of a connection or credential. Supports
13
+ * UAC third-party credentials, telephony credentials, and SIP credential
14
+ * connections.
15
+ */
16
+ retrieve(
17
+ query: SipRegistrationStatusRetrieveParams,
18
+ options?: RequestOptions,
19
+ ): APIPromise<SipRegistrationStatusRetrieveResponse> {
20
+ return this._client.get('/sip_registration_status', { query, ...options });
21
+ }
22
+ }
23
+
24
+ export interface SipRegistrationStatusRetrieveResponse {
25
+ /**
26
+ * Identifier of the resource.
27
+ */
28
+ connection_id?: string;
29
+
30
+ /**
31
+ * Human-readable connection name.
32
+ */
33
+ connection_name?: string;
34
+
35
+ /**
36
+ * Outward-facing SIP settings used for registration. Password is redacted.
37
+ */
38
+ external_uac_settings?: SipRegistrationStatusRetrieveResponse.ExternalUacSettings;
39
+
40
+ /**
41
+ * Internal routing target the connection delivers calls to.
42
+ */
43
+ internal_uac_settings?: SipRegistrationStatusRetrieveResponse.InternalUacSettings;
44
+
45
+ /**
46
+ * SIP response from the last registration attempt.
47
+ */
48
+ last_registration_response?: string;
49
+
50
+ /**
51
+ * Internal pairing state, e.g. ACTIVE or INACTIVE.
52
+ */
53
+ pair_state?: string;
54
+
55
+ /**
56
+ * True if the endpoint is currently registered.
57
+ */
58
+ registered?: boolean;
59
+
60
+ /**
61
+ * Owner of the resource.
62
+ */
63
+ user_id?: string;
64
+
65
+ /**
66
+ * SIP username used for the registration.
67
+ */
68
+ username?: string;
69
+ }
70
+
71
+ export namespace SipRegistrationStatusRetrieveResponse {
72
+ /**
73
+ * Outward-facing SIP settings used for registration. Password is redacted.
74
+ */
75
+ export interface ExternalUacSettings {
76
+ auth_username?: string;
77
+
78
+ expiration_sec?: number;
79
+
80
+ from_user?: string;
81
+
82
+ outbound_proxy?: string;
83
+
84
+ password?: string;
85
+
86
+ proxy?: string;
87
+
88
+ transport?: 'TCP' | 'UDP' | 'TLS';
89
+
90
+ username?: string;
91
+ }
92
+
93
+ /**
94
+ * Internal routing target the connection delivers calls to.
95
+ */
96
+ export interface InternalUacSettings {
97
+ destination_uri?: string;
98
+ }
99
+ }
100
+
101
+ export interface SipRegistrationStatusRetrieveParams {
102
+ /**
103
+ * Identifier of the connection or credential to look up.
104
+ */
105
+ connection_id: string;
106
+
107
+ /**
108
+ * The kind of credential to look up.
109
+ */
110
+ credential_type: 'uac_external_credential' | 'telephony_credential' | 'sip_credential_connection';
111
+
112
+ /**
113
+ * Owner of the connection. Used to authorize the lookup.
114
+ */
115
+ user_id: string;
116
+ }
117
+
118
+ export declare namespace SipRegistrationStatus {
119
+ export {
120
+ type SipRegistrationStatusRetrieveResponse as SipRegistrationStatusRetrieveResponse,
121
+ type SipRegistrationStatusRetrieveParams as SipRegistrationStatusRetrieveParams,
122
+ };
123
+ }
@@ -2,13 +2,10 @@
2
2
 
3
3
  export {
4
4
  SpeechToText,
5
- type SpeechToTextTranscribeParams,
6
- type SpeechToTextStreamParams,
7
- type SttClientEvent,
8
- type SttServerEvent,
9
- type TranscriptFrame,
10
- type SttErrorFrame,
5
+ type SpeechToTextListProvidersResponse,
6
+ type TranscribeClientEvent,
7
+ type TranscribeServerEvent,
8
+ type SpeechToTextListProvidersParams,
11
9
  } from './speech-to-text';
12
-
13
- export { SpeechToTextWS } from './ws';
14
- export { WebSocketError } from './internal-base';
10
+ export { type SpeechToTextWSClientOptions } from './ws';
11
+ export { type SpeechToTextWSReconnectOptions } from './ws-base';
@@ -2,18 +2,32 @@
2
2
 
3
3
  import * as SpeechToTextAPI from './speech-to-text';
4
4
  import { Telnyx } from '../../client';
5
-
6
5
  import { EventEmitter } from '../../core/EventEmitter';
7
6
  import { TelnyxError } from '../../core/error';
8
- import { stringifyQuery } from '../../internal/utils';
7
+
8
+ import type { RawWebSocketData, ReconnectingEvent, UnsentMessage } from '../../internal/ws';
9
+
10
+ export type SpeechToTextStreamMessage =
11
+ | { type: 'connecting' | 'open' | 'closing' }
12
+ | {
13
+ type: 'close';
14
+ code: number;
15
+ reason: string;
16
+ unsent: UnsentMessage<SpeechToTextAPI.TranscribeClientEvent>[];
17
+ }
18
+ | { type: 'reconnecting'; reconnect: ReconnectingEvent }
19
+ | { type: 'reconnected' }
20
+ | { type: 'message'; message: SpeechToTextAPI.TranscribeServerEvent }
21
+ | { type: 'raw'; data: RawWebSocketData }
22
+ | { type: 'error'; error: WebSocketError };
9
23
 
10
24
  export class WebSocketError extends TelnyxError {
11
25
  /**
12
26
  * The error data that the API sent back in an error event.
13
27
  */
14
- error?: SpeechToTextAPI.SttServerEvent.ErrorFrame | undefined;
28
+ error?: SpeechToTextAPI.TranscribeServerEvent.SttErrorFrame | undefined;
15
29
 
16
- constructor(message: string, event: SpeechToTextAPI.SttServerEvent.ErrorFrame | null) {
30
+ constructor(message: string, event: SpeechToTextAPI.TranscribeServerEvent.SttErrorFrame | null) {
17
31
  super(message);
18
32
 
19
33
  this.error = event ?? undefined;
@@ -22,32 +36,48 @@ export class WebSocketError extends TelnyxError {
22
36
 
23
37
  type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
24
38
 
25
- type WebsocketEvents = Simplify<
39
+ type WebSocketEvents = Simplify<
26
40
  {
27
- event: (event: SpeechToTextAPI.SttServerEvent) => void;
41
+ event: (event: SpeechToTextAPI.TranscribeServerEvent) => void;
42
+ raw: (data: RawWebSocketData) => void;
28
43
  error: (error: WebSocketError) => void;
44
+ close: (
45
+ code: number,
46
+ reason: string,
47
+ unsent: UnsentMessage<SpeechToTextAPI.TranscribeClientEvent>[],
48
+ ) => void;
49
+ reconnecting: (event: ReconnectingEvent) => void;
50
+ reconnected: () => void;
29
51
  } & {
30
- [EventType in Exclude<NonNullable<SpeechToTextAPI.SttServerEvent['type']>, 'error'>]: (
31
- event: Extract<SpeechToTextAPI.SttServerEvent, { type?: EventType }>,
52
+ [EventType in Exclude<NonNullable<SpeechToTextAPI.TranscribeServerEvent['type']>, 'error'>]: (
53
+ event: Extract<SpeechToTextAPI.TranscribeServerEvent, { type?: EventType }>,
32
54
  ) => unknown;
33
55
  }
34
56
  >;
35
57
 
36
- export abstract class SpeechToTextEmitter extends EventEmitter<WebsocketEvents> {
58
+ export abstract class SpeechToTextEmitter extends EventEmitter<WebSocketEvents> {
59
+ /**
60
+ * Send an event to the API.
61
+ */
62
+ abstract send(event: SpeechToTextAPI.TranscribeClientEvent): void;
63
+
37
64
  /**
38
- * Send binary audio data to the API.
65
+ * Send raw data over the WebSocket without JSON serialization.
39
66
  */
40
- abstract send(data: SpeechToTextAPI.SttClientEvent): void;
67
+ abstract sendRaw(data: RawWebSocketData): void;
41
68
 
42
69
  /**
43
- * Close the websocket connection.
70
+ * Close the WebSocket connection.
44
71
  */
45
72
  abstract close(props?: { code: number; reason: string }): void;
46
73
 
47
74
  protected _onError(event: null, message: string, cause: any): void;
48
- protected _onError(event: SpeechToTextAPI.SttServerEvent.ErrorFrame, message?: string | undefined): void;
49
75
  protected _onError(
50
- event: SpeechToTextAPI.SttServerEvent.ErrorFrame | null,
76
+ event: SpeechToTextAPI.TranscribeServerEvent.SttErrorFrame,
77
+ message?: string | undefined,
78
+ ): void;
79
+ protected _onError(
80
+ event: SpeechToTextAPI.TranscribeServerEvent.SttErrorFrame | null,
51
81
  message?: string | undefined,
52
82
  cause?: any,
53
83
  ): void {
@@ -73,14 +103,11 @@ export abstract class SpeechToTextEmitter extends EventEmitter<WebsocketEvents>
73
103
  }
74
104
  }
75
105
 
76
- export function buildURL(client: Telnyx, query?: SpeechToTextAPI.SpeechToTextStreamParams | null): URL {
77
- const path = '/speech-to-text/transcription';
78
- const baseURL = client.baseURL;
79
- const url = new URL(baseURL + (baseURL.endsWith('/') ? path.slice(1) : path));
80
- if (query) {
81
- url.search = stringifyQuery(query);
82
- }
83
- url.protocol = 'wss';
106
+ export function buildURL(client: Telnyx, parameters: Record<string, unknown>): URL {
107
+ const { ...query } = parameters;
108
+ const endpoint = '/speech-to-text/transcription';
109
+ const url = new URL(client.buildURL(endpoint, query, undefined));
110
+ url.protocol = url.protocol === 'http:' || url.protocol === 'ws:' ? 'ws:' : 'wss:';
84
111
  return url;
85
112
  }
86
113