@onereach/step-voice 4.0.2 → 4.0.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.
package/dst/Cancel.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export default class VoiceCancel extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<unknown>;
1
+ import VoiceStep from './voice';
2
+ export default class VoiceCancel extends VoiceStep {
3
+ get useQueue(): boolean;
4
+ runStep(): Promise<void>;
4
5
  }
5
- import VoiceStep from "./voice";
package/dst/Cancel.js CHANGED
@@ -10,7 +10,7 @@ class VoiceCancel extends voice_1.default {
10
10
  const channel = await this.fetchData();
11
11
  await this.cancel();
12
12
  await this.sendCommands(channel, [{ name: 'cancel' }]);
13
- return this.exitStep('next');
13
+ this.exitStep('next');
14
14
  }
15
15
  }
16
16
  exports.default = VoiceCancel;
package/dst/Choice.d.ts CHANGED
@@ -1,5 +1,30 @@
1
- export default class Choice extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<import("@onereach/flow-sdk/dst/types").ITriggers>;
1
+ import VoiceStep, { TODO, VoiceEvent } from './voice';
2
+ interface INPUT {
3
+ textType: string;
4
+ asr: TODO;
5
+ tts: TODO;
6
+ audio: TODO[];
7
+ choices: TODO[];
8
+ prompts: TODO[];
9
+ sensitiveData: {
10
+ muteStep: boolean;
11
+ muteUser: boolean;
12
+ muteBot: boolean;
13
+ };
14
+ noReplyDelay: number;
15
+ promptsTriggers: TODO[];
16
+ usePromptsTriggers: boolean;
4
17
  }
5
- import VoiceStep from "./voice";
18
+ interface EVENT extends VoiceEvent {
19
+ callRecording?: TODO;
20
+ exitId?: string;
21
+ digit?: string;
22
+ digits?: string;
23
+ phrases?: TODO[];
24
+ tags?: string[];
25
+ out?: string;
26
+ }
27
+ export default class Choice extends VoiceStep<INPUT, {}, EVENT> {
28
+ runStep(): Promise<void>;
29
+ }
30
+ export {};
package/dst/Choice.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
4
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
5
- const _ = require('lodash');
6
6
  const digitWords = [
7
7
  'zero',
8
8
  'one',
@@ -28,7 +28,7 @@ const containsOnlyDigits = (stringsList) => {
28
28
  return isOnlyDigits;
29
29
  };
30
30
  const getPhrasesForSpeechRec = (choices) => {
31
- const texts = _.flatMap(choices, (choice) => choice.options.map((opt) => opt.text));
31
+ const texts = lodash_1.default.flatMap(choices, (choice) => choice.options.map((opt) => opt.text));
32
32
  if (containsOnlyDigits(texts)) {
33
33
  return ['$OOV_CLASS_DIGIT_SEQUENCE'];
34
34
  }
@@ -54,7 +54,7 @@ const isRepromptTrigger = (recogResult, promptsTriggers) => {
54
54
  return r.lexical;
55
55
  });
56
56
  const triggers = promptsTriggers.flatMap((trigger) => {
57
- if (_.isEmpty(trigger.grammar)) {
57
+ if (lodash_1.default.isEmpty(trigger.grammar)) {
58
58
  return trigger.text.replace(/`/g, '');
59
59
  }
60
60
  else {
@@ -63,14 +63,14 @@ const isRepromptTrigger = (recogResult, promptsTriggers) => {
63
63
  });
64
64
  }
65
65
  });
66
- return !_.isEmpty(phrases.filter((e) => triggers.indexOf(e) !== -1));
66
+ return !lodash_1.default.isEmpty(phrases.filter((e) => triggers.includes(e)));
67
67
  };
68
68
  class Choice extends voice_1.default {
69
69
  async runStep() {
70
70
  const channel = await this.fetchData();
71
71
  const { textType, asr, tts, sensitiveData, noReplyDelay, usePromptsTriggers } = this.data;
72
72
  const exitExists = (exitId) => {
73
- return _.some(choices, (choice) => choice.exitId === exitId);
73
+ return lodash_1.default.some(choices, (choice) => choice.exitId === exitId);
74
74
  };
75
75
  const choices = this.buildChoices({ choices: this.data.choices });
76
76
  const ttsSettings = tts.getSettings(channel.tts);
@@ -90,8 +90,7 @@ class Choice extends voice_1.default {
90
90
  }
91
91
  };
92
92
  // There's a specific need to do so. There might be ${variable} section
93
- return this.triggers
94
- .once(`in/voice/${channel.id}/event`, async (event) => {
93
+ this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
95
94
  if (channel.recordCall && sensitiveData?.muteStep) {
96
95
  await this.sendCommands(channel, [{
97
96
  name: 'resume-record-session',
@@ -106,13 +105,13 @@ class Choice extends voice_1.default {
106
105
  case 'digit':
107
106
  case 'digits': {
108
107
  const params = event.params;
109
- const digit = params.digit || params.digits;
110
- const exitId = params.exitId;
108
+ const digit = params.digit ?? params.digits;
109
+ const exitId = params.exitId ?? '';
111
110
  // On bargeIn, we should stop playback
112
111
  if (exitExists(exitId)) {
113
112
  await this.transcript(channel, {
114
113
  keyPress: digit,
115
- message: _.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
114
+ message: lodash_1.default.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
116
115
  reportingSettingsKey,
117
116
  action: 'Call DTMF',
118
117
  actionFromBot: false
@@ -150,19 +149,19 @@ class Choice extends voice_1.default {
150
149
  }
151
150
  case 'recognition': {
152
151
  const params = event.params;
153
- const exitId = params.exitId;
152
+ const exitId = params.exitId ?? '';
154
153
  const phrases = params.phrases;
155
- if (_.isEmpty(phrases)) {
154
+ if (lodash_1.default.isEmpty(phrases)) {
156
155
  return this.exitStep('unrecognized', {});
157
156
  }
158
- const voiceProcessResult = _.chain(phrases)
157
+ const voiceProcessResult = lodash_1.default.chain(phrases)
159
158
  .map((p) => p.lexical)
160
159
  .join(' | ')
161
160
  .value();
162
161
  // On bargeIn, we should stop playback
163
162
  if (exitExists(exitId)) {
164
163
  await this.transcript(channel, {
165
- message: _.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
164
+ message: lodash_1.default.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
166
165
  voiceProcessResult,
167
166
  reportingSettingsKey,
168
167
  action: 'Call Recognition',
@@ -241,8 +240,8 @@ class Choice extends voice_1.default {
241
240
  default:
242
241
  return this.exitFlow();
243
242
  }
244
- })
245
- .otherwise(async () => {
243
+ });
244
+ this.triggers.otherwise(async () => {
246
245
  await this.transcript(channel, {
247
246
  sections: speechSections,
248
247
  reprompt: {
@@ -256,13 +255,15 @@ class Choice extends voice_1.default {
256
255
  command.params.sections = speechSections;
257
256
  command.params.timeout = this.rptsTimeout({ noReplyDelay, repromptsList });
258
257
  await this.sendCommands(channel, [
259
- ...channel.recordCall && sensitiveData?.muteStep ? [{
260
- name: 'stop-record-session',
261
- params: {
262
- muteUser: sensitiveData.muteUser,
263
- muteBot: sensitiveData.muteBot
264
- }
265
- }] : [],
258
+ ...channel.recordCall && sensitiveData?.muteStep
259
+ ? [{
260
+ name: 'stop-record-session',
261
+ params: {
262
+ muteUser: sensitiveData.muteUser,
263
+ muteBot: sensitiveData.muteBot
264
+ }
265
+ }]
266
+ : [],
266
267
  command
267
268
  ]);
268
269
  return this.exitFlow();
@@ -1,5 +1,10 @@
1
- export default class ConferenceDial extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
1
+ import VoiceStep from './voice';
2
+ export default class ConferenceDial extends VoiceStep<{
3
+ stayInConference: boolean;
4
+ sourceConf: string;
5
+ botNumber: string;
6
+ headers?: Record<string, string>;
7
+ hearOnly: boolean;
8
+ }> {
3
9
  runStep(): Promise<void>;
4
10
  }
5
- import VoiceStep from "./voice";
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
4
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
5
- const _ = require('lodash');
6
6
  class ConferenceDial extends voice_1.default {
7
7
  async runStep() {
8
8
  const channel = await this.fetchData();
@@ -17,7 +17,7 @@ class ConferenceDial extends voice_1.default {
17
17
  return this.exitFlow();
18
18
  }
19
19
  else {
20
- return this.exitStep('next', _.omit(event.params, ['type']));
20
+ return this.exitStep('next', lodash_1.default.omit(event.params, ['type']));
21
21
  }
22
22
  case 'conference-end':
23
23
  return this.data.stayInConference ? this.exitStep('next') : this.exitFlow();
@@ -1,16 +1,39 @@
1
- export default class GlobalCommand extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- get autoCancel(): undefined;
1
+ import { ITypedEvent } from '@onereach/flow-sdk/dst/types';
2
+ import VoiceStep, { IVoiceChannel, TODO, VoiceEvent } from './voice';
3
+ interface INPUT {
4
+ asr: TODO;
5
+ processHangUp: 'user' | 'bot' | 'both' | 'none';
6
+ recordAfterTransfer: boolean;
7
+ recordCall: boolean;
8
+ choices: TODO[];
9
+ }
10
+ interface OUTPUT {
11
+ type: string;
12
+ digit?: string;
13
+ value?: string;
14
+ interpretation?: TODO[];
15
+ callRecording?: TODO;
16
+ tags?: string[];
17
+ out?: string;
18
+ }
19
+ interface EVENT extends VoiceEvent {
20
+ callRecording?: TODO;
21
+ exitId?: string;
22
+ digit?: string;
23
+ digits?: string;
24
+ phrases?: TODO[];
25
+ tags?: string[];
26
+ out?: string;
27
+ }
28
+ export default class GlobalCommand extends VoiceStep<INPUT, OUTPUT, EVENT> {
29
+ get isGlobal(): boolean;
30
+ get autoCancel(): boolean | undefined;
4
31
  runStep(): Promise<void>;
5
32
  globThread(): Promise<void>;
6
- hangup(channel: any, event: any): Promise<unknown>;
7
- exitThread(event: any, type: any, stepExit: any): Promise<void>;
8
- exitToThread(): Promise<void>;
9
- buildGrammar(channel: any, choices: any): Promise<{
10
- id: string;
11
- choices: any;
12
- asr: any;
13
- }>;
33
+ hangup(channel: IVoiceChannel): Promise<unknown>;
34
+ exitThread(event: ITypedEvent<EVENT>, type: string, stepExit: string): Promise<void>;
35
+ exitToThread(): void;
36
+ buildGrammar(channel: IVoiceChannel, choices: TODO[]): Promise<any>;
14
37
  exitFlow(): unknown;
15
38
  }
16
- import VoiceStep from "./voice";
39
+ export {};
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
5
+ const nanoid_1 = require("nanoid");
4
6
  const voice_1 = tslib_1.__importDefault(require("./voice"));
5
- const { nanoid } = require('nanoid');
6
- const _ = require('lodash');
7
7
  class GlobalCommand extends voice_1.default {
8
8
  get isGlobal() {
9
9
  return true;
@@ -60,9 +60,9 @@ class GlobalCommand extends voice_1.default {
60
60
  async globThread() {
61
61
  const channel = await this.fetchData();
62
62
  const choices = this.buildChoices({ choices: this.data.choices });
63
- const exitExists = (exitId) => {
64
- return _.some(choices, (choice) => choice.exitId === exitId);
65
- };
63
+ function exitExists(exitId) {
64
+ return lodash_1.default.some(choices, (choice) => choice.exitId === exitId);
65
+ }
66
66
  if (channel.autoHangup) {
67
67
  this.triggers.local('thread/end/main', async () => {
68
68
  delete this.thread.waits['thread/end/main'];
@@ -71,8 +71,8 @@ class GlobalCommand extends voice_1.default {
71
71
  channel.autoHangup = false;
72
72
  await this.updateData();
73
73
  this.local.background = undefined;
74
- this.sendCommands(channel, [{ name: 'hangup' }]);
75
- this.process.main.enqueueAndRun({ name: 'ending' });
74
+ await this.sendCommands(channel, [{ name: 'hangup' }]);
75
+ void this.process.main.enqueueAndRun({ name: 'ending' });
76
76
  this.exitFlow();
77
77
  }
78
78
  });
@@ -81,46 +81,46 @@ class GlobalCommand extends voice_1.default {
81
81
  event.processed = undefined;
82
82
  switch (event.params.type) {
83
83
  case 'hangup': {
84
- await this.hangup(channel, event);
84
+ await this.hangup(channel);
85
85
  return this.end();
86
86
  }
87
87
  case 'avm-detected':
88
88
  // this.event = {};
89
- return this.exitThread(event, 'AMD', 'AMD');
89
+ return await this.exitThread(event, 'AMD', 'AMD');
90
90
  case 'digit':
91
91
  case 'digits': {
92
92
  const params = event.params;
93
- const exitId = params.exitId;
94
- if (exitExists(params.exitId)) {
93
+ const exitId = params.exitId ?? '';
94
+ if (exitExists(exitId)) {
95
95
  await this.transcript(channel, {
96
96
  previousTranscriptId: channel.lastTranscriptId,
97
97
  keyPress: params.digit,
98
- message: _.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
98
+ message: lodash_1.default.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
99
99
  action: 'Call DTMF',
100
100
  reportingSettingsKey: 'transcript',
101
101
  actionFromBot: false
102
102
  });
103
- return this.exitThread(event, 'digit', params.exitId);
103
+ return await this.exitThread(event, 'digit', exitId);
104
104
  }
105
105
  return {};
106
106
  }
107
107
  case 'recognition': {
108
108
  const params = event.params;
109
- const exitId = params.exitId;
110
- if (exitExists(params.exitId)) {
111
- const voiceProcessResult = _.chain(params.phrases)
109
+ const exitId = params.exitId ?? '';
110
+ if (exitExists(exitId)) {
111
+ const voiceProcessResult = lodash_1.default.chain(params.phrases)
112
112
  .map((p) => p.lexical)
113
113
  .join(' | ')
114
114
  .value();
115
115
  await this.transcript(channel, {
116
116
  previousTranscriptId: channel.lastTranscriptId,
117
- message: _.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
117
+ message: lodash_1.default.replace(this.getExitStepLabel(exitId), /^(\d+\. )?(~ )?/, ''),
118
118
  action: 'Call Recognition',
119
119
  voiceProcessResult,
120
120
  reportingSettingsKey: 'transcript',
121
121
  actionFromBot: false
122
122
  });
123
- return this.exitThread(event, 'voice', params.exitId);
123
+ return await this.exitThread(event, 'voice', exitId);
124
124
  }
125
125
  return {};
126
126
  }
@@ -131,7 +131,7 @@ class GlobalCommand extends voice_1.default {
131
131
  }
132
132
  });
133
133
  }
134
- async hangup(channel, event) {
134
+ async hangup(channel) {
135
135
  await this.handleHangup(channel);
136
136
  // if (channel.recordCall || _.includes(['bot', 'both'], processHangUp)) {
137
137
  // // turn off protection of session deletion by "End" step
@@ -140,20 +140,20 @@ class GlobalCommand extends voice_1.default {
140
140
  const isHangedUpByBot = channel.sessionEndedBy === 'Bot';
141
141
  const hangUpType = isHangedUpByBot ? 'bot hang up' : 'user hang up';
142
142
  // process call recording in hangup event
143
- if (channel.recordCall && event.params.callRecording) {
144
- return this.exitThread(event, hangUpType, 'hang up');
143
+ if (channel.recordCall && this.event.params.callRecording != null) {
144
+ return await this.exitThread(this.event, hangUpType, 'hang up');
145
145
  }
146
146
  switch (this.data.processHangUp) {
147
147
  case 'user':
148
148
  return isHangedUpByBot
149
149
  ? this.exitFlow()
150
- : this.exitThread({}, hangUpType, 'hang up');
150
+ : await this.exitThread(this.event, hangUpType, 'hang up');
151
151
  case 'bot':
152
152
  return isHangedUpByBot
153
- ? this.exitThread({}, hangUpType, 'hang up')
153
+ ? await this.exitThread(this.event, hangUpType, 'hang up')
154
154
  : this.exitFlow();
155
155
  case 'both':
156
- return this.exitThread({}, hangUpType, 'hang up');
156
+ return await this.exitThread(this.event, hangUpType, 'hang up');
157
157
  case 'none':
158
158
  default:
159
159
  return this.exitFlow();
@@ -161,28 +161,26 @@ class GlobalCommand extends voice_1.default {
161
161
  }
162
162
  async exitThread(event, type, stepExit) {
163
163
  // this.log.warn('EXIT HOOK', type, stepExit);
164
- const params = event.params || {};
165
- const data = {
166
- type
167
- };
168
- if (!_.isEmpty(params.tags)) {
164
+ const params = event.params;
165
+ const data = { type };
166
+ if (!lodash_1.default.isEmpty(params.tags)) {
169
167
  data.tags = params.tags;
170
168
  }
171
- if (!_.isEmpty(params.out)) {
169
+ if (!lodash_1.default.isEmpty(params.out)) {
172
170
  data.out = params.out;
173
171
  }
174
- const digits = params.digits || params.digit;
175
- if (!_.isEmpty(digits)) {
172
+ const digits = params.digits ?? params.digit;
173
+ if (!lodash_1.default.isEmpty(digits)) {
176
174
  data.digit = digits;
177
175
  data.value = digits;
178
176
  }
179
- if (!_.isEmpty(params.phrases)) {
177
+ if (!lodash_1.default.isEmpty(params.phrases)) {
180
178
  const phrases = params.phrases;
181
179
  data.value = phrases[0].text;
182
180
  data.interpretation = phrases;
183
181
  }
184
182
  // add information about call recording to a merge field
185
- if (!_.isEmpty(params.callRecording)) {
183
+ if (!lodash_1.default.isEmpty(params.callRecording)) {
186
184
  data.callRecording = params.callRecording;
187
185
  }
188
186
  // await this.sendCommands(channel, [{
@@ -192,7 +190,7 @@ class GlobalCommand extends voice_1.default {
192
190
  // channel.global = null;
193
191
  await this.updateData();
194
192
  await this.process.runThread({
195
- id: `${stepExit}_${nanoid(8)}`,
193
+ id: `${stepExit}_${(0, nanoid_1.nanoid)(8)}`,
196
194
  state: {
197
195
  name: 'exitToThread',
198
196
  result: {
@@ -207,7 +205,7 @@ class GlobalCommand extends voice_1.default {
207
205
  // this is required to mark event as handled
208
206
  // this.gotoState(this.state, { name: 'exiting' })
209
207
  }
210
- async exitToThread() {
208
+ exitToThread() {
211
209
  this.thread.jumpTo(this.state.exitStep, this.state.result);
212
210
  }
213
211
  async buildGrammar(channel, choices) {
package/dst/Hangup.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- export default class Hangup extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
1
+ import VoiceStep from './voice';
2
+ export default class Hangup extends VoiceStep {
3
3
  runStep(): Promise<void>;
4
4
  }
5
- import VoiceStep from "./voice";
package/dst/Hangup.js CHANGED
@@ -24,7 +24,7 @@ class Hangup extends voice_1.default {
24
24
  await this.sendCommands(channel, [{ name: 'hangup' }]);
25
25
  }
26
26
  catch (err) {
27
- this.log.warn(`Catch hangup error: ${err}`);
27
+ this.log.warn('hangup error', err);
28
28
  return this.exitStep('next');
29
29
  }
30
30
  return this.exitFlow();
@@ -1,5 +1,12 @@
1
- export default class IdleMusic extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<unknown>;
1
+ import VoiceStep from './voice';
2
+ interface INPUT {
3
+ idleDuration: number;
4
+ idleMusicDelay: number;
5
+ idleMusicEnabled: boolean;
6
+ customIdleMusic: boolean;
7
+ idleMusicUrl: string;
4
8
  }
5
- import VoiceStep from "./voice";
9
+ export default class IdleMusic extends VoiceStep<INPUT> {
10
+ runStep(): Promise<void>;
11
+ }
12
+ export {};
@@ -1,29 +1,29 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
5
+ const joi_1 = tslib_1.__importDefault(require("joi"));
6
+ const timestring_1 = tslib_1.__importDefault(require("timestring"));
4
7
  const voice_1 = tslib_1.__importDefault(require("./voice"));
5
- const joi = require('joi');
6
- const timestring = require('timestring');
7
- const _ = require('lodash');
8
- const schema = joi.object().keys({
9
- idleMusicEnabled: joi.boolean().required(),
10
- idleDuration: joi.number().min(10000).max(1800000).required(),
11
- idleMusicDelay: joi.when('idleMusicEnabled', {
8
+ const schema = joi_1.default.object().keys({
9
+ idleMusicEnabled: joi_1.default.boolean().required(),
10
+ idleDuration: joi_1.default.number().min(10000).max(1800000).required(),
11
+ idleMusicDelay: joi_1.default.when('idleMusicEnabled', {
12
12
  is: true,
13
- then: joi.number().min(1).max(30000).required()
13
+ then: joi_1.default.number().min(1).max(30000).required()
14
14
  }),
15
- customIdleMusic: joi.boolean(),
16
- idleMusicUrl: joi.when('customIdleMusic', {
15
+ customIdleMusic: joi_1.default.boolean(),
16
+ idleMusicUrl: joi_1.default.when('customIdleMusic', {
17
17
  is: true,
18
- then: joi.string().uri().required()
18
+ then: joi_1.default.string().uri().required()
19
19
  })
20
20
  });
21
21
  class IdleMusic extends voice_1.default {
22
22
  async runStep() {
23
23
  const channel = await this.fetchData();
24
24
  const { idleDuration, idleMusicDelay, idleMusicEnabled, customIdleMusic, idleMusicUrl } = this.data;
25
- const idleDurationMs = timestring(_.get(idleDuration, 'input', '30s'), _.get(idleDuration, 'outputMode', 'ms'));
26
- const idleMusicDelayMs = timestring(_.get(idleMusicDelay, 'input', '3s'), _.get(idleMusicDelay, 'outputMode', 'ms'));
25
+ const idleDurationMs = (0, timestring_1.default)(lodash_1.default.get(idleDuration, 'input', '30s'), lodash_1.default.get(idleDuration, 'outputMode', 'ms'));
26
+ const idleMusicDelayMs = (0, timestring_1.default)(lodash_1.default.get(idleMusicDelay, 'input', '3s'), lodash_1.default.get(idleMusicDelay, 'outputMode', 'ms'));
27
27
  const { error: validationError } = await schema.validateAsync({
28
28
  idleMusicEnabled,
29
29
  customIdleMusic,
@@ -31,7 +31,7 @@ class IdleMusic extends voice_1.default {
31
31
  idleMusicDelay: idleMusicDelayMs,
32
32
  idleDuration: idleDurationMs
33
33
  });
34
- if (validationError)
34
+ if (validationError != null)
35
35
  throw new Error(validationError.message);
36
36
  const command = {
37
37
  name: 'idle',
@@ -39,11 +39,11 @@ class IdleMusic extends voice_1.default {
39
39
  disabled: !idleMusicEnabled,
40
40
  timeout: idleMusicDelayMs,
41
41
  maxDuration: idleDurationMs,
42
- musicUrl: idleMusicUrl || null
42
+ musicUrl: idleMusicUrl !== '' ? idleMusicUrl : undefined
43
43
  }
44
44
  };
45
45
  await this.sendCommands(channel, [command]);
46
- return this.exitStep('next');
46
+ this.exitStep('next');
47
47
  }
48
48
  }
49
49
  exports.default = IdleMusic;
@@ -1,11 +1,11 @@
1
- export default class InitiateCall extends VoiceStep<any, any> {
1
+ export default class InitiateCall extends VoiceStep<any, any, import("./voice").VoiceEvent> {
2
2
  constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
3
  get conversation(): string;
4
4
  get autoCancel(): undefined;
5
5
  runStep(): Promise<void>;
6
6
  waitForCall(): Promise<void>;
7
7
  error: {
8
- name: any;
8
+ name: string;
9
9
  message: string;
10
10
  stack: {};
11
11
  } | undefined;
@@ -1,5 +1,9 @@
1
- export default class JoinConference extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<import("@onereach/flow-sdk/dst/types").ITriggers>;
1
+ import VoiceStep from './voice';
2
+ interface INPUT {
3
+ conferenceName: string;
4
+ stayInConference: boolean;
4
5
  }
5
- import VoiceStep from "./voice";
6
+ export default class JoinConference extends VoiceStep<INPUT> {
7
+ runStep(): Promise<void>;
8
+ }
9
+ export {};
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
4
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
5
- const _ = require('lodash');
6
6
  class JoinConference extends voice_1.default {
7
7
  async runStep() {
8
8
  const channel = await this.fetchData();
9
9
  const { conferenceName, stayInConference } = this.data;
10
- return this.triggers
11
- .once(`in/voice/${channel.id}/event`, async (event) => {
10
+ this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
12
11
  switch (event.params.type) {
13
12
  case 'hangup':
14
13
  await this.handleHangup(channel);
@@ -24,7 +23,7 @@ class JoinConference extends voice_1.default {
24
23
  return this.exitFlow();
25
24
  }
26
25
  else {
27
- return this.exitStep('next', _.omit(event.params, ['type']));
26
+ return this.exitStep('next', lodash_1.default.omit(event.params, ['type']));
28
27
  }
29
28
  case 'conference-end':
30
29
  await this.transcript(channel, {
@@ -39,8 +38,8 @@ class JoinConference extends voice_1.default {
39
38
  default:
40
39
  return this.exitFlow();
41
40
  }
42
- })
43
- .otherwise(async () => {
41
+ });
42
+ this.triggers.otherwise(async () => {
44
43
  const command = {
45
44
  name: 'conference.start',
46
45
  params: {
@@ -1,5 +1,35 @@
1
- export default class KeypadInput extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<import("@onereach/flow-sdk/dst/types").ITriggers>;
1
+ import VoiceStep, { TODO, VoiceEvent } from './voice';
2
+ interface INPUT {
3
+ textType: string;
4
+ asr: TODO;
5
+ tts: TODO;
6
+ audio: TODO[];
7
+ prompts: TODO[];
8
+ sensitiveData: {
9
+ muteStep: boolean;
10
+ muteUser: boolean;
11
+ muteBot: boolean;
12
+ };
13
+ noReplyDelay: number;
14
+ interTimeout: number;
15
+ endUserInputValidationOther: TODO;
16
+ keypadBargeIn: boolean;
17
+ endInput: TODO;
18
+ terminationKey: string;
19
+ expectedNumberOfDigits: number;
20
+ regExToValidate: string;
21
+ mfVersion: string;
4
22
  }
5
- import VoiceStep from "./voice";
23
+ interface EVENT extends VoiceEvent {
24
+ callRecording?: TODO;
25
+ exitId?: string;
26
+ digit?: string;
27
+ digits?: string;
28
+ phrases?: TODO[];
29
+ tags?: string[];
30
+ out?: string;
31
+ }
32
+ export default class KeypadInput extends VoiceStep<INPUT, {}, EVENT> {
33
+ runStep(): Promise<void>;
34
+ }
35
+ export {};
@@ -12,8 +12,8 @@ const validateInput = ({ input = '', type, regex, expectedLength }) => {
12
12
  switch (type) {
13
13
  case 'regEx': {
14
14
  const regExInput = /^\/(.+)\/(\w*)$/.exec(regex);
15
- if (!regExInput)
16
- throw new Error('invalid regular expression: ' + regex);
15
+ if (regExInput == null)
16
+ throw new Error(`invalid regular expression: ${regex}`);
17
17
  const regexp = new RegExp(regExInput[1], regExInput[2]);
18
18
  return regexp.test(input);
19
19
  }
@@ -65,8 +65,7 @@ class KeypadInput extends voice_1.default {
65
65
  }
66
66
  const repromptsList = this.buildReprompts({ prompts: this.data.prompts, allowKeypadBargeIn: keypadBargeIn });
67
67
  const speechSections = this.buildSections({ sections: this.data.audio, textType, ttsSettings, allowKeypadBargeIn: keypadBargeIn });
68
- return this.triggers
69
- .once(`in/voice/${channel.id}/event`, async (event) => {
68
+ this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
70
69
  const reportingSettingsKey = this.rptsStarted ? 'transcriptRepromptResponse' : 'transcriptResponse';
71
70
  if (channel.recordCall && sensitiveData?.muteStep) {
72
71
  await this.sendCommands(channel, [{
@@ -162,8 +161,8 @@ class KeypadInput extends voice_1.default {
162
161
  default:
163
162
  return this.exitFlow();
164
163
  }
165
- })
166
- .otherwise(async () => {
164
+ });
165
+ this.triggers.otherwise(async () => {
167
166
  await this.transcript(channel, {
168
167
  sections: speechSections,
169
168
  reprompt: {
@@ -177,13 +176,15 @@ class KeypadInput extends voice_1.default {
177
176
  command.params.firstDigitTimeout = this.rptsTimeout({ noReplyDelay, repromptsList });
178
177
  command.params.sections = speechSections;
179
178
  await this.sendCommands(channel, [
180
- ...channel.recordCall && sensitiveData?.muteStep ? [{
181
- name: 'stop-record-session',
182
- params: {
183
- muteUser: sensitiveData.muteUser,
184
- muteBot: sensitiveData.muteBot
185
- }
186
- }] : [],
179
+ ...channel.recordCall && sensitiveData?.muteStep
180
+ ? [{
181
+ name: 'stop-record-session',
182
+ params: {
183
+ muteUser: sensitiveData.muteUser,
184
+ muteBot: sensitiveData.muteBot
185
+ }
186
+ }]
187
+ : [],
187
188
  command
188
189
  ]);
189
190
  return this.exitFlow();
@@ -1,5 +1,9 @@
1
- export default class KickFromConference extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<import("@onereach/flow-sdk/dst/types").ITriggers>;
1
+ import VoiceStep from './voice';
2
+ interface INPUT {
3
+ room: string;
4
+ user: string;
4
5
  }
5
- import VoiceStep from "./voice";
6
+ export default class KickFromConference extends VoiceStep<INPUT> {
7
+ runStep(): Promise<void>;
8
+ }
9
+ export {};
@@ -1,14 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
4
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
5
- const _ = require('lodash');
6
6
  class KickFromConference extends voice_1.default {
7
7
  async runStep() {
8
8
  const channel = await this.fetchData();
9
9
  const { room, user } = this.data;
10
- return this.triggers
11
- .once(`in/voice/${channel.id}/event`, async (event) => {
10
+ this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
12
11
  switch (event.params.type) {
13
12
  case 'hangup':
14
13
  await this.handleHangup(channel);
@@ -20,14 +19,14 @@ class KickFromConference extends voice_1.default {
20
19
  action: 'Conference Leave',
21
20
  actionFromBot: true
22
21
  });
23
- return this.exitStep('next', _.omit(event.params, ['type']));
22
+ return this.exitStep('next', lodash_1.default.omit(event.params, ['type']));
24
23
  case 'error':
25
24
  return this.throwError(event.params.error);
26
25
  default:
27
26
  return this.exitFlow();
28
27
  }
29
- })
30
- .otherwise(async () => {
28
+ });
29
+ this.triggers.otherwise(async () => {
31
30
  const command = {
32
31
  name: 'conference.kick',
33
32
  params: {
package/dst/Pause.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export default class VoicePause extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<unknown>;
1
+ import VoiceStep from './voice';
2
+ export default class VoicePause extends VoiceStep {
3
+ get useQueue(): boolean;
4
+ runStep(): Promise<void>;
4
5
  }
5
- import VoiceStep from "./voice";
package/dst/Pause.js CHANGED
@@ -10,7 +10,7 @@ class VoicePause extends voice_1.default {
10
10
  const channel = await this.fetchData();
11
11
  await this.pause();
12
12
  await this.sendCommands(channel, [{ name: 'cancel' }]);
13
- return this.exitStep('next');
13
+ this.exitStep('next');
14
14
  }
15
15
  }
16
16
  exports.default = VoicePause;
package/dst/Pickup.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- export default class Pickup extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<unknown>;
1
+ import VoiceStep, { TODO } from './voice';
2
+ export default class Pickup extends VoiceStep<{
3
+ asr: TODO;
4
+ }> {
5
+ runStep(): Promise<void>;
4
6
  }
5
- import VoiceStep from "./voice";
package/dst/Pickup.js CHANGED
@@ -7,7 +7,7 @@ class Pickup extends voice_1.default {
7
7
  const channel = await this.fetchData();
8
8
  channel.asr = this.data.asr.getSettings(channel.asr);
9
9
  await this.updateData();
10
- return this.exitStep('next');
10
+ this.exitStep('next');
11
11
  }
12
12
  }
13
13
  exports.default = Pickup;
package/dst/Resume.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export default class VoiceResume extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<unknown>;
1
+ import VoiceStep from './voice';
2
+ export default class VoiceResume extends VoiceStep {
3
+ get useQueue(): boolean;
4
+ runStep(): Promise<void>;
4
5
  }
5
- import VoiceStep from "./voice";
package/dst/Resume.js CHANGED
@@ -9,7 +9,7 @@ class VoiceResume extends voice_1.default {
9
9
  async runStep() {
10
10
  await this.fetchData();
11
11
  await this.resume();
12
- return this.exitStep('next');
12
+ this.exitStep('next');
13
13
  }
14
14
  }
15
15
  exports.default = VoiceResume;
@@ -1,5 +1,18 @@
1
- export default class SayMessage extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
1
+ import VoiceStep, { TODO } from './voice';
2
+ interface INPUT {
3
+ textType: string;
4
+ tts: TODO;
5
+ audio: TODO[];
6
+ choices: TODO[];
7
+ prompts: TODO[];
8
+ sensitiveData: {
9
+ muteStep: boolean;
10
+ muteUser: boolean;
11
+ muteBot: boolean;
12
+ };
13
+ interSpeechTimeout: number;
14
+ }
15
+ export default class SayMessage extends VoiceStep<INPUT> {
3
16
  runStep(): Promise<void>;
4
17
  }
5
- import VoiceStep from "./voice";
18
+ export {};
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
4
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
5
- const _ = require('lodash');
6
6
  class SayMessage extends voice_1.default {
7
7
  async runStep() {
8
8
  const { audio, textType, tts, sensitiveData, interSpeechTimeout } = this.data;
@@ -39,7 +39,7 @@ class SayMessage extends voice_1.default {
39
39
  params: {
40
40
  dictation: true,
41
41
  interSpeechTimeout: interSpeechTimeout * 1000,
42
- sections: _.map(audio, (section) => ({
42
+ sections: lodash_1.default.map(audio, (section) => ({
43
43
  text: section.voiceTextMsg,
44
44
  url: section.audioUrl,
45
45
  bargeInVoice: false,
package/dst/Transfer.d.ts CHANGED
@@ -1,5 +1,19 @@
1
- export default class Transfer extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<import("@onereach/flow-sdk/dst/types").ITriggers>;
1
+ import VoiceStep, { EventType } from './voice';
2
+ interface INPUT {
3
+ destination: string;
4
+ phoneNumber: string;
5
+ sessionTimeout: number;
6
+ sipHeaders: Array<{
7
+ name: string;
8
+ value: string;
9
+ }>;
10
+ refer: boolean;
4
11
  }
5
- import VoiceStep from "./voice";
12
+ interface EVENT {
13
+ type: EventType;
14
+ error?: string | Error;
15
+ }
16
+ export default class Transfer extends VoiceStep<INPUT, {}, EVENT> {
17
+ runStep(): Promise<void>;
18
+ }
19
+ export {};
package/dst/Transfer.js CHANGED
@@ -5,8 +5,7 @@ const voice_1 = tslib_1.__importDefault(require("./voice"));
5
5
  class Transfer extends voice_1.default {
6
6
  async runStep() {
7
7
  const channel = await this.fetchData();
8
- return this.triggers
9
- .once(`in/voice/${channel.id}/event`, async (event) => {
8
+ this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
10
9
  switch (event.params.type) {
11
10
  case 'bridge': {
12
11
  await this.transcript(channel, {
@@ -47,8 +46,8 @@ class Transfer extends voice_1.default {
47
46
  return this.throwError(event.params.error);
48
47
  }
49
48
  return this.exitFlow();
50
- })
51
- .otherwise(async () => {
49
+ });
50
+ this.triggers.otherwise(async () => {
52
51
  const { phoneNumber, sessionTimeout, destination, sipHeaders = [], refer } = this.data;
53
52
  const destinationIsSip = (/^sip:/i).test(destination);
54
53
  const destinationIsUser = (/^user:/i).test(destination);
@@ -1,5 +1,21 @@
1
- export default class Recording extends VoiceStep<any, any> {
2
- constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
- runStep(): Promise<import("@onereach/flow-sdk/dst/types").ITriggers>;
1
+ import VoiceStep, { TODO, VoiceEvent } from './voice';
2
+ interface INPUT {
3
+ textType: string;
4
+ audio: TODO;
5
+ tts: TODO;
6
+ sensitiveData: {
7
+ muteStep: boolean;
8
+ muteUser: boolean;
9
+ muteBot: boolean;
10
+ };
11
+ terminationKey: string;
12
+ recordDurationSeconds: string;
4
13
  }
5
- import VoiceStep from "./voice";
14
+ interface EVENT extends VoiceEvent {
15
+ mediaPath: string;
16
+ zombie: boolean;
17
+ }
18
+ export default class Recording extends VoiceStep<INPUT, {}, EVENT> {
19
+ runStep(): Promise<void>;
20
+ }
21
+ export {};
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
+ const lodash_1 = tslib_1.__importDefault(require("lodash"));
4
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
5
- const _ = require('lodash');
6
6
  class Recording extends voice_1.default {
7
7
  async runStep() {
8
8
  const channel = await this.fetchData();
@@ -23,8 +23,7 @@ class Recording extends voice_1.default {
23
23
  sections
24
24
  }
25
25
  };
26
- return this.triggers
27
- .once(`in/voice/${channel.id}/event`, async (event) => {
26
+ this.triggers.once(`in/voice/${channel.id}/event`, async (event) => {
28
27
  if (channel.recordCall && sensitiveData?.muteStep) {
29
28
  await this.sendCommands(channel, [{
30
29
  name: 'resume-record-session',
@@ -42,7 +41,7 @@ class Recording extends voice_1.default {
42
41
  await this.handleHangup(channel);
43
42
  return this.exitFlow();
44
43
  case 'record':
45
- if (url) {
44
+ if (!lodash_1.default.isEmpty(url)) {
46
45
  await this.transcript(channel, {
47
46
  message: 'Voicemail',
48
47
  reportingSettingsKey: 'transcriptRecording',
@@ -53,23 +52,23 @@ class Recording extends voice_1.default {
53
52
  // TODO do we need zombie?
54
53
  this.event.params.zombie = this.state.zombie;
55
54
  // TODO figure out Global Command compatibility
56
- _.unset(this.state.hooks, 'skipVoiceEventTypes');
55
+ lodash_1.default.unset(this.state.hooks, 'skipVoiceEventTypes');
57
56
  return this.exitStep('success', url);
58
57
  }
59
58
  else {
60
59
  // TODO What happens with reporting here?
61
60
  this.log.warn('Event params', event.params);
62
- throw new Error(_.get(event, ['params', 'error', 'message']) || 'Cannot finalize recording');
61
+ throw new Error(event.params.error?.message ?? 'Cannot finalize recording');
63
62
  }
64
63
  case 'error':
65
64
  return this.throwError(event.params.error);
66
65
  default:
67
66
  return this.exitFlow();
68
67
  }
69
- })
70
- .otherwise(async () => {
68
+ });
69
+ this.triggers.otherwise(async () => {
71
70
  // TODO figure out Global Command compatibility
72
- _.set(this.state.hooks, 'skipVoiceEventTypes', ['hangup']);
71
+ lodash_1.default.set(this.state.hooks, 'skipVoiceEventTypes', ['hangup']);
73
72
  await this.transcript(channel, {
74
73
  sections,
75
74
  reportingSettingsKey: 'transcriptPrompt',
@@ -77,13 +76,15 @@ class Recording extends voice_1.default {
77
76
  actionFromBot: true
78
77
  });
79
78
  await this.sendCommands(channel, [
80
- ...channel.recordCall && sensitiveData?.muteStep ? [{
81
- name: 'stop-record-session',
82
- params: {
83
- muteUser: sensitiveData.muteUser,
84
- muteBot: sensitiveData.muteBot
85
- }
86
- }] : [],
79
+ ...channel.recordCall && sensitiveData?.muteStep
80
+ ? [{
81
+ name: 'stop-record-session',
82
+ params: {
83
+ muteUser: sensitiveData.muteUser,
84
+ muteBot: sensitiveData.muteBot
85
+ }
86
+ }]
87
+ : [],
87
88
  command
88
89
  ]);
89
90
  return this.exitFlow();
@@ -1,4 +1,4 @@
1
- export default class WaitForCall extends VoiceStep<any, any> {
1
+ export default class WaitForCall extends VoiceStep<any, any, import("./voice").VoiceEvent> {
2
2
  constructor(thread: import("@onereach/flow-sdk/dst/types").IThread, stepData: import("@onereach/flow-sdk/dst/types").IStepData<any>);
3
3
  get conversation(): string | undefined;
4
4
  get autoCancel(): boolean;
package/dst/voice.d.ts CHANGED
@@ -1,6 +1,7 @@
1
1
  import { ICallback, IVoiceReporterTranscriptEventArgs, IPromtpSection } from '@onereach/flow-sdk/dst/types';
2
2
  import ConvStep from '@onereach/step-conversation/dst/step';
3
3
  import BasicError from '@onereach/flow-sdk/dst/errors/base';
4
+ export declare type TODO = any;
4
5
  export interface IVoiceChannel {
5
6
  id: string;
6
7
  autoHangup: boolean;
@@ -10,38 +11,45 @@ export interface IVoiceChannel {
10
11
  lastTranscriptId: string;
11
12
  type: string;
12
13
  callback: ICallback;
13
- global?: any;
14
- recordCall?: boolean;
15
- asr?: any;
16
- tts?: any;
14
+ global?: TODO;
15
+ recordCall: boolean;
16
+ asr?: TODO;
17
+ tts?: TODO;
17
18
  sessionEndedBy?: string;
18
19
  }
20
+ export declare type EventType = 'hangup' | 'error' | 'cancel' | 'avm-detected' | 'recognition' | 'digit' | 'digits' | 'conference-start' | 'conference-end' | 'playback' | 'timeout' | 'record' | 'bridge' | 'bridge/ended';
19
21
  export declare class VoiceStepError extends BasicError {
20
22
  }
21
- export default class VoiceStep<TIn = unknown, TOut = unknown> extends ConvStep<IVoiceChannel, TIn, TOut> {
23
+ export interface VoiceEvent {
24
+ type: EventType;
25
+ error?: Error;
26
+ }
27
+ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams = VoiceEvent> extends ConvStep<IVoiceChannel, TIn & {
28
+ handleCancel?: boolean;
29
+ }, TOut, TParams> {
22
30
  get autoCancel(): boolean | undefined;
23
31
  onCancel(): Promise<void>;
24
- sendCommands({ id, type, callback }: IVoiceChannel, commands: any[]): Promise<any>;
32
+ sendCommands({ id, type, callback }: IVoiceChannel, commands: TODO[]): Promise<unknown>;
25
33
  extractSectionMessages(sections: IPromtpSection[]): string;
26
34
  extractSectionFiles(sections: IPromtpSection[]): Array<{
27
35
  fileUrl: string;
28
36
  fileType: string;
29
37
  }>;
30
38
  transcript(channel: IVoiceChannel, data?: Partial<IVoiceReporterTranscriptEventArgs>): Promise<string>;
31
- throwError(error: {
39
+ throwError(error?: {
32
40
  name: string;
33
41
  message: string;
34
42
  }): never;
35
43
  handleHangup(channel: IVoiceChannel): Promise<void>;
36
- buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }: any): any;
37
- buildReprompts({ prompts, allowKeypadBargeIn }: any): any;
38
- buildChoices({ choices }: any): any;
39
- buildChoice(choice: any): any;
40
- exitChoiceData(type: string, params?: any): any;
41
- rptsSend(channel: IVoiceChannel, { command, reporting, repromptsList, noReplyDelay, speechSections, textType, ttsSettings }: any): Promise<void>;
42
- rptsTimeout({ noReplyDelay, repromptsList }: any): number;
44
+ buildSections({ sections, textType, ttsSettings, allowKeypadBargeIn }: TODO): TODO;
45
+ buildReprompts({ prompts, allowKeypadBargeIn }: TODO): TODO;
46
+ buildChoices({ choices }: TODO): TODO;
47
+ buildChoice(choice: TODO): TODO;
48
+ exitChoiceData(type: string, params?: TODO): TODO;
49
+ rptsSend(channel: IVoiceChannel, { command, reporting, repromptsList, noReplyDelay, speechSections, textType, ttsSettings }: TODO): Promise<void>;
50
+ rptsTimeout({ noReplyDelay, repromptsList }: TODO): number;
43
51
  rptsRestart(): void;
44
- rptsHasMore({ repromptsList }: any): boolean;
52
+ rptsHasMore({ repromptsList }: TODO): boolean;
45
53
  get rptsIndex(): number;
46
54
  get rptsStarted(): boolean;
47
55
  }
package/dst/voice.js CHANGED
@@ -17,7 +17,9 @@ class VoiceStep extends step_1.default {
17
17
  }
18
18
  async onCancel() {
19
19
  await super.onCancel();
20
- this.exitStep('cancel');
20
+ if (this.data.handleCancel === true) {
21
+ this.exitStep('cancel');
22
+ }
21
23
  }
22
24
  async sendCommands({ id, type, callback }, commands) {
23
25
  if (lodash_1.default.isEmpty(commands))
@@ -105,7 +107,7 @@ class VoiceStep extends step_1.default {
105
107
  await this.updateData();
106
108
  return eventId;
107
109
  }
108
- throwError(error) {
110
+ throwError(error = new Error('unknown')) {
109
111
  throw new VoiceStepError(error.message, null, { name: error.name });
110
112
  }
111
113
  async handleHangup(channel) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
@@ -13,19 +13,20 @@
13
13
  "npm": ">= 6.0.0"
14
14
  },
15
15
  "dependencies": {
16
- "@onereach/step-conversation": "^1.0.31",
16
+ "@onereach/step-conversation": "^1.0.32",
17
17
  "lodash": "^4.17.21",
18
18
  "uuid": "^8.3.2"
19
19
  },
20
20
  "devDependencies": {
21
- "@onereach/flow-sdk": "^3.0.5",
21
+ "@onereach/flow-sdk": "^3.0.12",
22
22
  "@swc/cli": "^0.1.57",
23
23
  "@swc/core": "^1.2.196",
24
24
  "@swc/jest": "^0.2.21",
25
25
  "@types/jest": "^28.1.0",
26
26
  "@types/lodash": "^4.14.182",
27
+ "@types/timestring": "^6.0.2",
27
28
  "@types/uuid": "^8.3.4",
28
- "aws-sdk": "^2.1147.0",
29
+ "aws-sdk": "^2.1148.0",
29
30
  "babel-runtime": "^6.26.0",
30
31
  "docdash": "^1.2.0",
31
32
  "husky": "^8.0.1",