@fonoster/voice 0.16.8 → 0.17.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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2024 Fonoster Inc
3
+ Copyright (c) 2026 Fonoster Inc
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
18
  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
19
  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
- SOFTWARE.
21
+ SOFTWARE.
@@ -71,7 +71,7 @@ class VoiceResponse {
71
71
  answer() {
72
72
  return __awaiter(this, void 0, void 0, function* () {
73
73
  yield new verbs_1.Answer(this.request, this.voice).run();
74
- return { sessionRef: this.request.sessionRef };
74
+ return { mediaSessionRef: this.request.mediaSessionRef };
75
75
  });
76
76
  }
77
77
  /**
@@ -85,7 +85,7 @@ class VoiceResponse {
85
85
  hangup() {
86
86
  return __awaiter(this, void 0, void 0, function* () {
87
87
  yield new verbs_1.Hangup(this.request, this.voice).run();
88
- return { sessionRef: this.request.sessionRef };
88
+ return { mediaSessionRef: this.request.mediaSessionRef };
89
89
  });
90
90
  }
91
91
  /**
@@ -104,7 +104,7 @@ class VoiceResponse {
104
104
  */
105
105
  play(url, options) {
106
106
  return __awaiter(this, void 0, void 0, function* () {
107
- const response = yield new verbs_1.Play(this.request, this.voice).run(Object.assign(Object.assign({}, options), { sessionRef: this.request.sessionRef, url }));
107
+ const response = yield new verbs_1.Play(this.request, this.voice).run(Object.assign(Object.assign({}, options), { mediaSessionRef: this.request.mediaSessionRef, url }));
108
108
  return response.playResponse;
109
109
  });
110
110
  }
@@ -122,7 +122,7 @@ class VoiceResponse {
122
122
  playDtmf(digits) {
123
123
  return __awaiter(this, void 0, void 0, function* () {
124
124
  yield new verbs_1.PlayDtmf(this.request, this.voice).run({
125
- sessionRef: this.request.sessionRef,
125
+ mediaSessionRef: this.request.mediaSessionRef,
126
126
  digits
127
127
  });
128
128
  });
@@ -146,11 +146,11 @@ class VoiceResponse {
146
146
  playbackControl(playbackRef, action) {
147
147
  return __awaiter(this, void 0, void 0, function* () {
148
148
  yield new verbs_1.PlaybackControl(this.request, this.voice).run({
149
- sessionRef: this.request.sessionRef,
149
+ mediaSessionRef: this.request.mediaSessionRef,
150
150
  playbackRef,
151
151
  action
152
152
  });
153
- return { sessionRef: this.request.sessionRef };
153
+ return { mediaSessionRef: this.request.mediaSessionRef };
154
154
  });
155
155
  }
156
156
  /**
@@ -174,7 +174,7 @@ class VoiceResponse {
174
174
  */
175
175
  gather() {
176
176
  return __awaiter(this, arguments, void 0, function* (options = { source: common_1.GatherSource.SPEECH_AND_DTMF }) {
177
- const response = yield new verbs_1.Gather(this.request, this.voice).run(Object.assign({ sessionRef: this.request.sessionRef }, options));
177
+ const response = yield new verbs_1.Gather(this.request, this.voice).run(Object.assign({ mediaSessionRef: this.request.mediaSessionRef }, options));
178
178
  return response.gatherResponse;
179
179
  });
180
180
  }
@@ -200,10 +200,10 @@ class VoiceResponse {
200
200
  return __awaiter(this, void 0, void 0, function* () {
201
201
  yield new verbs_1.Say(this.request, this.voice).run({
202
202
  options: options ? pb_util_1.struct.encode(options) : undefined,
203
- sessionRef: this.request.sessionRef,
203
+ mediaSessionRef: this.request.mediaSessionRef,
204
204
  text
205
205
  });
206
- return { sessionRef: this.request.sessionRef };
206
+ return { mediaSessionRef: this.request.mediaSessionRef };
207
207
  });
208
208
  }
209
209
  /**
@@ -224,10 +224,8 @@ class VoiceResponse {
224
224
  */
225
225
  stopSay() {
226
226
  return __awaiter(this, void 0, void 0, function* () {
227
- yield new verbs_1.StopSay(this.request, this.voice).run({
228
- sessionRef: this.request.sessionRef
229
- });
230
- return { sessionRef: this.request.sessionRef };
227
+ yield new verbs_1.StopSay(this.request, this.voice).run();
228
+ return { mediaSessionRef: this.request.mediaSessionRef };
231
229
  });
232
230
  }
233
231
  /**
@@ -249,7 +247,7 @@ class VoiceResponse {
249
247
  */
250
248
  record(options) {
251
249
  return __awaiter(this, void 0, void 0, function* () {
252
- const response = yield new verbs_1.Record(this.request, this.voice).run(Object.assign({ sessionRef: this.request.sessionRef }, options));
250
+ const response = yield new verbs_1.Record(this.request, this.voice).run(Object.assign({ mediaSessionRef: this.request.mediaSessionRef }, options));
253
251
  return response.recordResponse;
254
252
  });
255
253
  }
@@ -265,7 +263,7 @@ class VoiceResponse {
265
263
  dial(destination, options) {
266
264
  return __awaiter(this, void 0, void 0, function* () {
267
265
  const stream = new verbs_1.DialStatusStream();
268
- yield new verbs_1.Dial(this.request, this.voice).run(Object.assign({ sessionRef: this.request.sessionRef, destination }, options));
266
+ yield new verbs_1.Dial(this.request, this.voice).run(Object.assign({ mediaSessionRef: this.request.mediaSessionRef, destination }, options));
269
267
  this.voice.on(common_1.StreamEvent.DATA, (result) => {
270
268
  if (result.dialResponse) {
271
269
  stream.emit(result.dialResponse.status);
@@ -303,7 +301,7 @@ class VoiceResponse {
303
301
  const stream = new verbs_1.Stream();
304
302
  const startStream = new verbs_1.StartStream(this.request, this.voice);
305
303
  const stopStream = new verbs_1.StopStream(this.request, this.voice);
306
- const { startStreamResponse } = yield startStream.run(Object.assign({ sessionRef: this.request.sessionRef }, options));
304
+ const { startStreamResponse } = yield startStream.run(Object.assign({ mediaSessionRef: this.request.mediaSessionRef }, options));
307
305
  this.voice.on(common_1.StreamEvent.DATA, (result) => {
308
306
  if (result.streamPayload) {
309
307
  stream.emit("payloadOut", result.streamPayload);
@@ -316,7 +314,7 @@ class VoiceResponse {
316
314
  });
317
315
  stream.cleanup(() => {
318
316
  stopStream.run({
319
- sessionRef: this.request.sessionRef,
317
+ mediaSessionRef: this.request.mediaSessionRef,
320
318
  streamRef: startStreamResponse === null || startStreamResponse === void 0 ? void 0 : startStreamResponse.streamRef
321
319
  });
322
320
  });
@@ -345,16 +343,14 @@ class VoiceResponse {
345
343
  const stream = new verbs_1.StreamGatherStream();
346
344
  const startStreamGather = new verbs_1.StartStreamGather(this.request, this.voice);
347
345
  const stopStreamGather = new verbs_1.StopStreamGather(this.request, this.voice);
348
- yield startStreamGather.run(Object.assign({ sessionRef: this.request.sessionRef }, options));
346
+ yield startStreamGather.run(Object.assign({ mediaSessionRef: this.request.mediaSessionRef }, options));
349
347
  this.voice.on(common_1.StreamEvent.DATA, (result) => {
350
348
  if (result.streamGatherPayload) {
351
349
  stream.emit("data", result.streamGatherPayload);
352
350
  }
353
351
  });
354
352
  stream.cleanup(() => {
355
- stopStreamGather.run({
356
- sessionRef: this.request.sessionRef
357
- });
353
+ stopStreamGather.run();
358
354
  });
359
355
  return stream;
360
356
  });
@@ -376,7 +372,7 @@ class VoiceResponse {
376
372
  return __awaiter(this, arguments, void 0, function* (options = { direction: common_1.MuteDirection.BOTH }) {
377
373
  const { direction } = options;
378
374
  yield new verbs_1.Mute(this.request, this.voice).run({
379
- sessionRef: this.request.sessionRef,
375
+ mediaSessionRef: this.request.mediaSessionRef,
380
376
  direction
381
377
  });
382
378
  });
@@ -398,7 +394,7 @@ class VoiceResponse {
398
394
  return __awaiter(this, arguments, void 0, function* (options = { direction: common_1.MuteDirection.BOTH }) {
399
395
  const { direction } = options;
400
396
  yield new verbs_1.Unmute(this.request, this.voice).run({
401
- sessionRef: this.request.sessionRef,
397
+ mediaSessionRef: this.request.mediaSessionRef,
402
398
  direction
403
399
  });
404
400
  });
@@ -34,18 +34,18 @@ const VoiceResponse_1 = require("./VoiceResponse");
34
34
  const logger = (0, logger_1.getLogger)({ service: "voice", filePath: __filename });
35
35
  function createSession(handler) {
36
36
  return (voice) => new Promise((resolve) => {
37
- let sessionRef;
37
+ let mediaSessionRef;
38
38
  voice.once(common_1.StreamEvent.DATA, (params) => __awaiter(this, void 0, void 0, function* () {
39
39
  const { request } = params;
40
40
  if (request) {
41
- sessionRef = request.sessionRef;
41
+ mediaSessionRef = request.mediaSessionRef;
42
42
  const response = new VoiceResponse_1.VoiceResponse(request, voice);
43
43
  yield handler(request, response);
44
44
  resolve();
45
45
  }
46
46
  }));
47
47
  voice.once(common_1.StreamEvent.END, () => {
48
- logger.verbose("session ended", { sessionRef });
48
+ logger.verbose("session ended", { mediaSessionRef });
49
49
  voice.end();
50
50
  resolve();
51
51
  });
@@ -40,14 +40,14 @@ class Verb {
40
40
  }
41
41
  run(params) {
42
42
  return __awaiter(this, void 0, void 0, function* () {
43
- const { sessionRef } = this.request;
43
+ const { mediaSessionRef } = this.request;
44
44
  const { voice } = this;
45
45
  logger.verbose(`sending a request with the ${this.constructor.name} verb`, {
46
- sessionRef
46
+ mediaSessionRef
47
47
  });
48
48
  return new Promise((resolve, reject) => {
49
49
  try {
50
- const fullRequest = Object.assign(Object.assign({}, params), { sessionRef });
50
+ const fullRequest = Object.assign(Object.assign({}, params), { mediaSessionRef });
51
51
  (0, validateRequest_1.validateRequest)(this.getValidationSchema(), fullRequest);
52
52
  voice.write({
53
53
  [`${(0, common_1.toCamelCase)(this.constructor.name)}Request`]: fullRequest
@@ -58,7 +58,7 @@ class Verb {
58
58
  return;
59
59
  }
60
60
  logger.verbose(`received ${this.constructor.name} response`, {
61
- sessionRef
61
+ mediaSessionRef
62
62
  });
63
63
  resolve(result);
64
64
  voice.removeListener(common_1.StreamEvent.DATA, dataListener);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fonoster/voice",
3
- "version": "0.16.8",
3
+ "version": "0.17.0",
4
4
  "description": "Voice Server for Fonoster",
5
5
  "author": "Pedro Sanders <psanders@fonoster.com>",
6
6
  "homepage": "https://github.com/fonoster/fonoster#readme",
@@ -22,9 +22,9 @@
22
22
  "fonoster": "./dist/index.js"
23
23
  },
24
24
  "dependencies": {
25
- "@fonoster/common": "^0.16.8",
26
- "@fonoster/identity": "^0.16.8",
27
- "@fonoster/logger": "^0.16.7",
25
+ "@fonoster/common": "^0.17.0",
26
+ "@fonoster/identity": "^0.17.0",
27
+ "@fonoster/logger": "^0.17.0",
28
28
  "@grpc/grpc-js": "~1.10.6",
29
29
  "deepmerge": "^4.3.1",
30
30
  "grpc-health-check": "^2.0.2",
@@ -45,5 +45,5 @@
45
45
  "bugs": {
46
46
  "url": "https://github.com/fonoster/fonoster/issues"
47
47
  },
48
- "gitHead": "5972440bc8106a5db4b3536129b60d1df30fe6b3"
48
+ "gitHead": "4d1a9afaec6f294184386e009d1a4e292fb3583b"
49
49
  }