@azure/communication-chat 1.1.0-beta.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/CHANGELOG.md +6 -2
  2. package/dist/index.js +91 -194
  3. package/dist/index.js.map +1 -1
  4. package/dist-esm/src/chatClient.js +11 -25
  5. package/dist-esm/src/chatClient.js.map +1 -1
  6. package/dist-esm/src/chatThreadClient.js +19 -35
  7. package/dist-esm/src/chatThreadClient.js.map +1 -1
  8. package/dist-esm/src/credential/communicationTokenCredentialPolicy.js +8 -4
  9. package/dist-esm/src/credential/communicationTokenCredentialPolicy.js.map +1 -1
  10. package/dist-esm/src/generated/src/chatApiClient.js +3 -3
  11. package/dist-esm/src/generated/src/chatApiClient.js.map +1 -1
  12. package/dist-esm/src/generated/src/chatApiClientContext.js +14 -12
  13. package/dist-esm/src/generated/src/chatApiClientContext.js.map +1 -1
  14. package/dist-esm/src/generated/src/index.js +1 -0
  15. package/dist-esm/src/generated/src/index.js.map +1 -1
  16. package/dist-esm/src/generated/src/models/index.js +7 -1
  17. package/dist-esm/src/generated/src/models/index.js.map +1 -1
  18. package/dist-esm/src/generated/src/models/mappers.js.map +1 -1
  19. package/dist-esm/src/generated/src/models/parameters.js +1 -1
  20. package/dist-esm/src/generated/src/models/parameters.js.map +1 -1
  21. package/dist-esm/src/generated/src/operations/chat.js +8 -23
  22. package/dist-esm/src/generated/src/operations/chat.js.map +1 -1
  23. package/dist-esm/src/generated/src/operations/chatThread.js +20 -96
  24. package/dist-esm/src/generated/src/operations/chatThread.js.map +1 -1
  25. package/dist-esm/src/generated/src/operationsInterfaces/chat.js +9 -0
  26. package/dist-esm/src/generated/src/operationsInterfaces/chat.js.map +1 -0
  27. package/dist-esm/src/generated/src/operationsInterfaces/chatThread.js +9 -0
  28. package/dist-esm/src/generated/src/operationsInterfaces/chatThread.js.map +1 -0
  29. package/dist-esm/src/generated/src/operationsInterfaces/index.js +10 -0
  30. package/dist-esm/src/generated/src/operationsInterfaces/index.js.map +1 -0
  31. package/dist-esm/src/models/options.js.map +1 -1
  32. package/dist-esm/src/models/uuid.js +13 -0
  33. package/dist-esm/src/models/uuid.js.map +1 -0
  34. package/package.json +12 -13
  35. package/types/communication-chat.d.ts +8 -8
  36. package/types/src/chatClient.d.ts +0 -1
  37. package/types/src/chatClient.d.ts.map +1 -1
  38. package/types/src/chatThreadClient.d.ts.map +1 -1
  39. package/types/src/credential/communicationTokenCredentialPolicy.d.ts +2 -2
  40. package/types/src/credential/communicationTokenCredentialPolicy.d.ts.map +1 -1
  41. package/types/src/generated/src/chatApiClient.d.ts +1 -1
  42. package/types/src/generated/src/chatApiClient.d.ts.map +1 -1
  43. package/types/src/generated/src/chatApiClientContext.d.ts +2 -2
  44. package/types/src/generated/src/chatApiClientContext.d.ts.map +1 -1
  45. package/types/src/generated/src/index.d.ts +1 -0
  46. package/types/src/generated/src/index.d.ts.map +1 -1
  47. package/types/src/generated/src/models/index.d.ts +57 -131
  48. package/types/src/generated/src/models/index.d.ts.map +1 -1
  49. package/types/src/generated/src/models/mappers.d.ts +27 -27
  50. package/types/src/generated/src/models/mappers.d.ts.map +1 -1
  51. package/types/src/generated/src/models/parameters.d.ts +1 -1
  52. package/types/src/generated/src/models/parameters.d.ts.map +1 -1
  53. package/types/src/generated/src/operations/chat.d.ts +7 -7
  54. package/types/src/generated/src/operations/chat.d.ts.map +1 -1
  55. package/types/src/generated/src/operations/chatThread.d.ts +16 -16
  56. package/types/src/generated/src/operations/chatThread.d.ts.map +1 -1
  57. package/types/src/generated/src/operationsInterfaces/chat.d.ts +28 -0
  58. package/types/src/generated/src/operationsInterfaces/chat.d.ts.map +1 -0
  59. package/types/src/generated/src/operationsInterfaces/chatThread.d.ts +113 -0
  60. package/types/src/generated/src/operationsInterfaces/chatThread.d.ts.map +1 -0
  61. package/types/src/generated/src/operationsInterfaces/index.d.ts +3 -0
  62. package/types/src/generated/src/operationsInterfaces/index.d.ts.map +1 -0
  63. package/types/src/models/options.d.ts +2 -2
  64. package/types/src/models/options.d.ts.map +1 -1
  65. package/types/src/models/uuid.d.ts +8 -0
  66. package/types/src/models/uuid.d.ts.map +1 -0
  67. package/types/test/internal/utils/mockClient.d.ts +1 -1
  68. package/types/test/internal/utils/mockClient.d.ts.map +1 -1
  69. package/types/test/public/utils/connectionUtils.d.ts +1 -1
  70. package/types/test/public/utils/connectionUtils.d.ts.map +1 -1
  71. package/types/test/public/utils/recordedClient.d.ts +1 -1
  72. package/types/test/public/utils/recordedClient.d.ts.map +1 -1
  73. package/dist-esm/src/constants.js +0 -4
  74. package/dist-esm/src/constants.js.map +0 -1
  75. package/types/src/constants.d.ts +0 -2
  76. package/types/src/constants.d.ts.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,7 +1,11 @@
1
1
  # Release History
2
2
 
3
- ## 1.1.0-beta.2 (2021-08-30)
4
- - Updated to @azure/communication-signaling@1.0.0-beta.8.
3
+ ## 1.1.0 ((2021-09-15)
4
+
5
+ ### Features Added
6
+
7
+ - Migrated from using `@azure/core-http` to `@azure/core-rest-pipeline` for the handling of HTTP requests. See [Azure Core v1 vs v2](https://github.com/Azure/azure-sdk-for-js/blob/main/sdk/core/core-rest-pipeline/documentation/core2.md) for more on the difference and benefits of the move.
8
+ - Updated to @azure/communication-signaling@1.0.0-beta.10.
5
9
 
6
10
  ## 1.1.0-beta.1 (2021-08-10)
7
11
 
package/dist/index.js CHANGED
@@ -6,18 +6,15 @@ var tslib = require('tslib');
6
6
  var logger$1 = require('@azure/logger');
7
7
  var events = require('events');
8
8
  var communicationSignaling = require('@azure/communication-signaling');
9
- var coreHttp = require('@azure/core-http');
10
- require('@azure/core-paging');
11
9
  var coreTracing = require('@azure/core-tracing');
12
10
  var communicationCommon = require('@azure/communication-common');
11
+ var coreClient = require('@azure/core-client');
12
+ var coreRestPipeline = require('@azure/core-rest-pipeline');
13
+ var uuid = require('uuid');
13
14
 
14
15
  // Copyright (c) Microsoft Corporation.
15
16
  const logger = logger$1.createClientLogger("communication-chat");
16
17
 
17
- // Copyright (c) Microsoft Corporation.
18
- // Licensed under the MIT license.
19
- const SDK_VERSION = "1.1.0-beta.2";
20
-
21
18
  // Copyright (c) Microsoft Corporation.
22
19
  const getSignalingClient = (credential, logger) => {
23
20
  if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
@@ -979,7 +976,7 @@ const skip = {
979
976
  const apiVersion = {
980
977
  parameterPath: "apiVersion",
981
978
  mapper: {
982
- defaultValue: "2021-04-05-preview6",
979
+ defaultValue: "2021-09-07",
983
980
  isConstant: true,
984
981
  serializedName: "api-version",
985
982
  type: {
@@ -1088,8 +1085,8 @@ const repeatabilityRequestId = {
1088
1085
  * Code generated by Microsoft (R) AutoRest Code Generator.
1089
1086
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1090
1087
  */
1091
- /** Class representing a ChatThread. */
1092
- class ChatThread {
1088
+ /** Class containing ChatThread operations. */
1089
+ class ChatThreadImpl {
1093
1090
  /**
1094
1091
  * Initialize a new instance of the class ChatThread class.
1095
1092
  * @param client Reference to the service client
@@ -1103,11 +1100,7 @@ class ChatThread {
1103
1100
  * @param options The options parameters.
1104
1101
  */
1105
1102
  listChatReadReceipts(chatThreadId, options) {
1106
- const operationArguments = {
1107
- chatThreadId,
1108
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1109
- };
1110
- return this.client.sendOperationRequest(operationArguments, listChatReadReceiptsOperationSpec);
1103
+ return this.client.sendOperationRequest({ chatThreadId, options }, listChatReadReceiptsOperationSpec);
1111
1104
  }
1112
1105
  /**
1113
1106
  * Sends a read receipt event to a thread, on behalf of a user.
@@ -1116,12 +1109,7 @@ class ChatThread {
1116
1109
  * @param options The options parameters.
1117
1110
  */
1118
1111
  sendChatReadReceipt(chatThreadId, sendReadReceiptRequest, options) {
1119
- const operationArguments = {
1120
- chatThreadId,
1121
- sendReadReceiptRequest,
1122
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1123
- };
1124
- return this.client.sendOperationRequest(operationArguments, sendChatReadReceiptOperationSpec);
1112
+ return this.client.sendOperationRequest({ chatThreadId, sendReadReceiptRequest, options }, sendChatReadReceiptOperationSpec);
1125
1113
  }
1126
1114
  /**
1127
1115
  * Sends a message to a thread.
@@ -1130,12 +1118,7 @@ class ChatThread {
1130
1118
  * @param options The options parameters.
1131
1119
  */
1132
1120
  sendChatMessage(chatThreadId, sendChatMessageRequest, options) {
1133
- const operationArguments = {
1134
- chatThreadId,
1135
- sendChatMessageRequest,
1136
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1137
- };
1138
- return this.client.sendOperationRequest(operationArguments, sendChatMessageOperationSpec);
1121
+ return this.client.sendOperationRequest({ chatThreadId, sendChatMessageRequest, options }, sendChatMessageOperationSpec);
1139
1122
  }
1140
1123
  /**
1141
1124
  * Gets a list of messages from a thread.
@@ -1143,11 +1126,7 @@ class ChatThread {
1143
1126
  * @param options The options parameters.
1144
1127
  */
1145
1128
  listChatMessages(chatThreadId, options) {
1146
- const operationArguments = {
1147
- chatThreadId,
1148
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1149
- };
1150
- return this.client.sendOperationRequest(operationArguments, listChatMessagesOperationSpec);
1129
+ return this.client.sendOperationRequest({ chatThreadId, options }, listChatMessagesOperationSpec);
1151
1130
  }
1152
1131
  /**
1153
1132
  * Gets a message by id.
@@ -1156,12 +1135,7 @@ class ChatThread {
1156
1135
  * @param options The options parameters.
1157
1136
  */
1158
1137
  getChatMessage(chatThreadId, chatMessageId, options) {
1159
- const operationArguments = {
1160
- chatThreadId,
1161
- chatMessageId,
1162
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1163
- };
1164
- return this.client.sendOperationRequest(operationArguments, getChatMessageOperationSpec);
1138
+ return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, getChatMessageOperationSpec);
1165
1139
  }
1166
1140
  /**
1167
1141
  * Updates a message.
@@ -1171,13 +1145,7 @@ class ChatThread {
1171
1145
  * @param options The options parameters.
1172
1146
  */
1173
1147
  updateChatMessage(chatThreadId, chatMessageId, updateChatMessageRequest, options) {
1174
- const operationArguments = {
1175
- chatThreadId,
1176
- chatMessageId,
1177
- updateChatMessageRequest,
1178
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1179
- };
1180
- return this.client.sendOperationRequest(operationArguments, updateChatMessageOperationSpec);
1148
+ return this.client.sendOperationRequest({ chatThreadId, chatMessageId, updateChatMessageRequest, options }, updateChatMessageOperationSpec);
1181
1149
  }
1182
1150
  /**
1183
1151
  * Deletes a message.
@@ -1186,12 +1154,7 @@ class ChatThread {
1186
1154
  * @param options The options parameters.
1187
1155
  */
1188
1156
  deleteChatMessage(chatThreadId, chatMessageId, options) {
1189
- const operationArguments = {
1190
- chatThreadId,
1191
- chatMessageId,
1192
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1193
- };
1194
- return this.client.sendOperationRequest(operationArguments, deleteChatMessageOperationSpec);
1157
+ return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, deleteChatMessageOperationSpec);
1195
1158
  }
1196
1159
  /**
1197
1160
  * Gets the participants of a thread.
@@ -1199,11 +1162,7 @@ class ChatThread {
1199
1162
  * @param options The options parameters.
1200
1163
  */
1201
1164
  listChatParticipants(chatThreadId, options) {
1202
- const operationArguments = {
1203
- chatThreadId,
1204
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1205
- };
1206
- return this.client.sendOperationRequest(operationArguments, listChatParticipantsOperationSpec);
1165
+ return this.client.sendOperationRequest({ chatThreadId, options }, listChatParticipantsOperationSpec);
1207
1166
  }
1208
1167
  /**
1209
1168
  * Remove a participant from a thread.
@@ -1212,12 +1171,7 @@ class ChatThread {
1212
1171
  * @param options The options parameters.
1213
1172
  */
1214
1173
  removeChatParticipant(chatThreadId, participantCommunicationIdentifier, options) {
1215
- const operationArguments = {
1216
- chatThreadId,
1217
- participantCommunicationIdentifier,
1218
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1219
- };
1220
- return this.client.sendOperationRequest(operationArguments, removeChatParticipantOperationSpec);
1174
+ return this.client.sendOperationRequest({ chatThreadId, participantCommunicationIdentifier, options }, removeChatParticipantOperationSpec);
1221
1175
  }
1222
1176
  /**
1223
1177
  * Adds thread participants to a thread. If participants already exist, no change occurs.
@@ -1226,12 +1180,7 @@ class ChatThread {
1226
1180
  * @param options The options parameters.
1227
1181
  */
1228
1182
  addChatParticipants(chatThreadId, addChatParticipantsRequest, options) {
1229
- const operationArguments = {
1230
- chatThreadId,
1231
- addChatParticipantsRequest,
1232
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1233
- };
1234
- return this.client.sendOperationRequest(operationArguments, addChatParticipantsOperationSpec);
1183
+ return this.client.sendOperationRequest({ chatThreadId, addChatParticipantsRequest, options }, addChatParticipantsOperationSpec);
1235
1184
  }
1236
1185
  /**
1237
1186
  * Updates a thread's properties.
@@ -1240,12 +1189,7 @@ class ChatThread {
1240
1189
  * @param options The options parameters.
1241
1190
  */
1242
1191
  updateChatThreadProperties(chatThreadId, updateChatThreadRequest, options) {
1243
- const operationArguments = {
1244
- chatThreadId,
1245
- updateChatThreadRequest,
1246
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1247
- };
1248
- return this.client.sendOperationRequest(operationArguments, updateChatThreadPropertiesOperationSpec);
1192
+ return this.client.sendOperationRequest({ chatThreadId, updateChatThreadRequest, options }, updateChatThreadPropertiesOperationSpec);
1249
1193
  }
1250
1194
  /**
1251
1195
  * Gets a chat thread's properties.
@@ -1253,11 +1197,7 @@ class ChatThread {
1253
1197
  * @param options The options parameters.
1254
1198
  */
1255
1199
  getChatThreadProperties(chatThreadId, options) {
1256
- const operationArguments = {
1257
- chatThreadId,
1258
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1259
- };
1260
- return this.client.sendOperationRequest(operationArguments, getChatThreadPropertiesOperationSpec);
1200
+ return this.client.sendOperationRequest({ chatThreadId, options }, getChatThreadPropertiesOperationSpec);
1261
1201
  }
1262
1202
  /**
1263
1203
  * Posts a typing event to a thread, on behalf of a user.
@@ -1265,11 +1205,7 @@ class ChatThread {
1265
1205
  * @param options The options parameters.
1266
1206
  */
1267
1207
  sendTypingNotification(chatThreadId, options) {
1268
- const operationArguments = {
1269
- chatThreadId,
1270
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1271
- };
1272
- return this.client.sendOperationRequest(operationArguments, sendTypingNotificationOperationSpec);
1208
+ return this.client.sendOperationRequest({ chatThreadId, options }, sendTypingNotificationOperationSpec);
1273
1209
  }
1274
1210
  /**
1275
1211
  * ListChatReadReceiptsNext
@@ -1278,12 +1214,7 @@ class ChatThread {
1278
1214
  * @param options The options parameters.
1279
1215
  */
1280
1216
  listChatReadReceiptsNext(chatThreadId, nextLink, options) {
1281
- const operationArguments = {
1282
- chatThreadId,
1283
- nextLink,
1284
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1285
- };
1286
- return this.client.sendOperationRequest(operationArguments, listChatReadReceiptsNextOperationSpec);
1217
+ return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatReadReceiptsNextOperationSpec);
1287
1218
  }
1288
1219
  /**
1289
1220
  * ListChatMessagesNext
@@ -1292,12 +1223,7 @@ class ChatThread {
1292
1223
  * @param options The options parameters.
1293
1224
  */
1294
1225
  listChatMessagesNext(chatThreadId, nextLink, options) {
1295
- const operationArguments = {
1296
- chatThreadId,
1297
- nextLink,
1298
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1299
- };
1300
- return this.client.sendOperationRequest(operationArguments, listChatMessagesNextOperationSpec);
1226
+ return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatMessagesNextOperationSpec);
1301
1227
  }
1302
1228
  /**
1303
1229
  * ListChatParticipantsNext
@@ -1306,16 +1232,11 @@ class ChatThread {
1306
1232
  * @param options The options parameters.
1307
1233
  */
1308
1234
  listChatParticipantsNext(chatThreadId, nextLink, options) {
1309
- const operationArguments = {
1310
- chatThreadId,
1311
- nextLink,
1312
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1313
- };
1314
- return this.client.sendOperationRequest(operationArguments, listChatParticipantsNextOperationSpec);
1235
+ return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatParticipantsNextOperationSpec);
1315
1236
  }
1316
1237
  }
1317
1238
  // Operation Specifications
1318
- const serializer = new coreHttp.Serializer(Mappers, /* isXml */ false);
1239
+ const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
1319
1240
  const listChatReadReceiptsOperationSpec = {
1320
1241
  path: "/chat/threads/{chatThreadId}/readReceipts",
1321
1242
  httpMethod: "GET",
@@ -1838,8 +1759,8 @@ const listChatParticipantsNextOperationSpec = {
1838
1759
  * Code generated by Microsoft (R) AutoRest Code Generator.
1839
1760
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1840
1761
  */
1841
- /** Class representing a Chat. */
1842
- class Chat {
1762
+ /** Class containing Chat operations. */
1763
+ class ChatImpl {
1843
1764
  /**
1844
1765
  * Initialize a new instance of the class Chat class.
1845
1766
  * @param client Reference to the service client
@@ -1853,21 +1774,14 @@ class Chat {
1853
1774
  * @param options The options parameters.
1854
1775
  */
1855
1776
  createChatThread(createChatThreadRequest, options) {
1856
- const operationArguments = {
1857
- createChatThreadRequest,
1858
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1859
- };
1860
- return this.client.sendOperationRequest(operationArguments, createChatThreadOperationSpec);
1777
+ return this.client.sendOperationRequest({ createChatThreadRequest, options }, createChatThreadOperationSpec);
1861
1778
  }
1862
1779
  /**
1863
1780
  * Gets the list of chat threads of a user.
1864
1781
  * @param options The options parameters.
1865
1782
  */
1866
1783
  listChatThreads(options) {
1867
- const operationArguments = {
1868
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1869
- };
1870
- return this.client.sendOperationRequest(operationArguments, listChatThreadsOperationSpec);
1784
+ return this.client.sendOperationRequest({ options }, listChatThreadsOperationSpec);
1871
1785
  }
1872
1786
  /**
1873
1787
  * Deletes a thread.
@@ -1875,11 +1789,7 @@ class Chat {
1875
1789
  * @param options The options parameters.
1876
1790
  */
1877
1791
  deleteChatThread(chatThreadId, options) {
1878
- const operationArguments = {
1879
- chatThreadId,
1880
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1881
- };
1882
- return this.client.sendOperationRequest(operationArguments, deleteChatThreadOperationSpec);
1792
+ return this.client.sendOperationRequest({ chatThreadId, options }, deleteChatThreadOperationSpec);
1883
1793
  }
1884
1794
  /**
1885
1795
  * ListChatThreadsNext
@@ -1887,15 +1797,11 @@ class Chat {
1887
1797
  * @param options The options parameters.
1888
1798
  */
1889
1799
  listChatThreadsNext(nextLink, options) {
1890
- const operationArguments = {
1891
- nextLink,
1892
- options: coreHttp.operationOptionsToRequestOptionsBase(options || {})
1893
- };
1894
- return this.client.sendOperationRequest(operationArguments, listChatThreadsNextOperationSpec);
1800
+ return this.client.sendOperationRequest({ nextLink, options }, listChatThreadsNextOperationSpec);
1895
1801
  }
1896
1802
  }
1897
1803
  // Operation Specifications
1898
- const serializer$1 = new coreHttp.Serializer(Mappers, /* isXml */ false);
1804
+ const serializer$1 = coreClient.createSerializer(Mappers, /* isXml */ false);
1899
1805
  const createChatThreadOperationSpec = {
1900
1806
  path: "/chat/threads",
1901
1807
  httpMethod: "POST",
@@ -2032,9 +1938,7 @@ const listChatThreadsNextOperationSpec = {
2032
1938
  * Code generated by Microsoft (R) AutoRest Code Generator.
2033
1939
  * Changes may cause incorrect behavior and will be lost if the code is regenerated.
2034
1940
  */
2035
- const packageName = "azure-communication-chat";
2036
- const packageVersion = "1.1.0-beta.2";
2037
- class ChatApiClientContext extends coreHttp.ServiceClient {
1941
+ class ChatApiClientContext extends coreClient.ServiceClient {
2038
1942
  /**
2039
1943
  * Initializes a new instance of the ChatApiClientContext class.
2040
1944
  * @param endpoint The endpoint of the Azure Communication resource.
@@ -2048,17 +1952,21 @@ class ChatApiClientContext extends coreHttp.ServiceClient {
2048
1952
  if (!options) {
2049
1953
  options = {};
2050
1954
  }
2051
- if (!options.userAgent) {
2052
- const defaultUserAgent = coreHttp.getDefaultUserAgentValue();
2053
- options.userAgent = `${packageName}/${packageVersion} ${defaultUserAgent}`;
2054
- }
2055
- super(undefined, options);
2056
- this.requestContentType = "application/json; charset=utf-8";
2057
- this.baseUri = options.endpoint || "{endpoint}";
1955
+ const defaults = {
1956
+ requestContentType: "application/json; charset=utf-8"
1957
+ };
1958
+ const packageDetails = `azsdk-js-azure-communication-chat/1.1.0`;
1959
+ const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1960
+ ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1961
+ : `${packageDetails}`;
1962
+ const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1963
+ userAgentPrefix
1964
+ }, baseUri: options.endpoint || "{endpoint}" });
1965
+ super(optionsWithDefaults);
2058
1966
  // Parameter assignments
2059
1967
  this.endpoint = endpoint;
2060
1968
  // Assigning values to Constant parameters
2061
- this.apiVersion = options.apiVersion || "2021-04-05-preview6";
1969
+ this.apiVersion = options.apiVersion || "2021-09-07";
2062
1970
  }
2063
1971
  }
2064
1972
 
@@ -2077,8 +1985,8 @@ class ChatApiClient extends ChatApiClientContext {
2077
1985
  */
2078
1986
  constructor(endpoint, options) {
2079
1987
  super(endpoint, options);
2080
- this.chatThread = new ChatThread(this);
2081
- this.chat = new Chat(this);
1988
+ this.chatThread = new ChatThreadImpl(this);
1989
+ this.chat = new ChatImpl(this);
2082
1990
  }
2083
1991
  }
2084
1992
 
@@ -2089,9 +1997,13 @@ class ChatApiClient extends ChatApiClientContext {
2089
1997
  * @param credential - The CommunicationTokenCredential implementation that can supply the user credential.
2090
1998
  */
2091
1999
  const createCommunicationTokenCredentialPolicy = (credential) => {
2092
- return coreHttp.bearerTokenAuthenticationPolicy({
2093
- getToken: (_scopes, options) => credential.getToken({ abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal })
2094
- }, []);
2000
+ const policyOptions = {
2001
+ credential: {
2002
+ getToken: (_scopes, options) => credential.getToken({ abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal })
2003
+ },
2004
+ scopes: []
2005
+ };
2006
+ return coreRestPipeline.bearerTokenAuthenticationPolicy(policyOptions);
2095
2007
  };
2096
2008
 
2097
2009
  // Copyright (c) Microsoft Corporation.
@@ -2105,25 +2017,14 @@ class ChatThreadClient {
2105
2017
  this.timeOfLastTypingRequest = undefined;
2106
2018
  this.threadId = threadId;
2107
2019
  this.tokenCredential = credential;
2108
- const libInfo = `azsdk-js-communication-chat/${SDK_VERSION}`;
2109
- if (!options.userAgentOptions) {
2110
- options.userAgentOptions = {};
2111
- }
2112
- const userAgentOptions = Object.assign({}, options.userAgentOptions);
2113
- if (options.userAgentOptions.userAgentPrefix) {
2114
- userAgentOptions.userAgentPrefix = `${options.userAgentOptions.userAgentPrefix} ${libInfo}`;
2115
- }
2116
- else {
2117
- userAgentOptions.userAgentPrefix = libInfo;
2118
- }
2119
- const internalPipelineOptions = Object.assign(Object.assign({}, Object.assign(Object.assign({}, options), { userAgentOptions })), {
2020
+ const internalPipelineOptions = Object.assign(Object.assign({}, options), {
2120
2021
  loggingOptions: {
2121
2022
  logger: logger.info
2122
2023
  }
2123
2024
  });
2025
+ this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
2124
2026
  const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);
2125
- const pipeline = coreHttp.createPipelineFromOptions(internalPipelineOptions, authPolicy);
2126
- this.client = new ChatApiClient(this.endpoint, pipeline);
2027
+ this.client.pipeline.addPolicy(authPolicy);
2127
2028
  }
2128
2029
  /**
2129
2030
  * Gets a chat thread.
@@ -2133,7 +2034,7 @@ class ChatThreadClient {
2133
2034
  async getProperties(options = {}) {
2134
2035
  const { span, updatedOptions } = createSpan("ChatClient-GetProperties", options);
2135
2036
  try {
2136
- const _a = await this.client.chatThread.getChatThreadProperties(this.threadId, coreHttp.operationOptionsToRequestOptionsBase(updatedOptions)), { _response } = _a, result = tslib.__rest(_a, ["_response"]);
2037
+ const result = await this.client.chatThread.getChatThreadProperties(this.threadId, updatedOptions);
2137
2038
  return mapToChatThreadPropertiesSdkModel(result);
2138
2039
  }
2139
2040
  catch (e) {
@@ -2155,7 +2056,7 @@ class ChatThreadClient {
2155
2056
  async updateTopic(topic, options = {}) {
2156
2057
  const { span, updatedOptions } = createSpan("ChatThreadClient-UpdateTopic", options);
2157
2058
  try {
2158
- await this.client.chatThread.updateChatThreadProperties(this.threadId, { topic: topic }, coreHttp.operationOptionsToRequestOptionsBase(updatedOptions));
2059
+ await this.client.chatThread.updateChatThreadProperties(this.threadId, { topic: topic }, updatedOptions);
2159
2060
  }
2160
2061
  catch (e) {
2161
2062
  span.setStatus({
@@ -2179,7 +2080,7 @@ class ChatThreadClient {
2179
2080
  try {
2180
2081
  // reset typing notification clock
2181
2082
  this.timeOfLastTypingRequest = undefined;
2182
- const _a = await this.client.chatThread.sendChatMessage(this.threadId, Object.assign(Object.assign({}, request), options), coreHttp.operationOptionsToRequestOptionsBase(updatedOptions)), { _response } = _a, result = tslib.__rest(_a, ["_response"]);
2083
+ const result = await this.client.chatThread.sendChatMessage(this.threadId, Object.assign(Object.assign({}, request), options), updatedOptions);
2183
2084
  return result;
2184
2085
  }
2185
2086
  catch (e) {
@@ -2202,7 +2103,7 @@ class ChatThreadClient {
2202
2103
  async getMessage(messageId, options = {}) {
2203
2104
  const { span, updatedOptions } = createSpan("ChatThreadClient-GetMessage", options);
2204
2105
  try {
2205
- const _a = await this.client.chatThread.getChatMessage(this.threadId, messageId, coreHttp.operationOptionsToRequestOptionsBase(updatedOptions)), { _response } = _a, result = tslib.__rest(_a, ["_response"]);
2106
+ const result = await this.client.chatThread.getChatMessage(this.threadId, messageId, updatedOptions);
2206
2107
  return mapToChatMessageSdkModel(result);
2207
2108
  }
2208
2109
  catch (e) {
@@ -2218,16 +2119,15 @@ class ChatThreadClient {
2218
2119
  }
2219
2120
  listMessagesPage(pageSettings, options = {}) {
2220
2121
  return tslib.__asyncGenerator(this, arguments, function* listMessagesPage_1() {
2221
- const requestOptions = coreHttp.operationOptionsToRequestOptionsBase(options);
2222
2122
  if (!pageSettings.continuationToken) {
2223
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatMessages(this.threadId, requestOptions));
2123
+ const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatMessages(this.threadId, options));
2224
2124
  pageSettings.continuationToken = currentSetResponse.nextLink;
2225
2125
  if (currentSetResponse.value) {
2226
2126
  yield yield tslib.__await(currentSetResponse.value.map(mapToChatMessageSdkModel, this));
2227
2127
  }
2228
2128
  }
2229
2129
  while (pageSettings.continuationToken) {
2230
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatMessagesNext(this.threadId, pageSettings.continuationToken, requestOptions));
2130
+ const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatMessagesNext(this.threadId, pageSettings.continuationToken, options));
2231
2131
  pageSettings.continuationToken = currentSetResponse.nextLink;
2232
2132
  if (currentSetResponse.value) {
2233
2133
  yield yield tslib.__await(currentSetResponse.value.map(mapToChatMessageSdkModel, this));
@@ -2296,7 +2196,7 @@ class ChatThreadClient {
2296
2196
  async deleteMessage(messageId, options = {}) {
2297
2197
  const { span, updatedOptions } = createSpan("ChatThreadClient-DeleteMessage", options);
2298
2198
  try {
2299
- await this.client.chatThread.deleteChatMessage(this.threadId, messageId, coreHttp.operationOptionsToRequestOptionsBase(updatedOptions));
2199
+ await this.client.chatThread.deleteChatMessage(this.threadId, messageId, updatedOptions);
2300
2200
  }
2301
2201
  catch (e) {
2302
2202
  span.setStatus({
@@ -2317,7 +2217,7 @@ class ChatThreadClient {
2317
2217
  async updateMessage(messageId, options = {}) {
2318
2218
  const { span, updatedOptions } = createSpan("ChatThreadClient-UpdateMessage", options);
2319
2219
  try {
2320
- await this.client.chatThread.updateChatMessage(this.threadId, messageId, options, coreHttp.operationOptionsToRequestOptionsBase(updatedOptions));
2220
+ await this.client.chatThread.updateChatMessage(this.threadId, messageId, options, updatedOptions);
2321
2221
  }
2322
2222
  catch (e) {
2323
2223
  span.setStatus({
@@ -2338,7 +2238,7 @@ class ChatThreadClient {
2338
2238
  async addParticipants(request, options = {}) {
2339
2239
  const { span, updatedOptions } = createSpan("ChatThreadClient-AddParticipants", options);
2340
2240
  try {
2341
- const _a = await this.client.chatThread.addChatParticipants(this.threadId, mapToAddChatParticipantsRequestRestModel(request), coreHttp.operationOptionsToRequestOptionsBase(updatedOptions)), { _response } = _a, result = tslib.__rest(_a, ["_response"]);
2241
+ const result = await this.client.chatThread.addChatParticipants(this.threadId, mapToAddChatParticipantsRequestRestModel(request), updatedOptions);
2342
2242
  return result;
2343
2243
  }
2344
2244
  catch (e) {
@@ -2354,16 +2254,15 @@ class ChatThreadClient {
2354
2254
  }
2355
2255
  listParticipantsPage(continuationState, options = {}) {
2356
2256
  return tslib.__asyncGenerator(this, arguments, function* listParticipantsPage_1() {
2357
- const requestOptions = coreHttp.operationOptionsToRequestOptionsBase(options);
2358
2257
  if (!continuationState.continuationToken) {
2359
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatParticipants(this.threadId, requestOptions));
2258
+ const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatParticipants(this.threadId, options));
2360
2259
  continuationState.continuationToken = currentSetResponse.nextLink;
2361
2260
  if (currentSetResponse.value) {
2362
2261
  yield yield tslib.__await(currentSetResponse.value.map(mapToChatParticipantSdkModel, this));
2363
2262
  }
2364
2263
  }
2365
2264
  while (continuationState.continuationToken) {
2366
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatParticipantsNext(this.threadId, continuationState.continuationToken, requestOptions));
2265
+ const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatParticipantsNext(this.threadId, continuationState.continuationToken, options));
2367
2266
  continuationState.continuationToken = currentSetResponse.nextLink;
2368
2267
  if (currentSetResponse.value) {
2369
2268
  yield yield tslib.__await(currentSetResponse.value.map(mapToChatParticipantSdkModel, this));
@@ -2432,7 +2331,7 @@ class ChatThreadClient {
2432
2331
  async removeParticipant(participant, options = {}) {
2433
2332
  const { span, updatedOptions } = createSpan("ChatThreadClient-RemoveParticipant", options);
2434
2333
  try {
2435
- await this.client.chatThread.removeChatParticipant(this.threadId, communicationCommon.serializeCommunicationIdentifier(participant), coreHttp.operationOptionsToRequestOptionsBase(updatedOptions));
2334
+ await this.client.chatThread.removeChatParticipant(this.threadId, communicationCommon.serializeCommunicationIdentifier(participant), updatedOptions);
2436
2335
  }
2437
2336
  catch (e) {
2438
2337
  span.setStatus({
@@ -2455,7 +2354,7 @@ class ChatThreadClient {
2455
2354
  const { span, updatedOptions } = createSpan("ChatThreadClient-SendTypingNotification", options);
2456
2355
  try {
2457
2356
  const dateNow = new Date();
2458
- const _a = coreHttp.operationOptionsToRequestOptionsBase(updatedOptions), { senderDisplayName } = _a, restOptions = tslib.__rest(_a, ["senderDisplayName"]);
2357
+ const { senderDisplayName } = updatedOptions, restOptions = tslib.__rest(updatedOptions, ["senderDisplayName"]);
2459
2358
  if (this.canPostTypingNotification(dateNow)) {
2460
2359
  await this.client.chatThread.sendTypingNotification(this.threadId, Object.assign({ sendTypingNotificationRequest: { senderDisplayName: senderDisplayName } }, restOptions));
2461
2360
  this.timeOfLastTypingRequest = dateNow;
@@ -2484,7 +2383,7 @@ class ChatThreadClient {
2484
2383
  async sendReadReceipt(request, options = {}) {
2485
2384
  const { span, updatedOptions } = createSpan("ChatThreadClient-SendReadReceipt", options);
2486
2385
  try {
2487
- await this.client.chatThread.sendChatReadReceipt(this.threadId, request, coreHttp.operationOptionsToRequestOptionsBase(updatedOptions));
2386
+ await this.client.chatThread.sendChatReadReceipt(this.threadId, request, updatedOptions);
2488
2387
  }
2489
2388
  catch (e) {
2490
2389
  span.setStatus({
@@ -2499,16 +2398,15 @@ class ChatThreadClient {
2499
2398
  }
2500
2399
  listReadReceiptsPage(continuationState, options = {}) {
2501
2400
  return tslib.__asyncGenerator(this, arguments, function* listReadReceiptsPage_1() {
2502
- const requestOptions = coreHttp.operationOptionsToRequestOptionsBase(options);
2503
2401
  if (!continuationState.continuationToken) {
2504
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatReadReceipts(this.threadId, requestOptions));
2402
+ const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatReadReceipts(this.threadId, options));
2505
2403
  continuationState.continuationToken = currentSetResponse.nextLink;
2506
2404
  if (currentSetResponse.value) {
2507
2405
  yield yield tslib.__await(currentSetResponse.value.map(mapToReadReceiptSdkModel, this));
2508
2406
  }
2509
2407
  }
2510
2408
  while (continuationState.continuationToken) {
2511
- const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatReadReceiptsNext(this.threadId, continuationState.continuationToken, requestOptions));
2409
+ const currentSetResponse = yield tslib.__await(this.client.chatThread.listChatReadReceiptsNext(this.threadId, continuationState.continuationToken, options));
2512
2410
  continuationState.continuationToken = currentSetResponse.nextLink;
2513
2411
  if (currentSetResponse.value) {
2514
2412
  yield yield tslib.__await(currentSetResponse.value.map(mapToReadReceiptSdkModel, this));
@@ -2581,6 +2479,17 @@ class ChatThreadClient {
2581
2479
  }
2582
2480
  }
2583
2481
 
2482
+ // Copyright (c) Microsoft Corporation.
2483
+ /**
2484
+ * Generated Universally Unique Identifier
2485
+ *
2486
+ * @returns RFC4122 v4 UUID.
2487
+ * @internal
2488
+ */
2489
+ function generateUuid() {
2490
+ return uuid.v4();
2491
+ }
2492
+
2584
2493
  // Copyright (c) Microsoft Corporation.
2585
2494
  /**
2586
2495
  * The client to do chat operations
@@ -2600,25 +2509,14 @@ class ChatClient {
2600
2509
  this.isRealtimeNotificationsStarted = false;
2601
2510
  this.tokenCredential = credential;
2602
2511
  this.clientOptions = Object.assign({}, options);
2603
- const libInfo = `azsdk-js-communication-chat/${SDK_VERSION}`;
2604
- if (!options.userAgentOptions) {
2605
- options.userAgentOptions = {};
2606
- }
2607
- const userAgentOptions = Object.assign({}, options.userAgentOptions);
2608
- if (options.userAgentOptions.userAgentPrefix) {
2609
- userAgentOptions.userAgentPrefix = `${options.userAgentOptions.userAgentPrefix} ${libInfo}`;
2610
- }
2611
- else {
2612
- userAgentOptions.userAgentPrefix = libInfo;
2613
- }
2614
- const internalPipelineOptions = Object.assign(Object.assign({}, Object.assign(Object.assign({}, options), { userAgentOptions })), {
2512
+ const internalPipelineOptions = Object.assign(Object.assign({}, options), {
2615
2513
  loggingOptions: {
2616
2514
  logger: logger.info
2617
2515
  }
2618
2516
  });
2517
+ this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
2619
2518
  const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);
2620
- const pipeline = coreHttp.createPipelineFromOptions(internalPipelineOptions, authPolicy);
2621
- this.client = new ChatApiClient(this.endpoint, pipeline);
2519
+ this.client.pipeline.addPolicy(authPolicy);
2622
2520
  this.signalingClient = getSignalingClient(credential, logger);
2623
2521
  }
2624
2522
  /**
@@ -2639,12 +2537,12 @@ class ChatClient {
2639
2537
  const { span, updatedOptions } = createSpan("ChatClient-CreateChatThread", options);
2640
2538
  try {
2641
2539
  // We generate an UUID if the user does not provide an idempotencyToken value
2642
- updatedOptions.idempotencyToken = (_a = updatedOptions.idempotencyToken) !== null && _a !== void 0 ? _a : coreHttp.generateUuid();
2540
+ updatedOptions.idempotencyToken = (_a = updatedOptions.idempotencyToken) !== null && _a !== void 0 ? _a : generateUuid();
2643
2541
  const updatedRestModelOptions = mapToCreateChatThreadOptionsRestModel(updatedOptions);
2644
- const _c = await this.client.chat.createChatThread({
2542
+ const result = await this.client.chat.createChatThread({
2645
2543
  topic: request.topic,
2646
2544
  participants: (_b = options.participants) === null || _b === void 0 ? void 0 : _b.map((participant) => mapToChatParticipantRestModel(participant))
2647
- }, coreHttp.operationOptionsToRequestOptionsBase(updatedRestModelOptions)), { _response } = _c, result = tslib.__rest(_c, ["_response"]);
2545
+ }, updatedRestModelOptions);
2648
2546
  return mapToCreateChatThreadResultSdkModel(result);
2649
2547
  }
2650
2548
  catch (e) {
@@ -2660,16 +2558,15 @@ class ChatClient {
2660
2558
  }
2661
2559
  listChatThreadsPage(continuationState, options = {}) {
2662
2560
  return tslib.__asyncGenerator(this, arguments, function* listChatThreadsPage_1() {
2663
- const requestOptions = coreHttp.operationOptionsToRequestOptionsBase(options);
2664
2561
  if (!continuationState.continuationToken) {
2665
- const currentSetResponse = yield tslib.__await(this.client.chat.listChatThreads(requestOptions));
2562
+ const currentSetResponse = yield tslib.__await(this.client.chat.listChatThreads(options));
2666
2563
  continuationState.continuationToken = currentSetResponse.nextLink;
2667
2564
  if (currentSetResponse.value) {
2668
2565
  yield yield tslib.__await(currentSetResponse.value);
2669
2566
  }
2670
2567
  }
2671
2568
  while (continuationState.continuationToken) {
2672
- const currentSetResponse = yield tslib.__await(this.client.chat.listChatThreadsNext(continuationState.continuationToken, requestOptions));
2569
+ const currentSetResponse = yield tslib.__await(this.client.chat.listChatThreadsNext(continuationState.continuationToken, options));
2673
2570
  continuationState.continuationToken = currentSetResponse.nextLink;
2674
2571
  if (currentSetResponse.value) {
2675
2572
  yield yield tslib.__await(currentSetResponse.value);
@@ -2737,7 +2634,7 @@ class ChatClient {
2737
2634
  async deleteChatThread(threadId, options = {}) {
2738
2635
  const { span, updatedOptions } = createSpan("ChatClient-DeleteChatThread", options);
2739
2636
  try {
2740
- await this.client.chat.deleteChatThread(threadId, coreHttp.operationOptionsToRequestOptionsBase(updatedOptions));
2637
+ await this.client.chat.deleteChatThread(threadId, updatedOptions);
2741
2638
  }
2742
2639
  catch (e) {
2743
2640
  span.setStatus({