@azure/communication-call-automation 1.5.0-beta.2 → 1.5.0

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.
Files changed (281) hide show
  1. package/README.md +3 -1
  2. package/dist/browser/callAutomationClient.d.ts +2 -3
  3. package/dist/browser/callAutomationClient.d.ts.map +1 -1
  4. package/dist/browser/callAutomationClient.js +79 -31
  5. package/dist/browser/callAutomationClient.js.map +1 -1
  6. package/dist/browser/callAutomationEventParser.d.ts.map +1 -1
  7. package/dist/browser/callAutomationEventParser.js +9 -10
  8. package/dist/browser/callAutomationEventParser.js.map +1 -1
  9. package/dist/browser/callConnection.d.ts +1 -1
  10. package/dist/browser/callConnection.d.ts.map +1 -1
  11. package/dist/browser/callConnection.js +82 -38
  12. package/dist/browser/callConnection.js.map +1 -1
  13. package/dist/browser/callMedia.d.ts +1 -1
  14. package/dist/browser/callMedia.d.ts.map +1 -1
  15. package/dist/browser/callMedia.js +33 -12
  16. package/dist/browser/callMedia.js.map +1 -1
  17. package/dist/browser/callRecording.js +11 -6
  18. package/dist/browser/callRecording.js.map +1 -1
  19. package/dist/browser/contentDownloader.js +11 -12
  20. package/dist/browser/contentDownloader.js.map +1 -1
  21. package/dist/browser/credential/callAutomationAccessKeyCredentialPolicy.js +1 -2
  22. package/dist/browser/credential/callAutomationAccessKeyCredentialPolicy.js.map +1 -1
  23. package/dist/browser/credential/callAutomationAuthPolicy.js +1 -1
  24. package/dist/browser/credential/callAutomationAuthPolicy.js.map +1 -1
  25. package/dist/browser/credential/cryptoUtils-browser.mjs.map +1 -1
  26. package/dist/browser/credential/cryptoUtils.js +1 -2
  27. package/dist/browser/generated/src/callAutomationApiClient.js +14 -5
  28. package/dist/browser/generated/src/callAutomationApiClient.js.map +1 -1
  29. package/dist/browser/generated/src/models/index.d.ts +305 -322
  30. package/dist/browser/generated/src/models/index.d.ts.map +1 -1
  31. package/dist/browser/generated/src/models/index.js +29 -35
  32. package/dist/browser/generated/src/models/index.js.map +1 -1
  33. package/dist/browser/generated/src/models/mappers.d.ts +41 -34
  34. package/dist/browser/generated/src/models/mappers.d.ts.map +1 -1
  35. package/dist/browser/generated/src/models/mappers.js +481 -462
  36. package/dist/browser/generated/src/models/mappers.js.map +1 -1
  37. package/dist/browser/generated/src/models/parameters.js +1 -1
  38. package/dist/browser/generated/src/models/parameters.js.map +1 -1
  39. package/dist/browser/generated/src/operations/callConnection.js +23 -40
  40. package/dist/browser/generated/src/operations/callConnection.js.map +1 -1
  41. package/dist/browser/generated/src/operations/callMedia.js +1 -0
  42. package/dist/browser/generated/src/operations/callMedia.js.map +1 -1
  43. package/dist/browser/generated/src/operations/callRecording.js +1 -0
  44. package/dist/browser/generated/src/operations/callRecording.js.map +1 -1
  45. package/dist/browser/generated/src/pagingHelper.js +2 -4
  46. package/dist/browser/generated/src/pagingHelper.js.map +1 -1
  47. package/dist/browser/models/constants.d.ts.map +1 -1
  48. package/dist/browser/models/constants.js +1 -1
  49. package/dist/browser/models/constants.js.map +1 -1
  50. package/dist/browser/models/events.d.ts +295 -209
  51. package/dist/browser/models/events.d.ts.map +1 -1
  52. package/dist/browser/models/events.js.map +1 -1
  53. package/dist/browser/models/models.d.ts +44 -4
  54. package/dist/browser/models/models.d.ts.map +1 -1
  55. package/dist/browser/models/models.js +1 -1
  56. package/dist/browser/models/models.js.map +1 -1
  57. package/dist/browser/models/options.d.ts +17 -0
  58. package/dist/browser/models/options.d.ts.map +1 -1
  59. package/dist/browser/models/options.js.map +1 -1
  60. package/dist/browser/models/responses.d.ts +1 -1
  61. package/dist/browser/models/responses.d.ts.map +1 -1
  62. package/dist/browser/models/responses.js.map +1 -1
  63. package/dist/browser/models/streaming.d.ts +26 -27
  64. package/dist/browser/models/streaming.d.ts.map +1 -1
  65. package/dist/browser/models/streaming.js +28 -57
  66. package/dist/browser/models/streaming.js.map +1 -1
  67. package/dist/browser/streamingData.d.ts.map +1 -1
  68. package/dist/browser/streamingData.js +10 -1
  69. package/dist/browser/streamingData.js.map +1 -1
  70. package/dist/browser/utli/converters.d.ts.map +1 -1
  71. package/dist/browser/utli/converters.js +30 -9
  72. package/dist/browser/utli/converters.js.map +1 -1
  73. package/dist/commonjs/callAutomationClient.d.ts +2 -3
  74. package/dist/commonjs/callAutomationClient.d.ts.map +1 -1
  75. package/dist/commonjs/callAutomationClient.js +79 -31
  76. package/dist/commonjs/callAutomationClient.js.map +1 -1
  77. package/dist/commonjs/callAutomationEventParser.d.ts.map +1 -1
  78. package/dist/commonjs/callAutomationEventParser.js +9 -10
  79. package/dist/commonjs/callAutomationEventParser.js.map +1 -1
  80. package/dist/commonjs/callConnection.d.ts +1 -1
  81. package/dist/commonjs/callConnection.d.ts.map +1 -1
  82. package/dist/commonjs/callConnection.js +82 -38
  83. package/dist/commonjs/callConnection.js.map +1 -1
  84. package/dist/commonjs/callMedia.d.ts +1 -1
  85. package/dist/commonjs/callMedia.d.ts.map +1 -1
  86. package/dist/commonjs/callMedia.js +42 -21
  87. package/dist/commonjs/callMedia.js.map +1 -1
  88. package/dist/commonjs/callRecording.js +12 -7
  89. package/dist/commonjs/callRecording.js.map +1 -1
  90. package/dist/commonjs/contentDownloader.js +11 -12
  91. package/dist/commonjs/contentDownloader.js.map +1 -1
  92. package/dist/commonjs/credential/callAutomationAccessKeyCredentialPolicy.js +1 -2
  93. package/dist/commonjs/credential/callAutomationAccessKeyCredentialPolicy.js.map +1 -1
  94. package/dist/commonjs/credential/callAutomationAuthPolicy.js +1 -1
  95. package/dist/commonjs/credential/callAutomationAuthPolicy.js.map +1 -1
  96. package/dist/commonjs/generated/src/callAutomationApiClient.js +14 -5
  97. package/dist/commonjs/generated/src/callAutomationApiClient.js.map +1 -1
  98. package/dist/commonjs/generated/src/models/index.d.ts +305 -322
  99. package/dist/commonjs/generated/src/models/index.d.ts.map +1 -1
  100. package/dist/commonjs/generated/src/models/index.js +30 -36
  101. package/dist/commonjs/generated/src/models/index.js.map +1 -1
  102. package/dist/commonjs/generated/src/models/mappers.d.ts +41 -34
  103. package/dist/commonjs/generated/src/models/mappers.d.ts.map +1 -1
  104. package/dist/commonjs/generated/src/models/mappers.js +484 -465
  105. package/dist/commonjs/generated/src/models/mappers.js.map +1 -1
  106. package/dist/commonjs/generated/src/models/parameters.js +1 -1
  107. package/dist/commonjs/generated/src/models/parameters.js.map +1 -1
  108. package/dist/commonjs/generated/src/operations/callConnection.js +23 -39
  109. package/dist/commonjs/generated/src/operations/callConnection.js.map +1 -1
  110. package/dist/commonjs/generated/src/operations/callMedia.js +1 -0
  111. package/dist/commonjs/generated/src/operations/callMedia.js.map +1 -1
  112. package/dist/commonjs/generated/src/operations/callRecording.js +1 -0
  113. package/dist/commonjs/generated/src/operations/callRecording.js.map +1 -1
  114. package/dist/commonjs/generated/src/pagingHelper.js +2 -4
  115. package/dist/commonjs/generated/src/pagingHelper.js.map +1 -1
  116. package/dist/commonjs/models/constants.d.ts.map +1 -1
  117. package/dist/commonjs/models/constants.js +1 -1
  118. package/dist/commonjs/models/constants.js.map +1 -1
  119. package/dist/commonjs/models/events.d.ts +295 -209
  120. package/dist/commonjs/models/events.d.ts.map +1 -1
  121. package/dist/commonjs/models/events.js.map +1 -1
  122. package/dist/commonjs/models/models.d.ts +44 -4
  123. package/dist/commonjs/models/models.d.ts.map +1 -1
  124. package/dist/commonjs/models/models.js +2 -16
  125. package/dist/commonjs/models/models.js.map +1 -1
  126. package/dist/commonjs/models/options.d.ts +17 -0
  127. package/dist/commonjs/models/options.d.ts.map +1 -1
  128. package/dist/commonjs/models/options.js.map +1 -1
  129. package/dist/commonjs/models/responses.d.ts +1 -1
  130. package/dist/commonjs/models/responses.d.ts.map +1 -1
  131. package/dist/commonjs/models/responses.js.map +1 -1
  132. package/dist/commonjs/models/streaming.d.ts +26 -27
  133. package/dist/commonjs/models/streaming.d.ts.map +1 -1
  134. package/dist/commonjs/models/streaming.js +31 -59
  135. package/dist/commonjs/models/streaming.js.map +1 -1
  136. package/dist/commonjs/streamingData.d.ts.map +1 -1
  137. package/dist/commonjs/streamingData.js +10 -1
  138. package/dist/commonjs/streamingData.js.map +1 -1
  139. package/dist/commonjs/tsdoc-metadata.json +11 -11
  140. package/dist/commonjs/utli/converters.d.ts.map +1 -1
  141. package/dist/commonjs/utli/converters.js +30 -9
  142. package/dist/commonjs/utli/converters.js.map +1 -1
  143. package/dist/esm/callAutomationClient.d.ts +2 -3
  144. package/dist/esm/callAutomationClient.d.ts.map +1 -1
  145. package/dist/esm/callAutomationClient.js +79 -31
  146. package/dist/esm/callAutomationClient.js.map +1 -1
  147. package/dist/esm/callAutomationEventParser.d.ts.map +1 -1
  148. package/dist/esm/callAutomationEventParser.js +9 -10
  149. package/dist/esm/callAutomationEventParser.js.map +1 -1
  150. package/dist/esm/callConnection.d.ts +1 -1
  151. package/dist/esm/callConnection.d.ts.map +1 -1
  152. package/dist/esm/callConnection.js +82 -38
  153. package/dist/esm/callConnection.js.map +1 -1
  154. package/dist/esm/callMedia.d.ts +1 -1
  155. package/dist/esm/callMedia.d.ts.map +1 -1
  156. package/dist/esm/callMedia.js +33 -12
  157. package/dist/esm/callMedia.js.map +1 -1
  158. package/dist/esm/callRecording.js +11 -6
  159. package/dist/esm/callRecording.js.map +1 -1
  160. package/dist/esm/contentDownloader.js +11 -12
  161. package/dist/esm/contentDownloader.js.map +1 -1
  162. package/dist/esm/credential/callAutomationAccessKeyCredentialPolicy.js +1 -2
  163. package/dist/esm/credential/callAutomationAccessKeyCredentialPolicy.js.map +1 -1
  164. package/dist/esm/credential/callAutomationAuthPolicy.js +1 -1
  165. package/dist/esm/credential/callAutomationAuthPolicy.js.map +1 -1
  166. package/dist/esm/generated/src/callAutomationApiClient.js +14 -5
  167. package/dist/esm/generated/src/callAutomationApiClient.js.map +1 -1
  168. package/dist/esm/generated/src/models/index.d.ts +305 -322
  169. package/dist/esm/generated/src/models/index.d.ts.map +1 -1
  170. package/dist/esm/generated/src/models/index.js +29 -35
  171. package/dist/esm/generated/src/models/index.js.map +1 -1
  172. package/dist/esm/generated/src/models/mappers.d.ts +41 -34
  173. package/dist/esm/generated/src/models/mappers.d.ts.map +1 -1
  174. package/dist/esm/generated/src/models/mappers.js +481 -462
  175. package/dist/esm/generated/src/models/mappers.js.map +1 -1
  176. package/dist/esm/generated/src/models/parameters.js +1 -1
  177. package/dist/esm/generated/src/models/parameters.js.map +1 -1
  178. package/dist/esm/generated/src/operations/callConnection.js +23 -40
  179. package/dist/esm/generated/src/operations/callConnection.js.map +1 -1
  180. package/dist/esm/generated/src/operations/callMedia.js +1 -0
  181. package/dist/esm/generated/src/operations/callMedia.js.map +1 -1
  182. package/dist/esm/generated/src/operations/callRecording.js +1 -0
  183. package/dist/esm/generated/src/operations/callRecording.js.map +1 -1
  184. package/dist/esm/generated/src/pagingHelper.js +2 -4
  185. package/dist/esm/generated/src/pagingHelper.js.map +1 -1
  186. package/dist/esm/models/constants.d.ts.map +1 -1
  187. package/dist/esm/models/constants.js +1 -1
  188. package/dist/esm/models/constants.js.map +1 -1
  189. package/dist/esm/models/events.d.ts +295 -209
  190. package/dist/esm/models/events.d.ts.map +1 -1
  191. package/dist/esm/models/events.js.map +1 -1
  192. package/dist/esm/models/models.d.ts +44 -4
  193. package/dist/esm/models/models.d.ts.map +1 -1
  194. package/dist/esm/models/models.js +1 -1
  195. package/dist/esm/models/models.js.map +1 -1
  196. package/dist/esm/models/options.d.ts +17 -0
  197. package/dist/esm/models/options.d.ts.map +1 -1
  198. package/dist/esm/models/options.js.map +1 -1
  199. package/dist/esm/models/responses.d.ts +1 -1
  200. package/dist/esm/models/responses.d.ts.map +1 -1
  201. package/dist/esm/models/responses.js.map +1 -1
  202. package/dist/esm/models/streaming.d.ts +26 -27
  203. package/dist/esm/models/streaming.d.ts.map +1 -1
  204. package/dist/esm/models/streaming.js +28 -57
  205. package/dist/esm/models/streaming.js.map +1 -1
  206. package/dist/esm/streamingData.d.ts.map +1 -1
  207. package/dist/esm/streamingData.js +10 -1
  208. package/dist/esm/streamingData.js.map +1 -1
  209. package/dist/esm/utli/converters.d.ts.map +1 -1
  210. package/dist/esm/utli/converters.js +30 -9
  211. package/dist/esm/utli/converters.js.map +1 -1
  212. package/dist/react-native/callAutomationClient.d.ts +2 -3
  213. package/dist/react-native/callAutomationClient.d.ts.map +1 -1
  214. package/dist/react-native/callAutomationClient.js +79 -31
  215. package/dist/react-native/callAutomationClient.js.map +1 -1
  216. package/dist/react-native/callAutomationEventParser.d.ts.map +1 -1
  217. package/dist/react-native/callAutomationEventParser.js +9 -10
  218. package/dist/react-native/callAutomationEventParser.js.map +1 -1
  219. package/dist/react-native/callConnection.d.ts +1 -1
  220. package/dist/react-native/callConnection.d.ts.map +1 -1
  221. package/dist/react-native/callConnection.js +82 -38
  222. package/dist/react-native/callConnection.js.map +1 -1
  223. package/dist/react-native/callMedia.d.ts +1 -1
  224. package/dist/react-native/callMedia.d.ts.map +1 -1
  225. package/dist/react-native/callMedia.js +33 -12
  226. package/dist/react-native/callMedia.js.map +1 -1
  227. package/dist/react-native/callRecording.js +11 -6
  228. package/dist/react-native/callRecording.js.map +1 -1
  229. package/dist/react-native/contentDownloader.js +11 -12
  230. package/dist/react-native/contentDownloader.js.map +1 -1
  231. package/dist/react-native/credential/callAutomationAccessKeyCredentialPolicy.js +1 -2
  232. package/dist/react-native/credential/callAutomationAccessKeyCredentialPolicy.js.map +1 -1
  233. package/dist/react-native/credential/callAutomationAuthPolicy.js +1 -1
  234. package/dist/react-native/credential/callAutomationAuthPolicy.js.map +1 -1
  235. package/dist/react-native/generated/src/callAutomationApiClient.js +14 -5
  236. package/dist/react-native/generated/src/callAutomationApiClient.js.map +1 -1
  237. package/dist/react-native/generated/src/models/index.d.ts +305 -322
  238. package/dist/react-native/generated/src/models/index.d.ts.map +1 -1
  239. package/dist/react-native/generated/src/models/index.js +29 -35
  240. package/dist/react-native/generated/src/models/index.js.map +1 -1
  241. package/dist/react-native/generated/src/models/mappers.d.ts +41 -34
  242. package/dist/react-native/generated/src/models/mappers.d.ts.map +1 -1
  243. package/dist/react-native/generated/src/models/mappers.js +481 -462
  244. package/dist/react-native/generated/src/models/mappers.js.map +1 -1
  245. package/dist/react-native/generated/src/models/parameters.js +1 -1
  246. package/dist/react-native/generated/src/models/parameters.js.map +1 -1
  247. package/dist/react-native/generated/src/operations/callConnection.js +23 -40
  248. package/dist/react-native/generated/src/operations/callConnection.js.map +1 -1
  249. package/dist/react-native/generated/src/operations/callMedia.js +1 -0
  250. package/dist/react-native/generated/src/operations/callMedia.js.map +1 -1
  251. package/dist/react-native/generated/src/operations/callRecording.js +1 -0
  252. package/dist/react-native/generated/src/operations/callRecording.js.map +1 -1
  253. package/dist/react-native/generated/src/pagingHelper.js +2 -4
  254. package/dist/react-native/generated/src/pagingHelper.js.map +1 -1
  255. package/dist/react-native/models/constants.d.ts.map +1 -1
  256. package/dist/react-native/models/constants.js +1 -1
  257. package/dist/react-native/models/constants.js.map +1 -1
  258. package/dist/react-native/models/events.d.ts +295 -209
  259. package/dist/react-native/models/events.d.ts.map +1 -1
  260. package/dist/react-native/models/events.js.map +1 -1
  261. package/dist/react-native/models/models.d.ts +44 -4
  262. package/dist/react-native/models/models.d.ts.map +1 -1
  263. package/dist/react-native/models/models.js +1 -1
  264. package/dist/react-native/models/models.js.map +1 -1
  265. package/dist/react-native/models/options.d.ts +17 -0
  266. package/dist/react-native/models/options.d.ts.map +1 -1
  267. package/dist/react-native/models/options.js.map +1 -1
  268. package/dist/react-native/models/responses.d.ts +1 -1
  269. package/dist/react-native/models/responses.d.ts.map +1 -1
  270. package/dist/react-native/models/responses.js.map +1 -1
  271. package/dist/react-native/models/streaming.d.ts +26 -27
  272. package/dist/react-native/models/streaming.d.ts.map +1 -1
  273. package/dist/react-native/models/streaming.js +28 -57
  274. package/dist/react-native/models/streaming.js.map +1 -1
  275. package/dist/react-native/streamingData.d.ts.map +1 -1
  276. package/dist/react-native/streamingData.js +10 -1
  277. package/dist/react-native/streamingData.js.map +1 -1
  278. package/dist/react-native/utli/converters.d.ts.map +1 -1
  279. package/dist/react-native/utli/converters.js +30 -9
  280. package/dist/react-native/utli/converters.js.map +1 -1
  281. package/package.json +37 -44
@@ -1,6 +1,5 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT License.
3
- import { __asyncValues, __rest } from "tslib";
4
3
  import { createCommunicationAuthPolicy, } from "@azure/communication-common";
5
4
  import { CallMedia } from "./callMedia.js";
6
5
  import { CallAutomationApiClient, } from "./generated/src/index.js";
@@ -11,6 +10,12 @@ import { randomUUID } from "@azure/core-util";
11
10
  * CallConnection class represents call connection based APIs.
12
11
  */
13
12
  export class CallConnection {
13
+ callConnectionId;
14
+ callConnection;
15
+ callAutomationApiClient;
16
+ endpoint;
17
+ credential;
18
+ callAutomationApiClientOptions;
14
19
  constructor(callConnectionId, endpoint, credential, options) {
15
20
  this.callAutomationApiClient = new CallAutomationApiClient(endpoint, options);
16
21
  const authPolicy = createCommunicationAuthPolicy(credential);
@@ -31,10 +36,17 @@ export class CallConnection {
31
36
  * Get call connection properties of the call
32
37
  */
33
38
  async getCallConnectionProperties(options = {}) {
34
- const _a = await this.callConnection.getCall(this.callConnectionId, options), { targets, sourceCallerIdNumber, answeredBy, source, answeredFor } = _a, result = __rest(_a, ["targets", "sourceCallerIdNumber", "answeredBy", "source", "answeredFor"]);
35
- const callConnectionProperties = Object.assign(Object.assign({}, result), { source: source ? communicationIdentifierConverter(source) : undefined, answeredby: communicationUserIdentifierConverter(answeredBy), answeredFor: answeredFor ? phoneNumberIdentifierConverter(answeredFor) : undefined, targetParticipants: targets === null || targets === void 0 ? void 0 : targets.map((target) => communicationIdentifierConverter(target)), sourceCallerIdNumber: sourceCallerIdNumber
39
+ const { targets, sourceCallerIdNumber, answeredBy, source, answeredFor, ...result } = await this.callConnection.getCall(this.callConnectionId, options);
40
+ const callConnectionProperties = {
41
+ ...result,
42
+ source: source ? communicationIdentifierConverter(source) : undefined,
43
+ answeredby: communicationUserIdentifierConverter(answeredBy),
44
+ answeredFor: answeredFor ? phoneNumberIdentifierConverter(answeredFor) : undefined,
45
+ targetParticipants: targets?.map((target) => communicationIdentifierConverter(target)),
46
+ sourceCallerIdNumber: sourceCallerIdNumber
36
47
  ? phoneNumberIdentifierConverter(sourceCallerIdNumber)
37
- : undefined });
48
+ : undefined,
49
+ };
38
50
  return callConnectionProperties;
39
51
  }
40
52
  /**
@@ -44,7 +56,11 @@ export class CallConnection {
44
56
  */
45
57
  async hangUp(isForEveryone, options = {}) {
46
58
  if (isForEveryone) {
47
- const optionsInternal = Object.assign(Object.assign({}, options), { repeatabilityFirstSent: new Date(), repeatabilityRequestID: randomUUID() });
59
+ const optionsInternal = {
60
+ ...options,
61
+ repeatabilityFirstSent: new Date(),
62
+ repeatabilityRequestID: randomUUID(),
63
+ };
48
64
  await this.callConnection.terminateCall(this.callConnectionId, optionsInternal);
49
65
  }
50
66
  else {
@@ -74,28 +90,18 @@ export class CallConnection {
74
90
  * Get all participants from the call
75
91
  */
76
92
  async listParticipants(options = {}) {
77
- var _a, e_1, _b, _c;
78
93
  const result = this.callConnection.listParticipants(this.callConnectionId, options);
79
94
  const participants = [];
80
- const pages = result === null || result === void 0 ? void 0 : result.byPage();
81
- try {
82
- for (var _d = true, pages_1 = __asyncValues(pages), pages_1_1; pages_1_1 = await pages_1.next(), _a = pages_1_1.done, !_a; _d = true) {
83
- _c = pages_1_1.value;
84
- _d = false;
85
- const page = _c;
86
- for (const participant of page) {
87
- participants.push(callParticipantConverter(participant));
88
- }
89
- }
90
- }
91
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
92
- finally {
93
- try {
94
- if (!_d && !_a && (_b = pages_1.return)) await _b.call(pages_1);
95
+ const pages = result?.byPage();
96
+ for await (const page of pages) {
97
+ for (const participant of page) {
98
+ participants.push(callParticipantConverter(participant));
95
99
  }
96
- finally { if (e_1) throw e_1.error; }
97
100
  }
98
- const listParticipantResponse = Object.assign(Object.assign({}, result), { values: participants });
101
+ const listParticipantResponse = {
102
+ ...result,
103
+ values: participants,
104
+ };
99
105
  return listParticipantResponse;
100
106
  }
101
107
  createCustomCallingContextInternal(customCallingContext) {
@@ -107,7 +113,12 @@ export class CallConnection {
107
113
  sipHeaders[`User-To-User`] = header.value;
108
114
  }
109
115
  else if (header.kind === "sipx") {
110
- sipHeaders[`X-MS-Custom-${header.key}`] = header.value;
116
+ if (header.sipHeaderPrefix === "X-") {
117
+ sipHeaders[`X-${header.key}`] = header.value;
118
+ }
119
+ else {
120
+ sipHeaders[`X-MS-Custom-${header.key}`] = header.value;
121
+ }
111
122
  }
112
123
  else if (header.kind === "voip") {
113
124
  voipHeaders[`${header.key}`] = header.value;
@@ -122,7 +133,6 @@ export class CallConnection {
122
133
  * @param participant - The participant is going to be added.
123
134
  */
124
135
  async addParticipant(targetParticipant, options = {}) {
125
- var _a, _b;
126
136
  const addParticipantRequest = {
127
137
  participantToAdd: communicationIdentifierModelConverter(targetParticipant.targetParticipant),
128
138
  sourceCallerIdNumber: PhoneNumberIdentifierModelConverter(targetParticipant.sourceCallIdNumber),
@@ -132,11 +142,21 @@ export class CallConnection {
132
142
  operationCallbackUri: options.operationCallbackUrl,
133
143
  customCallingContext: this.createCustomCallingContextInternal(targetParticipant.customCallingContext),
134
144
  };
135
- const optionsInternal = Object.assign(Object.assign({}, options), { repeatabilityFirstSent: new Date(), repeatabilityRequestID: randomUUID() });
145
+ const optionsInternal = {
146
+ ...options,
147
+ repeatabilityFirstSent: new Date(),
148
+ repeatabilityRequestID: randomUUID(),
149
+ };
136
150
  const result = await this.callConnection.addParticipant(this.callConnectionId, addParticipantRequest, optionsInternal);
137
- const addParticipantsResult = Object.assign(Object.assign({}, result), { participant: Object.assign(Object.assign({}, result.participant), { identifier: ((_a = result.participant) === null || _a === void 0 ? void 0 : _a.identifier)
138
- ? communicationIdentifierConverter((_b = result.participant) === null || _b === void 0 ? void 0 : _b.identifier)
139
- : undefined }) });
151
+ const addParticipantsResult = {
152
+ ...result,
153
+ participant: {
154
+ ...result.participant,
155
+ identifier: result.participant?.identifier
156
+ ? communicationIdentifierConverter(result.participant?.identifier)
157
+ : undefined,
158
+ },
159
+ };
140
160
  return addParticipantsResult;
141
161
  }
142
162
  /**
@@ -153,9 +173,15 @@ export class CallConnection {
153
173
  customCallingContext: this.createCustomCallingContextInternal(options.customCallingContext),
154
174
  sourceCallerIdNumber: PhoneNumberIdentifierModelConverter(options.sourceCallIdNumber),
155
175
  };
156
- const optionsInternal = Object.assign(Object.assign({}, options), { repeatabilityFirstSent: new Date(), repeatabilityRequestID: randomUUID() });
176
+ const optionsInternal = {
177
+ ...options,
178
+ repeatabilityFirstSent: new Date(),
179
+ repeatabilityRequestID: randomUUID(),
180
+ };
157
181
  const result = await this.callConnection.transferToParticipant(this.callConnectionId, transferToParticipantRequest, optionsInternal);
158
- const transferCallResult = Object.assign({}, result);
182
+ const transferCallResult = {
183
+ ...result,
184
+ };
159
185
  return transferCallResult;
160
186
  }
161
187
  /**
@@ -169,9 +195,15 @@ export class CallConnection {
169
195
  operationContext: options.operationContext ? options.operationContext : randomUUID(),
170
196
  operationCallbackUri: options.operationCallbackUrl,
171
197
  };
172
- const optionsInternal = Object.assign(Object.assign({}, options), { repeatabilityFirstSent: new Date(), repeatabilityRequestID: randomUUID() });
198
+ const optionsInternal = {
199
+ ...options,
200
+ repeatabilityFirstSent: new Date(),
201
+ repeatabilityRequestID: randomUUID(),
202
+ };
173
203
  const result = await this.callConnection.removeParticipant(this.callConnectionId, removeParticipantRequest, optionsInternal);
174
- const removeParticipantsResult = Object.assign({}, result);
204
+ const removeParticipantsResult = {
205
+ ...result,
206
+ };
175
207
  return removeParticipantsResult;
176
208
  }
177
209
  /**
@@ -185,9 +217,15 @@ export class CallConnection {
185
217
  targetParticipants: [communicationIdentifierModelConverter(participant)],
186
218
  operationContext: options.operationContext,
187
219
  };
188
- const optionsInternal = Object.assign(Object.assign({}, options), { repeatabilityFirstSent: new Date(), repeatabilityRequestID: randomUUID() });
220
+ const optionsInternal = {
221
+ ...options,
222
+ repeatabilityFirstSent: new Date(),
223
+ repeatabilityRequestID: randomUUID(),
224
+ };
189
225
  const result = await this.callConnection.mute(this.callConnectionId, muteParticipantsRequest, optionsInternal);
190
- const muteParticipantResult = Object.assign({}, result);
226
+ const muteParticipantResult = {
227
+ ...result,
228
+ };
191
229
  return muteParticipantResult;
192
230
  }
193
231
  /** Cancel add participant request.
@@ -195,15 +233,21 @@ export class CallConnection {
195
233
  * @param invitationId - Invitation ID used to cancel the add participant request.
196
234
  */
197
235
  async cancelAddParticipantOperation(invitationId, options = {}) {
198
- const { operationContext, operationCallbackUrl: operationCallbackUri } = options, operationOptions = __rest(options, ["operationContext", "operationCallbackUrl"]);
236
+ const { operationContext, operationCallbackUrl: operationCallbackUri, ...operationOptions } = options;
199
237
  const cancelAddParticipantRequest = {
200
238
  invitationId,
201
239
  operationContext: operationContext ? operationContext : randomUUID(),
202
240
  operationCallbackUri,
203
241
  };
204
- const optionsInternal = Object.assign(Object.assign({}, operationOptions), { repeatabilityFirstSent: new Date(), repeatabilityRequestID: randomUUID() });
242
+ const optionsInternal = {
243
+ ...operationOptions,
244
+ repeatabilityFirstSent: new Date(),
245
+ repeatabilityRequestID: randomUUID(),
246
+ };
205
247
  const result = await this.callConnection.cancelAddParticipant(this.callConnectionId, cancelAddParticipantRequest, optionsInternal);
206
- const cancelAddParticipantResult = Object.assign({}, result);
248
+ const cancelAddParticipantResult = {
249
+ ...result,
250
+ };
207
251
  return cancelAddParticipantResult;
208
252
  }
209
253
  }
@@ -1 +1 @@
1
- {"version":3,"file":"callConnection.js","sourceRoot":"","sources":["../../src/callConnection.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAEL,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAEL,uBAAuB,GAMxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,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,oBAAoB,EAAE,oBAAoB,KAExC,OAAO,EADN,gBAAgB,UACjB,OAAO,EAJL,4CAIL,CAAU,CAAC;QACZ,MAAM,2BAA2B,GAAG;YAClC,YAAY;YACZ,gBAAgB,EAAE,gBAAgB,CAAC,CAAC,CAAC,gBAAgB,CAAC,CAAC,CAAC,UAAU,EAAE;YACpE,oBAAoB;SACrB,CAAC;QACF,MAAM,eAAe,mCAChB,gBAAgB,KACnB,sBAAsB,EAAE,IAAI,IAAI,EAAE,EAClC,sBAAsB,EAAE,UAAU,EAAE,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","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,OAAO,EAEL,6BAA6B,GAC9B,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAEL,uBAAuB,GAMxB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,kBAAkB,EAAE,MAAM,qCAAqC,CAAC;AAyBzE,OAAO,EACL,wBAAwB,EACxB,gCAAgC,EAChC,qCAAqC,EACrC,oCAAoC,EACpC,8BAA8B,EAC9B,mCAAmC,GACpC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAG9C;;GAEG;AACH,MAAM,OAAO,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,uBAAuB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC9E,MAAM,UAAU,GAAG,6BAA6B,CAAC,UAAU,CAAC,CA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B,EAAE,IAAI,IAAI,EAAE;YAClC,sBAAsB,EAAE,UAAU,EAAE;SACrC,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,oBAAoB,CAC3D,IAAI,CAAC,gBAAgB,EACrB,2BAA2B,EAC3B,eAAe,CAChB,CAAC;QAEF,MAAM,0BAA0B,GAAwC;YACtE,GAAG,MAAM;SACV,CAAC;QAEF,OAAO,0BAA0B,CAAC;IACpC,CAAC;CACF","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,EACL,uBAAuB,EAExB,MAAM,6BAA6B,CAAC;AAGrC,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,CA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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"}
@@ -3,13 +3,15 @@
3
3
  import { CallAutomationApiClient, } from "./generated/src/index.js";
4
4
  import { KnownPlaySourceType, KnownRecognizeInputType } from "./generated/src/index.js";
5
5
  import { CallMediaImpl } from "./generated/src/operations/index.js";
6
- import { createCommunicationAuthPolicy, } from "@azure/communication-common";
7
- import { serializeCommunicationIdentifier } from "@azure/communication-common";
6
+ import { createCommunicationAuthPolicy, serializeCommunicationIdentifier, } from "@azure/communication-common";
8
7
  import { randomUUID } from "@azure/core-util";
9
8
  /**
10
9
  * CallMedia class represents call media related APIs.
11
10
  */
12
11
  export class CallMedia {
12
+ callConnectionId;
13
+ callMedia;
14
+ callAutomationApiClient;
13
15
  constructor(callConnectionId, endpoint, credential, options) {
14
16
  this.callAutomationApiClient = new CallAutomationApiClient(endpoint, options);
15
17
  const authPolicy = createCommunicationAuthPolicy(credential);
@@ -25,6 +27,9 @@ export class CallMedia {
25
27
  return {
26
28
  kind: KnownPlaySourceType.File,
27
29
  file: fileSource,
30
+ playSourceCacheId: playSource.playSourceCacheId
31
+ ? playSource.playSourceCacheId
32
+ : playSource.playsourcacheid,
28
33
  };
29
34
  }
30
35
  else if (playSource.kind === "textSource") {
@@ -38,6 +43,9 @@ export class CallMedia {
38
43
  return {
39
44
  kind: KnownPlaySourceType.Text,
40
45
  text: textSource,
46
+ playSourceCacheId: playSource.playSourceCacheId
47
+ ? playSource.playSourceCacheId
48
+ : playSource.playsourcacheid,
41
49
  };
42
50
  }
43
51
  else if (playSource.kind === "ssmlSource") {
@@ -48,6 +56,9 @@ export class CallMedia {
48
56
  return {
49
57
  kind: KnownPlaySourceType.Ssml,
50
58
  ssml: ssmlSource,
59
+ playSourceCacheId: playSource.playSourceCacheId
60
+ ? playSource.playSourceCacheId
61
+ : playSource.playsourcacheid,
51
62
  };
52
63
  }
53
64
  throw new Error("Invalid play source");
@@ -73,7 +84,7 @@ export class CallMedia {
73
84
  playRequest.playOptions = playRequest.playOptions || { loop: false }; // Ensure playOptions is defined
74
85
  playRequest.playOptions.loop = options.loop;
75
86
  }
76
- return this.callMedia.play(this.callConnectionId, playRequest, options);
87
+ await this.callMedia.play(this.callConnectionId, playRequest, options);
77
88
  }
78
89
  /**
79
90
  * Play to all participants.
@@ -98,10 +109,10 @@ export class CallMedia {
98
109
  if (options.interruptCallMediaOperation !== undefined) {
99
110
  playRequest.playOptions = playRequest.playOptions || {
100
111
  loop: false,
101
- };
112
+ }; // Ensure playOptions is defined
102
113
  playRequest.interruptCallMediaOperation = options.interruptCallMediaOperation;
103
114
  }
104
- return this.callMedia.play(this.callConnectionId, playRequest, options);
115
+ await this.callMedia.play(this.callConnectionId, playRequest, options);
105
116
  }
106
117
  createRecognizeRequest(targetParticipant, recognizeOptions) {
107
118
  if (recognizeOptions.kind === "callMediaRecognizeDtmfOptions") {
@@ -233,7 +244,7 @@ export class CallMedia {
233
244
  // Old function signature logic
234
245
  console.warn("Deprecated function signature used. Please use the new signature with targetParticipant and options params instead, and set maxTonesToCollect in options.");
235
246
  options.maxTonesToCollect = maxTonesOrOptions;
236
- await this.callMedia.recognize(this.callConnectionId, this.createRecognizeRequest(targetParticipant, options), {});
247
+ return this.callMedia.recognize(this.callConnectionId, this.createRecognizeRequest(targetParticipant, options), {});
237
248
  }
238
249
  else if (typeof maxTonesOrOptions !== "number" && !options) {
239
250
  maxTonesOrOptions.operationContext = maxTonesOrOptions.operationContext
@@ -248,7 +259,7 @@ export class CallMedia {
248
259
  * Cancels all the queued media operations.
249
260
  */
250
261
  async cancelAllOperations() {
251
- return this.callMedia.cancelAllMediaOperations(this.callConnectionId, {});
262
+ await this.callMedia.cancelAllMediaOperations(this.callConnectionId, {});
252
263
  }
253
264
  /**
254
265
  * Start continuous Dtmf recognition by subscribing to tones.
@@ -288,9 +299,15 @@ export class CallMedia {
288
299
  operationContext: options.operationContext,
289
300
  operationCallbackUri: options.operationCallbackUrl,
290
301
  };
291
- const optionsInternal = Object.assign(Object.assign({}, options), { repeatabilityFirstSent: new Date(), repeatabilityRequestID: randomUUID() });
302
+ const optionsInternal = {
303
+ ...options,
304
+ repeatabilityFirstSent: new Date(),
305
+ repeatabilityRequestID: randomUUID(),
306
+ };
292
307
  const result = await this.callMedia.sendDtmfTones(this.callConnectionId, sendDtmfTonesRequest, optionsInternal);
293
- const sendDtmfTonesResult = Object.assign({}, result);
308
+ const sendDtmfTonesResult = {
309
+ ...result,
310
+ };
294
311
  return sendDtmfTonesResult;
295
312
  }
296
313
  /**
@@ -320,6 +337,7 @@ export class CallMedia {
320
337
  const unholdRequest = {
321
338
  targetParticipant: serializeCommunicationIdentifier(targetParticipant),
322
339
  operationContext: options.operationContext !== undefined ? options.operationContext : undefined,
340
+ operationCallbackUri: options.operationCallbackUrl !== undefined ? options.operationCallbackUrl : undefined,
323
341
  };
324
342
  return this.callMedia.unhold(this.callConnectionId, unholdRequest);
325
343
  }
@@ -331,7 +349,8 @@ export class CallMedia {
331
349
  const startTranscriptionRequest = {
332
350
  locale: options.locale,
333
351
  operationContext: options.operationContext,
334
- speechRecognitionModelEndpointId: options.speechRecognitionModelEndpointId,
352
+ speechModelEndpointId: options.speechRecognitionModelEndpointId,
353
+ operationCallbackUri: options.operationCallbackUrl,
335
354
  };
336
355
  return this.callMedia.startTranscription(this.callConnectionId, startTranscriptionRequest, {});
337
356
  }
@@ -342,6 +361,7 @@ export class CallMedia {
342
361
  async stopTranscription(options = {}) {
343
362
  const stopTranscriptionRequest = {
344
363
  operationContext: options.operationContext,
364
+ operationCallbackUri: options.operationCallbackUrl,
345
365
  };
346
366
  return this.callMedia.stopTranscription(this.callConnectionId, stopTranscriptionRequest, {});
347
367
  }
@@ -352,8 +372,9 @@ export class CallMedia {
352
372
  async updateTranscription(locale, options) {
353
373
  const updateTranscriptionRequest = {
354
374
  locale: locale,
355
- speechRecognitionModelEndpointId: options === null || options === void 0 ? void 0 : options.speechRecognitionModelEndpointId,
356
- operationContext: options === null || options === void 0 ? void 0 : options.operationContext,
375
+ speechModelEndpointId: options?.speechRecognitionModelEndpointId,
376
+ operationContext: options?.operationContext,
377
+ operationCallbackUri: options?.operationCallbackUrl,
357
378
  };
358
379
  return this.callMedia.updateTranscription(this.callConnectionId, updateTranscriptionRequest, {});
359
380
  }