@fonoster/common 0.5.4 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/dist/constants.d.ts +4 -0
- package/dist/constants.js +6 -0
- package/dist/errors.d.ts +8 -0
- package/dist/errors.js +95 -0
- package/dist/grpcStatusMap.d.ts +4 -0
- package/dist/{envs.js → grpcStatusMap.js} +8 -6
- package/dist/index.d.ts +7 -8
- package/dist/index.js +38 -14
- package/dist/notifications/compileTemplate.d.ts +6 -0
- package/dist/{env_is_set.js → notifications/compileTemplate.js} +12 -14
- package/dist/notifications/createEmailSender.d.ts +17 -0
- package/dist/notifications/createEmailSender.js +55 -0
- package/dist/notifications/index.d.ts +2 -0
- package/dist/notifications/index.js +36 -0
- package/dist/protos/acls.proto +119 -0
- package/dist/protos/agents.proto +155 -0
- package/dist/protos/applications.proto +154 -0
- package/dist/protos/calls.proto +162 -0
- package/dist/protos/credentials.proto +119 -0
- package/dist/protos/domains.proto +127 -0
- package/dist/protos/identity.proto +286 -0
- package/dist/protos/numbers.proto +155 -0
- package/dist/protos/secrets.proto +113 -0
- package/dist/protos/trunks.proto +164 -0
- package/dist/protos/voice.proto +421 -0
- package/dist/tts/AzureVoices.d.ts +523 -0
- package/dist/tts/AzureVoices.js +3622 -0
- package/dist/tts/GoogleVoices.d.ts +475 -0
- package/dist/tts/GoogleVoices.js +3284 -0
- package/dist/tts/index.d.ts +3 -0
- package/dist/tts/index.js +37 -0
- package/dist/tts/types.d.ts +164 -0
- package/dist/tts/types.js +186 -0
- package/dist/utils/assertEnvsAreSet.d.ts +7 -0
- package/dist/utils/assertEnvsAreSet.js +37 -0
- package/dist/utils/assertFileExists.d.ts +5 -0
- package/dist/utils/assertFileExists.js +38 -0
- package/dist/utils/createInterceptingCall.d.ts +7 -0
- package/dist/utils/createInterceptingCall.js +9 -0
- package/dist/utils/createService.d.ts +9 -0
- package/dist/{service_runner.js → utils/createService.js} +15 -40
- package/dist/utils/datesMapper.d.ts +9 -0
- package/dist/utils/datesMapper.js +8 -0
- package/dist/utils/getServerCredentials.d.ts +10 -0
- package/dist/{trust_util.js → utils/getServerCredentials.js} +33 -37
- package/dist/utils/index.d.ts +8 -0
- package/dist/utils/index.js +42 -0
- package/dist/utils/toCamelCase.d.ts +2 -0
- package/dist/utils/toCamelCase.js +27 -0
- package/dist/utils/toPascalCase.d.ts +2 -0
- package/dist/{speech/plugin.js → utils/toPascalCase.js} +9 -13
- package/dist/voice/Dial.d.ts +23 -0
- package/dist/voice/Dial.js +19 -0
- package/dist/voice/Gather.d.ts +18 -0
- package/dist/voice/Gather.js +9 -0
- package/dist/voice/Mute.d.ts +13 -0
- package/dist/voice/Mute.js +9 -0
- package/dist/voice/Play.d.ts +12 -0
- package/dist/voice/PlayDtmf.d.ts +5 -0
- package/dist/voice/PlaybackControl.d.ts +13 -0
- package/dist/voice/PlaybackControl.js +11 -0
- package/dist/voice/Record.d.ts +18 -0
- package/dist/voice/Record.js +7 -0
- package/dist/voice/Say.d.ts +15 -0
- package/dist/voice/Say.js +2 -0
- package/dist/voice/Stream.d.ts +41 -0
- package/dist/voice/Stream.js +39 -0
- package/dist/voice/Verb.d.ts +9 -0
- package/dist/{healthcheck.js → voice/Verb.js} +2 -5
- package/dist/voice/index.d.ts +11 -0
- package/dist/voice/index.js +45 -0
- package/dist/voice/voice.d.ts +101 -0
- package/dist/voice/voice.js +44 -0
- package/package.json +28 -25
- package/LICENSE +0 -21
- package/dist/api_client.d.ts +0 -27
- package/dist/api_client.js +0 -110
- package/dist/env_is_set.d.ts +0 -1
- package/dist/envs.d.ts +0 -4
- package/dist/healthcheck.d.ts +0 -2
- package/dist/service_runner.d.ts +0 -13
- package/dist/speech/plugin.d.ts +0 -6
- package/dist/speech/types.d.ts +0 -17
- package/dist/trust_util.d.ts +0 -4
- package/dist/types.d.ts +0 -6
- /package/dist/{speech/types.js → voice/Play.js} +0 -0
- /package/dist/{types.js → voice/PlayDtmf.js} +0 -0
|
@@ -0,0 +1,421 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2024 by Fonoster Inc (https://fonoster.com)
|
|
3
|
+
* http://github.com/fonoster/fonoster
|
|
4
|
+
*
|
|
5
|
+
* This file is part of Fonoster
|
|
6
|
+
*
|
|
7
|
+
* Licensed under the MIT License (the "License");
|
|
8
|
+
* you may not use this file except in compliance with
|
|
9
|
+
* the License. You may obtain a copy of the License at
|
|
10
|
+
*
|
|
11
|
+
* https://opensource.org/licenses/MIT
|
|
12
|
+
*
|
|
13
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
+
* See the License for the specific language governing permissions and
|
|
17
|
+
* limitations under the License.
|
|
18
|
+
*/
|
|
19
|
+
syntax = "proto3";
|
|
20
|
+
|
|
21
|
+
package fonoster.voice.v1beta2;
|
|
22
|
+
|
|
23
|
+
import "google/protobuf/struct.proto";
|
|
24
|
+
|
|
25
|
+
// The voice service definition
|
|
26
|
+
service Voice {
|
|
27
|
+
rpc CreateSession(stream VoiceInStream) returns (stream VoiceOutStream) {}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// CreateSessionRequest is the request message for the CreateSession method
|
|
31
|
+
message CreateSessionRequest {
|
|
32
|
+
// The account making the request on behalf of the caller
|
|
33
|
+
string access_key_id = 1;
|
|
34
|
+
|
|
35
|
+
// Reference to an application living in the platform
|
|
36
|
+
string app_ref = 2;
|
|
37
|
+
|
|
38
|
+
// gRPC endpoint for the voice service
|
|
39
|
+
string endpoint = 3;
|
|
40
|
+
|
|
41
|
+
// PSTN number or SIP URI associated with the session
|
|
42
|
+
string ingress_number = 4;
|
|
43
|
+
|
|
44
|
+
// The name of the caller
|
|
45
|
+
string caller_name = 5;
|
|
46
|
+
|
|
47
|
+
// The caller number for the phone calling from the
|
|
48
|
+
string caller_number = 6;
|
|
49
|
+
|
|
50
|
+
// The session ID generated by the Media Server
|
|
51
|
+
string session_ref = 7;
|
|
52
|
+
|
|
53
|
+
// Use this token to validate the provenance of the request
|
|
54
|
+
// If the app_ref is provided, the token must include the app_ref as a claim
|
|
55
|
+
string session_token = 8;
|
|
56
|
+
|
|
57
|
+
// Metadata associated with the session
|
|
58
|
+
map<string, string> metadata = 9;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Common request for verbs
|
|
62
|
+
message VerbRequest {
|
|
63
|
+
string session_ref = 1;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Common response for verbs
|
|
67
|
+
message VerbResponse {
|
|
68
|
+
string session_ref = 1;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Request to play a sound
|
|
72
|
+
message PlayRequest {
|
|
73
|
+
// The session reference generated by the Media Server
|
|
74
|
+
string session_ref = 1;
|
|
75
|
+
|
|
76
|
+
// The URL of the sound to play
|
|
77
|
+
string url = 2;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// Request to play a sound
|
|
81
|
+
message PlayResponse {
|
|
82
|
+
// The session reference generated by the Media Server
|
|
83
|
+
string session_ref = 1;
|
|
84
|
+
|
|
85
|
+
// The playback reference generated by the Media Server
|
|
86
|
+
string playback_ref = 2;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// The request message for the PlaybackControl method
|
|
90
|
+
message PlaybackControlRequest {
|
|
91
|
+
// The session reference generated by the Media Server
|
|
92
|
+
string session_ref = 1;
|
|
93
|
+
|
|
94
|
+
// The playback reference generated by the Media Server
|
|
95
|
+
string playback_ref = 2;
|
|
96
|
+
|
|
97
|
+
// The action to take
|
|
98
|
+
enum Action {
|
|
99
|
+
STOP = 0;
|
|
100
|
+
RESTART = 1;
|
|
101
|
+
PAUSE = 2;
|
|
102
|
+
UNPAUSE = 3;
|
|
103
|
+
FORWARD = 4;
|
|
104
|
+
}
|
|
105
|
+
Action action = 3;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// PlayDtmfRequest is the request message for the PlayDtmf method
|
|
109
|
+
message PlayDtmfRequest {
|
|
110
|
+
// The session reference generated by the Media Server
|
|
111
|
+
string session_ref = 1;
|
|
112
|
+
|
|
113
|
+
// The digits to play
|
|
114
|
+
string digits = 2;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// Request to mute or unmute the call
|
|
118
|
+
message MuteRequest {
|
|
119
|
+
// The session reference generated by the Media Server
|
|
120
|
+
string session_ref = 1;
|
|
121
|
+
|
|
122
|
+
// The direction to mute
|
|
123
|
+
enum MuteDirection {
|
|
124
|
+
IN = 0;
|
|
125
|
+
OUT = 1;
|
|
126
|
+
BOTH = 2;
|
|
127
|
+
}
|
|
128
|
+
MuteDirection direction = 2;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// Request to gather speech or DTMF
|
|
132
|
+
message GatherRequest {
|
|
133
|
+
// The session reference generated by the Media Server
|
|
134
|
+
string session_ref = 1;
|
|
135
|
+
|
|
136
|
+
// The source of the gather
|
|
137
|
+
enum GatherSource {
|
|
138
|
+
SPEECH = 0;
|
|
139
|
+
DTMF = 1;
|
|
140
|
+
SPEECH_AND_DTMF = 2;
|
|
141
|
+
}
|
|
142
|
+
GatherSource source = 2;
|
|
143
|
+
|
|
144
|
+
// Optional key to finish the gather
|
|
145
|
+
string finish_on_key = 3;
|
|
146
|
+
|
|
147
|
+
// Optional timeout in seconds
|
|
148
|
+
int32 timeout = 4;
|
|
149
|
+
|
|
150
|
+
// Optional number of digits to gather
|
|
151
|
+
int32 max_digits = 5;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// Response to a gather request
|
|
155
|
+
message GatherResponse {
|
|
156
|
+
// The session reference generated by the Media Server
|
|
157
|
+
string session_ref = 1;
|
|
158
|
+
|
|
159
|
+
// The gathered speech or digits
|
|
160
|
+
oneof content {
|
|
161
|
+
string speech = 2;
|
|
162
|
+
string digits = 3;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
// RecordRequest is the request message to initiate a recording
|
|
167
|
+
message RecordRequest {
|
|
168
|
+
// The session reference generated by the Media Server
|
|
169
|
+
string session_ref = 1;
|
|
170
|
+
|
|
171
|
+
// The maximum duration of the recording in seconds
|
|
172
|
+
int32 max_duration = 2;
|
|
173
|
+
|
|
174
|
+
// The maximum silence before ending the recording in seconds
|
|
175
|
+
int32 max_silence = 3;
|
|
176
|
+
|
|
177
|
+
// Play a beep before recording
|
|
178
|
+
bool beep = 4;
|
|
179
|
+
|
|
180
|
+
// Finish recording on this key
|
|
181
|
+
string finish_on_key = 5;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Response to a record request
|
|
185
|
+
message RecordResponse {
|
|
186
|
+
// The session reference generated by the Media Server
|
|
187
|
+
string session_ref = 1;
|
|
188
|
+
|
|
189
|
+
// The name of the recording
|
|
190
|
+
string name = 2;
|
|
191
|
+
|
|
192
|
+
// The duration of the recording
|
|
193
|
+
int32 duration = 3;
|
|
194
|
+
|
|
195
|
+
// The format of the recording
|
|
196
|
+
enum RecordFormat {
|
|
197
|
+
WAV = 0;
|
|
198
|
+
}
|
|
199
|
+
RecordFormat format = 4;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
// Request to say a text
|
|
203
|
+
message SayRequest {
|
|
204
|
+
// The session reference generated by the Media Server
|
|
205
|
+
string session_ref = 1;
|
|
206
|
+
|
|
207
|
+
// The text to say
|
|
208
|
+
string text = 2;
|
|
209
|
+
|
|
210
|
+
// Assign a playback reference to the request
|
|
211
|
+
string playback_ref = 3;
|
|
212
|
+
|
|
213
|
+
// TTS options
|
|
214
|
+
google.protobuf.Struct options = 4;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Dial request message
|
|
218
|
+
message DialRequest {
|
|
219
|
+
// The session reference generated by the Media Server
|
|
220
|
+
string session_ref = 1;
|
|
221
|
+
|
|
222
|
+
// The number to dial
|
|
223
|
+
string destination = 2;
|
|
224
|
+
|
|
225
|
+
// The caller ID to use (reserved for future use)
|
|
226
|
+
string caller_id = 3;
|
|
227
|
+
|
|
228
|
+
// The timeout in seconds
|
|
229
|
+
int32 timeout = 4;
|
|
230
|
+
|
|
231
|
+
// Record direction
|
|
232
|
+
enum RecordDirection {
|
|
233
|
+
IN = 0;
|
|
234
|
+
OUT = 1;
|
|
235
|
+
BOTH = 2;
|
|
236
|
+
}
|
|
237
|
+
RecordDirection record_direction = 5;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
// Dial status message
|
|
241
|
+
message DialStatus {
|
|
242
|
+
// The session reference generated by the Media Server
|
|
243
|
+
string session_ref = 1;
|
|
244
|
+
|
|
245
|
+
// The status of the dial
|
|
246
|
+
enum Status {
|
|
247
|
+
TRYING = 0;
|
|
248
|
+
CANCEL = 1;
|
|
249
|
+
ANSWER = 2;
|
|
250
|
+
BUSY = 3;
|
|
251
|
+
PROGRESS = 4;
|
|
252
|
+
NOANSWER = 5;
|
|
253
|
+
FAILED = 6;
|
|
254
|
+
}
|
|
255
|
+
Status status = 2;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
// Request to start an audio stream
|
|
259
|
+
message StartStreamRequest {
|
|
260
|
+
// The session reference generated by the Media Server
|
|
261
|
+
string session_ref = 1;
|
|
262
|
+
|
|
263
|
+
// The direction of the stream
|
|
264
|
+
enum StreamDirection {
|
|
265
|
+
IN = 0;
|
|
266
|
+
OUT = 1;
|
|
267
|
+
BOTH = 2;
|
|
268
|
+
}
|
|
269
|
+
StreamDirection direction = 2;
|
|
270
|
+
|
|
271
|
+
// Output format
|
|
272
|
+
enum StreamAudioFormat {
|
|
273
|
+
WAV = 0;
|
|
274
|
+
}
|
|
275
|
+
StreamAudioFormat format = 3;
|
|
276
|
+
|
|
277
|
+
// Enable VAD (Voice Activity Detection)
|
|
278
|
+
bool enableVad = 4;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
// Response to a start stream request
|
|
282
|
+
message StartStreamResponse {
|
|
283
|
+
// The session reference generated by the Media Server
|
|
284
|
+
string session_ref = 1;
|
|
285
|
+
|
|
286
|
+
// The stream reference generated by the Media Server
|
|
287
|
+
string stream_ref = 2;
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
// Request to stop an audio stream
|
|
291
|
+
message StopStreamRequest {
|
|
292
|
+
// The session reference generated by the Media Server
|
|
293
|
+
string session_ref = 1;
|
|
294
|
+
|
|
295
|
+
// The stream reference generated by the Media Server
|
|
296
|
+
string stream_ref = 2;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// Message for the bidirectional streams
|
|
300
|
+
message StreamPayload {
|
|
301
|
+
// The session reference generated by the Media Server
|
|
302
|
+
string session_ref = 1;
|
|
303
|
+
|
|
304
|
+
// The stream reference generated by the Media Server
|
|
305
|
+
string stream_ref = 2;
|
|
306
|
+
|
|
307
|
+
// The message type
|
|
308
|
+
enum StreamMessageType {
|
|
309
|
+
AUDIO_IN = 0;
|
|
310
|
+
AUDIO_OUT = 1;
|
|
311
|
+
ERROR = 2;
|
|
312
|
+
VOICE_ACTIVITY_START = 3;
|
|
313
|
+
VOICE_ACTIVITY_END = 4;
|
|
314
|
+
}
|
|
315
|
+
StreamMessageType type = 3;
|
|
316
|
+
|
|
317
|
+
// The audio data
|
|
318
|
+
bytes data = 4;
|
|
319
|
+
|
|
320
|
+
// TODO: Consider turning this into a enum
|
|
321
|
+
// (Q. should we use the same error codes as gRPC?)
|
|
322
|
+
// Error code if any
|
|
323
|
+
string code = 5;
|
|
324
|
+
|
|
325
|
+
// Error message if any
|
|
326
|
+
string message = 6;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
// VoiceInStream is the input stream for the voice service
|
|
330
|
+
message VoiceInStream {
|
|
331
|
+
oneof content {
|
|
332
|
+
// Initial request to create a new session
|
|
333
|
+
CreateSessionRequest request = 1;
|
|
334
|
+
|
|
335
|
+
// Command to accept the call
|
|
336
|
+
VerbResponse answer_response = 2;
|
|
337
|
+
|
|
338
|
+
// Response to a play request
|
|
339
|
+
PlayResponse play_response = 3;
|
|
340
|
+
|
|
341
|
+
// Response to a hangup request
|
|
342
|
+
VerbResponse hangup_response = 4;
|
|
343
|
+
|
|
344
|
+
// Response to a mute request
|
|
345
|
+
VerbResponse mute_response = 5;
|
|
346
|
+
|
|
347
|
+
// Response to a unmute request
|
|
348
|
+
VerbResponse unmute_response = 6;
|
|
349
|
+
|
|
350
|
+
// Response to a play dtmf request
|
|
351
|
+
VerbResponse play_dtmf_response = 7;
|
|
352
|
+
|
|
353
|
+
// Response to a gather request
|
|
354
|
+
GatherResponse gather_response = 8;
|
|
355
|
+
|
|
356
|
+
// Response to a playback control request
|
|
357
|
+
VerbResponse playback_control_response = 9;
|
|
358
|
+
|
|
359
|
+
// Response to a say request (It shares the same response as play)
|
|
360
|
+
PlayResponse say_response = 10;
|
|
361
|
+
|
|
362
|
+
// Response to a record request
|
|
363
|
+
RecordResponse record_response = 11;
|
|
364
|
+
|
|
365
|
+
// Status of a dial request progress
|
|
366
|
+
DialStatus dial_status = 12;
|
|
367
|
+
|
|
368
|
+
// Response to a start stream request
|
|
369
|
+
StartStreamResponse start_stream_response = 13;
|
|
370
|
+
|
|
371
|
+
// Message for the bidirectional streams
|
|
372
|
+
StreamPayload stream_payload = 154;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
// VoiceOutStream is the output stream for the voice service
|
|
377
|
+
message VoiceOutStream {
|
|
378
|
+
oneof content {
|
|
379
|
+
// Request to accept the call
|
|
380
|
+
VerbRequest answer_request = 1;
|
|
381
|
+
|
|
382
|
+
// Request to play a sound
|
|
383
|
+
PlayRequest play_request = 2;
|
|
384
|
+
|
|
385
|
+
// Request to hangup the call
|
|
386
|
+
VerbRequest hangup_request = 3;
|
|
387
|
+
|
|
388
|
+
// Request to mute the call
|
|
389
|
+
MuteRequest mute_request = 4;
|
|
390
|
+
|
|
391
|
+
// Request to unmute the call
|
|
392
|
+
MuteRequest unmute_request = 5;
|
|
393
|
+
|
|
394
|
+
// Request to play dtmf
|
|
395
|
+
PlayDtmfRequest play_dtmf_request = 6;
|
|
396
|
+
|
|
397
|
+
// Request to gather speech or DTMF
|
|
398
|
+
GatherRequest gather_request = 7;
|
|
399
|
+
|
|
400
|
+
// Request to control a playback
|
|
401
|
+
PlaybackControlRequest playback_control_request = 9;
|
|
402
|
+
|
|
403
|
+
// Request to say a text
|
|
404
|
+
SayRequest say_request = 10;
|
|
405
|
+
|
|
406
|
+
// Request to record
|
|
407
|
+
RecordRequest record_request = 11;
|
|
408
|
+
|
|
409
|
+
// Request to dial a number
|
|
410
|
+
DialRequest dial_request = 12;
|
|
411
|
+
|
|
412
|
+
// Request to start an audio stream
|
|
413
|
+
StartStreamRequest start_stream_request = 14;
|
|
414
|
+
|
|
415
|
+
// Request to stop an audio stream
|
|
416
|
+
StopStreamRequest stop_stream_request = 15;
|
|
417
|
+
|
|
418
|
+
// Message for the bidirectional streams
|
|
419
|
+
StreamPayload stream_payload = 16;
|
|
420
|
+
}
|
|
421
|
+
}
|