@fonoster/voice 0.32.0 → 0.34.1
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/dist/Session.d.ts +10 -3
- package/dist/Session.js +10 -5
- package/dist/types.d.ts +2 -0
- package/package.json +5 -5
package/dist/Session.d.ts
CHANGED
|
@@ -16,7 +16,9 @@
|
|
|
16
16
|
* See the License for the specific language governing permissions and
|
|
17
17
|
* limitations under the License.
|
|
18
18
|
*/
|
|
19
|
-
import { SessionStart } from "@fonoster/common";
|
|
19
|
+
import { Hangup, SessionStart } from "@fonoster/common";
|
|
20
|
+
/** Why a call failed, for `hangup({ failure })`. */
|
|
21
|
+
export type HangupFailure = NonNullable<Hangup["failure"]>;
|
|
20
22
|
import { GatherOptions, GatherResult, PlayOptions, PlayResult, SayOptions, SayResult, SessionEventMap, SessionEventName, TransferOptions } from "./types";
|
|
21
23
|
/** What the session needs from its socket. */
|
|
22
24
|
export type SessionTransport = {
|
|
@@ -116,8 +118,13 @@ export declare class Session {
|
|
|
116
118
|
resume(): Promise<void>;
|
|
117
119
|
/** Hands the call to another app with a payload; resolves when this session ends. */
|
|
118
120
|
handoff(app: string, payload?: Record<string, unknown>): Promise<void>;
|
|
119
|
-
/**
|
|
120
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Hangs up; resolves when the session ends. `failure` ends the call as failed in the call record
|
|
123
|
+
* (@internal: reserved for Fonoster's own apps (Autopilot); AppBridge ignores it from others).
|
|
124
|
+
*/
|
|
125
|
+
hangup(options?: {
|
|
126
|
+
failure?: HangupFailure;
|
|
127
|
+
}): Promise<void>;
|
|
121
128
|
/**
|
|
122
129
|
* Adds a note to the call record (record.note).
|
|
123
130
|
*
|
package/dist/Session.js
CHANGED
|
@@ -274,11 +274,14 @@ class Session {
|
|
|
274
274
|
const id = this.nextId("handoff");
|
|
275
275
|
return this.untilEnd(["handoff"], id, () => this.send({ type: "handoff", id, app, payload }));
|
|
276
276
|
}
|
|
277
|
-
/**
|
|
278
|
-
|
|
277
|
+
/**
|
|
278
|
+
* Hangs up; resolves when the session ends. `failure` ends the call as failed in the call record
|
|
279
|
+
* (@internal: reserved for Fonoster's own apps (Autopilot); AppBridge ignores it from others).
|
|
280
|
+
*/
|
|
281
|
+
hangup(options = {}) {
|
|
279
282
|
if (this.endedReason)
|
|
280
283
|
return Promise.resolve();
|
|
281
|
-
return this.untilEnd(["app_hangup", "caller_hangup", "closed"], undefined, () => this.send({ type: "hangup" }));
|
|
284
|
+
return this.untilEnd(["app_hangup", "caller_hangup", "closed"], undefined, () => this.send(Object.assign({ type: "hangup" }, (options.failure ? { failure: options.failure } : {}))));
|
|
282
285
|
}
|
|
283
286
|
/**
|
|
284
287
|
* Adds a note to the call record (record.note).
|
|
@@ -342,7 +345,8 @@ class Session {
|
|
|
342
345
|
o === null || o === void 0 ? void 0 : o.resolve({
|
|
343
346
|
interrupted: false,
|
|
344
347
|
heardText: o.text,
|
|
345
|
-
heardMs: o.startedAt ? Date.now() - o.startedAt : 0
|
|
348
|
+
heardMs: o.startedAt ? Date.now() - o.startedAt : 0,
|
|
349
|
+
startedAt: o.startedAt
|
|
346
350
|
});
|
|
347
351
|
return;
|
|
348
352
|
}
|
|
@@ -351,7 +355,8 @@ class Session {
|
|
|
351
355
|
o === null || o === void 0 ? void 0 : o.resolve({
|
|
352
356
|
interrupted: true,
|
|
353
357
|
heardText: String((_a = msg.heardText) !== null && _a !== void 0 ? _a : ""),
|
|
354
|
-
heardMs: Number((_b = msg.heardMs) !== null && _b !== void 0 ? _b : 0)
|
|
358
|
+
heardMs: Number((_b = msg.heardMs) !== null && _b !== void 0 ? _b : 0),
|
|
359
|
+
startedAt: o.startedAt
|
|
355
360
|
});
|
|
356
361
|
return;
|
|
357
362
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -27,6 +27,8 @@ export type SayResult = {
|
|
|
27
27
|
interrupted: boolean;
|
|
28
28
|
heardText: string;
|
|
29
29
|
heardMs: number;
|
|
30
|
+
/** When this output's first audio started (output.started), in epoch ms on this side. */
|
|
31
|
+
startedAt?: number;
|
|
30
32
|
};
|
|
31
33
|
export type PlayOptions = {
|
|
32
34
|
loop?: boolean;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fonoster/voice",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.1",
|
|
4
4
|
"description": "Session SDK for Fonoster voice applications",
|
|
5
5
|
"author": "Pedro Sanders <psanders@fonoster.com>",
|
|
6
6
|
"homepage": "https://github.com/fonoster/fonoster#readme",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"generate:readme": "fonoster-readme"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@fonoster/common": "^0.
|
|
21
|
-
"@fonoster/logger": "^0.
|
|
20
|
+
"@fonoster/common": "^0.34.1",
|
|
21
|
+
"@fonoster/logger": "^0.34.1",
|
|
22
22
|
"ws": "^8.18.0"
|
|
23
23
|
},
|
|
24
24
|
"files": [
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
"bugs": {
|
|
37
37
|
"url": "https://github.com/fonoster/fonoster/issues"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "f521d836e94a24a5b17a25fba3e03e680637016d",
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@fonoster/conformance": "^0.
|
|
41
|
+
"@fonoster/conformance": "^0.34.1"
|
|
42
42
|
}
|
|
43
43
|
}
|