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
@@ -1,127 +1,42 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
3
  import * as WS from 'ws';
4
- import { SpeechToTextEmitter, buildURL } from './internal-base';
5
- import * as SpeechToTextAPI from './speech-to-text';
4
+ import { NodeWebSocket } from '../../internal/ws-adapter-node';
5
+ import { SpeechToTextWSBase, type SpeechToTextWSBaseOptions } from './ws-base';
6
6
  import { Telnyx } from '../../client';
7
7
 
8
- export class SpeechToTextWS extends SpeechToTextEmitter {
9
- url: URL;
10
- socket: WS.WebSocket;
11
- private client: Telnyx;
8
+ export type { SpeechToTextWSReconnectOptions } from './ws-base';
9
+
10
+ export interface SpeechToTextWSClientOptions extends WS.ClientOptions, SpeechToTextWSBaseOptions {}
11
+
12
+ export class SpeechToTextWS extends SpeechToTextWSBase<NodeWebSocket> {
13
+ private _wsOptions: WS.ClientOptions | null | undefined;
12
14
 
13
15
  constructor(
14
16
  client: Telnyx,
15
- parameters: SpeechToTextAPI.SpeechToTextStreamParams,
16
- options?: WS.ClientOptions | null | undefined,
17
+ parameters?: Record<string, unknown> | undefined,
18
+ options?: SpeechToTextWSClientOptions | null | undefined,
17
19
  ) {
18
- super();
19
- this.client = client;
20
- this.url = buildURL(client, parameters);
21
- this.socket = new WS.WebSocket(this.url, {
22
- ...options,
23
- headers: {
24
- ...this.authHeaders(),
25
- ...options?.headers,
26
- },
27
- });
28
-
29
- this.socket.on('open', () => {
30
- // Connection established, ready to send audio
31
- });
32
-
33
- this.socket.on('message', (wsEvent) => {
34
- const event = (() => {
35
- try {
36
- return JSON.parse(wsEvent.toString()) as SpeechToTextAPI.SttServerEvent;
37
- } catch (err) {
38
- this._onError(null, 'could not parse websocket event', err);
39
- return null;
40
- }
41
- })();
42
-
43
- if (event) {
44
- this._emit('event', event);
45
-
46
- if (event.type === 'error') {
47
- this._onError(event);
48
- } else {
49
- // @ts-ignore TS isn't smart enough to get the relationship right here
50
- this._emit(event.type, event);
51
- }
52
- }
53
- });
54
-
55
- this.socket.on('error', (err) => {
56
- this._onError(null, err.message, err);
57
- });
58
-
59
- this.socket.on('close', (code, reason) => {
60
- // Connection closed
61
- });
62
- }
63
-
64
- /**
65
- * Send binary audio data to the server for transcription.
66
- * @param data - Raw audio bytes (mp3 or wav format)
67
- */
68
- send(data: SpeechToTextAPI.SttClientEvent) {
69
- try {
70
- this.socket.send(data);
71
- } catch (err) {
72
- this._onError(null, 'could not send audio data', err);
20
+ if (!WS?.WebSocket) {
21
+ throw new Error(
22
+ 'SpeechToTextWS from "telnyx/resources/speech-to-text/ws" requires the "ws" package but it could not be loaded.',
23
+ );
73
24
  }
74
- }
75
25
 
76
- /**
77
- * Close the WebSocket connection.
78
- */
79
- close(props?: { code: number; reason: string }) {
80
- try {
81
- this.socket.close(props?.code ?? 1000, props?.reason ?? 'OK');
82
- } catch (err) {
83
- this._onError(null, 'could not close the connection', err);
84
- }
26
+ const { reconnect, maxQueueSize, ...wsOptions } = options ?? {};
27
+ super(client, parameters, { reconnect, maxQueueSize });
28
+ this._wsOptions = wsOptions;
29
+ this._connectInitial();
85
30
  }
86
31
 
87
- /**
88
- * Check if the WebSocket is open and ready to send data.
89
- */
90
- get isOpen(): boolean {
91
- return this.socket.readyState === WS.WebSocket.OPEN;
92
- }
93
-
94
- /**
95
- * Wait for the connection to be established.
96
- */
97
- waitForOpen(): Promise<void> {
98
- return new Promise((resolve, reject) => {
99
- if (this.socket.readyState === WS.WebSocket.OPEN) {
100
- resolve();
101
- return;
102
- }
103
-
104
- const onOpen = () => {
105
- this.socket.off('open', onOpen);
106
- this.socket.off('error', onError);
107
- resolve();
108
- };
109
-
110
- const onError = (err: Error) => {
111
- this.socket.off('open', onOpen);
112
- this.socket.off('error', onError);
113
- reject(err);
114
- };
115
-
116
- this.socket.on('open', onOpen);
117
- this.socket.on('error', onError);
32
+ protected _createSocket(url: URL, authHeaders: Record<string, string>): NodeWebSocket {
33
+ const ws = new WS.WebSocket(url, {
34
+ ...this._wsOptions,
35
+ headers: {
36
+ ...authHeaders,
37
+ ...this._wsOptions?.headers,
38
+ },
118
39
  });
119
- }
120
-
121
- private authHeaders(): Record<string, string> {
122
- if (this.client.apiKey) {
123
- return { Authorization: `Bearer ${this.client.apiKey}` };
124
- }
125
- return {};
40
+ return new NodeWebSocket(ws);
126
41
  }
127
42
  }
@@ -1,114 +1,3 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { APIResource } from '../core/resource';
4
- import { APIPromise } from '../core/api-promise';
5
- import { RequestOptions } from '../internal/request-options';
6
-
7
- /**
8
- * Discover available speech-to-text providers, models, and supported languages.
9
- */
10
- export class SpeechToText extends APIResource {
11
- /**
12
- * Retrieve the canonical list of supported speech-to-text providers, models,
13
- * accepted language codes, and the service types each model supports.
14
- *
15
- * Service types:
16
- *
17
- * - `streaming` — standalone WebSocket transcription via
18
- * `/speech-to-text/transcription`.
19
- * - `file_transcription` — file-based transcription via
20
- * `/ai/audio/transcriptions`.
21
- * - `in_call_transcription` — live call transcription via Call Control
22
- * `transcription_start`.
23
- *
24
- * Use this endpoint to discover which (provider, model) combinations are available
25
- * for the surface you need, and which language codes each accepts. `auto` in a
26
- * `languages` array indicates the provider performs language detection.
27
- */
28
- listProviders(
29
- query: SpeechToTextListProvidersParams | null | undefined = {},
30
- options?: RequestOptions,
31
- ): APIPromise<SpeechToTextListProvidersResponse> {
32
- return this._client.get('/speech-to-text/providers', {
33
- query,
34
- defaultBaseURL: 'https://api.telnyx.com/v2',
35
- ...options,
36
- });
37
- }
38
- }
39
-
40
- /**
41
- * List of supported STT providers and models.
42
- */
43
- export interface SpeechToTextListProvidersResponse {
44
- data: Array<SpeechToTextListProvidersResponse.Data>;
45
-
46
- meta: SpeechToTextListProvidersResponse.Meta;
47
- }
48
-
49
- export namespace SpeechToTextListProvidersResponse {
50
- /**
51
- * A (provider, model) tuple along with its supported service types and languages.
52
- */
53
- export interface Data {
54
- /**
55
- * Languages this (provider, model) accepts, in the provider's native code format.
56
- * `auto` indicates the provider performs language detection.
57
- */
58
- languages: Array<string>;
59
-
60
- /**
61
- * Provider-scoped model name.
62
- */
63
- model: string;
64
-
65
- /**
66
- * STT provider name.
67
- */
68
- provider: string;
69
-
70
- /**
71
- * Service surfaces this (provider, model) supports.
72
- */
73
- service_types: Array<'streaming' | 'file_transcription' | 'in_call_transcription'>;
74
- }
75
-
76
- export interface Meta {
77
- /**
78
- * Total number of entries returned.
79
- */
80
- total: number;
81
- }
82
- }
83
-
84
- export interface SpeechToTextListProvidersParams {
85
- /**
86
- * Filter to entries for a specific STT provider. The enum mirrors the providers
87
- * advertised across the speech-to-text spec (including `google` and `telnyx`,
88
- * which are accepted as WebSocket transcription engines). A provider that has no
89
- * models currently registered for any service type will return an empty `data`
90
- * array rather than an error.
91
- */
92
- provider?:
93
- | 'deepgram'
94
- | 'speechmatics'
95
- | 'assemblyai'
96
- | 'xai'
97
- | 'soniox'
98
- | 'azure'
99
- | 'openai'
100
- | 'google'
101
- | 'telnyx';
102
-
103
- /**
104
- * Filter to entries that support the given service type.
105
- */
106
- service_type?: 'streaming' | 'file_transcription' | 'in_call_transcription';
107
- }
108
-
109
- export declare namespace SpeechToText {
110
- export {
111
- type SpeechToTextListProvidersResponse as SpeechToTextListProvidersResponse,
112
- type SpeechToTextListProvidersParams as SpeechToTextListProvidersParams,
113
- };
114
- }
3
+ export * from './speech-to-text/index';