@onereach/step-voice 4.0.15 → 4.0.18

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.
@@ -83,6 +83,7 @@ class GlobalCommand extends voice_1.default {
83
83
  switch (event.params.type) {
84
84
  case 'hangup': {
85
85
  await this.hangup(channel);
86
+ await this.sendEventToStep({ toGlobal: false, event: { ...this.event, processed: undefined, action: 'local' } });
86
87
  return this.end();
87
88
  }
88
89
  case 'avm-detected':
package/dst/Hangup.js CHANGED
@@ -20,6 +20,8 @@ class Hangup extends voice_1.default {
20
20
  }
21
21
  });
22
22
  this.triggers.otherwise(async () => {
23
+ if (channel.hangup)
24
+ return this.exitStep('next');
23
25
  try {
24
26
  await this.sendCommands(channel, [{ name: 'hangup' }]);
25
27
  }
@@ -5,7 +5,7 @@ const tslib_1 = require("tslib");
5
5
  const voice_1 = tslib_1.__importDefault(require("./voice"));
6
6
  const lodash_1 = tslib_1.__importDefault(require("lodash"));
7
7
  const timestring_1 = tslib_1.__importDefault(require("timestring"));
8
- const uuid_1 = tslib_1.__importDefault(require("uuid"));
8
+ const uuid = tslib_1.__importStar(require("uuid"));
9
9
  const defaultSessionTimeoutMin = 5;
10
10
  class InitiateCall extends voice_1.default {
11
11
  get conversation() {
@@ -17,7 +17,7 @@ class InitiateCall extends voice_1.default {
17
17
  return undefined;
18
18
  }
19
19
  async runStep() {
20
- const { channelId = uuid_1.default.v4() } = this.data;
20
+ const { channelId = uuid.v4() } = this.data;
21
21
  if (!this.session.key) {
22
22
  const sessionTimeoutMs = (0, timestring_1.default)(`${this.data.sessionTimeout ?? defaultSessionTimeoutMin} min`, 'ms');
23
23
  await this.session.start({
package/dst/step.d.ts CHANGED
@@ -24,6 +24,7 @@ export default class ConvStep<TData = unknown, TIn = unknown, TOut = unknown, TP
24
24
  onSkipEvent(): Promise<void>;
25
25
  cancel(): Promise<void>;
26
26
  onCancel(): Promise<void>;
27
+ waitCancelEnd(): Promise<void>;
27
28
  pause(): Promise<void>;
28
29
  resume(): Promise<void>;
29
30
  sendEventToStep({ toGlobal, toStep, action, event }: {
package/dst/step.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
- /* eslint-disable @typescript-eslint/strict-boolean-expressions, @typescript-eslint/explicit-function-return-type */
2
+ /* eslint-disable @typescript-eslint/strict-boolean-expressions */
3
3
  Object.defineProperty(exports, "__esModule", { value: true });
4
4
  const tslib_1 = require("tslib");
5
5
  const step_1 = tslib_1.__importDefault(require("@onereach/flow-sdk/dst/step"));
@@ -12,7 +12,7 @@ class ConvStep extends step_1.default {
12
12
  /** id of the thread where conversation data is stored */
13
13
  get dataThreadId() {
14
14
  const dataThreadId = this.state.thread ?? this.data.conversationThread;
15
- return dataThreadId != null && dataThreadId !== '' ? dataThreadId : this.thread.id;
15
+ return dataThreadId || this.thread.id;
16
16
  }
17
17
  get autoCancel() {
18
18
  return undefined;
@@ -141,7 +141,7 @@ class ConvStep extends step_1.default {
141
141
  const conversationThread = this.state.thread ?? this.thread.id;
142
142
  if (conversationThread === this.thread.id) {
143
143
  this.log.debug('conv.cancel wait for end', this.conversation);
144
- this.gotoState({ name: 'waitForEnd', direct: true });
144
+ this.gotoState({ ...this.state, name: 'waitCancelEnd', direct: true });
145
145
  }
146
146
  else {
147
147
  this.log.debug('conv.cancel end', this.conversation);
@@ -149,6 +149,9 @@ class ConvStep extends step_1.default {
149
149
  }
150
150
  }
151
151
  }
152
+ async waitCancelEnd() {
153
+ this.exitFlow();
154
+ }
152
155
  async pause() {
153
156
  const conv = await this._getConversation();
154
157
  const activeStep = await this.activeStep(false);
@@ -241,7 +244,7 @@ class ConvStep extends step_1.default {
241
244
  }
242
245
  };
243
246
  await this.updateData();
244
- this.state.thread = this.dataThreadId;
247
+ // this.state.thread = this.dataThreadId
245
248
  }
246
249
  async _fetchData() {
247
250
  if (this.convDataCache != null)
package/dst/voice.d.ts CHANGED
@@ -35,7 +35,6 @@ export default class VoiceStep<TIn = unknown, TOut = unknown, TParams = VoiceEve
35
35
  handleCancel?: boolean;
36
36
  }, TOut, TParams> {
37
37
  get autoCancel(): boolean | undefined;
38
- waitForEnd(): Promise<void>;
39
38
  sendCommands({ id, type, callback }: IVoiceChannel, commands: TODO[]): Promise<unknown>;
40
39
  extractSectionMessages(sections: IPromtpSection[]): string;
41
40
  extractSectionFiles(sections: IPromtpSection[]): Array<{
package/dst/voice.js CHANGED
@@ -16,9 +16,6 @@ class VoiceStep extends step_1.default {
16
16
  get autoCancel() {
17
17
  return true;
18
18
  }
19
- async waitForEnd() {
20
- this.exitFlow();
21
- }
22
19
  async sendCommands({ id, type, callback }, commands) {
23
20
  if (lodash_1.default.isEmpty(commands))
24
21
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onereach/step-voice",
3
- "version": "4.0.15",
3
+ "version": "4.0.18",
4
4
  "author": "Roman Zolotarov <roman.zolotarov@onereach.com>",
5
5
  "contributors": [
6
6
  "Roman Zolotarov",
@@ -18,7 +18,7 @@
18
18
  "uuid": "^8.3.2"
19
19
  },
20
20
  "devDependencies": {
21
- "@onereach/flow-sdk": "^3.1.1",
21
+ "@onereach/flow-sdk": "^3.1.3",
22
22
  "@swc/cli": "^0.1.57",
23
23
  "@swc/core": "^1.2.197",
24
24
  "@swc/jest": "^0.2.21",