@azure/communication-call-automation 1.5.0-beta.1 → 1.5.0-beta.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/README.md +3 -1
- package/dist/browser/callAutomationClient.d.ts +2 -3
- package/dist/browser/callAutomationClient.d.ts.map +1 -1
- package/dist/browser/callAutomationClient.js +79 -31
- package/dist/browser/callAutomationClient.js.map +1 -1
- package/dist/browser/callAutomationEventParser.d.ts.map +1 -1
- package/dist/browser/callAutomationEventParser.js +9 -10
- package/dist/browser/callAutomationEventParser.js.map +1 -1
- package/dist/browser/callConnection.d.ts +1 -1
- package/dist/browser/callConnection.d.ts.map +1 -1
- package/dist/browser/callConnection.js +82 -38
- package/dist/browser/callConnection.js.map +1 -1
- package/dist/browser/callMedia.d.ts +1 -1
- package/dist/browser/callMedia.d.ts.map +1 -1
- package/dist/browser/callMedia.js +33 -12
- package/dist/browser/callMedia.js.map +1 -1
- package/dist/browser/callRecording.js +11 -6
- package/dist/browser/callRecording.js.map +1 -1
- package/dist/browser/contentDownloader.js +11 -12
- package/dist/browser/contentDownloader.js.map +1 -1
- package/dist/browser/credential/callAutomationAccessKeyCredentialPolicy.js +1 -2
- package/dist/browser/credential/callAutomationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/browser/credential/callAutomationAuthPolicy.js +1 -1
- package/dist/browser/credential/callAutomationAuthPolicy.js.map +1 -1
- package/dist/browser/credential/cryptoUtils-browser.mjs.map +1 -1
- package/dist/browser/credential/cryptoUtils.js +1 -2
- package/dist/browser/generated/src/callAutomationApiClient.js +14 -5
- package/dist/browser/generated/src/callAutomationApiClient.js.map +1 -1
- package/dist/browser/generated/src/models/index.d.ts +305 -322
- package/dist/browser/generated/src/models/index.d.ts.map +1 -1
- package/dist/browser/generated/src/models/index.js +29 -35
- package/dist/browser/generated/src/models/index.js.map +1 -1
- package/dist/browser/generated/src/models/mappers.d.ts +41 -34
- package/dist/browser/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/browser/generated/src/models/mappers.js +481 -462
- package/dist/browser/generated/src/models/mappers.js.map +1 -1
- package/dist/browser/generated/src/models/parameters.js +1 -1
- package/dist/browser/generated/src/models/parameters.js.map +1 -1
- package/dist/browser/generated/src/operations/callConnection.js +23 -40
- package/dist/browser/generated/src/operations/callConnection.js.map +1 -1
- package/dist/browser/generated/src/operations/callMedia.js +1 -0
- package/dist/browser/generated/src/operations/callMedia.js.map +1 -1
- package/dist/browser/generated/src/operations/callRecording.js +1 -0
- package/dist/browser/generated/src/operations/callRecording.js.map +1 -1
- package/dist/browser/generated/src/pagingHelper.js +2 -4
- package/dist/browser/generated/src/pagingHelper.js.map +1 -1
- package/dist/browser/models/constants.d.ts.map +1 -1
- package/dist/browser/models/constants.js +1 -1
- package/dist/browser/models/constants.js.map +1 -1
- package/dist/browser/models/events.d.ts +295 -209
- package/dist/browser/models/events.d.ts.map +1 -1
- package/dist/browser/models/events.js.map +1 -1
- package/dist/browser/models/models.d.ts +44 -4
- package/dist/browser/models/models.d.ts.map +1 -1
- package/dist/browser/models/models.js +1 -1
- package/dist/browser/models/models.js.map +1 -1
- package/dist/browser/models/options.d.ts +17 -0
- package/dist/browser/models/options.d.ts.map +1 -1
- package/dist/browser/models/options.js.map +1 -1
- package/dist/browser/models/responses.d.ts +1 -1
- package/dist/browser/models/responses.d.ts.map +1 -1
- package/dist/browser/models/responses.js.map +1 -1
- package/dist/browser/models/streaming.d.ts +26 -27
- package/dist/browser/models/streaming.d.ts.map +1 -1
- package/dist/browser/models/streaming.js +28 -57
- package/dist/browser/models/streaming.js.map +1 -1
- package/dist/browser/streamingData.d.ts.map +1 -1
- package/dist/browser/streamingData.js +10 -1
- package/dist/browser/streamingData.js.map +1 -1
- package/dist/browser/utli/converters.d.ts.map +1 -1
- package/dist/browser/utli/converters.js +30 -9
- package/dist/browser/utli/converters.js.map +1 -1
- package/dist/commonjs/callAutomationClient.d.ts +2 -3
- package/dist/commonjs/callAutomationClient.d.ts.map +1 -1
- package/dist/commonjs/callAutomationClient.js +79 -31
- package/dist/commonjs/callAutomationClient.js.map +1 -1
- package/dist/commonjs/callAutomationEventParser.d.ts.map +1 -1
- package/dist/commonjs/callAutomationEventParser.js +9 -10
- package/dist/commonjs/callAutomationEventParser.js.map +1 -1
- package/dist/commonjs/callConnection.d.ts +1 -1
- package/dist/commonjs/callConnection.d.ts.map +1 -1
- package/dist/commonjs/callConnection.js +82 -38
- package/dist/commonjs/callConnection.js.map +1 -1
- package/dist/commonjs/callMedia.d.ts +1 -1
- package/dist/commonjs/callMedia.d.ts.map +1 -1
- package/dist/commonjs/callMedia.js +42 -21
- package/dist/commonjs/callMedia.js.map +1 -1
- package/dist/commonjs/callRecording.js +12 -7
- package/dist/commonjs/callRecording.js.map +1 -1
- package/dist/commonjs/contentDownloader.js +11 -12
- package/dist/commonjs/contentDownloader.js.map +1 -1
- package/dist/commonjs/credential/callAutomationAccessKeyCredentialPolicy.js +1 -2
- package/dist/commonjs/credential/callAutomationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/commonjs/credential/callAutomationAuthPolicy.js +1 -1
- package/dist/commonjs/credential/callAutomationAuthPolicy.js.map +1 -1
- package/dist/commonjs/generated/src/callAutomationApiClient.js +14 -5
- package/dist/commonjs/generated/src/callAutomationApiClient.js.map +1 -1
- package/dist/commonjs/generated/src/models/index.d.ts +305 -322
- package/dist/commonjs/generated/src/models/index.d.ts.map +1 -1
- package/dist/commonjs/generated/src/models/index.js +30 -36
- package/dist/commonjs/generated/src/models/index.js.map +1 -1
- package/dist/commonjs/generated/src/models/mappers.d.ts +41 -34
- package/dist/commonjs/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/commonjs/generated/src/models/mappers.js +484 -465
- package/dist/commonjs/generated/src/models/mappers.js.map +1 -1
- package/dist/commonjs/generated/src/models/parameters.js +1 -1
- package/dist/commonjs/generated/src/models/parameters.js.map +1 -1
- package/dist/commonjs/generated/src/operations/callConnection.js +23 -39
- package/dist/commonjs/generated/src/operations/callConnection.js.map +1 -1
- package/dist/commonjs/generated/src/operations/callMedia.js +1 -0
- package/dist/commonjs/generated/src/operations/callMedia.js.map +1 -1
- package/dist/commonjs/generated/src/operations/callRecording.js +1 -0
- package/dist/commonjs/generated/src/operations/callRecording.js.map +1 -1
- package/dist/commonjs/generated/src/pagingHelper.js +2 -4
- package/dist/commonjs/generated/src/pagingHelper.js.map +1 -1
- package/dist/commonjs/models/constants.d.ts.map +1 -1
- package/dist/commonjs/models/constants.js +1 -1
- package/dist/commonjs/models/constants.js.map +1 -1
- package/dist/commonjs/models/events.d.ts +295 -209
- package/dist/commonjs/models/events.d.ts.map +1 -1
- package/dist/commonjs/models/events.js.map +1 -1
- package/dist/commonjs/models/models.d.ts +44 -4
- package/dist/commonjs/models/models.d.ts.map +1 -1
- package/dist/commonjs/models/models.js +2 -16
- package/dist/commonjs/models/models.js.map +1 -1
- package/dist/commonjs/models/options.d.ts +17 -0
- package/dist/commonjs/models/options.d.ts.map +1 -1
- package/dist/commonjs/models/options.js.map +1 -1
- package/dist/commonjs/models/responses.d.ts +1 -1
- package/dist/commonjs/models/responses.d.ts.map +1 -1
- package/dist/commonjs/models/responses.js.map +1 -1
- package/dist/commonjs/models/streaming.d.ts +26 -27
- package/dist/commonjs/models/streaming.d.ts.map +1 -1
- package/dist/commonjs/models/streaming.js +31 -59
- package/dist/commonjs/models/streaming.js.map +1 -1
- package/dist/commonjs/streamingData.d.ts.map +1 -1
- package/dist/commonjs/streamingData.js +10 -1
- package/dist/commonjs/streamingData.js.map +1 -1
- package/dist/commonjs/tsdoc-metadata.json +11 -11
- package/dist/commonjs/utli/converters.d.ts.map +1 -1
- package/dist/commonjs/utli/converters.js +30 -9
- package/dist/commonjs/utli/converters.js.map +1 -1
- package/dist/esm/callAutomationClient.d.ts +2 -3
- package/dist/esm/callAutomationClient.d.ts.map +1 -1
- package/dist/esm/callAutomationClient.js +79 -31
- package/dist/esm/callAutomationClient.js.map +1 -1
- package/dist/esm/callAutomationEventParser.d.ts.map +1 -1
- package/dist/esm/callAutomationEventParser.js +9 -10
- package/dist/esm/callAutomationEventParser.js.map +1 -1
- package/dist/esm/callConnection.d.ts +1 -1
- package/dist/esm/callConnection.d.ts.map +1 -1
- package/dist/esm/callConnection.js +82 -38
- package/dist/esm/callConnection.js.map +1 -1
- package/dist/esm/callMedia.d.ts +1 -1
- package/dist/esm/callMedia.d.ts.map +1 -1
- package/dist/esm/callMedia.js +33 -12
- package/dist/esm/callMedia.js.map +1 -1
- package/dist/esm/callRecording.js +11 -6
- package/dist/esm/callRecording.js.map +1 -1
- package/dist/esm/contentDownloader.js +11 -12
- package/dist/esm/contentDownloader.js.map +1 -1
- package/dist/esm/credential/callAutomationAccessKeyCredentialPolicy.js +1 -2
- package/dist/esm/credential/callAutomationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/esm/credential/callAutomationAuthPolicy.js +1 -1
- package/dist/esm/credential/callAutomationAuthPolicy.js.map +1 -1
- package/dist/esm/generated/src/callAutomationApiClient.js +14 -5
- package/dist/esm/generated/src/callAutomationApiClient.js.map +1 -1
- package/dist/esm/generated/src/models/index.d.ts +305 -322
- package/dist/esm/generated/src/models/index.d.ts.map +1 -1
- package/dist/esm/generated/src/models/index.js +29 -35
- package/dist/esm/generated/src/models/index.js.map +1 -1
- package/dist/esm/generated/src/models/mappers.d.ts +41 -34
- package/dist/esm/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/esm/generated/src/models/mappers.js +481 -462
- package/dist/esm/generated/src/models/mappers.js.map +1 -1
- package/dist/esm/generated/src/models/parameters.js +1 -1
- package/dist/esm/generated/src/models/parameters.js.map +1 -1
- package/dist/esm/generated/src/operations/callConnection.js +23 -40
- package/dist/esm/generated/src/operations/callConnection.js.map +1 -1
- package/dist/esm/generated/src/operations/callMedia.js +1 -0
- package/dist/esm/generated/src/operations/callMedia.js.map +1 -1
- package/dist/esm/generated/src/operations/callRecording.js +1 -0
- package/dist/esm/generated/src/operations/callRecording.js.map +1 -1
- package/dist/esm/generated/src/pagingHelper.js +2 -4
- package/dist/esm/generated/src/pagingHelper.js.map +1 -1
- package/dist/esm/models/constants.d.ts.map +1 -1
- package/dist/esm/models/constants.js +1 -1
- package/dist/esm/models/constants.js.map +1 -1
- package/dist/esm/models/events.d.ts +295 -209
- package/dist/esm/models/events.d.ts.map +1 -1
- package/dist/esm/models/events.js.map +1 -1
- package/dist/esm/models/models.d.ts +44 -4
- package/dist/esm/models/models.d.ts.map +1 -1
- package/dist/esm/models/models.js +1 -1
- package/dist/esm/models/models.js.map +1 -1
- package/dist/esm/models/options.d.ts +17 -0
- package/dist/esm/models/options.d.ts.map +1 -1
- package/dist/esm/models/options.js.map +1 -1
- package/dist/esm/models/responses.d.ts +1 -1
- package/dist/esm/models/responses.d.ts.map +1 -1
- package/dist/esm/models/responses.js.map +1 -1
- package/dist/esm/models/streaming.d.ts +26 -27
- package/dist/esm/models/streaming.d.ts.map +1 -1
- package/dist/esm/models/streaming.js +28 -57
- package/dist/esm/models/streaming.js.map +1 -1
- package/dist/esm/streamingData.d.ts.map +1 -1
- package/dist/esm/streamingData.js +10 -1
- package/dist/esm/streamingData.js.map +1 -1
- package/dist/esm/utli/converters.d.ts.map +1 -1
- package/dist/esm/utli/converters.js +30 -9
- package/dist/esm/utli/converters.js.map +1 -1
- package/dist/react-native/callAutomationClient.d.ts +2 -3
- package/dist/react-native/callAutomationClient.d.ts.map +1 -1
- package/dist/react-native/callAutomationClient.js +79 -31
- package/dist/react-native/callAutomationClient.js.map +1 -1
- package/dist/react-native/callAutomationEventParser.d.ts.map +1 -1
- package/dist/react-native/callAutomationEventParser.js +9 -10
- package/dist/react-native/callAutomationEventParser.js.map +1 -1
- package/dist/react-native/callConnection.d.ts +1 -1
- package/dist/react-native/callConnection.d.ts.map +1 -1
- package/dist/react-native/callConnection.js +82 -38
- package/dist/react-native/callConnection.js.map +1 -1
- package/dist/react-native/callMedia.d.ts +1 -1
- package/dist/react-native/callMedia.d.ts.map +1 -1
- package/dist/react-native/callMedia.js +33 -12
- package/dist/react-native/callMedia.js.map +1 -1
- package/dist/react-native/callRecording.js +11 -6
- package/dist/react-native/callRecording.js.map +1 -1
- package/dist/react-native/contentDownloader.js +11 -12
- package/dist/react-native/contentDownloader.js.map +1 -1
- package/dist/react-native/credential/callAutomationAccessKeyCredentialPolicy.js +1 -2
- package/dist/react-native/credential/callAutomationAccessKeyCredentialPolicy.js.map +1 -1
- package/dist/react-native/credential/callAutomationAuthPolicy.js +1 -1
- package/dist/react-native/credential/callAutomationAuthPolicy.js.map +1 -1
- package/dist/react-native/generated/src/callAutomationApiClient.js +14 -5
- package/dist/react-native/generated/src/callAutomationApiClient.js.map +1 -1
- package/dist/react-native/generated/src/models/index.d.ts +305 -322
- package/dist/react-native/generated/src/models/index.d.ts.map +1 -1
- package/dist/react-native/generated/src/models/index.js +29 -35
- package/dist/react-native/generated/src/models/index.js.map +1 -1
- package/dist/react-native/generated/src/models/mappers.d.ts +41 -34
- package/dist/react-native/generated/src/models/mappers.d.ts.map +1 -1
- package/dist/react-native/generated/src/models/mappers.js +481 -462
- package/dist/react-native/generated/src/models/mappers.js.map +1 -1
- package/dist/react-native/generated/src/models/parameters.js +1 -1
- package/dist/react-native/generated/src/models/parameters.js.map +1 -1
- package/dist/react-native/generated/src/operations/callConnection.js +23 -40
- package/dist/react-native/generated/src/operations/callConnection.js.map +1 -1
- package/dist/react-native/generated/src/operations/callMedia.js +1 -0
- package/dist/react-native/generated/src/operations/callMedia.js.map +1 -1
- package/dist/react-native/generated/src/operations/callRecording.js +1 -0
- package/dist/react-native/generated/src/operations/callRecording.js.map +1 -1
- package/dist/react-native/generated/src/pagingHelper.js +2 -4
- package/dist/react-native/generated/src/pagingHelper.js.map +1 -1
- package/dist/react-native/models/constants.d.ts.map +1 -1
- package/dist/react-native/models/constants.js +1 -1
- package/dist/react-native/models/constants.js.map +1 -1
- package/dist/react-native/models/events.d.ts +295 -209
- package/dist/react-native/models/events.d.ts.map +1 -1
- package/dist/react-native/models/events.js.map +1 -1
- package/dist/react-native/models/models.d.ts +44 -4
- package/dist/react-native/models/models.d.ts.map +1 -1
- package/dist/react-native/models/models.js +1 -1
- package/dist/react-native/models/models.js.map +1 -1
- package/dist/react-native/models/options.d.ts +17 -0
- package/dist/react-native/models/options.d.ts.map +1 -1
- package/dist/react-native/models/options.js.map +1 -1
- package/dist/react-native/models/responses.d.ts +1 -1
- package/dist/react-native/models/responses.d.ts.map +1 -1
- package/dist/react-native/models/responses.js.map +1 -1
- package/dist/react-native/models/streaming.d.ts +26 -27
- package/dist/react-native/models/streaming.d.ts.map +1 -1
- package/dist/react-native/models/streaming.js +28 -57
- package/dist/react-native/models/streaming.js.map +1 -1
- package/dist/react-native/streamingData.d.ts.map +1 -1
- package/dist/react-native/streamingData.js +10 -1
- package/dist/react-native/streamingData.js.map +1 -1
- package/dist/react-native/utli/converters.d.ts.map +1 -1
- package/dist/react-native/utli/converters.js +30 -9
- package/dist/react-native/utli/converters.js.map +1 -1
- package/package.json +38 -44
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
// Licensed under the MIT License.
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
5
|
exports.CallConnection = void 0;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
6
|
const communication_common_1 = require("@azure/communication-common");
|
|
8
7
|
const callMedia_js_1 = require("./callMedia.js");
|
|
9
8
|
const index_js_1 = require("./generated/src/index.js");
|
|
@@ -14,6 +13,12 @@ const core_util_1 = require("@azure/core-util");
|
|
|
14
13
|
* CallConnection class represents call connection based APIs.
|
|
15
14
|
*/
|
|
16
15
|
class CallConnection {
|
|
16
|
+
callConnectionId;
|
|
17
|
+
callConnection;
|
|
18
|
+
callAutomationApiClient;
|
|
19
|
+
endpoint;
|
|
20
|
+
credential;
|
|
21
|
+
callAutomationApiClientOptions;
|
|
17
22
|
constructor(callConnectionId, endpoint, credential, options) {
|
|
18
23
|
this.callAutomationApiClient = new index_js_1.CallAutomationApiClient(endpoint, options);
|
|
19
24
|
const authPolicy = (0, communication_common_1.createCommunicationAuthPolicy)(credential);
|
|
@@ -34,10 +39,17 @@ class CallConnection {
|
|
|
34
39
|
* Get call connection properties of the call
|
|
35
40
|
*/
|
|
36
41
|
async getCallConnectionProperties(options = {}) {
|
|
37
|
-
const
|
|
38
|
-
const callConnectionProperties =
|
|
42
|
+
const { targets, sourceCallerIdNumber, answeredBy, source, answeredFor, ...result } = await this.callConnection.getCall(this.callConnectionId, options);
|
|
43
|
+
const callConnectionProperties = {
|
|
44
|
+
...result,
|
|
45
|
+
source: source ? (0, converters_js_1.communicationIdentifierConverter)(source) : undefined,
|
|
46
|
+
answeredby: (0, converters_js_1.communicationUserIdentifierConverter)(answeredBy),
|
|
47
|
+
answeredFor: answeredFor ? (0, converters_js_1.phoneNumberIdentifierConverter)(answeredFor) : undefined,
|
|
48
|
+
targetParticipants: targets?.map((target) => (0, converters_js_1.communicationIdentifierConverter)(target)),
|
|
49
|
+
sourceCallerIdNumber: sourceCallerIdNumber
|
|
39
50
|
? (0, converters_js_1.phoneNumberIdentifierConverter)(sourceCallerIdNumber)
|
|
40
|
-
: undefined
|
|
51
|
+
: undefined,
|
|
52
|
+
};
|
|
41
53
|
return callConnectionProperties;
|
|
42
54
|
}
|
|
43
55
|
/**
|
|
@@ -47,7 +59,11 @@ class CallConnection {
|
|
|
47
59
|
*/
|
|
48
60
|
async hangUp(isForEveryone, options = {}) {
|
|
49
61
|
if (isForEveryone) {
|
|
50
|
-
const optionsInternal =
|
|
62
|
+
const optionsInternal = {
|
|
63
|
+
...options,
|
|
64
|
+
repeatabilityFirstSent: new Date(),
|
|
65
|
+
repeatabilityRequestID: (0, core_util_1.randomUUID)(),
|
|
66
|
+
};
|
|
51
67
|
await this.callConnection.terminateCall(this.callConnectionId, optionsInternal);
|
|
52
68
|
}
|
|
53
69
|
else {
|
|
@@ -77,28 +93,18 @@ class CallConnection {
|
|
|
77
93
|
* Get all participants from the call
|
|
78
94
|
*/
|
|
79
95
|
async listParticipants(options = {}) {
|
|
80
|
-
var _a, e_1, _b, _c;
|
|
81
96
|
const result = this.callConnection.listParticipants(this.callConnectionId, options);
|
|
82
97
|
const participants = [];
|
|
83
|
-
const pages = result
|
|
84
|
-
|
|
85
|
-
for (
|
|
86
|
-
|
|
87
|
-
_d = false;
|
|
88
|
-
const page = _c;
|
|
89
|
-
for (const participant of page) {
|
|
90
|
-
participants.push((0, converters_js_1.callParticipantConverter)(participant));
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
95
|
-
finally {
|
|
96
|
-
try {
|
|
97
|
-
if (!_d && !_a && (_b = pages_1.return)) await _b.call(pages_1);
|
|
98
|
+
const pages = result?.byPage();
|
|
99
|
+
for await (const page of pages) {
|
|
100
|
+
for (const participant of page) {
|
|
101
|
+
participants.push((0, converters_js_1.callParticipantConverter)(participant));
|
|
98
102
|
}
|
|
99
|
-
finally { if (e_1) throw e_1.error; }
|
|
100
103
|
}
|
|
101
|
-
const listParticipantResponse =
|
|
104
|
+
const listParticipantResponse = {
|
|
105
|
+
...result,
|
|
106
|
+
values: participants,
|
|
107
|
+
};
|
|
102
108
|
return listParticipantResponse;
|
|
103
109
|
}
|
|
104
110
|
createCustomCallingContextInternal(customCallingContext) {
|
|
@@ -110,7 +116,12 @@ class CallConnection {
|
|
|
110
116
|
sipHeaders[`User-To-User`] = header.value;
|
|
111
117
|
}
|
|
112
118
|
else if (header.kind === "sipx") {
|
|
113
|
-
|
|
119
|
+
if (header.sipHeaderPrefix === "X-") {
|
|
120
|
+
sipHeaders[`X-${header.key}`] = header.value;
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
sipHeaders[`X-MS-Custom-${header.key}`] = header.value;
|
|
124
|
+
}
|
|
114
125
|
}
|
|
115
126
|
else if (header.kind === "voip") {
|
|
116
127
|
voipHeaders[`${header.key}`] = header.value;
|
|
@@ -125,7 +136,6 @@ class CallConnection {
|
|
|
125
136
|
* @param participant - The participant is going to be added.
|
|
126
137
|
*/
|
|
127
138
|
async addParticipant(targetParticipant, options = {}) {
|
|
128
|
-
var _a, _b;
|
|
129
139
|
const addParticipantRequest = {
|
|
130
140
|
participantToAdd: (0, converters_js_1.communicationIdentifierModelConverter)(targetParticipant.targetParticipant),
|
|
131
141
|
sourceCallerIdNumber: (0, converters_js_1.PhoneNumberIdentifierModelConverter)(targetParticipant.sourceCallIdNumber),
|
|
@@ -135,11 +145,21 @@ class CallConnection {
|
|
|
135
145
|
operationCallbackUri: options.operationCallbackUrl,
|
|
136
146
|
customCallingContext: this.createCustomCallingContextInternal(targetParticipant.customCallingContext),
|
|
137
147
|
};
|
|
138
|
-
const optionsInternal =
|
|
148
|
+
const optionsInternal = {
|
|
149
|
+
...options,
|
|
150
|
+
repeatabilityFirstSent: new Date(),
|
|
151
|
+
repeatabilityRequestID: (0, core_util_1.randomUUID)(),
|
|
152
|
+
};
|
|
139
153
|
const result = await this.callConnection.addParticipant(this.callConnectionId, addParticipantRequest, optionsInternal);
|
|
140
|
-
const addParticipantsResult =
|
|
141
|
-
|
|
142
|
-
|
|
154
|
+
const addParticipantsResult = {
|
|
155
|
+
...result,
|
|
156
|
+
participant: {
|
|
157
|
+
...result.participant,
|
|
158
|
+
identifier: result.participant?.identifier
|
|
159
|
+
? (0, converters_js_1.communicationIdentifierConverter)(result.participant?.identifier)
|
|
160
|
+
: undefined,
|
|
161
|
+
},
|
|
162
|
+
};
|
|
143
163
|
return addParticipantsResult;
|
|
144
164
|
}
|
|
145
165
|
/**
|
|
@@ -156,9 +176,15 @@ class CallConnection {
|
|
|
156
176
|
customCallingContext: this.createCustomCallingContextInternal(options.customCallingContext),
|
|
157
177
|
sourceCallerIdNumber: (0, converters_js_1.PhoneNumberIdentifierModelConverter)(options.sourceCallIdNumber),
|
|
158
178
|
};
|
|
159
|
-
const optionsInternal =
|
|
179
|
+
const optionsInternal = {
|
|
180
|
+
...options,
|
|
181
|
+
repeatabilityFirstSent: new Date(),
|
|
182
|
+
repeatabilityRequestID: (0, core_util_1.randomUUID)(),
|
|
183
|
+
};
|
|
160
184
|
const result = await this.callConnection.transferToParticipant(this.callConnectionId, transferToParticipantRequest, optionsInternal);
|
|
161
|
-
const transferCallResult =
|
|
185
|
+
const transferCallResult = {
|
|
186
|
+
...result,
|
|
187
|
+
};
|
|
162
188
|
return transferCallResult;
|
|
163
189
|
}
|
|
164
190
|
/**
|
|
@@ -172,9 +198,15 @@ class CallConnection {
|
|
|
172
198
|
operationContext: options.operationContext ? options.operationContext : (0, core_util_1.randomUUID)(),
|
|
173
199
|
operationCallbackUri: options.operationCallbackUrl,
|
|
174
200
|
};
|
|
175
|
-
const optionsInternal =
|
|
201
|
+
const optionsInternal = {
|
|
202
|
+
...options,
|
|
203
|
+
repeatabilityFirstSent: new Date(),
|
|
204
|
+
repeatabilityRequestID: (0, core_util_1.randomUUID)(),
|
|
205
|
+
};
|
|
176
206
|
const result = await this.callConnection.removeParticipant(this.callConnectionId, removeParticipantRequest, optionsInternal);
|
|
177
|
-
const removeParticipantsResult =
|
|
207
|
+
const removeParticipantsResult = {
|
|
208
|
+
...result,
|
|
209
|
+
};
|
|
178
210
|
return removeParticipantsResult;
|
|
179
211
|
}
|
|
180
212
|
/**
|
|
@@ -188,9 +220,15 @@ class CallConnection {
|
|
|
188
220
|
targetParticipants: [(0, converters_js_1.communicationIdentifierModelConverter)(participant)],
|
|
189
221
|
operationContext: options.operationContext,
|
|
190
222
|
};
|
|
191
|
-
const optionsInternal =
|
|
223
|
+
const optionsInternal = {
|
|
224
|
+
...options,
|
|
225
|
+
repeatabilityFirstSent: new Date(),
|
|
226
|
+
repeatabilityRequestID: (0, core_util_1.randomUUID)(),
|
|
227
|
+
};
|
|
192
228
|
const result = await this.callConnection.mute(this.callConnectionId, muteParticipantsRequest, optionsInternal);
|
|
193
|
-
const muteParticipantResult =
|
|
229
|
+
const muteParticipantResult = {
|
|
230
|
+
...result,
|
|
231
|
+
};
|
|
194
232
|
return muteParticipantResult;
|
|
195
233
|
}
|
|
196
234
|
/** Cancel add participant request.
|
|
@@ -198,15 +236,21 @@ class CallConnection {
|
|
|
198
236
|
* @param invitationId - Invitation ID used to cancel the add participant request.
|
|
199
237
|
*/
|
|
200
238
|
async cancelAddParticipantOperation(invitationId, options = {}) {
|
|
201
|
-
const { operationContext, operationCallbackUrl: operationCallbackUri
|
|
239
|
+
const { operationContext, operationCallbackUrl: operationCallbackUri, ...operationOptions } = options;
|
|
202
240
|
const cancelAddParticipantRequest = {
|
|
203
241
|
invitationId,
|
|
204
242
|
operationContext: operationContext ? operationContext : (0, core_util_1.randomUUID)(),
|
|
205
243
|
operationCallbackUri,
|
|
206
244
|
};
|
|
207
|
-
const optionsInternal =
|
|
245
|
+
const optionsInternal = {
|
|
246
|
+
...operationOptions,
|
|
247
|
+
repeatabilityFirstSent: new Date(),
|
|
248
|
+
repeatabilityRequestID: (0, core_util_1.randomUUID)(),
|
|
249
|
+
};
|
|
208
250
|
const result = await this.callConnection.cancelAddParticipant(this.callConnectionId, cancelAddParticipantRequest, optionsInternal);
|
|
209
|
-
const cancelAddParticipantResult =
|
|
251
|
+
const cancelAddParticipantResult = {
|
|
252
|
+
...result,
|
|
253
|
+
};
|
|
210
254
|
return cancelAddParticipantResult;
|
|
211
255
|
}
|
|
212
256
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callConnection.js","sourceRoot":"","sources":["../../src/callConnection.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;;AAElC,sEAGqC;AACrC,iDAA2C;AAC3C,uDAQkC;AAClC,kEAAyE;AAyBzE,wDAO8B;AAC9B,gDAA8C;AAG9C;;GAEG;AACH,MAAa,cAAc;IAOzB,YACE,gBAAwB,EACxB,QAAgB,EAChB,UAA2C,EAC3C,OAA+C;QAE/C,IAAI,CAAC,uBAAuB,GAAG,IAAI,kCAAuB,CAAC,QAAQ,EAAE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AA,sBAAU,GAAE;YACpE,oBAAoB;SACrB,CAAC;QACF,MAAM,eAAe,mCAChB,gBAAgB,KACnB,sBAAsB,EAAE,IAAI,IAAI,EAAE,EAClC,sBAAsB,EAAE,IAAA,sBAAU,GAAE,GACrC,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAC3D,IAAI,CAAC,gBAAgB,EACrB,2BAA2B,EAC3B,eAAe,CAChB,CAAC;QAEF,MAAM,0BAA0B,qBAC3B,MAAM,CACV,CAAC;QAEF,OAAO,0BAA0B,CAAC;IACpC,CAAC;CACF;AAzTD,wCAyTC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n CommunicationIdentifier,\n createCommunicationAuthPolicy,\n} from \"@azure/communication-common\";\nimport { CallMedia } from \"./callMedia.js\";\nimport {\n AddParticipantRequest,\n CallAutomationApiClient,\n CallAutomationApiClientOptionalParams,\n CustomCallingContextInternal,\n MuteParticipantsRequest,\n RemoveParticipantRequest,\n TransferToParticipantRequest,\n} from \"./generated/src/index.js\";\nimport { CallConnectionImpl } from \"./generated/src/operations/index.js\";\nimport type {\n CallConnectionProperties,\n CallInvite,\n CallParticipant,\n CustomCallingContext,\n} from \"./models/models.js\";\nimport type {\n AddParticipantOptions,\n CancelAddParticipantOperationOptions,\n GetCallConnectionPropertiesOptions,\n GetParticipantOptions,\n HangUpOptions,\n MuteParticipantOption,\n RemoveParticipantsOption,\n TransferCallToParticipantOptions,\n} from \"./models/options.js\";\nimport type {\n ListParticipantsResult,\n TransferCallResult,\n AddParticipantResult,\n RemoveParticipantResult,\n MuteParticipantResult,\n CancelAddParticipantOperationResult,\n} from \"./models/responses.js\";\nimport {\n callParticipantConverter,\n communicationIdentifierConverter,\n communicationIdentifierModelConverter,\n communicationUserIdentifierConverter,\n phoneNumberIdentifierConverter,\n PhoneNumberIdentifierModelConverter,\n} from \"./utli/converters.js\";\nimport { randomUUID } from \"@azure/core-util\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\n\n/**\n * CallConnection class represents call connection based APIs.\n */\nexport class CallConnection {\n private readonly callConnectionId: string;\n private readonly callConnection: CallConnectionImpl;\n private readonly callAutomationApiClient: CallAutomationApiClient;\n private readonly endpoint: string;\n private readonly credential: TokenCredential | KeyCredential;\n private readonly callAutomationApiClientOptions?: CallAutomationApiClientOptionalParams;\n constructor(\n callConnectionId: string,\n endpoint: string,\n credential: KeyCredential | TokenCredential,\n options?: CallAutomationApiClientOptionalParams,\n ) {\n this.callAutomationApiClient = new CallAutomationApiClient(endpoint, options);\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.callAutomationApiClient.pipeline.addPolicy(authPolicy);\n this.callConnectionId = callConnectionId;\n this.callConnection = new CallConnectionImpl(this.callAutomationApiClient);\n this.endpoint = endpoint;\n this.credential = credential;\n this.callAutomationApiClientOptions = options;\n }\n\n /**\n * Initializes a new instance of CallMedia.\n */\n public getCallMedia(): CallMedia {\n return new CallMedia(\n this.callConnectionId,\n this.endpoint,\n this.credential,\n this.callAutomationApiClientOptions,\n );\n }\n\n /**\n * Get call connection properties of the call\n */\n public async getCallConnectionProperties(\n options: GetCallConnectionPropertiesOptions = {},\n ): Promise<CallConnectionProperties> {\n const { targets, sourceCallerIdNumber, answeredBy, source, answeredFor, ...result } =\n await this.callConnection.getCall(this.callConnectionId, options);\n const callConnectionProperties: CallConnectionProperties = {\n ...result,\n source: source ? communicationIdentifierConverter(source) : undefined,\n answeredby: communicationUserIdentifierConverter(answeredBy),\n answeredFor: answeredFor ? phoneNumberIdentifierConverter(answeredFor) : undefined,\n targetParticipants: targets?.map((target) => communicationIdentifierConverter(target)),\n sourceCallerIdNumber: sourceCallerIdNumber\n ? phoneNumberIdentifierConverter(sourceCallerIdNumber)\n : undefined,\n };\n return callConnectionProperties;\n }\n\n /**\n * Hang up the call for itself or terminate the whole call.\n *\n * @param isForEveryOne - Determine if every one in the call would be hung up or not.\n */\n public async hangUp(isForEveryone: boolean, options: HangUpOptions = {}): Promise<void> {\n if (isForEveryone) {\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n await this.callConnection.terminateCall(this.callConnectionId, optionsInternal);\n } else {\n await this.callConnection.hangupCall(this.callConnectionId, options);\n }\n return;\n }\n\n /**\n * Get a participant from the call\n *\n * @param targetParticipant - The communication identifier of requested participant.\n */\n public async getParticipant(\n targetParticipant: CommunicationIdentifier,\n options: GetParticipantOptions = {},\n ): Promise<CallParticipant> {\n let rawId: string | undefined = communicationIdentifierModelConverter(targetParticipant).rawId;\n rawId = rawId === undefined ? \"\" : rawId;\n\n const result = await this.callConnection.getParticipant(this.callConnectionId, rawId, options);\n const callParticipant: CallParticipant = {\n identifier: result.identifier\n ? communicationIdentifierConverter(result.identifier)\n : undefined,\n isMuted: result.isMuted,\n isOnHold: result.isOnHold,\n };\n return callParticipant;\n }\n\n /**\n * Get all participants from the call\n */\n public async listParticipants(\n options: GetParticipantOptions = {},\n ): Promise<ListParticipantsResult> {\n const result = this.callConnection.listParticipants(this.callConnectionId, options);\n const participants = [];\n const pages = result?.byPage();\n\n for await (const page of pages) {\n for (const participant of page) {\n participants.push(callParticipantConverter(participant));\n }\n }\n\n const listParticipantResponse: ListParticipantsResult = {\n ...result,\n values: participants,\n };\n return listParticipantResponse;\n }\n\n private createCustomCallingContextInternal(\n customCallingContext: CustomCallingContext,\n ): CustomCallingContextInternal {\n const sipHeaders: { [key: string]: string } = {};\n const voipHeaders: { [key: string]: string } = {};\n if (customCallingContext) {\n for (const header of customCallingContext) {\n if (header.kind === \"sipuui\") {\n sipHeaders[`User-To-User`] = header.value;\n } else if (header.kind === \"sipx\") {\n sipHeaders[`X-MS-Custom-${header.key}`] = header.value;\n } else if (header.kind === \"voip\") {\n voipHeaders[`${header.key}`] = header.value;\n }\n }\n }\n return { sipHeaders: sipHeaders, voipHeaders: voipHeaders };\n }\n\n /**\n * Add a participant to the call\n *\n * @param participant - The participant is going to be added.\n */\n public async addParticipant(\n targetParticipant: CallInvite,\n options: AddParticipantOptions = {},\n ): Promise<AddParticipantResult> {\n const addParticipantRequest: AddParticipantRequest = {\n participantToAdd: communicationIdentifierModelConverter(targetParticipant.targetParticipant),\n sourceCallerIdNumber: PhoneNumberIdentifierModelConverter(\n targetParticipant.sourceCallIdNumber,\n ),\n sourceDisplayName: targetParticipant.sourceDisplayName,\n invitationTimeoutInSeconds: options.invitationTimeoutInSeconds,\n operationContext: options.operationContext,\n operationCallbackUri: options.operationCallbackUrl,\n customCallingContext: this.createCustomCallingContextInternal(\n targetParticipant.customCallingContext!,\n ),\n };\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n const result = await this.callConnection.addParticipant(\n this.callConnectionId,\n addParticipantRequest,\n optionsInternal,\n );\n const addParticipantsResult: AddParticipantResult = {\n ...result,\n participant: {\n ...result.participant,\n identifier: result.participant?.identifier\n ? communicationIdentifierConverter(result.participant?.identifier)\n : undefined,\n },\n };\n return addParticipantsResult;\n }\n\n /**\n * Transfer the call to a target participant\n *\n * @param targetParticipant - The target to be transferred to.\n */\n public async transferCallToParticipant(\n targetParticipant: CommunicationIdentifier,\n options: TransferCallToParticipantOptions = {},\n ): Promise<TransferCallResult> {\n const transferToParticipantRequest: TransferToParticipantRequest = {\n targetParticipant: communicationIdentifierModelConverter(targetParticipant),\n operationContext: options.operationContext ? options.operationContext : randomUUID(),\n operationCallbackUri: options.operationCallbackUrl,\n transferee: options.transferee && communicationIdentifierModelConverter(options.transferee),\n customCallingContext: this.createCustomCallingContextInternal(options.customCallingContext!),\n sourceCallerIdNumber: PhoneNumberIdentifierModelConverter(options.sourceCallIdNumber),\n };\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n const result = await this.callConnection.transferToParticipant(\n this.callConnectionId,\n transferToParticipantRequest,\n optionsInternal,\n );\n const transferCallResult: TransferCallResult = {\n ...result,\n };\n return transferCallResult;\n }\n\n /**\n * Remove a participant from the call\n *\n * @param participant - The participant is going to be removed from the call.\n */\n public async removeParticipant(\n participant: CommunicationIdentifier,\n options: RemoveParticipantsOption = {},\n ): Promise<RemoveParticipantResult> {\n const removeParticipantRequest: RemoveParticipantRequest = {\n participantToRemove: communicationIdentifierModelConverter(participant),\n operationContext: options.operationContext ? options.operationContext : randomUUID(),\n operationCallbackUri: options.operationCallbackUrl,\n };\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n const result = await this.callConnection.removeParticipant(\n this.callConnectionId,\n removeParticipantRequest,\n optionsInternal,\n );\n const removeParticipantsResult: RemoveParticipantResult = {\n ...result,\n };\n return removeParticipantsResult;\n }\n\n /**\n * Mute participant from the call.\n *\n * @param participant - Participant to be muted from the call.\n * @param options - Additional attributes for mute participant.\n */\n public async muteParticipant(\n participant: CommunicationIdentifier,\n options: MuteParticipantOption = {},\n ): Promise<MuteParticipantResult> {\n const muteParticipantsRequest: MuteParticipantsRequest = {\n targetParticipants: [communicationIdentifierModelConverter(participant)],\n operationContext: options.operationContext,\n };\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n const result = await this.callConnection.mute(\n this.callConnectionId,\n muteParticipantsRequest,\n optionsInternal,\n );\n const muteParticipantResult: MuteParticipantResult = {\n ...result,\n };\n return muteParticipantResult;\n }\n\n /** Cancel add participant request.\n *\n * @param invitationId - Invitation ID used to cancel the add participant request.\n */\n public async cancelAddParticipantOperation(\n invitationId: string,\n options: CancelAddParticipantOperationOptions = {},\n ): Promise<CancelAddParticipantOperationResult> {\n const {\n operationContext,\n operationCallbackUrl: operationCallbackUri,\n ...operationOptions\n } = options;\n const cancelAddParticipantRequest = {\n invitationId,\n operationContext: operationContext ? operationContext : randomUUID(),\n operationCallbackUri,\n };\n const optionsInternal = {\n ...operationOptions,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n\n const result = await this.callConnection.cancelAddParticipant(\n this.callConnectionId,\n cancelAddParticipantRequest,\n optionsInternal,\n );\n\n const cancelAddParticipantResult: CancelAddParticipantOperationResult = {\n ...result,\n };\n\n return cancelAddParticipantResult;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"callConnection.js","sourceRoot":"","sources":["../../src/callConnection.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,sEAGqC;AACrC,iDAA2C;AAC3C,uDAQkC;AAClC,kEAAyE;AAyBzE,wDAO8B;AAC9B,gDAA8C;AAG9C;;GAEG;AACH,MAAa,cAAc;IACR,gBAAgB,CAAS;IACzB,cAAc,CAAqB;IACnC,uBAAuB,CAA0B;IACjD,QAAQ,CAAS;IACjB,UAAU,CAAkC;IAC5C,8BAA8B,CAAyC;IACxF,YACE,gBAAwB,EACxB,QAAgB,EAChB,UAA2C,EAC3C,OAA+C;QAE/C,IAAI,CAAC,uBAAuB,GAAG,IAAI,kCAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9E,MAAM,UAAU,GAAG,IAAA,oDAA6B,EAAC,UAAU,CAAC,CAAC;QAC7D,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;QAC5D,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QACzC,IAAI,CAAC,cAAc,GAAG,IAAI,6BAAkB,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;QAC3E,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,8BAA8B,GAAG,OAAO,CAAC;IAChD,CAAC;IAED;;OAEG;IACI,YAAY;QACjB,OAAO,IAAI,wBAAS,CAClB,IAAI,CAAC,gBAAgB,EACrB,IAAI,CAAC,QAAQ,EACb,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;AA7TD,wCA6TC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport {\n CommunicationIdentifier,\n createCommunicationAuthPolicy,\n} from \"@azure/communication-common\";\nimport { CallMedia } from \"./callMedia.js\";\nimport {\n AddParticipantRequest,\n CallAutomationApiClient,\n CallAutomationApiClientOptionalParams,\n CustomCallingContextInternal,\n MuteParticipantsRequest,\n RemoveParticipantRequest,\n TransferToParticipantRequest,\n} from \"./generated/src/index.js\";\nimport { CallConnectionImpl } from \"./generated/src/operations/index.js\";\nimport {\n type CallConnectionProperties,\n type CallInvite,\n type CallParticipant,\n type CustomCallingContext,\n} from \"./models/models.js\";\nimport type {\n AddParticipantOptions,\n CancelAddParticipantOperationOptions,\n GetCallConnectionPropertiesOptions,\n GetParticipantOptions,\n HangUpOptions,\n MuteParticipantOption,\n RemoveParticipantsOption,\n TransferCallToParticipantOptions,\n} from \"./models/options.js\";\nimport type {\n ListParticipantsResult,\n TransferCallResult,\n AddParticipantResult,\n RemoveParticipantResult,\n MuteParticipantResult,\n CancelAddParticipantOperationResult,\n} from \"./models/responses.js\";\nimport {\n callParticipantConverter,\n communicationIdentifierConverter,\n communicationIdentifierModelConverter,\n communicationUserIdentifierConverter,\n phoneNumberIdentifierConverter,\n PhoneNumberIdentifierModelConverter,\n} from \"./utli/converters.js\";\nimport { randomUUID } from \"@azure/core-util\";\nimport type { KeyCredential, TokenCredential } from \"@azure/core-auth\";\n\n/**\n * CallConnection class represents call connection based APIs.\n */\nexport class CallConnection {\n private readonly callConnectionId: string;\n private readonly callConnection: CallConnectionImpl;\n private readonly callAutomationApiClient: CallAutomationApiClient;\n private readonly endpoint: string;\n private readonly credential: TokenCredential | KeyCredential;\n private readonly callAutomationApiClientOptions?: CallAutomationApiClientOptionalParams;\n constructor(\n callConnectionId: string,\n endpoint: string,\n credential: KeyCredential | TokenCredential,\n options?: CallAutomationApiClientOptionalParams,\n ) {\n this.callAutomationApiClient = new CallAutomationApiClient(endpoint, options);\n const authPolicy = createCommunicationAuthPolicy(credential);\n this.callAutomationApiClient.pipeline.addPolicy(authPolicy);\n this.callConnectionId = callConnectionId;\n this.callConnection = new CallConnectionImpl(this.callAutomationApiClient);\n this.endpoint = endpoint;\n this.credential = credential;\n this.callAutomationApiClientOptions = options;\n }\n\n /**\n * Initializes a new instance of CallMedia.\n */\n public getCallMedia(): CallMedia {\n return new CallMedia(\n this.callConnectionId,\n this.endpoint,\n this.credential,\n this.callAutomationApiClientOptions,\n );\n }\n\n /**\n * Get call connection properties of the call\n */\n public async getCallConnectionProperties(\n options: GetCallConnectionPropertiesOptions = {},\n ): Promise<CallConnectionProperties> {\n const { targets, sourceCallerIdNumber, answeredBy, source, answeredFor, ...result } =\n await this.callConnection.getCall(this.callConnectionId, options);\n const callConnectionProperties: CallConnectionProperties = {\n ...result,\n source: source ? communicationIdentifierConverter(source) : undefined,\n answeredby: communicationUserIdentifierConverter(answeredBy),\n answeredFor: answeredFor ? phoneNumberIdentifierConverter(answeredFor) : undefined,\n targetParticipants: targets?.map((target) => communicationIdentifierConverter(target)),\n sourceCallerIdNumber: sourceCallerIdNumber\n ? phoneNumberIdentifierConverter(sourceCallerIdNumber)\n : undefined,\n };\n return callConnectionProperties;\n }\n\n /**\n * Hang up the call for itself or terminate the whole call.\n *\n * @param isForEveryOne - Determine if every one in the call would be hung up or not.\n */\n public async hangUp(isForEveryone: boolean, options: HangUpOptions = {}): Promise<void> {\n if (isForEveryone) {\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n await this.callConnection.terminateCall(this.callConnectionId, optionsInternal);\n } else {\n await this.callConnection.hangupCall(this.callConnectionId, options);\n }\n return;\n }\n\n /**\n * Get a participant from the call\n *\n * @param targetParticipant - The communication identifier of requested participant.\n */\n public async getParticipant(\n targetParticipant: CommunicationIdentifier,\n options: GetParticipantOptions = {},\n ): Promise<CallParticipant> {\n let rawId: string | undefined = communicationIdentifierModelConverter(targetParticipant).rawId;\n rawId = rawId === undefined ? \"\" : rawId;\n\n const result = await this.callConnection.getParticipant(this.callConnectionId, rawId, options);\n const callParticipant: CallParticipant = {\n identifier: result.identifier\n ? communicationIdentifierConverter(result.identifier)\n : undefined,\n isMuted: result.isMuted,\n isOnHold: result.isOnHold,\n };\n return callParticipant;\n }\n\n /**\n * Get all participants from the call\n */\n public async listParticipants(\n options: GetParticipantOptions = {},\n ): Promise<ListParticipantsResult> {\n const result = this.callConnection.listParticipants(this.callConnectionId, options);\n const participants = [];\n const pages = result?.byPage();\n\n for await (const page of pages) {\n for (const participant of page) {\n participants.push(callParticipantConverter(participant));\n }\n }\n\n const listParticipantResponse: ListParticipantsResult = {\n ...result,\n values: participants,\n };\n return listParticipantResponse;\n }\n\n private createCustomCallingContextInternal(\n customCallingContext: CustomCallingContext,\n ): CustomCallingContextInternal {\n const sipHeaders: { [key: string]: string } = {};\n const voipHeaders: { [key: string]: string } = {};\n if (customCallingContext) {\n for (const header of customCallingContext) {\n if (header.kind === \"sipuui\") {\n sipHeaders[`User-To-User`] = header.value;\n } else if (header.kind === \"sipx\") {\n if (header.sipHeaderPrefix === \"X-\") {\n sipHeaders[`X-${header.key}`] = header.value;\n } else {\n sipHeaders[`X-MS-Custom-${header.key}`] = header.value;\n }\n } else if (header.kind === \"voip\") {\n voipHeaders[`${header.key}`] = header.value;\n }\n }\n }\n return { sipHeaders: sipHeaders, voipHeaders: voipHeaders };\n }\n\n /**\n * Add a participant to the call\n *\n * @param participant - The participant is going to be added.\n */\n public async addParticipant(\n targetParticipant: CallInvite,\n options: AddParticipantOptions = {},\n ): Promise<AddParticipantResult> {\n const addParticipantRequest: AddParticipantRequest = {\n participantToAdd: communicationIdentifierModelConverter(targetParticipant.targetParticipant),\n sourceCallerIdNumber: PhoneNumberIdentifierModelConverter(\n targetParticipant.sourceCallIdNumber,\n ),\n sourceDisplayName: targetParticipant.sourceDisplayName,\n invitationTimeoutInSeconds: options.invitationTimeoutInSeconds,\n operationContext: options.operationContext,\n operationCallbackUri: options.operationCallbackUrl,\n customCallingContext: this.createCustomCallingContextInternal(\n targetParticipant.customCallingContext!,\n ),\n };\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n const result = await this.callConnection.addParticipant(\n this.callConnectionId,\n addParticipantRequest,\n optionsInternal,\n );\n const addParticipantsResult: AddParticipantResult = {\n ...result,\n participant: {\n ...result.participant,\n identifier: result.participant?.identifier\n ? communicationIdentifierConverter(result.participant?.identifier)\n : undefined,\n },\n };\n return addParticipantsResult;\n }\n\n /**\n * Transfer the call to a target participant\n *\n * @param targetParticipant - The target to be transferred to.\n */\n public async transferCallToParticipant(\n targetParticipant: CommunicationIdentifier,\n options: TransferCallToParticipantOptions = {},\n ): Promise<TransferCallResult> {\n const transferToParticipantRequest: TransferToParticipantRequest = {\n targetParticipant: communicationIdentifierModelConverter(targetParticipant),\n operationContext: options.operationContext ? options.operationContext : randomUUID(),\n operationCallbackUri: options.operationCallbackUrl,\n transferee: options.transferee && communicationIdentifierModelConverter(options.transferee),\n customCallingContext: this.createCustomCallingContextInternal(options.customCallingContext!),\n sourceCallerIdNumber: PhoneNumberIdentifierModelConverter(options.sourceCallIdNumber),\n };\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n const result = await this.callConnection.transferToParticipant(\n this.callConnectionId,\n transferToParticipantRequest,\n optionsInternal,\n );\n const transferCallResult: TransferCallResult = {\n ...result,\n };\n return transferCallResult;\n }\n\n /**\n * Remove a participant from the call\n *\n * @param participant - The participant is going to be removed from the call.\n */\n public async removeParticipant(\n participant: CommunicationIdentifier,\n options: RemoveParticipantsOption = {},\n ): Promise<RemoveParticipantResult> {\n const removeParticipantRequest: RemoveParticipantRequest = {\n participantToRemove: communicationIdentifierModelConverter(participant),\n operationContext: options.operationContext ? options.operationContext : randomUUID(),\n operationCallbackUri: options.operationCallbackUrl,\n };\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n const result = await this.callConnection.removeParticipant(\n this.callConnectionId,\n removeParticipantRequest,\n optionsInternal,\n );\n const removeParticipantsResult: RemoveParticipantResult = {\n ...result,\n };\n return removeParticipantsResult;\n }\n\n /**\n * Mute participant from the call.\n *\n * @param participant - Participant to be muted from the call.\n * @param options - Additional attributes for mute participant.\n */\n public async muteParticipant(\n participant: CommunicationIdentifier,\n options: MuteParticipantOption = {},\n ): Promise<MuteParticipantResult> {\n const muteParticipantsRequest: MuteParticipantsRequest = {\n targetParticipants: [communicationIdentifierModelConverter(participant)],\n operationContext: options.operationContext,\n };\n const optionsInternal = {\n ...options,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n const result = await this.callConnection.mute(\n this.callConnectionId,\n muteParticipantsRequest,\n optionsInternal,\n );\n const muteParticipantResult: MuteParticipantResult = {\n ...result,\n };\n return muteParticipantResult;\n }\n\n /** Cancel add participant request.\n *\n * @param invitationId - Invitation ID used to cancel the add participant request.\n */\n public async cancelAddParticipantOperation(\n invitationId: string,\n options: CancelAddParticipantOperationOptions = {},\n ): Promise<CancelAddParticipantOperationResult> {\n const {\n operationContext,\n operationCallbackUrl: operationCallbackUri,\n ...operationOptions\n } = options;\n const cancelAddParticipantRequest = {\n invitationId,\n operationContext: operationContext ? operationContext : randomUUID(),\n operationCallbackUri,\n };\n const optionsInternal = {\n ...operationOptions,\n repeatabilityFirstSent: new Date(),\n repeatabilityRequestID: randomUUID(),\n };\n\n const result = await this.callConnection.cancelAddParticipant(\n this.callConnectionId,\n cancelAddParticipantRequest,\n optionsInternal,\n );\n\n const cancelAddParticipantResult: CancelAddParticipantOperationResult = {\n ...result,\n };\n\n return cancelAddParticipantResult;\n }\n}\n"]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CallAutomationApiClientOptionalParams, Tone } from "./generated/src/index.js";
|
|
2
|
-
import { CommunicationIdentifier } from "@azure/communication-common";
|
|
2
|
+
import type { CommunicationIdentifier } from "@azure/communication-common";
|
|
3
3
|
import type { FileSource, TextSource, SsmlSource, DtmfTone } from "./models/models.js";
|
|
4
4
|
import type { PlayOptions, CallMediaRecognizeDtmfOptions, CallMediaRecognizeChoiceOptions, ContinuousDtmfRecognitionOptions, SendDtmfTonesOptions, CallMediaRecognizeSpeechOptions, CallMediaRecognizeSpeechOrDtmfOptions, StartTranscriptionOptions, StopTranscriptionOptions, HoldOptions, UnholdOptions, StartMediaStreamingOptions, StopMediaStreamingOptions, PlayToAllOptions, UpdateTranscriptionOptions } from "./models/options.js";
|
|
5
5
|
import type { KeyCredential, TokenCredential } from "@azure/core-auth";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callMedia.d.ts","sourceRoot":"","sources":["../../src/callMedia.ts"],"names":[],"mappings":"AAGA,OAAO,EAUL,qCAAqC,EAGrC,IAAI,EASL,MAAM,0BAA0B,CAAC;AAKlC,OAAO,
|
|
1
|
+
{"version":3,"file":"callMedia.d.ts","sourceRoot":"","sources":["../../src/callMedia.ts"],"names":[],"mappings":"AAGA,OAAO,EAUL,qCAAqC,EAGrC,IAAI,EASL,MAAM,0BAA0B,CAAC;AAKlC,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAM3E,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AACvF,OAAO,KAAK,EACV,WAAW,EACX,6BAA6B,EAC7B,+BAA+B,EAC/B,gCAAgC,EAChC,oBAAoB,EACpB,+BAA+B,EAC/B,qCAAqC,EACrC,yBAAyB,EACzB,wBAAwB,EACxB,WAAW,EACX,aAAa,EACb,0BAA0B,EAC1B,yBAAyB,EACzB,gBAAgB,EAChB,0BAA0B,EAC3B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,aAAa,EAAE,eAAe,EAAE,M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C,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;SAIK;IACQ,6BAA6B,CACxC,iBAAiB,EAAE,uBAAuB,EAC1C,OAAO,GAAE,gCAAqC,GAC7C,OAAO,CAAC,IAAI,CAAC;IAahB;;;;;SAKK;IACQ,aAAa,CACxB,KAAK,EAAE,IAAI,EAAE,GAAG,QAAQ,EAAE,EAC1B,iBAAiB,EAAE,uBAAuB,EAC1C,OAAO,GAAE,oBAAyB,GACjC,OAAO,CAAC,mBAAmB,CAAC;IAwB/B;;;;;OAKG;IACU,IAAI,CACf,iBAAiB,EAAE,uBAAuB,EAC1C,OAAO,GAAE,WAAgB,GACxB,OAAO,CAAC,IAAI,CAAC;IAehB;;;;;OAKG;IACU,MAAM,CACjB,iBAAiB,EAAE,uBAAuB,EAC1C,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,IAAI,CAAC;IAWhB;;;OAGG;IACU,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;IAUvF;;;OAGG;IACU,iBAAiB,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,IAAI,CAAC;IAQrF;;;OAGG;IACU,mBAAmB,CAC9B,MAAM,EAAE,MAAM,EACd,OAAO,CAAC,EAAE,0BAA0B,GACnC,OAAO,CAAC,IAAI,CAAC;IAahB;;;OAGG;IACU,mBAAmB,CAAC,OAAO,GAAE,0BAA+B,GAAG,OAAO,CAAC,IAAI,CAAC;IAYzF;;;OAGG;IACU,kBAAkB,CAAC,OAAO,GAAE,yBAA8B,GAAG,OAAO,CAAC,IAAI,CAAC;CAWxF"}
|
|
@@ -7,12 +7,14 @@ const index_js_1 = require("./generated/src/index.js");
|
|
|
7
7
|
const index_js_2 = require("./generated/src/index.js");
|
|
8
8
|
const index_js_3 = require("./generated/src/operations/index.js");
|
|
9
9
|
const communication_common_1 = require("@azure/communication-common");
|
|
10
|
-
const communication_common_2 = require("@azure/communication-common");
|
|
11
10
|
const core_util_1 = require("@azure/core-util");
|
|
12
11
|
/**
|
|
13
12
|
* CallMedia class represents call media related APIs.
|
|
14
13
|
*/
|
|
15
14
|
class CallMedia {
|
|
15
|
+
callConnectionId;
|
|
16
|
+
callMedia;
|
|
17
|
+
callAutomationApiClient;
|
|
16
18
|
constructor(callConnectionId, endpoint, credential, options) {
|
|
17
19
|
this.callAutomationApiClient = new index_js_1.CallAutomationApiClient(endpoint, options);
|
|
18
20
|
const authPolicy = (0, communication_common_1.createCommunicationAuthPolicy)(credential);
|
|
@@ -28,6 +30,9 @@ class CallMedia {
|
|
|
28
30
|
return {
|
|
29
31
|
kind: index_js_2.KnownPlaySourceType.File,
|
|
30
32
|
file: fileSource,
|
|
33
|
+
playSourceCacheId: playSource.playSourceCacheId
|
|
34
|
+
? playSource.playSourceCacheId
|
|
35
|
+
: playSource.playsourcacheid,
|
|
31
36
|
};
|
|
32
37
|
}
|
|
33
38
|
else if (playSource.kind === "textSource") {
|
|
@@ -41,6 +46,9 @@ class CallMedia {
|
|
|
41
46
|
return {
|
|
42
47
|
kind: index_js_2.KnownPlaySourceType.Text,
|
|
43
48
|
text: textSource,
|
|
49
|
+
playSourceCacheId: playSource.playSourceCacheId
|
|
50
|
+
? playSource.playSourceCacheId
|
|
51
|
+
: playSource.playsourcacheid,
|
|
44
52
|
};
|
|
45
53
|
}
|
|
46
54
|
else if (playSource.kind === "ssmlSource") {
|
|
@@ -51,6 +59,9 @@ class CallMedia {
|
|
|
51
59
|
return {
|
|
52
60
|
kind: index_js_2.KnownPlaySourceType.Ssml,
|
|
53
61
|
ssml: ssmlSource,
|
|
62
|
+
playSourceCacheId: playSource.playSourceCacheId
|
|
63
|
+
? playSource.playSourceCacheId
|
|
64
|
+
: playSource.playsourcacheid,
|
|
54
65
|
};
|
|
55
66
|
}
|
|
56
67
|
throw new Error("Invalid play source");
|
|
@@ -65,7 +76,7 @@ class CallMedia {
|
|
|
65
76
|
async play(playSources, playTo, options = { loop: false }) {
|
|
66
77
|
const playRequest = {
|
|
67
78
|
playSources: playSources.map((source) => this.createPlaySourceInternal(source)),
|
|
68
|
-
playTo: playTo.map((identifier) => (0,
|
|
79
|
+
playTo: playTo.map((identifier) => (0, communication_common_1.serializeCommunicationIdentifier)(identifier)),
|
|
69
80
|
playOptions: {
|
|
70
81
|
loop: false,
|
|
71
82
|
},
|
|
@@ -76,7 +87,7 @@ class CallMedia {
|
|
|
76
87
|
playRequest.playOptions = playRequest.playOptions || { loop: false }; // Ensure playOptions is defined
|
|
77
88
|
playRequest.playOptions.loop = options.loop;
|
|
78
89
|
}
|
|
79
|
-
|
|
90
|
+
await this.callMedia.play(this.callConnectionId, playRequest, options);
|
|
80
91
|
}
|
|
81
92
|
/**
|
|
82
93
|
* Play to all participants.
|
|
@@ -101,10 +112,10 @@ class CallMedia {
|
|
|
101
112
|
if (options.interruptCallMediaOperation !== undefined) {
|
|
102
113
|
playRequest.playOptions = playRequest.playOptions || {
|
|
103
114
|
loop: false,
|
|
104
|
-
};
|
|
115
|
+
}; // Ensure playOptions is defined
|
|
105
116
|
playRequest.interruptCallMediaOperation = options.interruptCallMediaOperation;
|
|
106
117
|
}
|
|
107
|
-
|
|
118
|
+
await this.callMedia.play(this.callConnectionId, playRequest, options);
|
|
108
119
|
}
|
|
109
120
|
createRecognizeRequest(targetParticipant, recognizeOptions) {
|
|
110
121
|
if (recognizeOptions.kind === "callMediaRecognizeDtmfOptions") {
|
|
@@ -120,7 +131,7 @@ class CallMedia {
|
|
|
120
131
|
initialSilenceTimeoutInSeconds: recognizeOptions.initialSilenceTimeoutInSeconds
|
|
121
132
|
? recognizeOptions.initialSilenceTimeoutInSeconds
|
|
122
133
|
: 5,
|
|
123
|
-
targetParticipant: (0,
|
|
134
|
+
targetParticipant: (0, communication_common_1.serializeCommunicationIdentifier)(targetParticipant),
|
|
124
135
|
dtmfOptions: dtmfOptionsInternal,
|
|
125
136
|
};
|
|
126
137
|
return {
|
|
@@ -143,7 +154,7 @@ class CallMedia {
|
|
|
143
154
|
initialSilenceTimeoutInSeconds: recognizeOptions.initialSilenceTimeoutInSeconds
|
|
144
155
|
? recognizeOptions.initialSilenceTimeoutInSeconds
|
|
145
156
|
: 5,
|
|
146
|
-
targetParticipant: (0,
|
|
157
|
+
targetParticipant: (0, communication_common_1.serializeCommunicationIdentifier)(targetParticipant),
|
|
147
158
|
speechLanguage: recognizeOptions.speechLanguage,
|
|
148
159
|
speechRecognitionModelEndpointId: recognizeOptions.speechRecognitionModelEndpointId,
|
|
149
160
|
choices: recognizeOptions.choices,
|
|
@@ -173,7 +184,7 @@ class CallMedia {
|
|
|
173
184
|
initialSilenceTimeoutInSeconds: recognizeOptions.initialSilenceTimeoutInSeconds
|
|
174
185
|
? recognizeOptions.initialSilenceTimeoutInSeconds
|
|
175
186
|
: 5,
|
|
176
|
-
targetParticipant: (0,
|
|
187
|
+
targetParticipant: (0, communication_common_1.serializeCommunicationIdentifier)(targetParticipant),
|
|
177
188
|
speechOptions: speechOptions,
|
|
178
189
|
speechLanguage: recognizeOptions.speechLanguage,
|
|
179
190
|
speechRecognitionModelEndpointId: recognizeOptions.speechRecognitionModelEndpointId,
|
|
@@ -210,7 +221,7 @@ class CallMedia {
|
|
|
210
221
|
initialSilenceTimeoutInSeconds: recognizeOptions.initialSilenceTimeoutInSeconds
|
|
211
222
|
? recognizeOptions.initialSilenceTimeoutInSeconds
|
|
212
223
|
: 5,
|
|
213
|
-
targetParticipant: (0,
|
|
224
|
+
targetParticipant: (0, communication_common_1.serializeCommunicationIdentifier)(targetParticipant),
|
|
214
225
|
speechOptions: speechOptions,
|
|
215
226
|
dtmfOptions: dtmfOptionsInternal,
|
|
216
227
|
speechRecognitionModelEndpointId: recognizeOptions.speechRecognitionModelEndpointId,
|
|
@@ -236,7 +247,7 @@ class CallMedia {
|
|
|
236
247
|
// Old function signature logic
|
|
237
248
|
console.warn("Deprecated function signature used. Please use the new signature with targetParticipant and options params instead, and set maxTonesToCollect in options.");
|
|
238
249
|
options.maxTonesToCollect = maxTonesOrOptions;
|
|
239
|
-
|
|
250
|
+
return this.callMedia.recognize(this.callConnectionId, this.createRecognizeRequest(targetParticipant, options), {});
|
|
240
251
|
}
|
|
241
252
|
else if (typeof maxTonesOrOptions !== "number" && !options) {
|
|
242
253
|
maxTonesOrOptions.operationContext = maxTonesOrOptions.operationContext
|
|
@@ -251,7 +262,7 @@ class CallMedia {
|
|
|
251
262
|
* Cancels all the queued media operations.
|
|
252
263
|
*/
|
|
253
264
|
async cancelAllOperations() {
|
|
254
|
-
|
|
265
|
+
await this.callMedia.cancelAllMediaOperations(this.callConnectionId, {});
|
|
255
266
|
}
|
|
256
267
|
/**
|
|
257
268
|
* Start continuous Dtmf recognition by subscribing to tones.
|
|
@@ -260,7 +271,7 @@ class CallMedia {
|
|
|
260
271
|
* */
|
|
261
272
|
async startContinuousDtmfRecognition(targetParticipant, options = {}) {
|
|
262
273
|
const continuousDtmfRecognitionRequest = {
|
|
263
|
-
targetParticipant: (0,
|
|
274
|
+
targetParticipant: (0, communication_common_1.serializeCommunicationIdentifier)(targetParticipant),
|
|
264
275
|
operationContext: options.operationContext,
|
|
265
276
|
};
|
|
266
277
|
return this.callMedia.startContinuousDtmfRecognition(this.callConnectionId, continuousDtmfRecognitionRequest, {});
|
|
@@ -272,7 +283,7 @@ class CallMedia {
|
|
|
272
283
|
* */
|
|
273
284
|
async stopContinuousDtmfRecognition(targetParticipant, options = {}) {
|
|
274
285
|
const continuousDtmfRecognitionRequest = {
|
|
275
|
-
targetParticipant: (0,
|
|
286
|
+
targetParticipant: (0, communication_common_1.serializeCommunicationIdentifier)(targetParticipant),
|
|
276
287
|
operationContext: options.operationContext,
|
|
277
288
|
operationCallbackUri: options.operationCallbackUrl,
|
|
278
289
|
};
|
|
@@ -287,13 +298,19 @@ class CallMedia {
|
|
|
287
298
|
async sendDtmfTones(tones, targetParticipant, options = {}) {
|
|
288
299
|
const sendDtmfTonesRequest = {
|
|
289
300
|
tones: tones,
|
|
290
|
-
targetParticipant: (0,
|
|
301
|
+
targetParticipant: (0, communication_common_1.serializeCommunicationIdentifier)(targetParticipant),
|
|
291
302
|
operationContext: options.operationContext,
|
|
292
303
|
operationCallbackUri: options.operationCallbackUrl,
|
|
293
304
|
};
|
|
294
|
-
const optionsInternal =
|
|
305
|
+
const optionsInternal = {
|
|
306
|
+
...options,
|
|
307
|
+
repeatabilityFirstSent: new Date(),
|
|
308
|
+
repeatabilityRequestID: (0, core_util_1.randomUUID)(),
|
|
309
|
+
};
|
|
295
310
|
const result = await this.callMedia.sendDtmfTones(this.callConnectionId, sendDtmfTonesRequest, optionsInternal);
|
|
296
|
-
const sendDtmfTonesResult =
|
|
311
|
+
const sendDtmfTonesResult = {
|
|
312
|
+
...result,
|
|
313
|
+
};
|
|
297
314
|
return sendDtmfTonesResult;
|
|
298
315
|
}
|
|
299
316
|
/**
|
|
@@ -304,7 +321,7 @@ class CallMedia {
|
|
|
304
321
|
*/
|
|
305
322
|
async hold(targetParticipant, options = {}) {
|
|
306
323
|
const holdRequest = {
|
|
307
|
-
targetParticipant: (0,
|
|
324
|
+
targetParticipant: (0, communication_common_1.serializeCommunicationIdentifier)(targetParticipant),
|
|
308
325
|
playSourceInfo: options.playSource !== undefined
|
|
309
326
|
? this.createPlaySourceInternal(options.playSource)
|
|
310
327
|
: undefined,
|
|
@@ -321,8 +338,9 @@ class CallMedia {
|
|
|
321
338
|
*/
|
|
322
339
|
async unhold(targetParticipant, options = {}) {
|
|
323
340
|
const unholdRequest = {
|
|
324
|
-
targetParticipant: (0,
|
|
341
|
+
targetParticipant: (0, communication_common_1.serializeCommunicationIdentifier)(targetParticipant),
|
|
325
342
|
operationContext: options.operationContext !== undefined ? options.operationContext : undefined,
|
|
343
|
+
operationCallbackUri: options.operationCallbackUrl !== undefined ? options.operationCallbackUrl : undefined,
|
|
326
344
|
};
|
|
327
345
|
return this.callMedia.unhold(this.callConnectionId, unholdRequest);
|
|
328
346
|
}
|
|
@@ -334,7 +352,8 @@ class CallMedia {
|
|
|
334
352
|
const startTranscriptionRequest = {
|
|
335
353
|
locale: options.locale,
|
|
336
354
|
operationContext: options.operationContext,
|
|
337
|
-
|
|
355
|
+
speechModelEndpointId: options.speechRecognitionModelEndpointId,
|
|
356
|
+
operationCallbackUri: options.operationCallbackUrl,
|
|
338
357
|
};
|
|
339
358
|
return this.callMedia.startTranscription(this.callConnectionId, startTranscriptionRequest, {});
|
|
340
359
|
}
|
|
@@ -345,6 +364,7 @@ class CallMedia {
|
|
|
345
364
|
async stopTranscription(options = {}) {
|
|
346
365
|
const stopTranscriptionRequest = {
|
|
347
366
|
operationContext: options.operationContext,
|
|
367
|
+
operationCallbackUri: options.operationCallbackUrl,
|
|
348
368
|
};
|
|
349
369
|
return this.callMedia.stopTranscription(this.callConnectionId, stopTranscriptionRequest, {});
|
|
350
370
|
}
|
|
@@ -355,8 +375,9 @@ class CallMedia {
|
|
|
355
375
|
async updateTranscription(locale, options) {
|
|
356
376
|
const updateTranscriptionRequest = {
|
|
357
377
|
locale: locale,
|
|
358
|
-
|
|
359
|
-
operationContext: options
|
|
378
|
+
speechModelEndpointId: options?.speechRecognitionModelEndpointId,
|
|
379
|
+
operationContext: options?.operationContext,
|
|
380
|
+
operationCallbackUri: options?.operationCallbackUrl,
|
|
360
381
|
};
|
|
361
382
|
return this.callMedia.updateTranscription(this.callConnectionId, updateTranscriptionRequest, {});
|
|
362
383
|
}
|