@azure/communication-chat 1.6.0-beta.3 → 1.6.0-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (454) hide show
  1. package/README.md +134 -45
  2. package/dist/browser/chatClient.d.ts +225 -0
  3. package/dist/browser/chatClient.d.ts.map +1 -0
  4. package/{dist-esm/src → dist/browser}/chatClient.js +15 -10
  5. package/dist/browser/chatClient.js.map +1 -0
  6. package/dist/browser/chatThreadClient.d.ts +142 -0
  7. package/dist/browser/chatThreadClient.d.ts.map +1 -0
  8. package/{dist-esm/src → dist/browser}/chatThreadClient.js +12 -9
  9. package/dist/browser/chatThreadClient.js.map +1 -0
  10. package/dist/browser/credential/communicationTokenCredentialPolicy.d.ts +9 -0
  11. package/dist/browser/credential/communicationTokenCredentialPolicy.d.ts.map +1 -0
  12. package/{dist-esm/src → dist/browser}/credential/communicationTokenCredentialPolicy.js +2 -2
  13. package/dist/browser/credential/communicationTokenCredentialPolicy.js.map +1 -0
  14. package/dist/browser/generated/src/chatApiClient.d.ts +18 -0
  15. package/dist/browser/generated/src/chatApiClient.d.ts.map +1 -0
  16. package/{dist-esm/src → dist/browser}/generated/src/chatApiClient.js +2 -2
  17. package/dist/browser/generated/src/chatApiClient.js.map +1 -0
  18. package/dist/browser/generated/src/index.d.ts +4 -0
  19. package/dist/browser/generated/src/index.d.ts.map +1 -0
  20. package/{dist-esm/src → dist/browser}/generated/src/index.js +3 -3
  21. package/dist/browser/generated/src/index.js.map +1 -0
  22. package/dist/browser/generated/src/models/index.d.ts +579 -0
  23. package/dist/browser/generated/src/models/index.d.ts.map +1 -0
  24. package/dist/browser/generated/src/models/mappers.d.ts +44 -0
  25. package/dist/browser/generated/src/models/mappers.d.ts.map +1 -0
  26. package/dist/browser/generated/src/models/parameters.d.ts +29 -0
  27. package/dist/browser/generated/src/models/parameters.d.ts.map +1 -0
  28. package/{dist-esm/src → dist/browser}/generated/src/models/parameters.js +1 -1
  29. package/dist/browser/generated/src/models/parameters.js.map +1 -0
  30. package/dist/browser/generated/src/operations/chat.d.ts +36 -0
  31. package/dist/browser/generated/src/operations/chat.d.ts.map +1 -0
  32. package/{dist-esm/src → dist/browser}/generated/src/operations/chat.js +3 -3
  33. package/dist/browser/generated/src/operations/chat.js.map +1 -0
  34. package/dist/browser/generated/src/operations/chatThread.d.ts +144 -0
  35. package/dist/browser/generated/src/operations/chatThread.d.ts.map +1 -0
  36. package/{dist-esm/src → dist/browser}/generated/src/operations/chatThread.js +3 -3
  37. package/dist/browser/generated/src/operations/chatThread.js.map +1 -0
  38. package/dist/browser/generated/src/operations/index.d.ts +3 -0
  39. package/dist/browser/generated/src/operations/index.d.ts.map +1 -0
  40. package/dist/browser/generated/src/operations/index.js +10 -0
  41. package/dist/browser/generated/src/operations/index.js.map +1 -0
  42. package/dist/browser/generated/src/operationsInterfaces/chat.d.ts +28 -0
  43. package/dist/browser/generated/src/operationsInterfaces/chat.d.ts.map +1 -0
  44. package/dist/browser/generated/src/operationsInterfaces/chat.js.map +1 -0
  45. package/dist/browser/generated/src/operationsInterfaces/chatThread.d.ts +136 -0
  46. package/dist/browser/generated/src/operationsInterfaces/chatThread.d.ts.map +1 -0
  47. package/dist/browser/generated/src/operationsInterfaces/chatThread.js.map +1 -0
  48. package/dist/browser/generated/src/operationsInterfaces/index.d.ts +3 -0
  49. package/dist/browser/generated/src/operationsInterfaces/index.d.ts.map +1 -0
  50. package/dist/browser/generated/src/operationsInterfaces/index.js +10 -0
  51. package/dist/browser/generated/src/operationsInterfaces/index.js.map +1 -0
  52. package/dist/browser/generated/src/tracing.d.ts +2 -0
  53. package/dist/browser/generated/src/tracing.d.ts.map +1 -0
  54. package/{dist-esm/src → dist/browser}/generated/src/tracing.js +1 -1
  55. package/{dist-esm/src → dist/browser}/generated/src/tracing.js.map +1 -1
  56. package/dist/browser/index.d.ts +7 -0
  57. package/dist/browser/index.d.ts.map +1 -0
  58. package/dist/browser/index.js +9 -0
  59. package/dist/browser/index.js.map +1 -0
  60. package/dist/browser/models/events.d.ts +4 -0
  61. package/dist/browser/models/events.d.ts.map +1 -0
  62. package/dist/browser/models/events.js +4 -0
  63. package/dist/browser/models/events.js.map +1 -0
  64. package/dist/browser/models/logger.d.ts +2 -0
  65. package/dist/browser/models/logger.d.ts.map +1 -0
  66. package/{dist-esm/src → dist/browser}/models/logger.js +1 -1
  67. package/{dist-esm/src → dist/browser}/models/logger.js.map +1 -1
  68. package/dist/browser/models/mappers.d.ts +79 -0
  69. package/dist/browser/models/mappers.d.ts.map +1 -0
  70. package/{dist-esm/src → dist/browser}/models/mappers.js +1 -1
  71. package/dist/browser/models/mappers.js.map +1 -0
  72. package/dist/browser/models/models.d.ts +153 -0
  73. package/dist/browser/models/models.d.ts.map +1 -0
  74. package/dist/browser/models/models.js +4 -0
  75. package/dist/browser/models/models.js.map +1 -0
  76. package/dist/browser/models/options.d.ts +135 -0
  77. package/dist/browser/models/options.d.ts.map +1 -0
  78. package/dist/browser/models/options.js.map +1 -0
  79. package/dist/browser/models/requests.d.ts +18 -0
  80. package/dist/browser/models/requests.d.ts.map +1 -0
  81. package/dist/browser/models/requests.js +4 -0
  82. package/dist/browser/models/requests.js.map +1 -0
  83. package/dist/browser/models/uuid.d.ts +8 -0
  84. package/dist/browser/models/uuid.d.ts.map +1 -0
  85. package/{dist-esm/src → dist/browser}/models/uuid.js +3 -3
  86. package/dist/browser/models/uuid.js.map +1 -0
  87. package/dist/browser/package.json +3 -0
  88. package/dist/browser/signaling/signalingClient-browser.d.mts.map +1 -0
  89. package/dist/browser/signaling/signalingClient-browser.mjs.map +1 -0
  90. package/dist/browser/signaling/signalingClient.d.ts +6 -0
  91. package/dist/browser/signaling/signalingClient.js +13 -0
  92. package/dist/browser/signaling/signalingClientOptions.d.ts +6 -0
  93. package/dist/browser/signaling/signalingClientOptions.d.ts.map +1 -0
  94. package/dist/browser/signaling/signalingClientOptions.js +4 -0
  95. package/dist/browser/signaling/signalingClientOptions.js.map +1 -0
  96. package/dist/browser/xhrHttpClient.d.ts +17 -0
  97. package/dist/browser/xhrHttpClient.d.ts.map +1 -0
  98. package/{dist-esm/src → dist/browser}/xhrHttpClient.js +2 -2
  99. package/dist/browser/xhrHttpClient.js.map +1 -0
  100. package/dist/commonjs/chatClient.d.ts +225 -0
  101. package/dist/commonjs/chatClient.d.ts.map +1 -0
  102. package/dist/commonjs/chatClient.js +250 -0
  103. package/dist/commonjs/chatClient.js.map +1 -0
  104. package/dist/commonjs/chatThreadClient.d.ts +142 -0
  105. package/dist/commonjs/chatThreadClient.d.ts.map +1 -0
  106. package/dist/commonjs/chatThreadClient.js +463 -0
  107. package/dist/commonjs/chatThreadClient.js.map +1 -0
  108. package/dist/commonjs/credential/communicationTokenCredentialPolicy.d.ts +9 -0
  109. package/dist/commonjs/credential/communicationTokenCredentialPolicy.d.ts.map +1 -0
  110. package/dist/commonjs/credential/communicationTokenCredentialPolicy.js +22 -0
  111. package/dist/commonjs/credential/communicationTokenCredentialPolicy.js.map +1 -0
  112. package/dist/commonjs/generated/src/chatApiClient.d.ts +18 -0
  113. package/dist/commonjs/generated/src/chatApiClient.d.ts.map +1 -0
  114. package/dist/commonjs/generated/src/chatApiClient.js +75 -0
  115. package/dist/commonjs/generated/src/chatApiClient.js.map +1 -0
  116. package/dist/commonjs/generated/src/index.d.ts +4 -0
  117. package/dist/commonjs/generated/src/index.d.ts.map +1 -0
  118. package/dist/commonjs/generated/src/index.js +16 -0
  119. package/dist/commonjs/generated/src/index.js.map +1 -0
  120. package/dist/commonjs/generated/src/models/index.d.ts +579 -0
  121. package/dist/commonjs/generated/src/models/index.d.ts.map +1 -0
  122. package/dist/commonjs/generated/src/models/index.js +43 -0
  123. package/dist/commonjs/generated/src/models/index.js.map +1 -0
  124. package/dist/commonjs/generated/src/models/mappers.d.ts +44 -0
  125. package/dist/commonjs/generated/src/models/mappers.d.ts.map +1 -0
  126. package/dist/commonjs/generated/src/models/mappers.js +1112 -0
  127. package/dist/commonjs/generated/src/models/mappers.js.map +1 -0
  128. package/dist/commonjs/generated/src/models/parameters.d.ts +29 -0
  129. package/dist/commonjs/generated/src/models/parameters.d.ts.map +1 -0
  130. package/dist/commonjs/generated/src/models/parameters.js +238 -0
  131. package/dist/commonjs/generated/src/models/parameters.js.map +1 -0
  132. package/dist/commonjs/generated/src/operations/chat.d.ts +36 -0
  133. package/dist/commonjs/generated/src/operations/chat.d.ts.map +1 -0
  134. package/dist/commonjs/generated/src/operations/chat.js +191 -0
  135. package/dist/commonjs/generated/src/operations/chat.js.map +1 -0
  136. package/dist/commonjs/generated/src/operations/chatThread.d.ts +144 -0
  137. package/dist/commonjs/generated/src/operations/chatThread.d.ts.map +1 -0
  138. package/dist/commonjs/generated/src/operations/chatThread.js +798 -0
  139. package/dist/commonjs/generated/src/operations/chatThread.js.map +1 -0
  140. package/dist/commonjs/generated/src/operations/index.d.ts +3 -0
  141. package/dist/commonjs/generated/src/operations/index.d.ts.map +1 -0
  142. package/dist/commonjs/generated/src/operations/index.js +13 -0
  143. package/dist/commonjs/generated/src/operations/index.js.map +1 -0
  144. package/dist/commonjs/generated/src/operationsInterfaces/chat.d.ts +28 -0
  145. package/dist/commonjs/generated/src/operationsInterfaces/chat.d.ts.map +1 -0
  146. package/dist/commonjs/generated/src/operationsInterfaces/chat.js +10 -0
  147. package/dist/commonjs/generated/src/operationsInterfaces/chat.js.map +1 -0
  148. package/dist/commonjs/generated/src/operationsInterfaces/chatThread.d.ts +136 -0
  149. package/dist/commonjs/generated/src/operationsInterfaces/chatThread.d.ts.map +1 -0
  150. package/dist/commonjs/generated/src/operationsInterfaces/chatThread.js +10 -0
  151. package/dist/commonjs/generated/src/operationsInterfaces/chatThread.js.map +1 -0
  152. package/dist/commonjs/generated/src/operationsInterfaces/index.d.ts +3 -0
  153. package/dist/commonjs/generated/src/operationsInterfaces/index.d.ts.map +1 -0
  154. package/dist/commonjs/generated/src/operationsInterfaces/index.js +13 -0
  155. package/dist/commonjs/generated/src/operationsInterfaces/index.js.map +1 -0
  156. package/dist/commonjs/generated/src/tracing.d.ts +2 -0
  157. package/dist/commonjs/generated/src/tracing.d.ts.map +1 -0
  158. package/dist/commonjs/generated/src/tracing.js +17 -0
  159. package/dist/commonjs/generated/src/tracing.js.map +1 -0
  160. package/dist/commonjs/index.d.ts +7 -0
  161. package/dist/commonjs/index.d.ts.map +1 -0
  162. package/dist/commonjs/index.js +12 -0
  163. package/dist/commonjs/index.js.map +1 -0
  164. package/dist/commonjs/models/events.d.ts +4 -0
  165. package/dist/commonjs/models/events.d.ts.map +1 -0
  166. package/dist/commonjs/models/events.js +5 -0
  167. package/dist/commonjs/models/events.js.map +1 -0
  168. package/dist/commonjs/models/logger.d.ts +2 -0
  169. package/dist/commonjs/models/logger.d.ts.map +1 -0
  170. package/dist/commonjs/models/logger.js +8 -0
  171. package/dist/commonjs/models/logger.js.map +1 -0
  172. package/dist/commonjs/models/mappers.d.ts +79 -0
  173. package/dist/commonjs/models/mappers.d.ts.map +1 -0
  174. package/dist/commonjs/models/mappers.js +203 -0
  175. package/dist/commonjs/models/mappers.js.map +1 -0
  176. package/dist/commonjs/models/models.d.ts +153 -0
  177. package/dist/commonjs/models/models.d.ts.map +1 -0
  178. package/dist/commonjs/models/models.js +5 -0
  179. package/dist/commonjs/models/models.js.map +1 -0
  180. package/dist/commonjs/models/options.d.ts +135 -0
  181. package/dist/commonjs/models/options.d.ts.map +1 -0
  182. package/dist/commonjs/models/options.js +3 -0
  183. package/dist/commonjs/models/options.js.map +1 -0
  184. package/dist/commonjs/models/requests.d.ts +18 -0
  185. package/dist/commonjs/models/requests.d.ts.map +1 -0
  186. package/dist/commonjs/models/requests.js +5 -0
  187. package/dist/commonjs/models/requests.js.map +1 -0
  188. package/dist/commonjs/models/uuid.d.ts +8 -0
  189. package/dist/commonjs/models/uuid.d.ts.map +1 -0
  190. package/dist/commonjs/models/uuid.js +16 -0
  191. package/dist/commonjs/models/uuid.js.map +1 -0
  192. package/dist/commonjs/package.json +3 -0
  193. package/dist/commonjs/signaling/signalingClient.d.ts +6 -0
  194. package/dist/commonjs/signaling/signalingClient.d.ts.map +1 -0
  195. package/dist/commonjs/signaling/signalingClient.js +11 -0
  196. package/dist/commonjs/signaling/signalingClient.js.map +1 -0
  197. package/dist/commonjs/signaling/signalingClientOptions.d.ts +6 -0
  198. package/dist/commonjs/signaling/signalingClientOptions.d.ts.map +1 -0
  199. package/dist/commonjs/signaling/signalingClientOptions.js +5 -0
  200. package/dist/commonjs/signaling/signalingClientOptions.js.map +1 -0
  201. package/dist/commonjs/tsdoc-metadata.json +11 -0
  202. package/dist/commonjs/xhrHttpClient.d.ts +17 -0
  203. package/dist/commonjs/xhrHttpClient.d.ts.map +1 -0
  204. package/dist/commonjs/xhrHttpClient.js +191 -0
  205. package/dist/commonjs/xhrHttpClient.js.map +1 -0
  206. package/dist/esm/chatClient.d.ts +225 -0
  207. package/dist/esm/chatClient.d.ts.map +1 -0
  208. package/dist/esm/chatClient.js +246 -0
  209. package/dist/esm/chatClient.js.map +1 -0
  210. package/dist/esm/chatThreadClient.d.ts +142 -0
  211. package/dist/esm/chatThreadClient.d.ts.map +1 -0
  212. package/dist/esm/chatThreadClient.js +459 -0
  213. package/dist/esm/chatThreadClient.js.map +1 -0
  214. package/dist/esm/credential/communicationTokenCredentialPolicy.d.ts +9 -0
  215. package/dist/esm/credential/communicationTokenCredentialPolicy.d.ts.map +1 -0
  216. package/dist/esm/credential/communicationTokenCredentialPolicy.js +18 -0
  217. package/dist/esm/credential/communicationTokenCredentialPolicy.js.map +1 -0
  218. package/dist/esm/generated/src/chatApiClient.d.ts +18 -0
  219. package/dist/esm/generated/src/chatApiClient.d.ts.map +1 -0
  220. package/dist/esm/generated/src/chatApiClient.js +70 -0
  221. package/dist/esm/generated/src/chatApiClient.js.map +1 -0
  222. package/dist/esm/generated/src/index.d.ts +4 -0
  223. package/dist/esm/generated/src/index.d.ts.map +1 -0
  224. package/dist/esm/generated/src/index.js +11 -0
  225. package/dist/esm/generated/src/index.js.map +1 -0
  226. package/dist/esm/generated/src/models/index.d.ts +579 -0
  227. package/dist/esm/generated/src/models/index.d.ts.map +1 -0
  228. package/dist/esm/generated/src/models/index.js +40 -0
  229. package/dist/esm/generated/src/models/index.js.map +1 -0
  230. package/dist/esm/generated/src/models/mappers.d.ts +44 -0
  231. package/dist/esm/generated/src/models/mappers.d.ts.map +1 -0
  232. package/dist/esm/generated/src/models/mappers.js +1109 -0
  233. package/dist/esm/generated/src/models/mappers.js.map +1 -0
  234. package/dist/esm/generated/src/models/parameters.d.ts +29 -0
  235. package/dist/esm/generated/src/models/parameters.d.ts.map +1 -0
  236. package/dist/esm/generated/src/models/parameters.js +235 -0
  237. package/dist/esm/generated/src/models/parameters.js.map +1 -0
  238. package/dist/esm/generated/src/operations/chat.d.ts +36 -0
  239. package/dist/esm/generated/src/operations/chat.d.ts.map +1 -0
  240. package/dist/esm/generated/src/operations/chat.js +186 -0
  241. package/dist/esm/generated/src/operations/chat.js.map +1 -0
  242. package/dist/esm/generated/src/operations/chatThread.d.ts +144 -0
  243. package/dist/esm/generated/src/operations/chatThread.d.ts.map +1 -0
  244. package/dist/esm/generated/src/operations/chatThread.js +793 -0
  245. package/dist/esm/generated/src/operations/chatThread.js.map +1 -0
  246. package/dist/esm/generated/src/operations/index.d.ts +3 -0
  247. package/dist/esm/generated/src/operations/index.d.ts.map +1 -0
  248. package/dist/esm/generated/src/operations/index.js +10 -0
  249. package/dist/esm/generated/src/operations/index.js.map +1 -0
  250. package/dist/esm/generated/src/operationsInterfaces/chat.d.ts +28 -0
  251. package/dist/esm/generated/src/operationsInterfaces/chat.d.ts.map +1 -0
  252. package/{dist-esm/src/generated/src/operationsInterfaces/index.js → dist/esm/generated/src/operationsInterfaces/chat.js} +2 -3
  253. package/dist/esm/generated/src/operationsInterfaces/chat.js.map +1 -0
  254. package/dist/esm/generated/src/operationsInterfaces/chatThread.d.ts +136 -0
  255. package/dist/esm/generated/src/operationsInterfaces/chatThread.d.ts.map +1 -0
  256. package/{dist-esm/src/generated/src/operations/index.js → dist/esm/generated/src/operationsInterfaces/chatThread.js} +2 -3
  257. package/dist/esm/generated/src/operationsInterfaces/chatThread.js.map +1 -0
  258. package/dist/esm/generated/src/operationsInterfaces/index.d.ts +3 -0
  259. package/dist/esm/generated/src/operationsInterfaces/index.d.ts.map +1 -0
  260. package/dist/esm/generated/src/operationsInterfaces/index.js +10 -0
  261. package/dist/esm/generated/src/operationsInterfaces/index.js.map +1 -0
  262. package/dist/esm/generated/src/tracing.d.ts +2 -0
  263. package/dist/esm/generated/src/tracing.d.ts.map +1 -0
  264. package/dist/esm/generated/src/tracing.js +14 -0
  265. package/dist/esm/generated/src/tracing.js.map +1 -0
  266. package/dist/esm/index.d.ts +7 -0
  267. package/dist/esm/index.d.ts.map +1 -0
  268. package/dist/esm/index.js +9 -0
  269. package/dist/esm/index.js.map +1 -0
  270. package/dist/esm/models/events.d.ts +4 -0
  271. package/dist/esm/models/events.d.ts.map +1 -0
  272. package/dist/esm/models/events.js +4 -0
  273. package/dist/esm/models/events.js.map +1 -0
  274. package/dist/esm/models/logger.d.ts +2 -0
  275. package/dist/esm/models/logger.d.ts.map +1 -0
  276. package/dist/esm/models/logger.js +5 -0
  277. package/dist/esm/models/logger.js.map +1 -0
  278. package/dist/esm/models/mappers.d.ts +79 -0
  279. package/dist/esm/models/mappers.d.ts.map +1 -0
  280. package/dist/esm/models/mappers.js +184 -0
  281. package/dist/esm/models/mappers.js.map +1 -0
  282. package/dist/esm/models/models.d.ts +153 -0
  283. package/dist/esm/models/models.d.ts.map +1 -0
  284. package/dist/esm/models/models.js +4 -0
  285. package/dist/esm/models/models.js.map +1 -0
  286. package/dist/esm/models/options.d.ts +135 -0
  287. package/dist/esm/models/options.d.ts.map +1 -0
  288. package/dist/esm/models/options.js +2 -0
  289. package/dist/esm/models/options.js.map +1 -0
  290. package/dist/esm/models/requests.d.ts +18 -0
  291. package/dist/esm/models/requests.d.ts.map +1 -0
  292. package/dist/esm/models/requests.js +4 -0
  293. package/dist/esm/models/requests.js.map +1 -0
  294. package/dist/esm/models/uuid.d.ts +8 -0
  295. package/dist/esm/models/uuid.d.ts.map +1 -0
  296. package/dist/esm/models/uuid.js +13 -0
  297. package/dist/esm/models/uuid.js.map +1 -0
  298. package/dist/esm/package.json +3 -0
  299. package/dist/esm/signaling/signalingClient.d.ts +6 -0
  300. package/dist/esm/signaling/signalingClient.d.ts.map +1 -0
  301. package/dist/esm/signaling/signalingClient.js +7 -0
  302. package/dist/esm/signaling/signalingClient.js.map +1 -0
  303. package/dist/esm/signaling/signalingClientOptions.d.ts +6 -0
  304. package/dist/esm/signaling/signalingClientOptions.d.ts.map +1 -0
  305. package/dist/esm/signaling/signalingClientOptions.js +4 -0
  306. package/dist/esm/signaling/signalingClientOptions.js.map +1 -0
  307. package/dist/esm/xhrHttpClient.d.ts +17 -0
  308. package/dist/esm/xhrHttpClient.d.ts.map +1 -0
  309. package/dist/esm/xhrHttpClient.js +186 -0
  310. package/dist/esm/xhrHttpClient.js.map +1 -0
  311. package/dist/react-native/chatClient.d.ts +225 -0
  312. package/dist/react-native/chatClient.d.ts.map +1 -0
  313. package/dist/react-native/chatClient.js +246 -0
  314. package/dist/react-native/chatClient.js.map +1 -0
  315. package/dist/react-native/chatThreadClient.d.ts +142 -0
  316. package/dist/react-native/chatThreadClient.d.ts.map +1 -0
  317. package/dist/react-native/chatThreadClient.js +459 -0
  318. package/dist/react-native/chatThreadClient.js.map +1 -0
  319. package/dist/react-native/credential/communicationTokenCredentialPolicy.d.ts +9 -0
  320. package/dist/react-native/credential/communicationTokenCredentialPolicy.d.ts.map +1 -0
  321. package/dist/react-native/credential/communicationTokenCredentialPolicy.js +18 -0
  322. package/dist/react-native/credential/communicationTokenCredentialPolicy.js.map +1 -0
  323. package/dist/react-native/generated/src/chatApiClient.d.ts +18 -0
  324. package/dist/react-native/generated/src/chatApiClient.d.ts.map +1 -0
  325. package/dist/react-native/generated/src/chatApiClient.js +70 -0
  326. package/dist/react-native/generated/src/chatApiClient.js.map +1 -0
  327. package/dist/react-native/generated/src/index.d.ts +4 -0
  328. package/dist/react-native/generated/src/index.d.ts.map +1 -0
  329. package/dist/react-native/generated/src/index.js +11 -0
  330. package/dist/react-native/generated/src/index.js.map +1 -0
  331. package/dist/react-native/generated/src/models/index.d.ts +579 -0
  332. package/dist/react-native/generated/src/models/index.d.ts.map +1 -0
  333. package/dist/react-native/generated/src/models/index.js +40 -0
  334. package/dist/react-native/generated/src/models/index.js.map +1 -0
  335. package/dist/react-native/generated/src/models/mappers.d.ts +44 -0
  336. package/dist/react-native/generated/src/models/mappers.d.ts.map +1 -0
  337. package/dist/react-native/generated/src/models/mappers.js +1109 -0
  338. package/dist/react-native/generated/src/models/mappers.js.map +1 -0
  339. package/dist/react-native/generated/src/models/parameters.d.ts +29 -0
  340. package/dist/react-native/generated/src/models/parameters.d.ts.map +1 -0
  341. package/dist/react-native/generated/src/models/parameters.js +235 -0
  342. package/dist/react-native/generated/src/models/parameters.js.map +1 -0
  343. package/dist/react-native/generated/src/operations/chat.d.ts +36 -0
  344. package/dist/react-native/generated/src/operations/chat.d.ts.map +1 -0
  345. package/dist/react-native/generated/src/operations/chat.js +186 -0
  346. package/dist/react-native/generated/src/operations/chat.js.map +1 -0
  347. package/dist/react-native/generated/src/operations/chatThread.d.ts +144 -0
  348. package/dist/react-native/generated/src/operations/chatThread.d.ts.map +1 -0
  349. package/dist/react-native/generated/src/operations/chatThread.js +793 -0
  350. package/dist/react-native/generated/src/operations/chatThread.js.map +1 -0
  351. package/dist/react-native/generated/src/operations/index.d.ts +3 -0
  352. package/dist/react-native/generated/src/operations/index.d.ts.map +1 -0
  353. package/dist/react-native/generated/src/operations/index.js +10 -0
  354. package/dist/react-native/generated/src/operations/index.js.map +1 -0
  355. package/dist/react-native/generated/src/operationsInterfaces/chat.d.ts +28 -0
  356. package/dist/react-native/generated/src/operationsInterfaces/chat.d.ts.map +1 -0
  357. package/dist/react-native/generated/src/operationsInterfaces/chat.js +9 -0
  358. package/dist/react-native/generated/src/operationsInterfaces/chat.js.map +1 -0
  359. package/dist/react-native/generated/src/operationsInterfaces/chatThread.d.ts +136 -0
  360. package/dist/react-native/generated/src/operationsInterfaces/chatThread.d.ts.map +1 -0
  361. package/dist/react-native/generated/src/operationsInterfaces/chatThread.js +9 -0
  362. package/dist/react-native/generated/src/operationsInterfaces/chatThread.js.map +1 -0
  363. package/dist/react-native/generated/src/operationsInterfaces/index.d.ts +3 -0
  364. package/dist/react-native/generated/src/operationsInterfaces/index.d.ts.map +1 -0
  365. package/dist/react-native/generated/src/operationsInterfaces/index.js +10 -0
  366. package/dist/react-native/generated/src/operationsInterfaces/index.js.map +1 -0
  367. package/dist/react-native/generated/src/tracing.d.ts +2 -0
  368. package/dist/react-native/generated/src/tracing.d.ts.map +1 -0
  369. package/dist/react-native/generated/src/tracing.js +14 -0
  370. package/dist/react-native/generated/src/tracing.js.map +1 -0
  371. package/dist/react-native/index.d.ts +7 -0
  372. package/dist/react-native/index.d.ts.map +1 -0
  373. package/dist/react-native/index.js +9 -0
  374. package/dist/react-native/index.js.map +1 -0
  375. package/dist/react-native/models/events.d.ts +4 -0
  376. package/dist/react-native/models/events.d.ts.map +1 -0
  377. package/dist/react-native/models/events.js +4 -0
  378. package/dist/react-native/models/events.js.map +1 -0
  379. package/dist/react-native/models/logger.d.ts +2 -0
  380. package/dist/react-native/models/logger.d.ts.map +1 -0
  381. package/dist/react-native/models/logger.js +5 -0
  382. package/dist/react-native/models/logger.js.map +1 -0
  383. package/dist/react-native/models/mappers.d.ts +79 -0
  384. package/dist/react-native/models/mappers.d.ts.map +1 -0
  385. package/dist/react-native/models/mappers.js +184 -0
  386. package/dist/react-native/models/mappers.js.map +1 -0
  387. package/dist/react-native/models/models.d.ts +153 -0
  388. package/dist/react-native/models/models.d.ts.map +1 -0
  389. package/dist/react-native/models/models.js +4 -0
  390. package/dist/react-native/models/models.js.map +1 -0
  391. package/dist/react-native/models/options.d.ts +135 -0
  392. package/dist/react-native/models/options.d.ts.map +1 -0
  393. package/dist/react-native/models/options.js +2 -0
  394. package/dist/react-native/models/options.js.map +1 -0
  395. package/dist/react-native/models/requests.d.ts +18 -0
  396. package/dist/react-native/models/requests.d.ts.map +1 -0
  397. package/dist/react-native/models/requests.js +4 -0
  398. package/dist/react-native/models/requests.js.map +1 -0
  399. package/dist/react-native/models/uuid.d.ts +8 -0
  400. package/dist/react-native/models/uuid.d.ts.map +1 -0
  401. package/dist/react-native/models/uuid.js +13 -0
  402. package/dist/react-native/models/uuid.js.map +1 -0
  403. package/dist/react-native/package.json +3 -0
  404. package/dist/react-native/signaling/signalingClient-react-native.d.mts.map +1 -0
  405. package/dist/react-native/signaling/signalingClient-react-native.mjs.map +1 -0
  406. package/dist/react-native/signaling/signalingClient.d.ts +6 -0
  407. package/dist/react-native/signaling/signalingClient.js +13 -0
  408. package/dist/react-native/signaling/signalingClientOptions.d.ts +6 -0
  409. package/dist/react-native/signaling/signalingClientOptions.d.ts.map +1 -0
  410. package/dist/react-native/signaling/signalingClientOptions.js +4 -0
  411. package/dist/react-native/signaling/signalingClientOptions.js.map +1 -0
  412. package/dist/react-native/xhrHttpClient.d.ts +17 -0
  413. package/dist/react-native/xhrHttpClient.d.ts.map +1 -0
  414. package/dist/react-native/xhrHttpClient.js +186 -0
  415. package/dist/react-native/xhrHttpClient.js.map +1 -0
  416. package/package.json +77 -64
  417. package/dist/index.js +0 -3560
  418. package/dist/index.js.map +0 -1
  419. package/dist-esm/src/chatClient.js.map +0 -1
  420. package/dist-esm/src/chatThreadClient.js.map +0 -1
  421. package/dist-esm/src/credential/communicationTokenCredentialPolicy.js.map +0 -1
  422. package/dist-esm/src/generated/src/chatApiClient.js.map +0 -1
  423. package/dist-esm/src/generated/src/index.js.map +0 -1
  424. package/dist-esm/src/generated/src/models/parameters.js.map +0 -1
  425. package/dist-esm/src/generated/src/operations/chat.js.map +0 -1
  426. package/dist-esm/src/generated/src/operations/chatThread.js.map +0 -1
  427. package/dist-esm/src/generated/src/operations/index.js.map +0 -1
  428. package/dist-esm/src/generated/src/operationsInterfaces/chat.js.map +0 -1
  429. package/dist-esm/src/generated/src/operationsInterfaces/chatThread.js.map +0 -1
  430. package/dist-esm/src/generated/src/operationsInterfaces/index.js.map +0 -1
  431. package/dist-esm/src/index.js +0 -9
  432. package/dist-esm/src/index.js.map +0 -1
  433. package/dist-esm/src/models/events.js +0 -4
  434. package/dist-esm/src/models/events.js.map +0 -1
  435. package/dist-esm/src/models/mappers.js.map +0 -1
  436. package/dist-esm/src/models/models.js +0 -4
  437. package/dist-esm/src/models/models.js.map +0 -1
  438. package/dist-esm/src/models/options.js.map +0 -1
  439. package/dist-esm/src/models/requests.js +0 -4
  440. package/dist-esm/src/models/requests.js.map +0 -1
  441. package/dist-esm/src/models/uuid.js.map +0 -1
  442. package/dist-esm/src/signaling/signalingClient.browser.js +0 -12
  443. package/dist-esm/src/signaling/signalingClient.browser.js.map +0 -1
  444. package/dist-esm/src/signaling/signalingClient.js +0 -17
  445. package/dist-esm/src/signaling/signalingClient.js.map +0 -1
  446. package/dist-esm/src/xhrHttpClient.js.map +0 -1
  447. package/types/communication-chat.d.ts +0 -803
  448. /package/{dist-esm/src → dist/browser}/generated/src/models/index.js +0 -0
  449. /package/{dist-esm/src → dist/browser}/generated/src/models/index.js.map +0 -0
  450. /package/{dist-esm/src → dist/browser}/generated/src/models/mappers.js +0 -0
  451. /package/{dist-esm/src → dist/browser}/generated/src/models/mappers.js.map +0 -0
  452. /package/{dist-esm/src → dist/browser}/generated/src/operationsInterfaces/chat.js +0 -0
  453. /package/{dist-esm/src → dist/browser}/generated/src/operationsInterfaces/chatThread.js +0 -0
  454. /package/{dist-esm/src → dist/browser}/models/options.js +0 -0
package/dist/index.js DELETED
@@ -1,3560 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var tslib = require('tslib');
6
- var communicationCommon = require('@azure/communication-common');
7
- var logger$1 = require('@azure/logger');
8
- var abortController = require('@azure/abort-controller');
9
- var coreRestPipeline = require('@azure/core-rest-pipeline');
10
- var coreTracing = require('@azure/core-tracing');
11
- var coreClient = require('@azure/core-client');
12
- var events = require('events');
13
- var uuid = require('uuid');
14
- var communicationSignaling = require('@azure/communication-signaling');
15
-
16
- function _interopNamespaceDefault(e) {
17
- var n = Object.create(null);
18
- if (e) {
19
- Object.keys(e).forEach(function (k) {
20
- if (k !== 'default') {
21
- var d = Object.getOwnPropertyDescriptor(e, k);
22
- Object.defineProperty(n, k, d.get ? d : {
23
- enumerable: true,
24
- get: function () { return e[k]; }
25
- });
26
- }
27
- });
28
- }
29
- n.default = e;
30
- return Object.freeze(n);
31
- }
32
-
33
- var coreClient__namespace = /*#__PURE__*/_interopNamespaceDefault(coreClient);
34
-
35
- // Copyright (c) Microsoft Corporation.
36
- // Licensed under the MIT license.
37
- const mapToCreateChatThreadOptionsRestModel = (options) => {
38
- const { participants, idempotencyToken } = options, rest = tslib.__rest(options, ["participants", "idempotencyToken"]);
39
- return Object.assign({ repeatabilityRequestId: idempotencyToken }, rest);
40
- };
41
- /**
42
- * @internal
43
- * Mapping chat participant customer model to chat participant REST model
44
- */
45
- const mapToChatParticipantRestModel = (chatParticipant) => {
46
- const { id } = chatParticipant, rest = tslib.__rest(chatParticipant, ["id"]);
47
- return Object.assign(Object.assign({}, rest), { communicationIdentifier: communicationCommon.serializeCommunicationIdentifier(id) });
48
- };
49
- /**
50
- * @internal
51
- * Mapping add participants request to add chat participants request REST model
52
- */
53
- const mapToAddChatParticipantsRequestRestModel = (addParticipantsRequest) => {
54
- var _a;
55
- return {
56
- participants: (_a = addParticipantsRequest.participants) === null || _a === void 0 ? void 0 : _a.map((participant) => mapToChatParticipantRestModel(participant)),
57
- };
58
- };
59
- /**
60
- * @internal
61
- * Mapping chat attachment SDK model to chat attachment REST model
62
- */
63
- const mapToChatAttachmentRestModel = (chatAttachment) => {
64
- const { attachmentType } = chatAttachment, rest = tslib.__rest(chatAttachment, ["attachmentType"]);
65
- if (attachmentType === "unknown") {
66
- throw new Error("'unknown' attachmentType not supported");
67
- }
68
- return Object.assign(Object.assign({}, rest), { attachmentType: attachmentType });
69
- };
70
- /**
71
- * @internal
72
- * Mapping send message request and options to send chat message request REST model
73
- */
74
- const mapToSendChatMessageRequestRestModel = (sendMessageRequest, sendMessageOptions) => {
75
- const { attachments } = sendMessageOptions, restOptions = tslib.__rest(sendMessageOptions, ["attachments"]);
76
- let request = Object.assign(Object.assign({}, sendMessageRequest), restOptions);
77
- if (attachments) {
78
- request = Object.assign(Object.assign({}, request), { attachments: attachments === null || attachments === void 0 ? void 0 : attachments.map((attachment) => mapToChatAttachmentRestModel(attachment)) });
79
- }
80
- return request;
81
- };
82
- /**
83
- * @internal
84
- * Mapping update message options to update chat message request REST model
85
- */
86
- const mapToUpdateChatMessageRequestRestModel = (updateMessageOptions) => {
87
- const { attachments } = updateMessageOptions, restOptions = tslib.__rest(updateMessageOptions, ["attachments"]);
88
- let request = Object.assign({}, restOptions);
89
- if (attachments) {
90
- request = Object.assign(Object.assign({}, request), { attachments: attachments === null || attachments === void 0 ? void 0 : attachments.map((attachment) => mapToChatAttachmentRestModel(attachment)) });
91
- }
92
- return request;
93
- };
94
- /**
95
- * @internal
96
- * Mapping chat participant REST model to chat participant SDK model
97
- */
98
- const mapToChatParticipantSdkModel = (chatParticipant) => {
99
- const { communicationIdentifier } = chatParticipant, rest = tslib.__rest(chatParticipant, ["communicationIdentifier"]);
100
- return Object.assign(Object.assign({}, rest), { id: communicationCommon.deserializeCommunicationIdentifier(communicationIdentifier) });
101
- };
102
- /**
103
- * @internal
104
- * Mapping chat attachment REST model to chat attachment SDK model
105
- */
106
- const mapToChatAttachmentSdkModel = (chatAttachment) => {
107
- const { attachmentType } = chatAttachment, rest = tslib.__rest(chatAttachment, ["attachmentType"]);
108
- return Object.assign(Object.assign({}, rest), { attachmentType: attachmentType });
109
- };
110
- /**
111
- * @internal
112
- */
113
- const mapToChatContentSdkModel = (content) => {
114
- const { participants, attachments, initiatorCommunicationIdentifier } = content, otherChatContents = tslib.__rest(content, ["participants", "attachments", "initiatorCommunicationIdentifier"]);
115
- let result = Object.assign({}, otherChatContents);
116
- if (initiatorCommunicationIdentifier) {
117
- const initiator = communicationCommon.deserializeCommunicationIdentifier(initiatorCommunicationIdentifier);
118
- result = Object.assign(Object.assign({}, result), { initiator });
119
- }
120
- if (participants) {
121
- result = Object.assign(Object.assign({}, result), { participants: participants === null || participants === void 0 ? void 0 : participants.map((participant) => mapToChatParticipantSdkModel(participant)) });
122
- }
123
- if (attachments) {
124
- result = Object.assign(Object.assign({}, result), { attachments: attachments === null || attachments === void 0 ? void 0 : attachments.map((attachment) => mapToChatAttachmentSdkModel(attachment)) });
125
- }
126
- return result;
127
- };
128
- /**
129
- * @internal
130
- */
131
- const mapToChatPolicyViolationSdkModel = (policyVolation) => {
132
- const { state } = policyVolation;
133
- const result = {
134
- result: state,
135
- };
136
- return result;
137
- };
138
- /**
139
- * @internal
140
- * Mapping chat message REST model to chat message SDK model
141
- */
142
- const mapToChatMessageSdkModel = (chatMessage) => {
143
- const { content, senderCommunicationIdentifier, policyViolation } = chatMessage, otherChatMessage = tslib.__rest(chatMessage, ["content", "senderCommunicationIdentifier", "policyViolation"]);
144
- let result = Object.assign({}, otherChatMessage);
145
- if (content) {
146
- result = Object.assign(Object.assign({}, result), { content: mapToChatContentSdkModel(content) });
147
- }
148
- if (senderCommunicationIdentifier) {
149
- const sender = communicationCommon.deserializeCommunicationIdentifier(senderCommunicationIdentifier);
150
- result = Object.assign(Object.assign({}, result), { sender });
151
- }
152
- if (policyViolation) {
153
- result = Object.assign(Object.assign({}, result), { policyViolation: mapToChatPolicyViolationSdkModel(policyViolation) });
154
- }
155
- return result;
156
- };
157
- /**
158
- * @internal
159
- * Mapping chat retention policy REST model to chat retention policy SDK model
160
- */
161
- const mapToRetentionPolicySdkModel = (retentionPolicy) => {
162
- if (retentionPolicy.kind === "threadCreationDate") {
163
- return retentionPolicy;
164
- }
165
- if (retentionPolicy.kind === "none") {
166
- return retentionPolicy;
167
- }
168
- else {
169
- throw new Error(`Retention Policy ${retentionPolicy.kind} is not supported`);
170
- }
171
- };
172
- /**
173
- * @internal
174
- * Mapping chat thread REST model to chat thread SDK model
175
- */
176
- const mapToChatThreadPropertiesSdkModel = (chatThread) => {
177
- const { createdByCommunicationIdentifier, retentionPolicy } = chatThread, rest = tslib.__rest(chatThread, ["createdByCommunicationIdentifier", "retentionPolicy"]);
178
- let result = Object.assign({}, rest);
179
- if (createdByCommunicationIdentifier) {
180
- result = Object.assign(Object.assign({}, result), { createdBy: communicationCommon.deserializeCommunicationIdentifier(createdByCommunicationIdentifier) });
181
- }
182
- if (retentionPolicy) {
183
- result = Object.assign(Object.assign({}, result), { retentionPolicy: mapToRetentionPolicySdkModel(retentionPolicy) });
184
- }
185
- return result;
186
- };
187
- /**
188
- * @internal
189
- * Mapping chat thread REST model to chat thread SDK model
190
- */
191
- const mapToCreateChatThreadResultSdkModel = (result) => {
192
- const { chatThread } = result, rest = tslib.__rest(result, ["chatThread"]);
193
- if (chatThread) {
194
- return Object.assign(Object.assign({}, rest), { chatThread: mapToChatThreadPropertiesSdkModel(chatThread) });
195
- }
196
- else {
197
- return Object.assign({}, rest);
198
- }
199
- };
200
- /**
201
- * @internal
202
- * Mapping read receipt REST model to read receipt SDK model
203
- */
204
- const mapToReadReceiptSdkModel = (readReceipt) => {
205
- const { senderCommunicationIdentifier } = readReceipt, rest = tslib.__rest(readReceipt, ["senderCommunicationIdentifier"]);
206
- return Object.assign(Object.assign({}, rest), { sender: communicationCommon.deserializeCommunicationIdentifier(senderCommunicationIdentifier) });
207
- };
208
-
209
- /*
210
- * Copyright (c) Microsoft Corporation.
211
- * Licensed under the MIT License.
212
- *
213
- * Code generated by Microsoft (R) AutoRest Code Generator.
214
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
215
- */
216
- const tracingClient = coreTracing.createTracingClient({
217
- namespace: "Azure.Communication",
218
- packageName: "@azure/communication-chat",
219
- packageVersion: "1.6.0-beta.2",
220
- });
221
-
222
- /*
223
- * Copyright (c) Microsoft Corporation.
224
- * Licensed under the MIT License.
225
- *
226
- * Code generated by Microsoft (R) AutoRest Code Generator.
227
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
228
- */
229
- const ChatMessageReadReceiptsCollection = {
230
- type: {
231
- name: "Composite",
232
- className: "ChatMessageReadReceiptsCollection",
233
- modelProperties: {
234
- value: {
235
- serializedName: "value",
236
- required: true,
237
- type: {
238
- name: "Sequence",
239
- element: {
240
- type: {
241
- name: "Composite",
242
- className: "ChatMessageReadReceipt",
243
- },
244
- },
245
- },
246
- },
247
- nextLink: {
248
- serializedName: "nextLink",
249
- readOnly: true,
250
- type: {
251
- name: "String",
252
- },
253
- },
254
- },
255
- },
256
- };
257
- const ChatMessageReadReceipt = {
258
- type: {
259
- name: "Composite",
260
- className: "ChatMessageReadReceipt",
261
- modelProperties: {
262
- senderCommunicationIdentifier: {
263
- serializedName: "senderCommunicationIdentifier",
264
- type: {
265
- name: "Composite",
266
- className: "CommunicationIdentifierModel",
267
- },
268
- },
269
- chatMessageId: {
270
- serializedName: "chatMessageId",
271
- required: true,
272
- type: {
273
- name: "String",
274
- },
275
- },
276
- readOn: {
277
- serializedName: "readOn",
278
- required: true,
279
- type: {
280
- name: "DateTime",
281
- },
282
- },
283
- },
284
- },
285
- };
286
- const CommunicationIdentifierModel = {
287
- type: {
288
- name: "Composite",
289
- className: "CommunicationIdentifierModel",
290
- modelProperties: {
291
- kind: {
292
- serializedName: "kind",
293
- type: {
294
- name: "String",
295
- },
296
- },
297
- rawId: {
298
- serializedName: "rawId",
299
- type: {
300
- name: "String",
301
- },
302
- },
303
- communicationUser: {
304
- serializedName: "communicationUser",
305
- type: {
306
- name: "Composite",
307
- className: "CommunicationUserIdentifierModel",
308
- },
309
- },
310
- phoneNumber: {
311
- serializedName: "phoneNumber",
312
- type: {
313
- name: "Composite",
314
- className: "PhoneNumberIdentifierModel",
315
- },
316
- },
317
- microsoftTeamsUser: {
318
- serializedName: "microsoftTeamsUser",
319
- type: {
320
- name: "Composite",
321
- className: "MicrosoftTeamsUserIdentifierModel",
322
- },
323
- },
324
- microsoftTeamsApp: {
325
- serializedName: "microsoftTeamsApp",
326
- type: {
327
- name: "Composite",
328
- className: "MicrosoftTeamsAppIdentifierModel",
329
- },
330
- },
331
- },
332
- },
333
- };
334
- const CommunicationUserIdentifierModel = {
335
- type: {
336
- name: "Composite",
337
- className: "CommunicationUserIdentifierModel",
338
- modelProperties: {
339
- id: {
340
- serializedName: "id",
341
- required: true,
342
- type: {
343
- name: "String",
344
- },
345
- },
346
- },
347
- },
348
- };
349
- const PhoneNumberIdentifierModel = {
350
- type: {
351
- name: "Composite",
352
- className: "PhoneNumberIdentifierModel",
353
- modelProperties: {
354
- value: {
355
- serializedName: "value",
356
- required: true,
357
- type: {
358
- name: "String",
359
- },
360
- },
361
- },
362
- },
363
- };
364
- const MicrosoftTeamsUserIdentifierModel = {
365
- type: {
366
- name: "Composite",
367
- className: "MicrosoftTeamsUserIdentifierModel",
368
- modelProperties: {
369
- userId: {
370
- serializedName: "userId",
371
- required: true,
372
- type: {
373
- name: "String",
374
- },
375
- },
376
- isAnonymous: {
377
- serializedName: "isAnonymous",
378
- type: {
379
- name: "Boolean",
380
- },
381
- },
382
- cloud: {
383
- serializedName: "cloud",
384
- type: {
385
- name: "String",
386
- },
387
- },
388
- },
389
- },
390
- };
391
- const MicrosoftTeamsAppIdentifierModel = {
392
- type: {
393
- name: "Composite",
394
- className: "MicrosoftTeamsAppIdentifierModel",
395
- modelProperties: {
396
- appId: {
397
- serializedName: "appId",
398
- required: true,
399
- type: {
400
- name: "String",
401
- },
402
- },
403
- cloud: {
404
- serializedName: "cloud",
405
- type: {
406
- name: "String",
407
- },
408
- },
409
- },
410
- },
411
- };
412
- const CommunicationErrorResponse = {
413
- type: {
414
- name: "Composite",
415
- className: "CommunicationErrorResponse",
416
- modelProperties: {
417
- error: {
418
- serializedName: "error",
419
- type: {
420
- name: "Composite",
421
- className: "ChatError",
422
- },
423
- },
424
- },
425
- },
426
- };
427
- const ChatError = {
428
- type: {
429
- name: "Composite",
430
- className: "ChatError",
431
- modelProperties: {
432
- code: {
433
- serializedName: "code",
434
- required: true,
435
- type: {
436
- name: "String",
437
- },
438
- },
439
- message: {
440
- serializedName: "message",
441
- required: true,
442
- type: {
443
- name: "String",
444
- },
445
- },
446
- target: {
447
- serializedName: "target",
448
- readOnly: true,
449
- type: {
450
- name: "String",
451
- },
452
- },
453
- details: {
454
- serializedName: "details",
455
- readOnly: true,
456
- type: {
457
- name: "Sequence",
458
- element: {
459
- type: {
460
- name: "Composite",
461
- className: "ChatError",
462
- },
463
- },
464
- },
465
- },
466
- innerError: {
467
- serializedName: "innererror",
468
- type: {
469
- name: "Composite",
470
- className: "ChatError",
471
- },
472
- },
473
- },
474
- },
475
- };
476
- const SendReadReceiptRequest = {
477
- type: {
478
- name: "Composite",
479
- className: "SendReadReceiptRequest",
480
- modelProperties: {
481
- chatMessageId: {
482
- serializedName: "chatMessageId",
483
- required: true,
484
- type: {
485
- name: "String",
486
- },
487
- },
488
- },
489
- },
490
- };
491
- const SendChatMessageRequest = {
492
- type: {
493
- name: "Composite",
494
- className: "SendChatMessageRequest",
495
- modelProperties: {
496
- content: {
497
- serializedName: "content",
498
- required: true,
499
- type: {
500
- name: "String",
501
- },
502
- },
503
- senderDisplayName: {
504
- serializedName: "senderDisplayName",
505
- type: {
506
- name: "String",
507
- },
508
- },
509
- type: {
510
- serializedName: "type",
511
- type: {
512
- name: "Enum",
513
- allowedValues: [
514
- "text",
515
- "html",
516
- "topicUpdated",
517
- "participantAdded",
518
- "participantRemoved",
519
- ],
520
- },
521
- },
522
- metadata: {
523
- serializedName: "metadata",
524
- type: {
525
- name: "Dictionary",
526
- value: { type: { name: "String" } },
527
- },
528
- },
529
- attachments: {
530
- serializedName: "attachments",
531
- type: {
532
- name: "Sequence",
533
- element: {
534
- type: {
535
- name: "Composite",
536
- className: "ChatAttachment",
537
- },
538
- },
539
- },
540
- },
541
- },
542
- },
543
- };
544
- const ChatAttachment = {
545
- type: {
546
- name: "Composite",
547
- className: "ChatAttachment",
548
- modelProperties: {
549
- id: {
550
- serializedName: "id",
551
- required: true,
552
- type: {
553
- name: "String",
554
- },
555
- },
556
- attachmentType: {
557
- serializedName: "attachmentType",
558
- required: true,
559
- type: {
560
- name: "Enum",
561
- allowedValues: ["image", "file"],
562
- },
563
- },
564
- name: {
565
- serializedName: "name",
566
- type: {
567
- name: "String",
568
- },
569
- },
570
- url: {
571
- serializedName: "url",
572
- type: {
573
- name: "String",
574
- },
575
- },
576
- previewUrl: {
577
- serializedName: "previewUrl",
578
- type: {
579
- name: "String",
580
- },
581
- },
582
- },
583
- },
584
- };
585
- const SendChatMessageResult = {
586
- type: {
587
- name: "Composite",
588
- className: "SendChatMessageResult",
589
- modelProperties: {
590
- id: {
591
- serializedName: "id",
592
- required: true,
593
- type: {
594
- name: "String",
595
- },
596
- },
597
- },
598
- },
599
- };
600
- const ChatMessagesCollection = {
601
- type: {
602
- name: "Composite",
603
- className: "ChatMessagesCollection",
604
- modelProperties: {
605
- value: {
606
- serializedName: "value",
607
- required: true,
608
- type: {
609
- name: "Sequence",
610
- element: {
611
- type: {
612
- name: "Composite",
613
- className: "ChatMessage",
614
- },
615
- },
616
- },
617
- },
618
- nextLink: {
619
- serializedName: "nextLink",
620
- readOnly: true,
621
- type: {
622
- name: "String",
623
- },
624
- },
625
- },
626
- },
627
- };
628
- const ChatMessage = {
629
- type: {
630
- name: "Composite",
631
- className: "ChatMessage",
632
- modelProperties: {
633
- id: {
634
- serializedName: "id",
635
- required: true,
636
- type: {
637
- name: "String",
638
- },
639
- },
640
- type: {
641
- serializedName: "type",
642
- required: true,
643
- type: {
644
- name: "Enum",
645
- allowedValues: [
646
- "text",
647
- "html",
648
- "topicUpdated",
649
- "participantAdded",
650
- "participantRemoved",
651
- ],
652
- },
653
- },
654
- sequenceId: {
655
- serializedName: "sequenceId",
656
- required: true,
657
- type: {
658
- name: "String",
659
- },
660
- },
661
- version: {
662
- serializedName: "version",
663
- required: true,
664
- type: {
665
- name: "String",
666
- },
667
- },
668
- content: {
669
- serializedName: "content",
670
- type: {
671
- name: "Composite",
672
- className: "ChatMessageContent",
673
- },
674
- },
675
- senderDisplayName: {
676
- serializedName: "senderDisplayName",
677
- type: {
678
- name: "String",
679
- },
680
- },
681
- createdOn: {
682
- serializedName: "createdOn",
683
- required: true,
684
- type: {
685
- name: "DateTime",
686
- },
687
- },
688
- senderCommunicationIdentifier: {
689
- serializedName: "senderCommunicationIdentifier",
690
- type: {
691
- name: "Composite",
692
- className: "CommunicationIdentifierModel",
693
- },
694
- },
695
- deletedOn: {
696
- serializedName: "deletedOn",
697
- type: {
698
- name: "DateTime",
699
- },
700
- },
701
- editedOn: {
702
- serializedName: "editedOn",
703
- type: {
704
- name: "DateTime",
705
- },
706
- },
707
- metadata: {
708
- serializedName: "metadata",
709
- type: {
710
- name: "Dictionary",
711
- value: { type: { name: "String" } },
712
- },
713
- },
714
- policyViolation: {
715
- serializedName: "policyViolation",
716
- type: {
717
- name: "Composite",
718
- className: "PolicyViolation",
719
- },
720
- },
721
- },
722
- },
723
- };
724
- const ChatMessageContent = {
725
- type: {
726
- name: "Composite",
727
- className: "ChatMessageContent",
728
- modelProperties: {
729
- message: {
730
- serializedName: "message",
731
- type: {
732
- name: "String",
733
- },
734
- },
735
- topic: {
736
- serializedName: "topic",
737
- type: {
738
- name: "String",
739
- },
740
- },
741
- participants: {
742
- serializedName: "participants",
743
- type: {
744
- name: "Sequence",
745
- element: {
746
- type: {
747
- name: "Composite",
748
- className: "ChatParticipant",
749
- },
750
- },
751
- },
752
- },
753
- attachments: {
754
- serializedName: "attachments",
755
- type: {
756
- name: "Sequence",
757
- element: {
758
- type: {
759
- name: "Composite",
760
- className: "ChatAttachment",
761
- },
762
- },
763
- },
764
- },
765
- initiatorCommunicationIdentifier: {
766
- serializedName: "initiatorCommunicationIdentifier",
767
- type: {
768
- name: "Composite",
769
- className: "CommunicationIdentifierModel",
770
- },
771
- },
772
- },
773
- },
774
- };
775
- const ChatParticipant = {
776
- type: {
777
- name: "Composite",
778
- className: "ChatParticipant",
779
- modelProperties: {
780
- communicationIdentifier: {
781
- serializedName: "communicationIdentifier",
782
- type: {
783
- name: "Composite",
784
- className: "CommunicationIdentifierModel",
785
- },
786
- },
787
- displayName: {
788
- serializedName: "displayName",
789
- type: {
790
- name: "String",
791
- },
792
- },
793
- shareHistoryTime: {
794
- serializedName: "shareHistoryTime",
795
- type: {
796
- name: "DateTime",
797
- },
798
- },
799
- metadata: {
800
- serializedName: "metadata",
801
- type: {
802
- name: "Dictionary",
803
- value: { type: { name: "String" } },
804
- },
805
- },
806
- },
807
- },
808
- };
809
- const PolicyViolation = {
810
- type: {
811
- name: "Composite",
812
- className: "PolicyViolation",
813
- modelProperties: {
814
- state: {
815
- serializedName: "state",
816
- required: true,
817
- type: {
818
- name: "Enum",
819
- allowedValues: ["contentBlocked", "warning"],
820
- },
821
- },
822
- },
823
- },
824
- };
825
- const UpdateChatMessageRequest = {
826
- type: {
827
- name: "Composite",
828
- className: "UpdateChatMessageRequest",
829
- modelProperties: {
830
- content: {
831
- serializedName: "content",
832
- type: {
833
- name: "String",
834
- },
835
- },
836
- metadata: {
837
- serializedName: "metadata",
838
- type: {
839
- name: "Dictionary",
840
- value: { type: { name: "String" } },
841
- },
842
- },
843
- attachments: {
844
- serializedName: "attachments",
845
- type: {
846
- name: "Sequence",
847
- element: {
848
- type: {
849
- name: "Composite",
850
- className: "ChatAttachment",
851
- },
852
- },
853
- },
854
- },
855
- },
856
- },
857
- };
858
- const ChatParticipantsCollection = {
859
- type: {
860
- name: "Composite",
861
- className: "ChatParticipantsCollection",
862
- modelProperties: {
863
- value: {
864
- serializedName: "value",
865
- required: true,
866
- type: {
867
- name: "Sequence",
868
- element: {
869
- type: {
870
- name: "Composite",
871
- className: "ChatParticipant",
872
- },
873
- },
874
- },
875
- },
876
- nextLink: {
877
- serializedName: "nextLink",
878
- readOnly: true,
879
- type: {
880
- name: "String",
881
- },
882
- },
883
- },
884
- },
885
- };
886
- const AddChatParticipantsRequest = {
887
- type: {
888
- name: "Composite",
889
- className: "AddChatParticipantsRequest",
890
- modelProperties: {
891
- participants: {
892
- serializedName: "participants",
893
- required: true,
894
- type: {
895
- name: "Sequence",
896
- element: {
897
- type: {
898
- name: "Composite",
899
- className: "ChatParticipant",
900
- },
901
- },
902
- },
903
- },
904
- },
905
- },
906
- };
907
- const AddChatParticipantsResult = {
908
- type: {
909
- name: "Composite",
910
- className: "AddChatParticipantsResult",
911
- modelProperties: {
912
- invalidParticipants: {
913
- serializedName: "invalidParticipants",
914
- readOnly: true,
915
- type: {
916
- name: "Sequence",
917
- element: {
918
- type: {
919
- name: "Composite",
920
- className: "ChatError",
921
- },
922
- },
923
- },
924
- },
925
- },
926
- },
927
- };
928
- const CreateChatThreadRequest = {
929
- type: {
930
- name: "Composite",
931
- className: "CreateChatThreadRequest",
932
- modelProperties: {
933
- topic: {
934
- serializedName: "topic",
935
- required: true,
936
- type: {
937
- name: "String",
938
- },
939
- },
940
- participants: {
941
- serializedName: "participants",
942
- type: {
943
- name: "Sequence",
944
- element: {
945
- type: {
946
- name: "Composite",
947
- className: "ChatParticipant",
948
- },
949
- },
950
- },
951
- },
952
- metadata: {
953
- serializedName: "metadata",
954
- type: {
955
- name: "Dictionary",
956
- value: { type: { name: "String" } },
957
- },
958
- },
959
- retentionPolicy: {
960
- serializedName: "retentionPolicy",
961
- type: {
962
- name: "Composite",
963
- className: "ChatRetentionPolicy",
964
- },
965
- },
966
- },
967
- },
968
- };
969
- const ChatRetentionPolicy = {
970
- type: {
971
- name: "Composite",
972
- className: "ChatRetentionPolicy",
973
- uberParent: "ChatRetentionPolicy",
974
- polymorphicDiscriminator: {
975
- serializedName: "kind",
976
- clientName: "kind",
977
- },
978
- modelProperties: {
979
- kind: {
980
- serializedName: "kind",
981
- required: true,
982
- type: {
983
- name: "Enum",
984
- allowedValues: ["threadCreationDate", "none"],
985
- },
986
- },
987
- },
988
- },
989
- };
990
- const CreateChatThreadResult = {
991
- type: {
992
- name: "Composite",
993
- className: "CreateChatThreadResult",
994
- modelProperties: {
995
- chatThread: {
996
- serializedName: "chatThread",
997
- type: {
998
- name: "Composite",
999
- className: "ChatThreadProperties",
1000
- },
1001
- },
1002
- invalidParticipants: {
1003
- serializedName: "invalidParticipants",
1004
- readOnly: true,
1005
- type: {
1006
- name: "Sequence",
1007
- element: {
1008
- type: {
1009
- name: "Composite",
1010
- className: "ChatError",
1011
- },
1012
- },
1013
- },
1014
- },
1015
- },
1016
- },
1017
- };
1018
- const ChatThreadProperties = {
1019
- type: {
1020
- name: "Composite",
1021
- className: "ChatThreadProperties",
1022
- modelProperties: {
1023
- id: {
1024
- serializedName: "id",
1025
- required: true,
1026
- type: {
1027
- name: "String",
1028
- },
1029
- },
1030
- topic: {
1031
- serializedName: "topic",
1032
- required: true,
1033
- type: {
1034
- name: "String",
1035
- },
1036
- },
1037
- createdOn: {
1038
- serializedName: "createdOn",
1039
- required: true,
1040
- type: {
1041
- name: "DateTime",
1042
- },
1043
- },
1044
- createdByCommunicationIdentifier: {
1045
- serializedName: "createdByCommunicationIdentifier",
1046
- type: {
1047
- name: "Composite",
1048
- className: "CommunicationIdentifierModel",
1049
- },
1050
- },
1051
- deletedOn: {
1052
- serializedName: "deletedOn",
1053
- type: {
1054
- name: "DateTime",
1055
- },
1056
- },
1057
- metadata: {
1058
- serializedName: "metadata",
1059
- type: {
1060
- name: "Dictionary",
1061
- value: { type: { name: "String" } },
1062
- },
1063
- },
1064
- retentionPolicy: {
1065
- serializedName: "retentionPolicy",
1066
- type: {
1067
- name: "Composite",
1068
- className: "ChatRetentionPolicy",
1069
- },
1070
- },
1071
- messagingPolicy: {
1072
- serializedName: "messagingPolicy",
1073
- type: {
1074
- name: "Composite",
1075
- className: "MessagingPolicy",
1076
- },
1077
- },
1078
- },
1079
- },
1080
- };
1081
- const MessagingPolicy = {
1082
- type: {
1083
- name: "Composite",
1084
- className: "MessagingPolicy",
1085
- modelProperties: {
1086
- textOnlyChat: {
1087
- serializedName: "textOnlyChat",
1088
- type: {
1089
- name: "Boolean",
1090
- },
1091
- },
1092
- },
1093
- },
1094
- };
1095
- const ChatThreadsItemCollection = {
1096
- type: {
1097
- name: "Composite",
1098
- className: "ChatThreadsItemCollection",
1099
- modelProperties: {
1100
- value: {
1101
- serializedName: "value",
1102
- required: true,
1103
- type: {
1104
- name: "Sequence",
1105
- element: {
1106
- type: {
1107
- name: "Composite",
1108
- className: "ChatThreadItem",
1109
- },
1110
- },
1111
- },
1112
- },
1113
- nextLink: {
1114
- serializedName: "nextLink",
1115
- readOnly: true,
1116
- type: {
1117
- name: "String",
1118
- },
1119
- },
1120
- },
1121
- },
1122
- };
1123
- const ChatThreadItem = {
1124
- type: {
1125
- name: "Composite",
1126
- className: "ChatThreadItem",
1127
- modelProperties: {
1128
- id: {
1129
- serializedName: "id",
1130
- required: true,
1131
- type: {
1132
- name: "String",
1133
- },
1134
- },
1135
- topic: {
1136
- serializedName: "topic",
1137
- required: true,
1138
- type: {
1139
- name: "String",
1140
- },
1141
- },
1142
- deletedOn: {
1143
- serializedName: "deletedOn",
1144
- type: {
1145
- name: "DateTime",
1146
- },
1147
- },
1148
- lastMessageReceivedOn: {
1149
- serializedName: "lastMessageReceivedOn",
1150
- readOnly: true,
1151
- type: {
1152
- name: "DateTime",
1153
- },
1154
- },
1155
- },
1156
- },
1157
- };
1158
- const UpdateChatThreadRequest = {
1159
- type: {
1160
- name: "Composite",
1161
- className: "UpdateChatThreadRequest",
1162
- modelProperties: {
1163
- topic: {
1164
- serializedName: "topic",
1165
- type: {
1166
- name: "String",
1167
- },
1168
- },
1169
- metadata: {
1170
- serializedName: "metadata",
1171
- type: {
1172
- name: "Dictionary",
1173
- value: { type: { name: "String" } },
1174
- },
1175
- },
1176
- retentionPolicy: {
1177
- serializedName: "retentionPolicy",
1178
- type: {
1179
- name: "Composite",
1180
- className: "ChatRetentionPolicy",
1181
- },
1182
- },
1183
- },
1184
- },
1185
- };
1186
- const SendTypingNotificationRequest = {
1187
- type: {
1188
- name: "Composite",
1189
- className: "SendTypingNotificationRequest",
1190
- modelProperties: {
1191
- senderDisplayName: {
1192
- serializedName: "senderDisplayName",
1193
- type: {
1194
- name: "String",
1195
- },
1196
- },
1197
- },
1198
- },
1199
- };
1200
- const UploadChatImageResult = {
1201
- type: {
1202
- name: "Composite",
1203
- className: "UploadChatImageResult",
1204
- modelProperties: {
1205
- id: {
1206
- serializedName: "id",
1207
- required: true,
1208
- type: {
1209
- name: "String",
1210
- },
1211
- },
1212
- attachmentType: {
1213
- serializedName: "attachmentType",
1214
- type: {
1215
- name: "Enum",
1216
- allowedValues: ["image", "file"],
1217
- },
1218
- },
1219
- name: {
1220
- serializedName: "name",
1221
- type: {
1222
- name: "String",
1223
- },
1224
- },
1225
- },
1226
- },
1227
- };
1228
- const ErrorResponse = {
1229
- type: {
1230
- name: "Composite",
1231
- className: "ErrorResponse",
1232
- modelProperties: {
1233
- error: {
1234
- serializedName: "error",
1235
- type: {
1236
- name: "Composite",
1237
- className: "ErrorModel",
1238
- },
1239
- },
1240
- },
1241
- },
1242
- };
1243
- const ErrorModel = {
1244
- type: {
1245
- name: "Composite",
1246
- className: "ErrorModel",
1247
- modelProperties: {
1248
- code: {
1249
- serializedName: "code",
1250
- required: true,
1251
- type: {
1252
- name: "String",
1253
- },
1254
- },
1255
- message: {
1256
- serializedName: "message",
1257
- required: true,
1258
- type: {
1259
- name: "String",
1260
- },
1261
- },
1262
- details: {
1263
- serializedName: "details",
1264
- type: {
1265
- name: "Sequence",
1266
- element: {
1267
- type: {
1268
- name: "Composite",
1269
- className: "ErrorDetail",
1270
- },
1271
- },
1272
- },
1273
- },
1274
- },
1275
- },
1276
- };
1277
- const ErrorDetail = {
1278
- type: {
1279
- name: "Composite",
1280
- className: "ErrorDetail",
1281
- modelProperties: {
1282
- code: {
1283
- serializedName: "code",
1284
- required: true,
1285
- type: {
1286
- name: "String",
1287
- },
1288
- },
1289
- message: {
1290
- serializedName: "message",
1291
- required: true,
1292
- type: {
1293
- name: "String",
1294
- },
1295
- },
1296
- },
1297
- },
1298
- };
1299
- const ThreadCreationDateRetentionPolicy = {
1300
- serializedName: "threadCreationDate",
1301
- type: {
1302
- name: "Composite",
1303
- className: "ThreadCreationDateRetentionPolicy",
1304
- uberParent: "ChatRetentionPolicy",
1305
- polymorphicDiscriminator: ChatRetentionPolicy.type.polymorphicDiscriminator,
1306
- modelProperties: Object.assign(Object.assign({}, ChatRetentionPolicy.type.modelProperties), { deleteThreadAfterDays: {
1307
- serializedName: "deleteThreadAfterDays",
1308
- required: true,
1309
- type: {
1310
- name: "Number",
1311
- },
1312
- } }),
1313
- },
1314
- };
1315
- const NoneRetentionPolicy = {
1316
- serializedName: "none",
1317
- type: {
1318
- name: "Composite",
1319
- className: "NoneRetentionPolicy",
1320
- uberParent: "ChatRetentionPolicy",
1321
- polymorphicDiscriminator: ChatRetentionPolicy.type.polymorphicDiscriminator,
1322
- modelProperties: Object.assign({}, ChatRetentionPolicy.type.modelProperties),
1323
- },
1324
- };
1325
- let discriminators = {
1326
- ChatRetentionPolicy: ChatRetentionPolicy,
1327
- "ChatRetentionPolicy.threadCreationDate": ThreadCreationDateRetentionPolicy,
1328
- "ChatRetentionPolicy.none": NoneRetentionPolicy,
1329
- };
1330
-
1331
- var Mappers = /*#__PURE__*/Object.freeze({
1332
- __proto__: null,
1333
- AddChatParticipantsRequest: AddChatParticipantsRequest,
1334
- AddChatParticipantsResult: AddChatParticipantsResult,
1335
- ChatAttachment: ChatAttachment,
1336
- ChatError: ChatError,
1337
- ChatMessage: ChatMessage,
1338
- ChatMessageContent: ChatMessageContent,
1339
- ChatMessageReadReceipt: ChatMessageReadReceipt,
1340
- ChatMessageReadReceiptsCollection: ChatMessageReadReceiptsCollection,
1341
- ChatMessagesCollection: ChatMessagesCollection,
1342
- ChatParticipant: ChatParticipant,
1343
- ChatParticipantsCollection: ChatParticipantsCollection,
1344
- ChatRetentionPolicy: ChatRetentionPolicy,
1345
- ChatThreadItem: ChatThreadItem,
1346
- ChatThreadProperties: ChatThreadProperties,
1347
- ChatThreadsItemCollection: ChatThreadsItemCollection,
1348
- CommunicationErrorResponse: CommunicationErrorResponse,
1349
- CommunicationIdentifierModel: CommunicationIdentifierModel,
1350
- CommunicationUserIdentifierModel: CommunicationUserIdentifierModel,
1351
- CreateChatThreadRequest: CreateChatThreadRequest,
1352
- CreateChatThreadResult: CreateChatThreadResult,
1353
- ErrorDetail: ErrorDetail,
1354
- ErrorModel: ErrorModel,
1355
- ErrorResponse: ErrorResponse,
1356
- MessagingPolicy: MessagingPolicy,
1357
- MicrosoftTeamsAppIdentifierModel: MicrosoftTeamsAppIdentifierModel,
1358
- MicrosoftTeamsUserIdentifierModel: MicrosoftTeamsUserIdentifierModel,
1359
- NoneRetentionPolicy: NoneRetentionPolicy,
1360
- PhoneNumberIdentifierModel: PhoneNumberIdentifierModel,
1361
- PolicyViolation: PolicyViolation,
1362
- SendChatMessageRequest: SendChatMessageRequest,
1363
- SendChatMessageResult: SendChatMessageResult,
1364
- SendReadReceiptRequest: SendReadReceiptRequest,
1365
- SendTypingNotificationRequest: SendTypingNotificationRequest,
1366
- ThreadCreationDateRetentionPolicy: ThreadCreationDateRetentionPolicy,
1367
- UpdateChatMessageRequest: UpdateChatMessageRequest,
1368
- UpdateChatThreadRequest: UpdateChatThreadRequest,
1369
- UploadChatImageResult: UploadChatImageResult,
1370
- discriminators: discriminators
1371
- });
1372
-
1373
- /*
1374
- * Copyright (c) Microsoft Corporation.
1375
- * Licensed under the MIT License.
1376
- *
1377
- * Code generated by Microsoft (R) AutoRest Code Generator.
1378
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1379
- */
1380
- const accept = {
1381
- parameterPath: "accept",
1382
- mapper: {
1383
- defaultValue: "application/json",
1384
- isConstant: true,
1385
- serializedName: "Accept",
1386
- type: {
1387
- name: "String",
1388
- },
1389
- },
1390
- };
1391
- const endpoint = {
1392
- parameterPath: "endpoint",
1393
- mapper: {
1394
- serializedName: "endpoint",
1395
- required: true,
1396
- type: {
1397
- name: "String",
1398
- },
1399
- },
1400
- skipEncoding: true,
1401
- };
1402
- const chatThreadId = {
1403
- parameterPath: "chatThreadId",
1404
- mapper: {
1405
- serializedName: "chatThreadId",
1406
- required: true,
1407
- type: {
1408
- name: "String",
1409
- },
1410
- },
1411
- };
1412
- const maxPageSize = {
1413
- parameterPath: ["options", "maxPageSize"],
1414
- mapper: {
1415
- serializedName: "maxPageSize",
1416
- type: {
1417
- name: "Number",
1418
- },
1419
- },
1420
- };
1421
- const skip = {
1422
- parameterPath: ["options", "skip"],
1423
- mapper: {
1424
- serializedName: "skip",
1425
- type: {
1426
- name: "Number",
1427
- },
1428
- },
1429
- };
1430
- const apiVersion = {
1431
- parameterPath: "apiVersion",
1432
- mapper: {
1433
- defaultValue: "2024-06-05-preview",
1434
- isConstant: true,
1435
- serializedName: "api-version",
1436
- type: {
1437
- name: "String",
1438
- },
1439
- },
1440
- };
1441
- const contentType = {
1442
- parameterPath: ["options", "contentType"],
1443
- mapper: {
1444
- defaultValue: "application/json",
1445
- isConstant: true,
1446
- serializedName: "Content-Type",
1447
- type: {
1448
- name: "String",
1449
- },
1450
- },
1451
- };
1452
- const sendReadReceiptRequest = {
1453
- parameterPath: "sendReadReceiptRequest",
1454
- mapper: SendReadReceiptRequest,
1455
- };
1456
- const sendChatMessageRequest = {
1457
- parameterPath: "sendChatMessageRequest",
1458
- mapper: SendChatMessageRequest,
1459
- };
1460
- const startTime = {
1461
- parameterPath: ["options", "startTime"],
1462
- mapper: {
1463
- serializedName: "startTime",
1464
- type: {
1465
- name: "DateTime",
1466
- },
1467
- },
1468
- };
1469
- const chatMessageId = {
1470
- parameterPath: "chatMessageId",
1471
- mapper: {
1472
- serializedName: "chatMessageId",
1473
- required: true,
1474
- type: {
1475
- name: "String",
1476
- },
1477
- },
1478
- };
1479
- const contentType1 = {
1480
- parameterPath: ["options", "contentType"],
1481
- mapper: {
1482
- defaultValue: "application/merge-patch+json",
1483
- isConstant: true,
1484
- serializedName: "Content-Type",
1485
- type: {
1486
- name: "String",
1487
- },
1488
- },
1489
- };
1490
- const updateChatMessageRequest = {
1491
- parameterPath: "updateChatMessageRequest",
1492
- mapper: UpdateChatMessageRequest,
1493
- };
1494
- const participantCommunicationIdentifier = {
1495
- parameterPath: "participantCommunicationIdentifier",
1496
- mapper: CommunicationIdentifierModel,
1497
- };
1498
- const addChatParticipantsRequest = {
1499
- parameterPath: "addChatParticipantsRequest",
1500
- mapper: AddChatParticipantsRequest,
1501
- };
1502
- const updateChatThreadRequest = {
1503
- parameterPath: "updateChatThreadRequest",
1504
- mapper: UpdateChatThreadRequest,
1505
- };
1506
- const sendTypingNotificationRequest = {
1507
- parameterPath: ["options", "sendTypingNotificationRequest"],
1508
- mapper: SendTypingNotificationRequest,
1509
- };
1510
- const contentType2 = {
1511
- parameterPath: ["options", "contentType"],
1512
- mapper: {
1513
- defaultValue: "application/octet-stream",
1514
- isConstant: true,
1515
- serializedName: "Content-Type",
1516
- type: {
1517
- name: "String",
1518
- },
1519
- },
1520
- };
1521
- const chatImageFile = {
1522
- parameterPath: "chatImageFile",
1523
- mapper: {
1524
- serializedName: "chatImageFile",
1525
- required: true,
1526
- type: {
1527
- name: "Stream",
1528
- },
1529
- },
1530
- };
1531
- const accept1 = {
1532
- parameterPath: "accept",
1533
- mapper: {
1534
- defaultValue: "application/json",
1535
- isConstant: true,
1536
- serializedName: "Accept",
1537
- type: {
1538
- name: "String",
1539
- },
1540
- },
1541
- };
1542
- const imageFilename = {
1543
- parameterPath: ["options", "imageFilename"],
1544
- mapper: {
1545
- serializedName: "image-filename",
1546
- type: {
1547
- name: "String",
1548
- },
1549
- },
1550
- };
1551
- const accept2 = {
1552
- parameterPath: "accept",
1553
- mapper: {
1554
- defaultValue: "application/json, image/gif, image/jpeg, image/png, image/bmp, image/tiff",
1555
- isConstant: true,
1556
- serializedName: "Accept",
1557
- type: {
1558
- name: "String",
1559
- },
1560
- },
1561
- };
1562
- const imageId = {
1563
- parameterPath: "imageId",
1564
- mapper: {
1565
- serializedName: "imageId",
1566
- required: true,
1567
- type: {
1568
- name: "String",
1569
- },
1570
- },
1571
- };
1572
- const imageViewType = {
1573
- parameterPath: "imageViewType",
1574
- mapper: {
1575
- serializedName: "imageViewType",
1576
- required: true,
1577
- type: {
1578
- name: "String",
1579
- },
1580
- },
1581
- };
1582
- const nextLink = {
1583
- parameterPath: "nextLink",
1584
- mapper: {
1585
- serializedName: "nextLink",
1586
- required: true,
1587
- type: {
1588
- name: "String",
1589
- },
1590
- },
1591
- skipEncoding: true,
1592
- };
1593
- const createChatThreadRequest = {
1594
- parameterPath: "createChatThreadRequest",
1595
- mapper: CreateChatThreadRequest,
1596
- };
1597
- const repeatabilityRequestId = {
1598
- parameterPath: ["options", "repeatabilityRequestId"],
1599
- mapper: {
1600
- serializedName: "repeatability-request-id",
1601
- type: {
1602
- name: "String",
1603
- },
1604
- },
1605
- };
1606
-
1607
- /*
1608
- * Copyright (c) Microsoft Corporation.
1609
- * Licensed under the MIT License.
1610
- *
1611
- * Code generated by Microsoft (R) AutoRest Code Generator.
1612
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1613
- */
1614
- /** Class containing ChatThread operations. */
1615
- class ChatThreadImpl {
1616
- /**
1617
- * Initialize a new instance of the class ChatThread class.
1618
- * @param client Reference to the service client
1619
- */
1620
- constructor(client) {
1621
- this.client = client;
1622
- }
1623
- /**
1624
- * Gets chat message read receipts for a thread.
1625
- * @param chatThreadId Thread id to get the chat message read receipts for.
1626
- * @param options The options parameters.
1627
- */
1628
- async listChatReadReceipts(chatThreadId, options) {
1629
- return tracingClient.withSpan("ChatApiClient.listChatReadReceipts", options !== null && options !== void 0 ? options : {}, async (options) => {
1630
- return this.client.sendOperationRequest({ chatThreadId, options }, listChatReadReceiptsOperationSpec);
1631
- });
1632
- }
1633
- /**
1634
- * Sends a read receipt event to a thread, on behalf of a user.
1635
- * @param chatThreadId Thread id to send the read receipt event to.
1636
- * @param sendReadReceiptRequest Read receipt details.
1637
- * @param options The options parameters.
1638
- */
1639
- async sendChatReadReceipt(chatThreadId, sendReadReceiptRequest, options) {
1640
- return tracingClient.withSpan("ChatApiClient.sendChatReadReceipt", options !== null && options !== void 0 ? options : {}, async (options) => {
1641
- return this.client.sendOperationRequest({ chatThreadId, sendReadReceiptRequest, options }, sendChatReadReceiptOperationSpec);
1642
- });
1643
- }
1644
- /**
1645
- * Sends a message to a thread.
1646
- * @param chatThreadId The thread id to send the message to.
1647
- * @param sendChatMessageRequest Details of the message to send.
1648
- * @param options The options parameters.
1649
- */
1650
- async sendChatMessage(chatThreadId, sendChatMessageRequest, options) {
1651
- return tracingClient.withSpan("ChatApiClient.sendChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
1652
- return this.client.sendOperationRequest({ chatThreadId, sendChatMessageRequest, options }, sendChatMessageOperationSpec);
1653
- });
1654
- }
1655
- /**
1656
- * Gets a list of messages from a thread.
1657
- * @param chatThreadId The thread id of the message.
1658
- * @param options The options parameters.
1659
- */
1660
- async listChatMessages(chatThreadId, options) {
1661
- return tracingClient.withSpan("ChatApiClient.listChatMessages", options !== null && options !== void 0 ? options : {}, async (options) => {
1662
- return this.client.sendOperationRequest({ chatThreadId, options }, listChatMessagesOperationSpec);
1663
- });
1664
- }
1665
- /**
1666
- * Gets a message by id.
1667
- * @param chatThreadId The thread id to which the message was sent.
1668
- * @param chatMessageId The message id.
1669
- * @param options The options parameters.
1670
- */
1671
- async getChatMessage(chatThreadId, chatMessageId, options) {
1672
- return tracingClient.withSpan("ChatApiClient.getChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
1673
- return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, getChatMessageOperationSpec);
1674
- });
1675
- }
1676
- /**
1677
- * Updates a message.
1678
- * @param chatThreadId The thread id to which the message was sent.
1679
- * @param chatMessageId The message id.
1680
- * @param updateChatMessageRequest Details of the request to update the message.
1681
- * @param options The options parameters.
1682
- */
1683
- async updateChatMessage(chatThreadId, chatMessageId, updateChatMessageRequest, options) {
1684
- return tracingClient.withSpan("ChatApiClient.updateChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
1685
- return this.client.sendOperationRequest({ chatThreadId, chatMessageId, updateChatMessageRequest, options }, updateChatMessageOperationSpec);
1686
- });
1687
- }
1688
- /**
1689
- * Deletes a message.
1690
- * @param chatThreadId The thread id to which the message was sent.
1691
- * @param chatMessageId The message id.
1692
- * @param options The options parameters.
1693
- */
1694
- async deleteChatMessage(chatThreadId, chatMessageId, options) {
1695
- return tracingClient.withSpan("ChatApiClient.deleteChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
1696
- return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, deleteChatMessageOperationSpec);
1697
- });
1698
- }
1699
- /**
1700
- * Gets the participants of a thread.
1701
- * @param chatThreadId Thread id to get participants for.
1702
- * @param options The options parameters.
1703
- */
1704
- async listChatParticipants(chatThreadId, options) {
1705
- return tracingClient.withSpan("ChatApiClient.listChatParticipants", options !== null && options !== void 0 ? options : {}, async (options) => {
1706
- return this.client.sendOperationRequest({ chatThreadId, options }, listChatParticipantsOperationSpec);
1707
- });
1708
- }
1709
- /**
1710
- * Remove a participant from a thread.
1711
- * @param chatThreadId Thread id to remove the participant from.
1712
- * @param participantCommunicationIdentifier Id of the thread participant to remove from the thread.
1713
- * @param options The options parameters.
1714
- */
1715
- async removeChatParticipant(chatThreadId, participantCommunicationIdentifier, options) {
1716
- return tracingClient.withSpan("ChatApiClient.removeChatParticipant", options !== null && options !== void 0 ? options : {}, async (options) => {
1717
- return this.client.sendOperationRequest({ chatThreadId, participantCommunicationIdentifier, options }, removeChatParticipantOperationSpec);
1718
- });
1719
- }
1720
- /**
1721
- * Adds thread participants to a thread. If participants already exist, no change occurs.
1722
- * @param chatThreadId Id of the thread to add participants to.
1723
- * @param addChatParticipantsRequest Thread participants to be added to the thread.
1724
- * @param options The options parameters.
1725
- */
1726
- async addChatParticipants(chatThreadId, addChatParticipantsRequest, options) {
1727
- return tracingClient.withSpan("ChatApiClient.addChatParticipants", options !== null && options !== void 0 ? options : {}, async (options) => {
1728
- return this.client.sendOperationRequest({ chatThreadId, addChatParticipantsRequest, options }, addChatParticipantsOperationSpec);
1729
- });
1730
- }
1731
- /**
1732
- * Updates a thread's properties.
1733
- * @param chatThreadId The id of the thread to update.
1734
- * @param updateChatThreadRequest Request payload for updating a chat thread.
1735
- * @param options The options parameters.
1736
- */
1737
- async updateChatThreadProperties(chatThreadId, updateChatThreadRequest, options) {
1738
- return tracingClient.withSpan("ChatApiClient.updateChatThreadProperties", options !== null && options !== void 0 ? options : {}, async (options) => {
1739
- return this.client.sendOperationRequest({ chatThreadId, updateChatThreadRequest, options }, updateChatThreadPropertiesOperationSpec);
1740
- });
1741
- }
1742
- /**
1743
- * Gets a chat thread's properties.
1744
- * @param chatThreadId Id of the thread.
1745
- * @param options The options parameters.
1746
- */
1747
- async getChatThreadProperties(chatThreadId, options) {
1748
- return tracingClient.withSpan("ChatApiClient.getChatThreadProperties", options !== null && options !== void 0 ? options : {}, async (options) => {
1749
- return this.client.sendOperationRequest({ chatThreadId, options }, getChatThreadPropertiesOperationSpec);
1750
- });
1751
- }
1752
- /**
1753
- * Posts a typing event to a thread, on behalf of a user.
1754
- * @param chatThreadId Id of the thread.
1755
- * @param options The options parameters.
1756
- */
1757
- async sendTypingNotification(chatThreadId, options) {
1758
- return tracingClient.withSpan("ChatApiClient.sendTypingNotification", options !== null && options !== void 0 ? options : {}, async (options) => {
1759
- return this.client.sendOperationRequest({ chatThreadId, options }, sendTypingNotificationOperationSpec);
1760
- });
1761
- }
1762
- /**
1763
- * Upload an image in a thread, on behalf of a user.
1764
- * @param chatThreadId Thread id where the uploaded image belongs to. (Teams meeting only)
1765
- * @param chatImageFile Image binary data, allowed image formats: jpeg, png, gif, heic, webp
1766
- * @param options The options parameters.
1767
- */
1768
- async uploadChatImage(chatThreadId, chatImageFile, options) {
1769
- return tracingClient.withSpan("ChatApiClient.uploadChatImage", options !== null && options !== void 0 ? options : {}, async (options) => {
1770
- return this.client.sendOperationRequest({ chatThreadId, chatImageFile, options }, uploadChatImageOperationSpec);
1771
- });
1772
- }
1773
- /**
1774
- * Get an image by view type.
1775
- * @param chatThreadId The thread id to which the message was sent.
1776
- * @param imageId The image id.
1777
- * @param imageViewType The view type of image.
1778
- * @param options The options parameters.
1779
- */
1780
- async getChatImage(chatThreadId, imageId, imageViewType, options) {
1781
- return tracingClient.withSpan("ChatApiClient.getChatImage", options !== null && options !== void 0 ? options : {}, async (options) => {
1782
- return this.client.sendOperationRequest({ chatThreadId, imageId, imageViewType, options }, getChatImageOperationSpec);
1783
- });
1784
- }
1785
- /**
1786
- * Deletes a image.
1787
- * @param chatThreadId The thread id to which the message was sent.
1788
- * @param imageId The image id.
1789
- * @param options The options parameters.
1790
- */
1791
- async deleteChatImage(chatThreadId, imageId, options) {
1792
- return tracingClient.withSpan("ChatApiClient.deleteChatImage", options !== null && options !== void 0 ? options : {}, async (options) => {
1793
- return this.client.sendOperationRequest({ chatThreadId, imageId, options }, deleteChatImageOperationSpec);
1794
- });
1795
- }
1796
- /**
1797
- * ListChatReadReceiptsNext
1798
- * @param chatThreadId Thread id to get the chat message read receipts for.
1799
- * @param nextLink The nextLink from the previous successful call to the ListChatReadReceipts method.
1800
- * @param options The options parameters.
1801
- */
1802
- async listChatReadReceiptsNext(chatThreadId, nextLink, options) {
1803
- return tracingClient.withSpan("ChatApiClient.listChatReadReceiptsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
1804
- return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatReadReceiptsNextOperationSpec);
1805
- });
1806
- }
1807
- /**
1808
- * ListChatMessagesNext
1809
- * @param chatThreadId The thread id of the message.
1810
- * @param nextLink The nextLink from the previous successful call to the ListChatMessages method.
1811
- * @param options The options parameters.
1812
- */
1813
- async listChatMessagesNext(chatThreadId, nextLink, options) {
1814
- return tracingClient.withSpan("ChatApiClient.listChatMessagesNext", options !== null && options !== void 0 ? options : {}, async (options) => {
1815
- return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatMessagesNextOperationSpec);
1816
- });
1817
- }
1818
- /**
1819
- * ListChatParticipantsNext
1820
- * @param chatThreadId Thread id to get participants for.
1821
- * @param nextLink The nextLink from the previous successful call to the ListChatParticipants method.
1822
- * @param options The options parameters.
1823
- */
1824
- async listChatParticipantsNext(chatThreadId, nextLink, options) {
1825
- return tracingClient.withSpan("ChatApiClient.listChatParticipantsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
1826
- return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatParticipantsNextOperationSpec);
1827
- });
1828
- }
1829
- }
1830
- // Operation Specifications
1831
- const serializer$1 = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
1832
- const listChatReadReceiptsOperationSpec = {
1833
- path: "/chat/threads/{chatThreadId}/readReceipts",
1834
- httpMethod: "GET",
1835
- responses: {
1836
- 200: {
1837
- bodyMapper: ChatMessageReadReceiptsCollection,
1838
- },
1839
- 401: {
1840
- bodyMapper: CommunicationErrorResponse,
1841
- isError: true,
1842
- },
1843
- 403: {
1844
- bodyMapper: CommunicationErrorResponse,
1845
- isError: true,
1846
- },
1847
- 429: {
1848
- bodyMapper: CommunicationErrorResponse,
1849
- isError: true,
1850
- },
1851
- 503: {
1852
- bodyMapper: CommunicationErrorResponse,
1853
- isError: true,
1854
- },
1855
- },
1856
- queryParameters: [
1857
- maxPageSize,
1858
- skip,
1859
- apiVersion,
1860
- ],
1861
- urlParameters: [endpoint, chatThreadId],
1862
- headerParameters: [accept],
1863
- serializer: serializer$1,
1864
- };
1865
- const sendChatReadReceiptOperationSpec = {
1866
- path: "/chat/threads/{chatThreadId}/readReceipts",
1867
- httpMethod: "POST",
1868
- responses: {
1869
- 200: {},
1870
- 401: {
1871
- bodyMapper: CommunicationErrorResponse,
1872
- isError: true,
1873
- },
1874
- 403: {
1875
- bodyMapper: CommunicationErrorResponse,
1876
- isError: true,
1877
- },
1878
- 429: {
1879
- bodyMapper: CommunicationErrorResponse,
1880
- isError: true,
1881
- },
1882
- 503: {
1883
- bodyMapper: CommunicationErrorResponse,
1884
- isError: true,
1885
- },
1886
- },
1887
- requestBody: sendReadReceiptRequest,
1888
- queryParameters: [apiVersion],
1889
- urlParameters: [endpoint, chatThreadId],
1890
- headerParameters: [accept, contentType],
1891
- mediaType: "json",
1892
- serializer: serializer$1,
1893
- };
1894
- const sendChatMessageOperationSpec = {
1895
- path: "/chat/threads/{chatThreadId}/messages",
1896
- httpMethod: "POST",
1897
- responses: {
1898
- 201: {
1899
- bodyMapper: SendChatMessageResult,
1900
- },
1901
- 401: {
1902
- bodyMapper: CommunicationErrorResponse,
1903
- isError: true,
1904
- },
1905
- 403: {
1906
- bodyMapper: CommunicationErrorResponse,
1907
- isError: true,
1908
- },
1909
- 429: {
1910
- bodyMapper: CommunicationErrorResponse,
1911
- isError: true,
1912
- },
1913
- 503: {
1914
- bodyMapper: CommunicationErrorResponse,
1915
- isError: true,
1916
- },
1917
- },
1918
- requestBody: sendChatMessageRequest,
1919
- queryParameters: [apiVersion],
1920
- urlParameters: [endpoint, chatThreadId],
1921
- headerParameters: [accept, contentType],
1922
- mediaType: "json",
1923
- serializer: serializer$1,
1924
- };
1925
- const listChatMessagesOperationSpec = {
1926
- path: "/chat/threads/{chatThreadId}/messages",
1927
- httpMethod: "GET",
1928
- responses: {
1929
- 200: {
1930
- bodyMapper: ChatMessagesCollection,
1931
- },
1932
- 401: {
1933
- bodyMapper: CommunicationErrorResponse,
1934
- isError: true,
1935
- },
1936
- 403: {
1937
- bodyMapper: CommunicationErrorResponse,
1938
- isError: true,
1939
- },
1940
- 429: {
1941
- bodyMapper: CommunicationErrorResponse,
1942
- isError: true,
1943
- },
1944
- 503: {
1945
- bodyMapper: CommunicationErrorResponse,
1946
- isError: true,
1947
- },
1948
- },
1949
- queryParameters: [
1950
- maxPageSize,
1951
- apiVersion,
1952
- startTime,
1953
- ],
1954
- urlParameters: [endpoint, chatThreadId],
1955
- headerParameters: [accept],
1956
- serializer: serializer$1,
1957
- };
1958
- const getChatMessageOperationSpec = {
1959
- path: "/chat/threads/{chatThreadId}/messages/{chatMessageId}",
1960
- httpMethod: "GET",
1961
- responses: {
1962
- 200: {
1963
- bodyMapper: ChatMessage,
1964
- },
1965
- 401: {
1966
- bodyMapper: CommunicationErrorResponse,
1967
- isError: true,
1968
- },
1969
- 403: {
1970
- bodyMapper: CommunicationErrorResponse,
1971
- isError: true,
1972
- },
1973
- 429: {
1974
- bodyMapper: CommunicationErrorResponse,
1975
- isError: true,
1976
- },
1977
- 503: {
1978
- bodyMapper: CommunicationErrorResponse,
1979
- isError: true,
1980
- },
1981
- },
1982
- queryParameters: [apiVersion],
1983
- urlParameters: [
1984
- endpoint,
1985
- chatThreadId,
1986
- chatMessageId,
1987
- ],
1988
- headerParameters: [accept],
1989
- serializer: serializer$1,
1990
- };
1991
- const updateChatMessageOperationSpec = {
1992
- path: "/chat/threads/{chatThreadId}/messages/{chatMessageId}",
1993
- httpMethod: "PATCH",
1994
- responses: {
1995
- 204: {},
1996
- 401: {
1997
- bodyMapper: CommunicationErrorResponse,
1998
- isError: true,
1999
- },
2000
- 403: {
2001
- bodyMapper: CommunicationErrorResponse,
2002
- isError: true,
2003
- },
2004
- 429: {
2005
- bodyMapper: CommunicationErrorResponse,
2006
- isError: true,
2007
- },
2008
- 503: {
2009
- bodyMapper: CommunicationErrorResponse,
2010
- isError: true,
2011
- },
2012
- },
2013
- requestBody: updateChatMessageRequest,
2014
- queryParameters: [apiVersion],
2015
- urlParameters: [
2016
- endpoint,
2017
- chatThreadId,
2018
- chatMessageId,
2019
- ],
2020
- headerParameters: [accept, contentType1],
2021
- mediaType: "json",
2022
- serializer: serializer$1,
2023
- };
2024
- const deleteChatMessageOperationSpec = {
2025
- path: "/chat/threads/{chatThreadId}/messages/{chatMessageId}",
2026
- httpMethod: "DELETE",
2027
- responses: {
2028
- 204: {},
2029
- 401: {
2030
- bodyMapper: CommunicationErrorResponse,
2031
- isError: true,
2032
- },
2033
- 403: {
2034
- bodyMapper: CommunicationErrorResponse,
2035
- isError: true,
2036
- },
2037
- 429: {
2038
- bodyMapper: CommunicationErrorResponse,
2039
- isError: true,
2040
- },
2041
- 503: {
2042
- bodyMapper: CommunicationErrorResponse,
2043
- isError: true,
2044
- },
2045
- },
2046
- queryParameters: [apiVersion],
2047
- urlParameters: [
2048
- endpoint,
2049
- chatThreadId,
2050
- chatMessageId,
2051
- ],
2052
- headerParameters: [accept],
2053
- serializer: serializer$1,
2054
- };
2055
- const listChatParticipantsOperationSpec = {
2056
- path: "/chat/threads/{chatThreadId}/participants",
2057
- httpMethod: "GET",
2058
- responses: {
2059
- 200: {
2060
- bodyMapper: ChatParticipantsCollection,
2061
- },
2062
- 401: {
2063
- bodyMapper: CommunicationErrorResponse,
2064
- isError: true,
2065
- },
2066
- 403: {
2067
- bodyMapper: CommunicationErrorResponse,
2068
- isError: true,
2069
- },
2070
- 429: {
2071
- bodyMapper: CommunicationErrorResponse,
2072
- isError: true,
2073
- },
2074
- 503: {
2075
- bodyMapper: CommunicationErrorResponse,
2076
- isError: true,
2077
- },
2078
- },
2079
- queryParameters: [
2080
- maxPageSize,
2081
- skip,
2082
- apiVersion,
2083
- ],
2084
- urlParameters: [endpoint, chatThreadId],
2085
- headerParameters: [accept],
2086
- serializer: serializer$1,
2087
- };
2088
- const removeChatParticipantOperationSpec = {
2089
- path: "/chat/threads/{chatThreadId}/participants/:remove",
2090
- httpMethod: "POST",
2091
- responses: {
2092
- 204: {},
2093
- 401: {
2094
- bodyMapper: CommunicationErrorResponse,
2095
- isError: true,
2096
- },
2097
- 403: {
2098
- bodyMapper: CommunicationErrorResponse,
2099
- isError: true,
2100
- },
2101
- 429: {
2102
- bodyMapper: CommunicationErrorResponse,
2103
- isError: true,
2104
- },
2105
- 503: {
2106
- bodyMapper: CommunicationErrorResponse,
2107
- isError: true,
2108
- },
2109
- },
2110
- requestBody: participantCommunicationIdentifier,
2111
- queryParameters: [apiVersion],
2112
- urlParameters: [endpoint, chatThreadId],
2113
- headerParameters: [accept, contentType],
2114
- mediaType: "json",
2115
- serializer: serializer$1,
2116
- };
2117
- const addChatParticipantsOperationSpec = {
2118
- path: "/chat/threads/{chatThreadId}/participants/:add",
2119
- httpMethod: "POST",
2120
- responses: {
2121
- 201: {
2122
- bodyMapper: AddChatParticipantsResult,
2123
- },
2124
- 401: {
2125
- bodyMapper: CommunicationErrorResponse,
2126
- isError: true,
2127
- },
2128
- 403: {
2129
- bodyMapper: CommunicationErrorResponse,
2130
- isError: true,
2131
- },
2132
- 429: {
2133
- bodyMapper: CommunicationErrorResponse,
2134
- isError: true,
2135
- },
2136
- 503: {
2137
- bodyMapper: CommunicationErrorResponse,
2138
- isError: true,
2139
- },
2140
- },
2141
- requestBody: addChatParticipantsRequest,
2142
- queryParameters: [apiVersion],
2143
- urlParameters: [endpoint, chatThreadId],
2144
- headerParameters: [accept, contentType],
2145
- mediaType: "json",
2146
- serializer: serializer$1,
2147
- };
2148
- const updateChatThreadPropertiesOperationSpec = {
2149
- path: "/chat/threads/{chatThreadId}",
2150
- httpMethod: "PATCH",
2151
- responses: {
2152
- 204: {},
2153
- 401: {
2154
- bodyMapper: CommunicationErrorResponse,
2155
- isError: true,
2156
- },
2157
- 403: {
2158
- bodyMapper: CommunicationErrorResponse,
2159
- isError: true,
2160
- },
2161
- 429: {
2162
- bodyMapper: CommunicationErrorResponse,
2163
- isError: true,
2164
- },
2165
- 503: {
2166
- bodyMapper: CommunicationErrorResponse,
2167
- isError: true,
2168
- },
2169
- },
2170
- requestBody: updateChatThreadRequest,
2171
- queryParameters: [apiVersion],
2172
- urlParameters: [endpoint, chatThreadId],
2173
- headerParameters: [accept, contentType1],
2174
- mediaType: "json",
2175
- serializer: serializer$1,
2176
- };
2177
- const getChatThreadPropertiesOperationSpec = {
2178
- path: "/chat/threads/{chatThreadId}",
2179
- httpMethod: "GET",
2180
- responses: {
2181
- 200: {
2182
- bodyMapper: ChatThreadProperties,
2183
- },
2184
- 401: {
2185
- bodyMapper: CommunicationErrorResponse,
2186
- isError: true,
2187
- },
2188
- 403: {
2189
- bodyMapper: CommunicationErrorResponse,
2190
- isError: true,
2191
- },
2192
- 429: {
2193
- bodyMapper: CommunicationErrorResponse,
2194
- isError: true,
2195
- },
2196
- 503: {
2197
- bodyMapper: CommunicationErrorResponse,
2198
- isError: true,
2199
- },
2200
- },
2201
- queryParameters: [apiVersion],
2202
- urlParameters: [endpoint, chatThreadId],
2203
- headerParameters: [accept],
2204
- serializer: serializer$1,
2205
- };
2206
- const sendTypingNotificationOperationSpec = {
2207
- path: "/chat/threads/{chatThreadId}/typing",
2208
- httpMethod: "POST",
2209
- responses: {
2210
- 200: {},
2211
- 401: {
2212
- bodyMapper: CommunicationErrorResponse,
2213
- isError: true,
2214
- },
2215
- 403: {
2216
- bodyMapper: CommunicationErrorResponse,
2217
- isError: true,
2218
- },
2219
- 429: {
2220
- bodyMapper: CommunicationErrorResponse,
2221
- isError: true,
2222
- },
2223
- 503: {
2224
- bodyMapper: CommunicationErrorResponse,
2225
- isError: true,
2226
- },
2227
- },
2228
- requestBody: sendTypingNotificationRequest,
2229
- queryParameters: [apiVersion],
2230
- urlParameters: [endpoint, chatThreadId],
2231
- headerParameters: [accept, contentType],
2232
- mediaType: "json",
2233
- serializer: serializer$1,
2234
- };
2235
- const uploadChatImageOperationSpec = {
2236
- path: "/chat/threads/{chatThreadId}/images",
2237
- httpMethod: "POST",
2238
- responses: {
2239
- 201: {
2240
- bodyMapper: UploadChatImageResult,
2241
- },
2242
- default: {
2243
- bodyMapper: ErrorResponse,
2244
- },
2245
- },
2246
- requestBody: chatImageFile,
2247
- queryParameters: [apiVersion],
2248
- urlParameters: [endpoint, chatThreadId],
2249
- headerParameters: [
2250
- contentType2,
2251
- accept1,
2252
- imageFilename,
2253
- ],
2254
- mediaType: "binary",
2255
- serializer: serializer$1,
2256
- };
2257
- const getChatImageOperationSpec = {
2258
- path: "/chat/threads/{chatThreadId}/images/{imageId}/view/{imageViewType}",
2259
- httpMethod: "GET",
2260
- responses: {
2261
- 200: {
2262
- bodyMapper: {
2263
- type: { name: "Stream" },
2264
- serializedName: "parsedResponse",
2265
- },
2266
- },
2267
- default: {
2268
- bodyMapper: ErrorResponse,
2269
- },
2270
- },
2271
- queryParameters: [apiVersion],
2272
- urlParameters: [
2273
- endpoint,
2274
- chatThreadId,
2275
- imageId,
2276
- imageViewType,
2277
- ],
2278
- headerParameters: [accept2],
2279
- serializer: serializer$1,
2280
- };
2281
- const deleteChatImageOperationSpec = {
2282
- path: "/chat/threads/{chatThreadId}/images/{imageId}",
2283
- httpMethod: "DELETE",
2284
- responses: {
2285
- 204: {},
2286
- default: {
2287
- bodyMapper: ErrorResponse,
2288
- },
2289
- },
2290
- queryParameters: [apiVersion],
2291
- urlParameters: [
2292
- endpoint,
2293
- chatThreadId,
2294
- imageId,
2295
- ],
2296
- headerParameters: [accept],
2297
- serializer: serializer$1,
2298
- };
2299
- const listChatReadReceiptsNextOperationSpec = {
2300
- path: "{nextLink}",
2301
- httpMethod: "GET",
2302
- responses: {
2303
- 200: {
2304
- bodyMapper: ChatMessageReadReceiptsCollection,
2305
- },
2306
- 401: {
2307
- bodyMapper: CommunicationErrorResponse,
2308
- isError: true,
2309
- },
2310
- 403: {
2311
- bodyMapper: CommunicationErrorResponse,
2312
- isError: true,
2313
- },
2314
- 429: {
2315
- bodyMapper: CommunicationErrorResponse,
2316
- isError: true,
2317
- },
2318
- 503: {
2319
- bodyMapper: CommunicationErrorResponse,
2320
- isError: true,
2321
- },
2322
- },
2323
- urlParameters: [
2324
- endpoint,
2325
- chatThreadId,
2326
- nextLink,
2327
- ],
2328
- headerParameters: [accept],
2329
- serializer: serializer$1,
2330
- };
2331
- const listChatMessagesNextOperationSpec = {
2332
- path: "{nextLink}",
2333
- httpMethod: "GET",
2334
- responses: {
2335
- 200: {
2336
- bodyMapper: ChatMessagesCollection,
2337
- },
2338
- 401: {
2339
- bodyMapper: CommunicationErrorResponse,
2340
- isError: true,
2341
- },
2342
- 403: {
2343
- bodyMapper: CommunicationErrorResponse,
2344
- isError: true,
2345
- },
2346
- 429: {
2347
- bodyMapper: CommunicationErrorResponse,
2348
- isError: true,
2349
- },
2350
- 503: {
2351
- bodyMapper: CommunicationErrorResponse,
2352
- isError: true,
2353
- },
2354
- },
2355
- urlParameters: [
2356
- endpoint,
2357
- chatThreadId,
2358
- nextLink,
2359
- ],
2360
- headerParameters: [accept],
2361
- serializer: serializer$1,
2362
- };
2363
- const listChatParticipantsNextOperationSpec = {
2364
- path: "{nextLink}",
2365
- httpMethod: "GET",
2366
- responses: {
2367
- 200: {
2368
- bodyMapper: ChatParticipantsCollection,
2369
- },
2370
- 401: {
2371
- bodyMapper: CommunicationErrorResponse,
2372
- isError: true,
2373
- },
2374
- 403: {
2375
- bodyMapper: CommunicationErrorResponse,
2376
- isError: true,
2377
- },
2378
- 429: {
2379
- bodyMapper: CommunicationErrorResponse,
2380
- isError: true,
2381
- },
2382
- 503: {
2383
- bodyMapper: CommunicationErrorResponse,
2384
- isError: true,
2385
- },
2386
- },
2387
- urlParameters: [
2388
- endpoint,
2389
- chatThreadId,
2390
- nextLink,
2391
- ],
2392
- headerParameters: [accept],
2393
- serializer: serializer$1,
2394
- };
2395
-
2396
- /*
2397
- * Copyright (c) Microsoft Corporation.
2398
- * Licensed under the MIT License.
2399
- *
2400
- * Code generated by Microsoft (R) AutoRest Code Generator.
2401
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
2402
- */
2403
- /** Class containing Chat operations. */
2404
- class ChatImpl {
2405
- /**
2406
- * Initialize a new instance of the class Chat class.
2407
- * @param client Reference to the service client
2408
- */
2409
- constructor(client) {
2410
- this.client = client;
2411
- }
2412
- /**
2413
- * Creates a chat thread.
2414
- * @param createChatThreadRequest Request payload for creating a chat thread.
2415
- * @param options The options parameters.
2416
- */
2417
- async createChatThread(createChatThreadRequest, options) {
2418
- return tracingClient.withSpan("ChatApiClient.createChatThread", options !== null && options !== void 0 ? options : {}, async (options) => {
2419
- return this.client.sendOperationRequest({ createChatThreadRequest, options }, createChatThreadOperationSpec);
2420
- });
2421
- }
2422
- /**
2423
- * Gets the list of chat threads of a user.
2424
- * @param options The options parameters.
2425
- */
2426
- async listChatThreads(options) {
2427
- return tracingClient.withSpan("ChatApiClient.listChatThreads", options !== null && options !== void 0 ? options : {}, async (options) => {
2428
- return this.client.sendOperationRequest({ options }, listChatThreadsOperationSpec);
2429
- });
2430
- }
2431
- /**
2432
- * Deletes a thread.
2433
- * @param chatThreadId Id of the thread to be deleted.
2434
- * @param options The options parameters.
2435
- */
2436
- async deleteChatThread(chatThreadId, options) {
2437
- return tracingClient.withSpan("ChatApiClient.deleteChatThread", options !== null && options !== void 0 ? options : {}, async (options) => {
2438
- return this.client.sendOperationRequest({ chatThreadId, options }, deleteChatThreadOperationSpec);
2439
- });
2440
- }
2441
- /**
2442
- * ListChatThreadsNext
2443
- * @param nextLink The nextLink from the previous successful call to the ListChatThreads method.
2444
- * @param options The options parameters.
2445
- */
2446
- async listChatThreadsNext(nextLink, options) {
2447
- return tracingClient.withSpan("ChatApiClient.listChatThreadsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
2448
- return this.client.sendOperationRequest({ nextLink, options }, listChatThreadsNextOperationSpec);
2449
- });
2450
- }
2451
- }
2452
- // Operation Specifications
2453
- const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
2454
- const createChatThreadOperationSpec = {
2455
- path: "/chat/threads",
2456
- httpMethod: "POST",
2457
- responses: {
2458
- 201: {
2459
- bodyMapper: CreateChatThreadResult,
2460
- },
2461
- 401: {
2462
- bodyMapper: CommunicationErrorResponse,
2463
- isError: true,
2464
- },
2465
- 403: {
2466
- bodyMapper: CommunicationErrorResponse,
2467
- isError: true,
2468
- },
2469
- 429: {
2470
- bodyMapper: CommunicationErrorResponse,
2471
- isError: true,
2472
- },
2473
- 503: {
2474
- bodyMapper: CommunicationErrorResponse,
2475
- isError: true,
2476
- },
2477
- },
2478
- requestBody: createChatThreadRequest,
2479
- queryParameters: [apiVersion],
2480
- urlParameters: [endpoint],
2481
- headerParameters: [
2482
- accept,
2483
- contentType,
2484
- repeatabilityRequestId,
2485
- ],
2486
- mediaType: "json",
2487
- serializer,
2488
- };
2489
- const listChatThreadsOperationSpec = {
2490
- path: "/chat/threads",
2491
- httpMethod: "GET",
2492
- responses: {
2493
- 200: {
2494
- bodyMapper: ChatThreadsItemCollection,
2495
- },
2496
- 401: {
2497
- bodyMapper: CommunicationErrorResponse,
2498
- isError: true,
2499
- },
2500
- 403: {
2501
- bodyMapper: CommunicationErrorResponse,
2502
- isError: true,
2503
- },
2504
- 429: {
2505
- bodyMapper: CommunicationErrorResponse,
2506
- isError: true,
2507
- },
2508
- 503: {
2509
- bodyMapper: CommunicationErrorResponse,
2510
- isError: true,
2511
- },
2512
- },
2513
- queryParameters: [
2514
- maxPageSize,
2515
- apiVersion,
2516
- startTime,
2517
- ],
2518
- urlParameters: [endpoint],
2519
- headerParameters: [accept],
2520
- serializer,
2521
- };
2522
- const deleteChatThreadOperationSpec = {
2523
- path: "/chat/threads/{chatThreadId}",
2524
- httpMethod: "DELETE",
2525
- responses: {
2526
- 204: {},
2527
- 401: {
2528
- bodyMapper: CommunicationErrorResponse,
2529
- isError: true,
2530
- },
2531
- 403: {
2532
- bodyMapper: CommunicationErrorResponse,
2533
- isError: true,
2534
- },
2535
- 429: {
2536
- bodyMapper: CommunicationErrorResponse,
2537
- isError: true,
2538
- },
2539
- 503: {
2540
- bodyMapper: CommunicationErrorResponse,
2541
- isError: true,
2542
- },
2543
- },
2544
- queryParameters: [apiVersion],
2545
- urlParameters: [endpoint, chatThreadId],
2546
- headerParameters: [accept],
2547
- serializer,
2548
- };
2549
- const listChatThreadsNextOperationSpec = {
2550
- path: "{nextLink}",
2551
- httpMethod: "GET",
2552
- responses: {
2553
- 200: {
2554
- bodyMapper: ChatThreadsItemCollection,
2555
- },
2556
- 401: {
2557
- bodyMapper: CommunicationErrorResponse,
2558
- isError: true,
2559
- },
2560
- 403: {
2561
- bodyMapper: CommunicationErrorResponse,
2562
- isError: true,
2563
- },
2564
- 429: {
2565
- bodyMapper: CommunicationErrorResponse,
2566
- isError: true,
2567
- },
2568
- 503: {
2569
- bodyMapper: CommunicationErrorResponse,
2570
- isError: true,
2571
- },
2572
- },
2573
- urlParameters: [endpoint, nextLink],
2574
- headerParameters: [accept],
2575
- serializer,
2576
- };
2577
-
2578
- /*
2579
- * Copyright (c) Microsoft Corporation.
2580
- * Licensed under the MIT License.
2581
- *
2582
- * Code generated by Microsoft (R) AutoRest Code Generator.
2583
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
2584
- */
2585
- class ChatApiClient extends coreClient__namespace.ServiceClient {
2586
- /**
2587
- * Initializes a new instance of the ChatApiClient class.
2588
- * @param endpoint The endpoint of the Azure Communication resource.
2589
- * @param options The parameter options
2590
- */
2591
- constructor(endpoint, options) {
2592
- var _a, _b;
2593
- if (endpoint === undefined) {
2594
- throw new Error("'endpoint' cannot be null");
2595
- }
2596
- // Initializing default values for options
2597
- if (!options) {
2598
- options = {};
2599
- }
2600
- const defaults = {
2601
- requestContentType: "application/json; charset=utf-8",
2602
- };
2603
- const packageDetails = `azsdk-js-communication-chat/1.6.0-beta.2`;
2604
- const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
2605
- ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
2606
- : `${packageDetails}`;
2607
- const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
2608
- userAgentPrefix,
2609
- }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{endpoint}" });
2610
- super(optionsWithDefaults);
2611
- // Parameter assignments
2612
- this.endpoint = endpoint;
2613
- // Assigning values to Constant parameters
2614
- this.apiVersion = options.apiVersion || "2024-06-05-preview";
2615
- this.chatThread = new ChatThreadImpl(this);
2616
- this.chat = new ChatImpl(this);
2617
- this.addCustomApiVersionPolicy(options.apiVersion);
2618
- }
2619
- /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
2620
- addCustomApiVersionPolicy(apiVersion) {
2621
- if (!apiVersion) {
2622
- return;
2623
- }
2624
- const apiVersionPolicy = {
2625
- name: "CustomApiVersionPolicy",
2626
- async sendRequest(request, next) {
2627
- const param = request.url.split("?");
2628
- if (param.length > 1) {
2629
- const newParams = param[1].split("&").map((item) => {
2630
- if (item.indexOf("api-version") > -1) {
2631
- return "api-version=" + apiVersion;
2632
- }
2633
- else {
2634
- return item;
2635
- }
2636
- });
2637
- request.url = param[0] + "?" + newParams.join("&");
2638
- }
2639
- return next(request);
2640
- },
2641
- };
2642
- this.pipeline.addPolicy(apiVersionPolicy);
2643
- }
2644
- }
2645
-
2646
- // Copyright (c) Microsoft Corporation.
2647
- // Licensed under the MIT license.
2648
- const logger = logger$1.createClientLogger("communication-chat");
2649
-
2650
- // Copyright (c) Microsoft Corporation.
2651
- // Licensed under the MIT license.
2652
- // Temporary workaround with local copy of XhrHttpClient
2653
- function isNodeReadableStream(body) {
2654
- return body && typeof body.pipe === "function";
2655
- }
2656
- /**
2657
- * Checks if the body is a Blob or Blob-like
2658
- * @internal
2659
- */
2660
- function isBlob(body) {
2661
- // File objects count as a type of Blob, so we want to use instanceof explicitly
2662
- return (typeof Blob === "function" || typeof Blob === "object") && body instanceof Blob;
2663
- }
2664
- /**
2665
- * Checks if the body is a ReadableStream supported by browsers
2666
- * @internal
2667
- */
2668
- function isReadableStream(body) {
2669
- return Boolean(body &&
2670
- typeof body.getReader === "function" &&
2671
- typeof body.tee === "function");
2672
- }
2673
- /**
2674
- * A HttpClient implementation that uses XMLHttpRequest to send HTTP requests.
2675
- * @internal
2676
- */
2677
- class XhrHttpClient {
2678
- /**
2679
- * Makes a request over an underlying transport layer and returns the response.
2680
- * @param request - The request to be made.
2681
- */
2682
- async sendRequest(request) {
2683
- var _a;
2684
- const url = new URL(request.url);
2685
- const isInsecure = url.protocol !== "https:";
2686
- if (isInsecure && !request.allowInsecureConnection) {
2687
- throw new Error(`Cannot connect to ${request.url} while allowInsecureConnection is false.`);
2688
- }
2689
- const xhr = new XMLHttpRequest();
2690
- if (request.proxySettings) {
2691
- throw new Error("HTTP proxy is not supported in browser environment");
2692
- }
2693
- const abortSignal = request.abortSignal;
2694
- if (abortSignal) {
2695
- if (abortSignal.aborted) {
2696
- throw new abortController.AbortError("The operation was aborted.");
2697
- }
2698
- const listener = () => {
2699
- xhr.abort();
2700
- };
2701
- abortSignal.addEventListener("abort", listener);
2702
- xhr.addEventListener("readystatechange", () => {
2703
- if (xhr.readyState === XMLHttpRequest.DONE) {
2704
- abortSignal.removeEventListener("abort", listener);
2705
- }
2706
- });
2707
- }
2708
- addProgressListener(xhr.upload, request.onUploadProgress);
2709
- addProgressListener(xhr, request.onDownloadProgress);
2710
- xhr.open(request.method, request.url);
2711
- xhr.timeout = request.timeout;
2712
- xhr.withCredentials = request.withCredentials;
2713
- for (const [name, value] of request.headers) {
2714
- xhr.setRequestHeader(name, value);
2715
- }
2716
- xhr.responseType = ((_a = request.streamResponseStatusCodes) === null || _a === void 0 ? void 0 : _a.size) ? "blob" : "text";
2717
- const body = typeof request.body === "function" ? request.body() : request.body;
2718
- if (isNodeReadableStream(body) || isReadableStream(body)) {
2719
- throw new Error("Streams are not supported by xhrHttpClient.");
2720
- }
2721
- xhr.send(body === undefined ? null : body);
2722
- if (xhr.responseType === "blob") {
2723
- return new Promise((resolve, reject) => {
2724
- handleBlobResponse(xhr, request, resolve, reject);
2725
- rejectOnTerminalEvent(request, xhr, reject);
2726
- });
2727
- }
2728
- else {
2729
- return new Promise(function (resolve, reject) {
2730
- xhr.addEventListener("load", () => resolve({
2731
- request,
2732
- status: xhr.status,
2733
- headers: parseHeaders(xhr),
2734
- bodyAsText: xhr.responseText,
2735
- }));
2736
- rejectOnTerminalEvent(request, xhr, reject);
2737
- });
2738
- }
2739
- }
2740
- }
2741
- function handleBlobResponse(xhr, request, res, rej) {
2742
- xhr.addEventListener("readystatechange", () => {
2743
- var _a, _b;
2744
- // Resolve as soon as headers are loaded
2745
- if (xhr.readyState === XMLHttpRequest.HEADERS_RECEIVED) {
2746
- if (
2747
- // Value of POSITIVE_INFINITY in streamResponseStatusCodes is considered as any status code
2748
- ((_a = request.streamResponseStatusCodes) === null || _a === void 0 ? void 0 : _a.has(Number.POSITIVE_INFINITY)) ||
2749
- ((_b = request.streamResponseStatusCodes) === null || _b === void 0 ? void 0 : _b.has(xhr.status))) {
2750
- const blobBody = new Promise((resolve, reject) => {
2751
- xhr.addEventListener("load", () => {
2752
- resolve(xhr.response);
2753
- });
2754
- rejectOnTerminalEvent(request, xhr, reject);
2755
- });
2756
- res({
2757
- request,
2758
- status: xhr.status,
2759
- headers: parseHeaders(xhr),
2760
- blobBody,
2761
- });
2762
- }
2763
- else {
2764
- xhr.addEventListener("load", () => {
2765
- // xhr.response is of Blob type if the request is sent with xhr.responseType === "blob"
2766
- // but the status code is not one of the stream response status codes,
2767
- // so treat it as text and convert from Blob to text
2768
- if (xhr.response) {
2769
- xhr.response
2770
- .text()
2771
- .then((text) => {
2772
- res({
2773
- request: request,
2774
- status: xhr.status,
2775
- headers: parseHeaders(xhr),
2776
- bodyAsText: text,
2777
- });
2778
- return;
2779
- })
2780
- .catch((e) => {
2781
- rej(e);
2782
- });
2783
- }
2784
- else {
2785
- res({
2786
- request,
2787
- status: xhr.status,
2788
- headers: parseHeaders(xhr),
2789
- });
2790
- }
2791
- });
2792
- }
2793
- }
2794
- });
2795
- }
2796
- function addProgressListener(xhr, listener) {
2797
- if (listener) {
2798
- xhr.addEventListener("progress", (rawEvent) => listener({
2799
- loadedBytes: rawEvent.loaded,
2800
- }));
2801
- }
2802
- }
2803
- function parseHeaders(xhr) {
2804
- const responseHeaders = coreRestPipeline.createHttpHeaders();
2805
- const headerLines = xhr
2806
- .getAllResponseHeaders()
2807
- .trim()
2808
- .split(/[\r\n]+/);
2809
- for (const line of headerLines) {
2810
- const index = line.indexOf(":");
2811
- const headerName = line.slice(0, index);
2812
- const headerValue = line.slice(index + 2);
2813
- responseHeaders.set(headerName, headerValue);
2814
- }
2815
- return responseHeaders;
2816
- }
2817
- function rejectOnTerminalEvent(request, xhr, reject) {
2818
- xhr.addEventListener("error", () => reject(new coreRestPipeline.RestError(`Failed to send request to ${request.url}`, {
2819
- code: coreRestPipeline.RestError.REQUEST_SEND_ERROR,
2820
- request,
2821
- })));
2822
- const abortError = new abortController.AbortError("The operation was aborted.");
2823
- xhr.addEventListener("abort", () => reject(abortError));
2824
- xhr.addEventListener("timeout", () => reject(abortError));
2825
- }
2826
- /**
2827
- * Create a new HttpClient instance for the browser environment.
2828
- * @internal
2829
- */
2830
- function createXhrHttpClient() {
2831
- return new XhrHttpClient();
2832
- }
2833
-
2834
- // Copyright (c) Microsoft Corporation.
2835
- // Licensed under the MIT license.
2836
- /**
2837
- * Creates a new CommunicationTokenCredentialPolicy factory.
2838
- *
2839
- * @param credential - The CommunicationTokenCredential implementation that can supply the user credential.
2840
- */
2841
- const createCommunicationTokenCredentialPolicy = (credential) => {
2842
- const policyOptions = {
2843
- credential: {
2844
- getToken: (_scopes, options) => credential.getToken({ abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal }),
2845
- },
2846
- scopes: [],
2847
- };
2848
- return coreRestPipeline.bearerTokenAuthenticationPolicy(policyOptions);
2849
- };
2850
-
2851
- // Copyright (c) Microsoft Corporation.
2852
- // Licensed under the MIT license.
2853
- const minimumTypingIntervalInMilliSeconds = 8000;
2854
- /**
2855
- * The client to do chat operations
2856
- */
2857
- class ChatThreadClient {
2858
- constructor(endpoint, threadId, credential, options = {}) {
2859
- this.endpoint = endpoint;
2860
- this.timeOfLastTypingRequest = undefined;
2861
- this.threadId = threadId;
2862
- this.tokenCredential = credential;
2863
- const internalPipelineOptions = Object.assign(Object.assign({}, options), {
2864
- loggingOptions: {
2865
- logger: logger.info,
2866
- },
2867
- });
2868
- this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
2869
- const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);
2870
- this.client.pipeline.addPolicy(authPolicy);
2871
- if (typeof XMLHttpRequest !== "undefined") {
2872
- this.xhrClient = new ChatApiClient(this.endpoint, Object.assign(Object.assign({ endpoint: this.endpoint }, internalPipelineOptions), { httpClient: createXhrHttpClient() }));
2873
- this.xhrClient.pipeline.addPolicy(authPolicy);
2874
- }
2875
- }
2876
- /**
2877
- * Gets a chat thread.
2878
- * Returns the chat thread.
2879
- * @param options - Operation options.
2880
- */
2881
- getProperties(options = {}) {
2882
- return tracingClient.withSpan("ChatClient-GetProperties", options, async (updatedOptions) => {
2883
- const result = await this.client.chatThread.getChatThreadProperties(this.threadId, updatedOptions);
2884
- return mapToChatThreadPropertiesSdkModel(result);
2885
- });
2886
- }
2887
- /**
2888
- * Updates a thread's topic.
2889
- * @param topic - The topic needs to be updated to.
2890
- * @param options - Operation options.
2891
- */
2892
- updateTopic(topic, options = {}) {
2893
- return tracingClient.withSpan("ChatThreadClient-UpdateTopic", options, async (updatedOptions) => {
2894
- await this.client.chatThread.updateChatThreadProperties(this.threadId, { topic: topic }, updatedOptions);
2895
- });
2896
- }
2897
- /**
2898
- * Updates a thread's properties.
2899
- * @param options - Operation options.
2900
- */
2901
- updateProperties(options = {}) {
2902
- return tracingClient.withSpan("ChatThreadClient-UpdateProperties", options, async (updatedOptions) => {
2903
- await this.client.chatThread.updateChatThreadProperties(this.threadId, options, updatedOptions);
2904
- });
2905
- }
2906
- /**
2907
- * Sends a chat message to a thread identified by threadId.
2908
- * Returns the id of the created message.
2909
- * @param request - Request for sending a message.
2910
- * @param options - Operation options.
2911
- */
2912
- sendMessage(request, options = {}) {
2913
- return tracingClient.withSpan("ChatThreadClient-SendMessage", options, async (updatedOptions) => {
2914
- // reset typing notification clock
2915
- this.timeOfLastTypingRequest = undefined;
2916
- const result = await this.client.chatThread.sendChatMessage(this.threadId, mapToSendChatMessageRequestRestModel(request, options), updatedOptions);
2917
- return result;
2918
- });
2919
- }
2920
- /**
2921
- * Gets a chat message identified by messageId.
2922
- * Returns the specific message.
2923
- * @param messageId - The message id of the message.
2924
- * @param options - Operation options.
2925
- */
2926
- getMessage(messageId, options = {}) {
2927
- return tracingClient.withSpan("ChatThreadClient-GetMessage", options, async (updatedOptions) => {
2928
- const result = await this.client.chatThread.getChatMessage(this.threadId, messageId, updatedOptions);
2929
- return mapToChatMessageSdkModel(result);
2930
- });
2931
- }
2932
- listMessagesPage(pageSettings_1) {
2933
- return tslib.__asyncGenerator(this, arguments, function* listMessagesPage_1(pageSettings, options = {}) {
2934
- if (!pageSettings.continuationToken) {
2935
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatMessages(this.threadId, options));
2936
- pageSettings.continuationToken = currentSetResponse.nextLink;
2937
- if (currentSetResponse.value) {
2938
- yield yield tslib.__await(currentSetResponse.value.map(mapToChatMessageSdkModel, this));
2939
- }
2940
- }
2941
- while (pageSettings.continuationToken) {
2942
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatMessagesNext(this.threadId, pageSettings.continuationToken, options));
2943
- pageSettings.continuationToken = currentSetResponse.nextLink;
2944
- if (currentSetResponse.value) {
2945
- yield yield tslib.__await(currentSetResponse.value.map(mapToChatMessageSdkModel, this));
2946
- }
2947
- else {
2948
- break;
2949
- }
2950
- }
2951
- });
2952
- }
2953
- listMessagesAll(options) {
2954
- return tslib.__asyncGenerator(this, arguments, function* listMessagesAll_1() {
2955
- var _a, e_1, _b, _c;
2956
- try {
2957
- for (var _d = true, _e = tslib.__asyncValues(this.listMessagesPage({}, options)), _f; _f = yield tslib.__await(_e.next()), _a = _f.done, !_a; _d = true) {
2958
- _c = _f.value;
2959
- _d = false;
2960
- const page = _c;
2961
- yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
2962
- }
2963
- }
2964
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2965
- finally {
2966
- try {
2967
- if (!_d && !_a && (_b = _e.return)) yield tslib.__await(_b.call(_e));
2968
- }
2969
- finally { if (e_1) throw e_1.error; }
2970
- }
2971
- });
2972
- }
2973
- /**
2974
- * Gets a list of message from a thread identified by threadId.
2975
- * Returns the list of the messages.
2976
- * @param options - Get messages options.
2977
- */
2978
- listMessages(options = {}) {
2979
- const { span, updatedOptions } = tracingClient.startSpan("ChatThreadClient-ListMessages", options);
2980
- try {
2981
- const iter = this.listMessagesAll(updatedOptions);
2982
- return {
2983
- next() {
2984
- return iter.next();
2985
- },
2986
- [Symbol.asyncIterator]() {
2987
- return this;
2988
- },
2989
- byPage: (settings = {}) => {
2990
- return this.listMessagesPage(settings, updatedOptions);
2991
- },
2992
- };
2993
- }
2994
- catch (e) {
2995
- span.setStatus({
2996
- status: "error",
2997
- error: e,
2998
- });
2999
- throw e;
3000
- }
3001
- finally {
3002
- span.end();
3003
- }
3004
- }
3005
- /**
3006
- * Deletes a message identified by threadId and messageId
3007
- * @param messageId - The message id of the message.
3008
- * @param options - Operation options.
3009
- */
3010
- deleteMessage(messageId, options = {}) {
3011
- return tracingClient.withSpan("ChatThreadClient-DeleteMessage", options, async (updatedOptions) => {
3012
- await this.client.chatThread.deleteChatMessage(this.threadId, messageId, updatedOptions);
3013
- });
3014
- }
3015
- /**
3016
- * Updates a message identified by threadId and messageId
3017
- * @param messageId - The message id of the message.
3018
- * @param options - Operation options.
3019
- */
3020
- async updateMessage(messageId, options = {}) {
3021
- return tracingClient.withSpan("ChatThreadClient-UpdateMessage", options, async (updatedOptions) => {
3022
- await this.client.chatThread.updateChatMessage(this.threadId, messageId, mapToUpdateChatMessageRequestRestModel(options), updatedOptions);
3023
- });
3024
- }
3025
- /**
3026
- * Adds the details of chat participants belonging to the thread identified by threadId.
3027
- * @param request - Thread participants' details to add in the thread roster
3028
- * @param options - Operation options.
3029
- */
3030
- async addParticipants(request, options = {}) {
3031
- return tracingClient.withSpan("ChatThreadClient-AddParticipants", options, async (updatedOptions) => {
3032
- const result = await this.client.chatThread.addChatParticipants(this.threadId, mapToAddChatParticipantsRequestRestModel(request), updatedOptions);
3033
- return result;
3034
- });
3035
- }
3036
- listParticipantsPage(continuationState_1) {
3037
- return tslib.__asyncGenerator(this, arguments, function* listParticipantsPage_1(continuationState, options = {}) {
3038
- if (!continuationState.continuationToken) {
3039
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatParticipants(this.threadId, options));
3040
- continuationState.continuationToken = currentSetResponse.nextLink;
3041
- if (currentSetResponse.value) {
3042
- yield yield tslib.__await(currentSetResponse.value.map(mapToChatParticipantSdkModel, this));
3043
- }
3044
- }
3045
- while (continuationState.continuationToken) {
3046
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatParticipantsNext(this.threadId, continuationState.continuationToken, options));
3047
- continuationState.continuationToken = currentSetResponse.nextLink;
3048
- if (currentSetResponse.value) {
3049
- yield yield tslib.__await(currentSetResponse.value.map(mapToChatParticipantSdkModel, this));
3050
- }
3051
- else {
3052
- break;
3053
- }
3054
- }
3055
- });
3056
- }
3057
- listParticipantsAll(options) {
3058
- return tslib.__asyncGenerator(this, arguments, function* listParticipantsAll_1() {
3059
- var _a, e_2, _b, _c;
3060
- try {
3061
- for (var _d = true, _e = tslib.__asyncValues(this.listParticipantsPage({}, options)), _f; _f = yield tslib.__await(_e.next()), _a = _f.done, !_a; _d = true) {
3062
- _c = _f.value;
3063
- _d = false;
3064
- const page = _c;
3065
- yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
3066
- }
3067
- }
3068
- catch (e_2_1) { e_2 = { error: e_2_1 }; }
3069
- finally {
3070
- try {
3071
- if (!_d && !_a && (_b = _e.return)) yield tslib.__await(_b.call(_e));
3072
- }
3073
- finally { if (e_2) throw e_2.error; }
3074
- }
3075
- });
3076
- }
3077
- /**
3078
- * Gets the participants of the thread identified by threadId.
3079
- * Returns the lists of the participants.
3080
- * @param options - Operation options.
3081
- */
3082
- listParticipants(options = {}) {
3083
- const { span, updatedOptions } = tracingClient.startSpan("ChatThreadClient-ListParticipants", options);
3084
- try {
3085
- const iter = this.listParticipantsAll(updatedOptions);
3086
- return {
3087
- next() {
3088
- return iter.next();
3089
- },
3090
- [Symbol.asyncIterator]() {
3091
- return this;
3092
- },
3093
- byPage: (settings = {}) => {
3094
- return this.listParticipantsPage(settings, updatedOptions);
3095
- },
3096
- };
3097
- }
3098
- catch (e) {
3099
- span.setStatus({
3100
- status: "error",
3101
- error: e,
3102
- });
3103
- throw e;
3104
- }
3105
- finally {
3106
- span.end();
3107
- }
3108
- }
3109
- /**
3110
- * Removes participant from the thread identified by threadId.
3111
- * @param participant - Thread participant to remove from the thread roster
3112
- * @param options - Operation options.
3113
- */
3114
- async removeParticipant(participant, options = {}) {
3115
- return tracingClient.withSpan("ChatThreadClient-RemoveParticipant", options, async (updatedOptions) => {
3116
- await this.client.chatThread.removeChatParticipant(this.threadId, communicationCommon.serializeCommunicationIdentifier(participant), updatedOptions);
3117
- });
3118
- }
3119
- /**
3120
- * Sends a typing notification to the thread.
3121
- * Doesn't attempt to send if the time since last notification is smaller than the minimum typing interval
3122
- * @param options - - Operation options
3123
- * @returns True if the typing message notification could be sent, otherwise false.
3124
- */
3125
- async sendTypingNotification(options = {}) {
3126
- return tracingClient.withSpan("ChatThreadClient-SendTypingNotification", options, async (updatedOptions) => {
3127
- const dateNow = new Date();
3128
- const { senderDisplayName } = updatedOptions, restOptions = tslib.__rest(updatedOptions, ["senderDisplayName"]);
3129
- if (this.canPostTypingNotification(dateNow)) {
3130
- this.timeOfLastTypingRequest = dateNow;
3131
- await this.client.chatThread.sendTypingNotification(this.threadId, Object.assign({ sendTypingNotificationRequest: { senderDisplayName: senderDisplayName } }, restOptions));
3132
- return true;
3133
- }
3134
- logger.info(`Typing Notification NOT Send. [thread_id=${this.threadId}]`);
3135
- return false;
3136
- });
3137
- }
3138
- /**
3139
- * Sends a read receipt to the thread identified by threadId.
3140
- * @param request - Request for sending a read receipt
3141
- * @param options - Operation options.
3142
- */
3143
- async sendReadReceipt(request, options = {}) {
3144
- return tracingClient.withSpan("ChatThreadClient-SendReadReceipt", options, async (updatedOptions) => {
3145
- await this.client.chatThread.sendChatReadReceipt(this.threadId, request, updatedOptions);
3146
- });
3147
- }
3148
- listReadReceiptsPage(continuationState_1) {
3149
- return tslib.__asyncGenerator(this, arguments, function* listReadReceiptsPage_1(continuationState, options = {}) {
3150
- if (!continuationState.continuationToken) {
3151
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatReadReceipts(this.threadId, options));
3152
- continuationState.continuationToken = currentSetResponse.nextLink;
3153
- if (currentSetResponse.value) {
3154
- yield yield tslib.__await(currentSetResponse.value.map(mapToReadReceiptSdkModel, this));
3155
- }
3156
- }
3157
- while (continuationState.continuationToken) {
3158
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatReadReceiptsNext(this.threadId, continuationState.continuationToken, options));
3159
- continuationState.continuationToken = currentSetResponse.nextLink;
3160
- if (currentSetResponse.value) {
3161
- yield yield tslib.__await(currentSetResponse.value.map(mapToReadReceiptSdkModel, this));
3162
- }
3163
- else {
3164
- break;
3165
- }
3166
- }
3167
- });
3168
- }
3169
- listReadReceiptsAll(options) {
3170
- return tslib.__asyncGenerator(this, arguments, function* listReadReceiptsAll_1() {
3171
- var _a, e_3, _b, _c;
3172
- try {
3173
- for (var _d = true, _e = tslib.__asyncValues(this.listReadReceiptsPage({}, options)), _f; _f = yield tslib.__await(_e.next()), _a = _f.done, !_a; _d = true) {
3174
- _c = _f.value;
3175
- _d = false;
3176
- const page = _c;
3177
- yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
3178
- }
3179
- }
3180
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
3181
- finally {
3182
- try {
3183
- if (!_d && !_a && (_b = _e.return)) yield tslib.__await(_b.call(_e));
3184
- }
3185
- finally { if (e_3) throw e_3.error; }
3186
- }
3187
- });
3188
- }
3189
- /**
3190
- * Gets a list of read receipt from a thread identified by threadId.
3191
- * Returns the list of the messages.
3192
- * @param options - Get messages options.
3193
- */
3194
- listReadReceipts(options = {}) {
3195
- const { span, updatedOptions } = tracingClient.startSpan("ChatThreadClient-ListChatReadReceipts", options);
3196
- try {
3197
- const iter = this.listReadReceiptsAll(updatedOptions);
3198
- return {
3199
- next() {
3200
- return iter.next();
3201
- },
3202
- [Symbol.asyncIterator]() {
3203
- return this;
3204
- },
3205
- byPage: (settings = {}) => {
3206
- return this.listReadReceiptsPage(settings, updatedOptions);
3207
- },
3208
- };
3209
- }
3210
- catch (e) {
3211
- span.setStatus({
3212
- status: "error",
3213
- error: e,
3214
- });
3215
- throw e;
3216
- }
3217
- finally {
3218
- span.end();
3219
- }
3220
- }
3221
- canPostTypingNotification(dateNow) {
3222
- if (this.timeOfLastTypingRequest) {
3223
- const timeSinceLastRequestInMilliSeconds = dateNow.getTime() - this.timeOfLastTypingRequest.getTime();
3224
- if (timeSinceLastRequestInMilliSeconds < minimumTypingIntervalInMilliSeconds) {
3225
- logger.info(`Typing interval check failed. [last_request=${this.timeOfLastTypingRequest}]`);
3226
- return false;
3227
- }
3228
- }
3229
- return true;
3230
- }
3231
- async uploadImage(image, imageFilename, imageBytesLengthOrOptions, options = {}) {
3232
- let uploadImageOptions = {};
3233
- if (imageBytesLengthOrOptions !== undefined) {
3234
- if (typeof imageBytesLengthOrOptions === "number") {
3235
- uploadImageOptions = Object.assign(Object.assign({}, options), { imageBytesLength: imageBytesLengthOrOptions });
3236
- }
3237
- else {
3238
- uploadImageOptions = Object.assign(Object.assign({}, options), imageBytesLengthOrOptions);
3239
- }
3240
- }
3241
- return tracingClient.withSpan("ChatThreadClient-UploadImage", uploadImageOptions, async (updatedOptions) => {
3242
- let result;
3243
- if (this.xhrClient && // is browser
3244
- ((!this.supportsReadableStream() && isReadableStream(image)) || // is readable stream but no support, need to convert
3245
- !isReadableStream(image))) {
3246
- // use xhrClient if (to support onUploadProgress)
3247
- // - is readable stream but no support => convert to ArrayBuffer (so will have content-length)
3248
- // - is not readable stream
3249
- result = await this.xhrClient.chatThread.uploadChatImage(this.threadId, isReadableStream(image) ? await this.getArrayBufferFromReadableStream(image) : image, Object.assign({ imageFilename }, updatedOptions));
3250
- }
3251
- else {
3252
- // backend (node fetch client) or readable readable stream
3253
- // Backend (no browser) need to convert Blob/ReadableStream to ArrayBuffer
3254
- let chatImageFile = image;
3255
- if (isBlob(image)) {
3256
- chatImageFile = await this.getArrayBufferFromBlob(image);
3257
- }
3258
- else if (isReadableStream(image)) {
3259
- chatImageFile = await this.getArrayBufferFromReadableStream(image);
3260
- }
3261
- result = await this.client.chatThread.uploadChatImage(this.threadId, chatImageFile, Object.assign({ imageFilename }, updatedOptions));
3262
- }
3263
- return result;
3264
- });
3265
- }
3266
- /**
3267
- * Deletes an image identified by threadId and imageId
3268
- * @param imageId - The image id of the image.
3269
- * @param options - Operation options.
3270
- */
3271
- deleteImage(imageId, options = {}) {
3272
- return tracingClient.withSpan("ChatThreadClient-DeleteImage", options, async (updatedOptions) => {
3273
- await this.client.chatThread.deleteChatImage(this.threadId, imageId, updatedOptions);
3274
- });
3275
- }
3276
- supportsReadableStream() {
3277
- let duplexAccessed = false;
3278
- const hasContentType = new Request("", {
3279
- body: new ReadableStream(),
3280
- method: "POST",
3281
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
3282
- // @ts-ignore
3283
- get duplex() {
3284
- duplexAccessed = true;
3285
- return "half";
3286
- },
3287
- }).headers.has("Content-Type");
3288
- return duplexAccessed && !hasContentType;
3289
- }
3290
- async getArrayBufferFromReadableStream(body) {
3291
- const arrayBuffer = await new Response(body).arrayBuffer();
3292
- return new Uint8Array(arrayBuffer);
3293
- }
3294
- async getArrayBufferFromBlob(body) {
3295
- return new Uint8Array(await body.arrayBuffer());
3296
- }
3297
- }
3298
-
3299
- // Copyright (c) Microsoft Corporation.
3300
- // Licensed under the MIT license.
3301
- /**
3302
- * Generated Universally Unique Identifier
3303
- *
3304
- * @returns RFC4122 v4 UUID.
3305
- * @internal
3306
- */
3307
- function generateUuid() {
3308
- return uuid.v4();
3309
- }
3310
-
3311
- // Copyright (c) Microsoft Corporation.
3312
- // Licensed under the MIT license.
3313
- const getSignalingClient = (credential, logger, options) => {
3314
- var _a, _b, _c;
3315
- if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
3316
- // In React Native
3317
- return new communicationSignaling.CommunicationSignalingClient(credential, logger, {
3318
- environment: (_a = options === null || options === void 0 ? void 0 : options.environment) !== null && _a !== void 0 ? _a : undefined,
3319
- resourceEndpoint: (_b = options === null || options === void 0 ? void 0 : options.resourceEndpoint) !== null && _b !== void 0 ? _b : undefined,
3320
- gatewayApiVersion: (_c = options === null || options === void 0 ? void 0 : options.gatewayApiVersion) !== null && _c !== void 0 ? _c : undefined,
3321
- });
3322
- }
3323
- // In node js
3324
- return undefined;
3325
- };
3326
-
3327
- // Copyright (c) Microsoft Corporation.
3328
- // Licensed under the MIT license.
3329
- /// <reference lib="esnext.asynciterable" />
3330
- /**
3331
- * The client to do chat operations
3332
- */
3333
- class ChatClient {
3334
- /**
3335
- * Creates an instance of the ChatClient for a given resource and user.
3336
- *
3337
- * @param endpoint - The url of the Communication Services resource.
3338
- * @param credential - The token credential. Use AzureCommunicationTokenCredential from \@azure/communication-common to create a credential.
3339
- * @param options - Additional client options.
3340
- */
3341
- constructor(endpoint, credential, options = {}) {
3342
- this.endpoint = endpoint;
3343
- this.signalingClient = undefined;
3344
- this.emitter = new events.EventEmitter();
3345
- this.isRealtimeNotificationsStarted = false;
3346
- this.tokenCredential = credential;
3347
- const internalPipelineOptions = Object.assign(Object.assign({}, options), {
3348
- loggingOptions: {
3349
- logger: logger.info,
3350
- },
3351
- });
3352
- this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
3353
- const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);
3354
- this.client.pipeline.addPolicy(authPolicy);
3355
- this.clientOptions = Object.assign({}, options);
3356
- this.clientOptions.signalingClientOptions = Object.assign(Object.assign({}, this.clientOptions.signalingClientOptions), { resourceEndpoint: this.endpoint, gatewayApiVersion: this.client.apiVersion });
3357
- this.signalingClient = getSignalingClient(credential, logger, this.clientOptions.signalingClientOptions);
3358
- }
3359
- /**
3360
- * Returns ChatThreadClient with the specific thread id.
3361
- * @param threadId - Thread ID for the ChatThreadClient
3362
- */
3363
- getChatThreadClient(threadId) {
3364
- return new ChatThreadClient(this.endpoint, threadId, this.tokenCredential, this.clientOptions);
3365
- }
3366
- /**
3367
- * Creates a chat thread.
3368
- * Returns thread client with the id of the created thread.
3369
- * @param request - Request for creating a chat thread.
3370
- * @param options - Operation options.
3371
- */
3372
- async createChatThread(request, options = {}) {
3373
- return tracingClient.withSpan("ChatClient-CreateChatThread", options, async (updatedOptions) => {
3374
- var _a, _b;
3375
- // We generate an UUID if the user does not provide an idempotencyToken value
3376
- updatedOptions.idempotencyToken = (_a = updatedOptions.idempotencyToken) !== null && _a !== void 0 ? _a : generateUuid();
3377
- const updatedRestModelOptions = mapToCreateChatThreadOptionsRestModel(updatedOptions);
3378
- const result = await this.client.chat.createChatThread({
3379
- topic: request.topic,
3380
- participants: (_b = options.participants) === null || _b === void 0 ? void 0 : _b.map((participant) => mapToChatParticipantRestModel(participant)),
3381
- metadata: options.metadata,
3382
- retentionPolicy: options.retentionPolicy,
3383
- }, updatedRestModelOptions);
3384
- return mapToCreateChatThreadResultSdkModel(result);
3385
- });
3386
- }
3387
- listChatThreadsPage(continuationState_1) {
3388
- return tslib.__asyncGenerator(this, arguments, function* listChatThreadsPage_1(continuationState, options = {}) {
3389
- if (!continuationState.continuationToken) {
3390
- const currentSetResponse = yield tslib.__await(this.client.chat.listChatThreads(options));
3391
- continuationState.continuationToken = currentSetResponse.nextLink;
3392
- if (currentSetResponse.value) {
3393
- yield yield tslib.__await(currentSetResponse.value);
3394
- }
3395
- }
3396
- while (continuationState.continuationToken) {
3397
- const currentSetResponse = yield tslib.__await(this.client.chat.listChatThreadsNext(continuationState.continuationToken, options));
3398
- continuationState.continuationToken = currentSetResponse.nextLink;
3399
- if (currentSetResponse.value) {
3400
- yield yield tslib.__await(currentSetResponse.value);
3401
- }
3402
- else {
3403
- break;
3404
- }
3405
- }
3406
- });
3407
- }
3408
- listChatThreadsAll(options) {
3409
- return tslib.__asyncGenerator(this, arguments, function* listChatThreadsAll_1() {
3410
- var _a, e_1, _b, _c;
3411
- try {
3412
- for (var _d = true, _e = tslib.__asyncValues(this.listChatThreadsPage({}, options)), _f; _f = yield tslib.__await(_e.next()), _a = _f.done, !_a; _d = true) {
3413
- _c = _f.value;
3414
- _d = false;
3415
- const page = _c;
3416
- yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
3417
- }
3418
- }
3419
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
3420
- finally {
3421
- try {
3422
- if (!_d && !_a && (_b = _e.return)) yield tslib.__await(_b.call(_e));
3423
- }
3424
- finally { if (e_1) throw e_1.error; }
3425
- }
3426
- });
3427
- }
3428
- /**
3429
- * Gets the list of chat threads of a user.
3430
- * @param options - List chat threads options.
3431
- */
3432
- listChatThreads(options = {}) {
3433
- const { span, updatedOptions } = tracingClient.startSpan("ChatClient-ListChatThreads", options);
3434
- try {
3435
- const iter = this.listChatThreadsAll(updatedOptions);
3436
- return {
3437
- next() {
3438
- return iter.next();
3439
- },
3440
- [Symbol.asyncIterator]() {
3441
- return this;
3442
- },
3443
- byPage: (settings = {}) => {
3444
- return this.listChatThreadsPage(settings, updatedOptions);
3445
- },
3446
- };
3447
- }
3448
- catch (e) {
3449
- span.setStatus({
3450
- error: e,
3451
- status: "error",
3452
- });
3453
- throw e;
3454
- }
3455
- finally {
3456
- span.end();
3457
- }
3458
- }
3459
- /**
3460
- * Deletes a chat thread.
3461
- * @param threadId - The ID of the thread to delete.
3462
- * @param options - Operation options.
3463
- */
3464
- async deleteChatThread(threadId, options = {}) {
3465
- return tracingClient.withSpan("ChatClient-DeleteChatThread", options, async (updatedOptions) => {
3466
- await this.client.chat.deleteChatThread(threadId, updatedOptions);
3467
- });
3468
- }
3469
- /**
3470
- * Start receiving realtime notifications.
3471
- * Call this function before subscribing to any event.
3472
- */
3473
- async startRealtimeNotifications() {
3474
- if (this.signalingClient === undefined) {
3475
- throw new Error("Realtime notifications are not supported in node js.");
3476
- }
3477
- if (this.isRealtimeNotificationsStarted) {
3478
- return;
3479
- }
3480
- this.isRealtimeNotificationsStarted = true;
3481
- await this.signalingClient.start();
3482
- this.subscribeToSignalingEvents();
3483
- }
3484
- /**
3485
- * Stop receiving realtime notifications.
3486
- * This function would unsubscribe to all events.
3487
- */
3488
- async stopRealtimeNotifications() {
3489
- if (this.signalingClient === undefined) {
3490
- throw new Error("Realtime notifications are not supported in node js.");
3491
- }
3492
- this.isRealtimeNotificationsStarted = false;
3493
- await this.signalingClient.stop();
3494
- this.emitter.removeAllListeners();
3495
- }
3496
- on(event, listener) {
3497
- if (this.signalingClient === undefined) {
3498
- throw new Error("Realtime notifications are only supported in the browser.");
3499
- }
3500
- if (!this.isRealtimeNotificationsStarted &&
3501
- event !== "realTimeNotificationConnected" &&
3502
- event !== "realTimeNotificationDisconnected") {
3503
- throw new Error("You must call startRealtimeNotifications before you can subscribe to events.");
3504
- }
3505
- this.emitter.on(event, listener);
3506
- }
3507
- off(event, listener) {
3508
- if (this.signalingClient === undefined) {
3509
- throw new Error("Realtime notifications are only supported in the browser.");
3510
- }
3511
- this.emitter.removeListener(event, listener);
3512
- }
3513
- subscribeToSignalingEvents() {
3514
- if (this.signalingClient === undefined) {
3515
- throw new Error("Realtime notifications are only supported in the browser.");
3516
- }
3517
- this.signalingClient.on("connectionChanged", (payload) => {
3518
- if (payload === 2 /* ConnectionState.Connected */) {
3519
- this.emitter.emit("realTimeNotificationConnected");
3520
- }
3521
- else if (payload === 3 /* ConnectionState.Disconnected */) {
3522
- this.emitter.emit("realTimeNotificationDisconnected");
3523
- }
3524
- });
3525
- this.signalingClient.on("chatMessageReceived", (payload) => {
3526
- this.emitter.emit("chatMessageReceived", payload);
3527
- });
3528
- this.signalingClient.on("chatMessageEdited", (payload) => {
3529
- this.emitter.emit("chatMessageEdited", payload);
3530
- });
3531
- this.signalingClient.on("chatMessageDeleted", (payload) => {
3532
- this.emitter.emit("chatMessageDeleted", payload);
3533
- });
3534
- this.signalingClient.on("typingIndicatorReceived", (payload) => {
3535
- this.emitter.emit("typingIndicatorReceived", payload);
3536
- });
3537
- this.signalingClient.on("readReceiptReceived", (payload) => {
3538
- this.emitter.emit("readReceiptReceived", payload);
3539
- });
3540
- this.signalingClient.on("chatThreadCreated", (payload) => {
3541
- this.emitter.emit("chatThreadCreated", payload);
3542
- });
3543
- this.signalingClient.on("chatThreadDeleted", (payload) => {
3544
- this.emitter.emit("chatThreadDeleted", payload);
3545
- });
3546
- this.signalingClient.on("chatThreadPropertiesUpdated", (payload) => {
3547
- this.emitter.emit("chatThreadPropertiesUpdated", payload);
3548
- });
3549
- this.signalingClient.on("participantsAdded", (payload) => {
3550
- this.emitter.emit("participantsAdded", payload);
3551
- });
3552
- this.signalingClient.on("participantsRemoved", (payload) => {
3553
- this.emitter.emit("participantsRemoved", payload);
3554
- });
3555
- }
3556
- }
3557
-
3558
- exports.ChatClient = ChatClient;
3559
- exports.ChatThreadClient = ChatThreadClient;
3560
- //# sourceMappingURL=index.js.map