@onereach/step-voice 7.0.46-deskphoneintegration.2 → 7.0.46-deskphoneintegration.4
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/Conference Dial.d.ts +29 -0
- package/dst/Conference Dial.js +26 -1
- package/package.json +1 -1
package/dst/Conference Dial.d.ts
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
import VoiceStep from './voice';
|
|
2
|
+
declare const enum GATEWAY_SETTINGS_MODE {
|
|
3
|
+
DEFAULT = "default",
|
|
4
|
+
CUSTOM = "custom",
|
|
5
|
+
INHERIT = "inherit",
|
|
6
|
+
PROFILE = "profile"
|
|
7
|
+
}
|
|
8
|
+
declare const enum SIP_PROFILE {
|
|
9
|
+
DEFAULT = "default",
|
|
10
|
+
INTERNAL = "internal",
|
|
11
|
+
EXTERNAL = "external"
|
|
12
|
+
}
|
|
2
13
|
type ConferenceDialInput = {
|
|
3
14
|
stayInConference: boolean;
|
|
4
15
|
sourceConf: string;
|
|
5
16
|
botNumber: string;
|
|
6
17
|
headers?: Record<string, string>;
|
|
7
18
|
hearOnly: boolean;
|
|
19
|
+
/**
|
|
20
|
+
* The SIP caller identity presented on the dialed leg (becomes `variable_sip_from_user`). For a
|
|
21
|
+
* desk-phone breakout (`isDeskPhone === true`) this MUST be an enabled `subscriber.username`
|
|
22
|
+
* because voicer resolves the account from it; an empty or non-subscriber value is refused by the
|
|
23
|
+
* switch. When empty/absent the param is omitted from the dial entirely (never sent as an empty
|
|
24
|
+
* string or the literal `undefined`).
|
|
25
|
+
*/
|
|
26
|
+
fromNumber?: string;
|
|
8
27
|
/**
|
|
9
28
|
* Set `true` only on the step instance that dials the desk phone. When true (and `botNumber`
|
|
10
29
|
* trims to a non-empty SIP username), the step records a desk-phone correlation entry on
|
|
@@ -12,6 +31,16 @@ type ConferenceDialInput = {
|
|
|
12
31
|
* use leaves it absent, so their behavior is unchanged.
|
|
13
32
|
*/
|
|
14
33
|
isDeskPhone?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* SIP gateway/profile selector (mirrors Initiate Call). Optional — when no profile/custom host
|
|
36
|
+
* is selected no gateway is attached and the conference join is unchanged. `isDeskPhone` alone
|
|
37
|
+
* does NOT synthesize a gateway.
|
|
38
|
+
*/
|
|
39
|
+
gatewaySettingsMode?: GATEWAY_SETTINGS_MODE;
|
|
40
|
+
sipProfile?: SIP_PROFILE;
|
|
41
|
+
sipHost?: string;
|
|
42
|
+
sipUser?: string;
|
|
43
|
+
sipPassword?: string;
|
|
15
44
|
};
|
|
16
45
|
export default class ConferenceDial extends VoiceStep<ConferenceDialInput> {
|
|
17
46
|
runStep(): Promise<void>;
|
package/dst/Conference Dial.js
CHANGED
|
@@ -8,6 +8,10 @@ const deskphoneCorrelation_1 = require("./deskphoneCorrelation");
|
|
|
8
8
|
function isDeskPhoneSipUser(data) {
|
|
9
9
|
return data.isDeskPhone === true && lodash_1.default.trim(String(data.botNumber ?? '')) !== '';
|
|
10
10
|
}
|
|
11
|
+
/** True when a desk-phone dial is requested but no caller (From) identity was provided. */
|
|
12
|
+
function isDeskPhoneWithoutFromNumber(data) {
|
|
13
|
+
return data.isDeskPhone === true && lodash_1.default.trim(String(data.fromNumber ?? '')) === '';
|
|
14
|
+
}
|
|
11
15
|
class ConferenceDial extends voice_1.default {
|
|
12
16
|
async runStep() {
|
|
13
17
|
const call = await this.fetchData();
|
|
@@ -55,6 +59,25 @@ class ConferenceDial extends voice_1.default {
|
|
|
55
59
|
});
|
|
56
60
|
this.triggers.otherwise(async () => {
|
|
57
61
|
const { sourceConf, botNumber, headers, hearOnly } = this.data;
|
|
62
|
+
if (isDeskPhoneWithoutFromNumber(this.data)) {
|
|
63
|
+
this.throwError(new Error("Conference Dial: 'Caller (From)' is required when 'Desk phone dial' is enabled. " +
|
|
64
|
+
'It must be an enabled desk-phone subscriber username (e.g. desk-2001) so the platform ' +
|
|
65
|
+
'can resolve the account; an empty or non-subscriber value is refused by the switch.'));
|
|
66
|
+
}
|
|
67
|
+
const fromNumber = lodash_1.default.trim(String(this.data.fromNumber ?? ''));
|
|
68
|
+
const { gatewaySettingsMode, sipProfile, sipHost, sipUser, sipPassword } = this.data;
|
|
69
|
+
// Hardened vs Initiate Call (null-safe): sipProfile is optional here. Does NOT branch on isDeskPhone.
|
|
70
|
+
const profile = sipProfile != null && sipProfile !== "default" /* SIP_PROFILE.DEFAULT */ ? sipProfile : undefined;
|
|
71
|
+
let gateway;
|
|
72
|
+
switch (gatewaySettingsMode) {
|
|
73
|
+
case "custom" /* GATEWAY_SETTINGS_MODE.CUSTOM */:
|
|
74
|
+
gateway = { host: sipHost, user: sipUser, username: sipUser, password: sipPassword, profile };
|
|
75
|
+
break;
|
|
76
|
+
case "profile" /* GATEWAY_SETTINGS_MODE.PROFILE */:
|
|
77
|
+
gateway = profile != null ? { profile } : undefined;
|
|
78
|
+
break;
|
|
79
|
+
// DEFAULT / INHERIT / undefined -> gateway stays undefined (today's behavior)
|
|
80
|
+
}
|
|
58
81
|
const command = {
|
|
59
82
|
name: 'conference.joinBot',
|
|
60
83
|
params: {
|
|
@@ -62,7 +85,9 @@ class ConferenceDial extends voice_1.default {
|
|
|
62
85
|
botNumber,
|
|
63
86
|
headers,
|
|
64
87
|
hearOnly,
|
|
65
|
-
stayInConference: this.data.stayInConference
|
|
88
|
+
stayInConference: this.data.stayInConference,
|
|
89
|
+
...(fromNumber !== '' ? { fromNumber } : {}),
|
|
90
|
+
...(gateway != null ? { gateway } : {})
|
|
66
91
|
}
|
|
67
92
|
};
|
|
68
93
|
await this.sendCommands(call, [command]);
|