@azure/communication-chat 1.2.1 → 1.2.3-alpha.20220815.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +163 -227
- package/dist/index.js.map +1 -1
- package/dist-esm/src/chatClient.js +9 -32
- package/dist-esm/src/chatClient.js.map +1 -1
- package/dist-esm/src/chatThreadClient.js +35 -147
- package/dist-esm/src/chatThreadClient.js.map +1 -1
- package/dist-esm/src/generated/src/chatApiClient.js +27 -1
- package/dist-esm/src/generated/src/chatApiClient.js.map +1 -1
- package/dist-esm/src/generated/src/models/index.js +3 -0
- package/dist-esm/src/generated/src/models/index.js.map +1 -1
- package/dist-esm/src/generated/src/operations/chat.js +17 -8
- package/dist-esm/src/generated/src/operations/chat.js.map +1 -1
- package/dist-esm/src/generated/src/operations/chatThread.js +65 -32
- package/dist-esm/src/generated/src/operations/chatThread.js.map +1 -1
- package/dist-esm/src/generated/src/tracing.js +14 -0
- package/dist-esm/src/generated/src/tracing.js.map +1 -0
- package/package.json +6 -6
- package/types/communication-chat.d.ts +1 -2
- package/dist-esm/src/generated/src/chatApiClientContext.js +0 -40
- package/dist-esm/src/generated/src/chatApiClientContext.js.map +0 -1
- package/dist-esm/src/tracing.js +0 -12
- package/dist-esm/src/tracing.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
6
|
var communicationCommon = require('@azure/communication-common');
|
|
7
7
|
var logger$1 = require('@azure/logger');
|
|
8
|
-
var coreTracing = require('@azure/core-tracing');
|
|
9
8
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
9
|
+
var coreTracing = require('@azure/core-tracing');
|
|
10
10
|
var coreClient = require('@azure/core-client');
|
|
11
11
|
var events = require('events');
|
|
12
12
|
var uuid = require('uuid');
|
|
@@ -129,6 +129,19 @@ const mapToReadReceiptSdkModel = (readReceipt) => {
|
|
|
129
129
|
return Object.assign(Object.assign({}, rest), { sender: communicationCommon.deserializeCommunicationIdentifier(senderCommunicationIdentifier) });
|
|
130
130
|
};
|
|
131
131
|
|
|
132
|
+
/*
|
|
133
|
+
* Copyright (c) Microsoft Corporation.
|
|
134
|
+
* Licensed under the MIT License.
|
|
135
|
+
*
|
|
136
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
|
137
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
|
138
|
+
*/
|
|
139
|
+
const tracingClient = coreTracing.createTracingClient({
|
|
140
|
+
namespace: "Azure.Communication",
|
|
141
|
+
packageName: "@azure/communication-chat",
|
|
142
|
+
packageVersion: "1.2.3"
|
|
143
|
+
});
|
|
144
|
+
|
|
132
145
|
/*
|
|
133
146
|
* Copyright (c) Microsoft Corporation.
|
|
134
147
|
* Licensed under the MIT License.
|
|
@@ -1096,8 +1109,10 @@ class ChatThreadImpl {
|
|
|
1096
1109
|
* @param chatThreadId Thread id to get the chat message read receipts for.
|
|
1097
1110
|
* @param options The options parameters.
|
|
1098
1111
|
*/
|
|
1099
|
-
listChatReadReceipts(chatThreadId, options) {
|
|
1100
|
-
return
|
|
1112
|
+
async listChatReadReceipts(chatThreadId, options) {
|
|
1113
|
+
return tracingClient.withSpan("ChatApiClient.listChatReadReceipts", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1114
|
+
return this.client.sendOperationRequest({ chatThreadId, options }, listChatReadReceiptsOperationSpec);
|
|
1115
|
+
});
|
|
1101
1116
|
}
|
|
1102
1117
|
/**
|
|
1103
1118
|
* Sends a read receipt event to a thread, on behalf of a user.
|
|
@@ -1105,8 +1120,10 @@ class ChatThreadImpl {
|
|
|
1105
1120
|
* @param sendReadReceiptRequest Read receipt details.
|
|
1106
1121
|
* @param options The options parameters.
|
|
1107
1122
|
*/
|
|
1108
|
-
sendChatReadReceipt(chatThreadId, sendReadReceiptRequest, options) {
|
|
1109
|
-
return
|
|
1123
|
+
async sendChatReadReceipt(chatThreadId, sendReadReceiptRequest, options) {
|
|
1124
|
+
return tracingClient.withSpan("ChatApiClient.sendChatReadReceipt", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1125
|
+
return this.client.sendOperationRequest({ chatThreadId, sendReadReceiptRequest, options }, sendChatReadReceiptOperationSpec);
|
|
1126
|
+
});
|
|
1110
1127
|
}
|
|
1111
1128
|
/**
|
|
1112
1129
|
* Sends a message to a thread.
|
|
@@ -1114,16 +1131,20 @@ class ChatThreadImpl {
|
|
|
1114
1131
|
* @param sendChatMessageRequest Details of the message to send.
|
|
1115
1132
|
* @param options The options parameters.
|
|
1116
1133
|
*/
|
|
1117
|
-
sendChatMessage(chatThreadId, sendChatMessageRequest, options) {
|
|
1118
|
-
return
|
|
1134
|
+
async sendChatMessage(chatThreadId, sendChatMessageRequest, options) {
|
|
1135
|
+
return tracingClient.withSpan("ChatApiClient.sendChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1136
|
+
return this.client.sendOperationRequest({ chatThreadId, sendChatMessageRequest, options }, sendChatMessageOperationSpec);
|
|
1137
|
+
});
|
|
1119
1138
|
}
|
|
1120
1139
|
/**
|
|
1121
1140
|
* Gets a list of messages from a thread.
|
|
1122
1141
|
* @param chatThreadId The thread id of the message.
|
|
1123
1142
|
* @param options The options parameters.
|
|
1124
1143
|
*/
|
|
1125
|
-
listChatMessages(chatThreadId, options) {
|
|
1126
|
-
return
|
|
1144
|
+
async listChatMessages(chatThreadId, options) {
|
|
1145
|
+
return tracingClient.withSpan("ChatApiClient.listChatMessages", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1146
|
+
return this.client.sendOperationRequest({ chatThreadId, options }, listChatMessagesOperationSpec);
|
|
1147
|
+
});
|
|
1127
1148
|
}
|
|
1128
1149
|
/**
|
|
1129
1150
|
* Gets a message by id.
|
|
@@ -1131,8 +1152,10 @@ class ChatThreadImpl {
|
|
|
1131
1152
|
* @param chatMessageId The message id.
|
|
1132
1153
|
* @param options The options parameters.
|
|
1133
1154
|
*/
|
|
1134
|
-
getChatMessage(chatThreadId, chatMessageId, options) {
|
|
1135
|
-
return
|
|
1155
|
+
async getChatMessage(chatThreadId, chatMessageId, options) {
|
|
1156
|
+
return tracingClient.withSpan("ChatApiClient.getChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1157
|
+
return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, getChatMessageOperationSpec);
|
|
1158
|
+
});
|
|
1136
1159
|
}
|
|
1137
1160
|
/**
|
|
1138
1161
|
* Updates a message.
|
|
@@ -1141,8 +1164,10 @@ class ChatThreadImpl {
|
|
|
1141
1164
|
* @param updateChatMessageRequest Details of the request to update the message.
|
|
1142
1165
|
* @param options The options parameters.
|
|
1143
1166
|
*/
|
|
1144
|
-
updateChatMessage(chatThreadId, chatMessageId, updateChatMessageRequest, options) {
|
|
1145
|
-
return
|
|
1167
|
+
async updateChatMessage(chatThreadId, chatMessageId, updateChatMessageRequest, options) {
|
|
1168
|
+
return tracingClient.withSpan("ChatApiClient.updateChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1169
|
+
return this.client.sendOperationRequest({ chatThreadId, chatMessageId, updateChatMessageRequest, options }, updateChatMessageOperationSpec);
|
|
1170
|
+
});
|
|
1146
1171
|
}
|
|
1147
1172
|
/**
|
|
1148
1173
|
* Deletes a message.
|
|
@@ -1150,16 +1175,20 @@ class ChatThreadImpl {
|
|
|
1150
1175
|
* @param chatMessageId The message id.
|
|
1151
1176
|
* @param options The options parameters.
|
|
1152
1177
|
*/
|
|
1153
|
-
deleteChatMessage(chatThreadId, chatMessageId, options) {
|
|
1154
|
-
return
|
|
1178
|
+
async deleteChatMessage(chatThreadId, chatMessageId, options) {
|
|
1179
|
+
return tracingClient.withSpan("ChatApiClient.deleteChatMessage", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1180
|
+
return this.client.sendOperationRequest({ chatThreadId, chatMessageId, options }, deleteChatMessageOperationSpec);
|
|
1181
|
+
});
|
|
1155
1182
|
}
|
|
1156
1183
|
/**
|
|
1157
1184
|
* Gets the participants of a thread.
|
|
1158
1185
|
* @param chatThreadId Thread id to get participants for.
|
|
1159
1186
|
* @param options The options parameters.
|
|
1160
1187
|
*/
|
|
1161
|
-
listChatParticipants(chatThreadId, options) {
|
|
1162
|
-
return
|
|
1188
|
+
async listChatParticipants(chatThreadId, options) {
|
|
1189
|
+
return tracingClient.withSpan("ChatApiClient.listChatParticipants", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1190
|
+
return this.client.sendOperationRequest({ chatThreadId, options }, listChatParticipantsOperationSpec);
|
|
1191
|
+
});
|
|
1163
1192
|
}
|
|
1164
1193
|
/**
|
|
1165
1194
|
* Remove a participant from a thread.
|
|
@@ -1167,8 +1196,10 @@ class ChatThreadImpl {
|
|
|
1167
1196
|
* @param participantCommunicationIdentifier Id of the thread participant to remove from the thread.
|
|
1168
1197
|
* @param options The options parameters.
|
|
1169
1198
|
*/
|
|
1170
|
-
removeChatParticipant(chatThreadId, participantCommunicationIdentifier, options) {
|
|
1171
|
-
return
|
|
1199
|
+
async removeChatParticipant(chatThreadId, participantCommunicationIdentifier, options) {
|
|
1200
|
+
return tracingClient.withSpan("ChatApiClient.removeChatParticipant", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1201
|
+
return this.client.sendOperationRequest({ chatThreadId, participantCommunicationIdentifier, options }, removeChatParticipantOperationSpec);
|
|
1202
|
+
});
|
|
1172
1203
|
}
|
|
1173
1204
|
/**
|
|
1174
1205
|
* Adds thread participants to a thread. If participants already exist, no change occurs.
|
|
@@ -1176,8 +1207,10 @@ class ChatThreadImpl {
|
|
|
1176
1207
|
* @param addChatParticipantsRequest Thread participants to be added to the thread.
|
|
1177
1208
|
* @param options The options parameters.
|
|
1178
1209
|
*/
|
|
1179
|
-
addChatParticipants(chatThreadId, addChatParticipantsRequest, options) {
|
|
1180
|
-
return
|
|
1210
|
+
async addChatParticipants(chatThreadId, addChatParticipantsRequest, options) {
|
|
1211
|
+
return tracingClient.withSpan("ChatApiClient.addChatParticipants", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1212
|
+
return this.client.sendOperationRequest({ chatThreadId, addChatParticipantsRequest, options }, addChatParticipantsOperationSpec);
|
|
1213
|
+
});
|
|
1181
1214
|
}
|
|
1182
1215
|
/**
|
|
1183
1216
|
* Updates a thread's properties.
|
|
@@ -1185,24 +1218,30 @@ class ChatThreadImpl {
|
|
|
1185
1218
|
* @param updateChatThreadRequest Request payload for updating a chat thread.
|
|
1186
1219
|
* @param options The options parameters.
|
|
1187
1220
|
*/
|
|
1188
|
-
updateChatThreadProperties(chatThreadId, updateChatThreadRequest, options) {
|
|
1189
|
-
return
|
|
1221
|
+
async updateChatThreadProperties(chatThreadId, updateChatThreadRequest, options) {
|
|
1222
|
+
return tracingClient.withSpan("ChatApiClient.updateChatThreadProperties", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1223
|
+
return this.client.sendOperationRequest({ chatThreadId, updateChatThreadRequest, options }, updateChatThreadPropertiesOperationSpec);
|
|
1224
|
+
});
|
|
1190
1225
|
}
|
|
1191
1226
|
/**
|
|
1192
1227
|
* Gets a chat thread's properties.
|
|
1193
1228
|
* @param chatThreadId Id of the thread.
|
|
1194
1229
|
* @param options The options parameters.
|
|
1195
1230
|
*/
|
|
1196
|
-
getChatThreadProperties(chatThreadId, options) {
|
|
1197
|
-
return
|
|
1231
|
+
async getChatThreadProperties(chatThreadId, options) {
|
|
1232
|
+
return tracingClient.withSpan("ChatApiClient.getChatThreadProperties", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1233
|
+
return this.client.sendOperationRequest({ chatThreadId, options }, getChatThreadPropertiesOperationSpec);
|
|
1234
|
+
});
|
|
1198
1235
|
}
|
|
1199
1236
|
/**
|
|
1200
1237
|
* Posts a typing event to a thread, on behalf of a user.
|
|
1201
1238
|
* @param chatThreadId Id of the thread.
|
|
1202
1239
|
* @param options The options parameters.
|
|
1203
1240
|
*/
|
|
1204
|
-
sendTypingNotification(chatThreadId, options) {
|
|
1205
|
-
return
|
|
1241
|
+
async sendTypingNotification(chatThreadId, options) {
|
|
1242
|
+
return tracingClient.withSpan("ChatApiClient.sendTypingNotification", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1243
|
+
return this.client.sendOperationRequest({ chatThreadId, options }, sendTypingNotificationOperationSpec);
|
|
1244
|
+
});
|
|
1206
1245
|
}
|
|
1207
1246
|
/**
|
|
1208
1247
|
* ListChatReadReceiptsNext
|
|
@@ -1210,8 +1249,10 @@ class ChatThreadImpl {
|
|
|
1210
1249
|
* @param nextLink The nextLink from the previous successful call to the ListChatReadReceipts method.
|
|
1211
1250
|
* @param options The options parameters.
|
|
1212
1251
|
*/
|
|
1213
|
-
listChatReadReceiptsNext(chatThreadId, nextLink, options) {
|
|
1214
|
-
return
|
|
1252
|
+
async listChatReadReceiptsNext(chatThreadId, nextLink, options) {
|
|
1253
|
+
return tracingClient.withSpan("ChatApiClient.listChatReadReceiptsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1254
|
+
return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatReadReceiptsNextOperationSpec);
|
|
1255
|
+
});
|
|
1215
1256
|
}
|
|
1216
1257
|
/**
|
|
1217
1258
|
* ListChatMessagesNext
|
|
@@ -1219,8 +1260,10 @@ class ChatThreadImpl {
|
|
|
1219
1260
|
* @param nextLink The nextLink from the previous successful call to the ListChatMessages method.
|
|
1220
1261
|
* @param options The options parameters.
|
|
1221
1262
|
*/
|
|
1222
|
-
listChatMessagesNext(chatThreadId, nextLink, options) {
|
|
1223
|
-
return
|
|
1263
|
+
async listChatMessagesNext(chatThreadId, nextLink, options) {
|
|
1264
|
+
return tracingClient.withSpan("ChatApiClient.listChatMessagesNext", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1265
|
+
return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatMessagesNextOperationSpec);
|
|
1266
|
+
});
|
|
1224
1267
|
}
|
|
1225
1268
|
/**
|
|
1226
1269
|
* ListChatParticipantsNext
|
|
@@ -1228,8 +1271,10 @@ class ChatThreadImpl {
|
|
|
1228
1271
|
* @param nextLink The nextLink from the previous successful call to the ListChatParticipants method.
|
|
1229
1272
|
* @param options The options parameters.
|
|
1230
1273
|
*/
|
|
1231
|
-
listChatParticipantsNext(chatThreadId, nextLink, options) {
|
|
1232
|
-
return
|
|
1274
|
+
async listChatParticipantsNext(chatThreadId, nextLink, options) {
|
|
1275
|
+
return tracingClient.withSpan("ChatApiClient.listChatParticipantsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1276
|
+
return this.client.sendOperationRequest({ chatThreadId, nextLink, options }, listChatParticipantsNextOperationSpec);
|
|
1277
|
+
});
|
|
1233
1278
|
}
|
|
1234
1279
|
}
|
|
1235
1280
|
// Operation Specifications
|
|
@@ -1770,31 +1815,39 @@ class ChatImpl {
|
|
|
1770
1815
|
* @param createChatThreadRequest Request payload for creating a chat thread.
|
|
1771
1816
|
* @param options The options parameters.
|
|
1772
1817
|
*/
|
|
1773
|
-
createChatThread(createChatThreadRequest, options) {
|
|
1774
|
-
return
|
|
1818
|
+
async createChatThread(createChatThreadRequest, options) {
|
|
1819
|
+
return tracingClient.withSpan("ChatApiClient.createChatThread", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1820
|
+
return this.client.sendOperationRequest({ createChatThreadRequest, options }, createChatThreadOperationSpec);
|
|
1821
|
+
});
|
|
1775
1822
|
}
|
|
1776
1823
|
/**
|
|
1777
1824
|
* Gets the list of chat threads of a user.
|
|
1778
1825
|
* @param options The options parameters.
|
|
1779
1826
|
*/
|
|
1780
|
-
listChatThreads(options) {
|
|
1781
|
-
return
|
|
1827
|
+
async listChatThreads(options) {
|
|
1828
|
+
return tracingClient.withSpan("ChatApiClient.listChatThreads", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1829
|
+
return this.client.sendOperationRequest({ options }, listChatThreadsOperationSpec);
|
|
1830
|
+
});
|
|
1782
1831
|
}
|
|
1783
1832
|
/**
|
|
1784
1833
|
* Deletes a thread.
|
|
1785
1834
|
* @param chatThreadId Id of the thread to be deleted.
|
|
1786
1835
|
* @param options The options parameters.
|
|
1787
1836
|
*/
|
|
1788
|
-
deleteChatThread(chatThreadId, options) {
|
|
1789
|
-
return
|
|
1837
|
+
async deleteChatThread(chatThreadId, options) {
|
|
1838
|
+
return tracingClient.withSpan("ChatApiClient.deleteChatThread", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1839
|
+
return this.client.sendOperationRequest({ chatThreadId, options }, deleteChatThreadOperationSpec);
|
|
1840
|
+
});
|
|
1790
1841
|
}
|
|
1791
1842
|
/**
|
|
1792
1843
|
* ListChatThreadsNext
|
|
1793
1844
|
* @param nextLink The nextLink from the previous successful call to the ListChatThreads method.
|
|
1794
1845
|
* @param options The options parameters.
|
|
1795
1846
|
*/
|
|
1796
|
-
listChatThreadsNext(nextLink, options) {
|
|
1797
|
-
return
|
|
1847
|
+
async listChatThreadsNext(nextLink, options) {
|
|
1848
|
+
return tracingClient.withSpan("ChatApiClient.listChatThreadsNext", options !== null && options !== void 0 ? options : {}, async (options) => {
|
|
1849
|
+
return this.client.sendOperationRequest({ nextLink, options }, listChatThreadsNextOperationSpec);
|
|
1850
|
+
});
|
|
1798
1851
|
}
|
|
1799
1852
|
}
|
|
1800
1853
|
// Operation Specifications
|
|
@@ -1953,7 +2006,7 @@ class ChatApiClient extends coreClient__namespace.ServiceClient {
|
|
|
1953
2006
|
const defaults = {
|
|
1954
2007
|
requestContentType: "application/json; charset=utf-8"
|
|
1955
2008
|
};
|
|
1956
|
-
const packageDetails = `azsdk-js-communication-chat/1.2.
|
|
2009
|
+
const packageDetails = `azsdk-js-communication-chat/1.2.3`;
|
|
1957
2010
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
1958
2011
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
1959
2012
|
: `${packageDetails}`;
|
|
@@ -1967,22 +2020,38 @@ class ChatApiClient extends coreClient__namespace.ServiceClient {
|
|
|
1967
2020
|
this.apiVersion = options.apiVersion || "2021-09-07";
|
|
1968
2021
|
this.chatThread = new ChatThreadImpl(this);
|
|
1969
2022
|
this.chat = new ChatImpl(this);
|
|
2023
|
+
this.addCustomApiVersionPolicy(options.apiVersion);
|
|
2024
|
+
}
|
|
2025
|
+
/** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
|
|
2026
|
+
addCustomApiVersionPolicy(apiVersion) {
|
|
2027
|
+
if (!apiVersion) {
|
|
2028
|
+
return;
|
|
2029
|
+
}
|
|
2030
|
+
const apiVersionPolicy = {
|
|
2031
|
+
name: "CustomApiVersionPolicy",
|
|
2032
|
+
async sendRequest(request, next) {
|
|
2033
|
+
const param = request.url.split("?");
|
|
2034
|
+
if (param.length > 1) {
|
|
2035
|
+
const newParams = param[1].split("&").map((item) => {
|
|
2036
|
+
if (item.indexOf("api-version") > -1) {
|
|
2037
|
+
return "api-version=" + apiVersion;
|
|
2038
|
+
}
|
|
2039
|
+
else {
|
|
2040
|
+
return item;
|
|
2041
|
+
}
|
|
2042
|
+
});
|
|
2043
|
+
request.url = param[0] + "?" + newParams.join("&");
|
|
2044
|
+
}
|
|
2045
|
+
return next(request);
|
|
2046
|
+
}
|
|
2047
|
+
};
|
|
2048
|
+
this.pipeline.addPolicy(apiVersionPolicy);
|
|
1970
2049
|
}
|
|
1971
2050
|
}
|
|
1972
2051
|
|
|
1973
2052
|
// Copyright (c) Microsoft Corporation.
|
|
1974
2053
|
const logger = logger$1.createClientLogger("communication-chat");
|
|
1975
2054
|
|
|
1976
|
-
// Copyright (c) Microsoft Corporation.
|
|
1977
|
-
/**
|
|
1978
|
-
* Creates a span using the global tracer.
|
|
1979
|
-
* @internal
|
|
1980
|
-
*/
|
|
1981
|
-
const createSpan = coreTracing.createSpanFunction({
|
|
1982
|
-
packagePrefix: "Azure.Communication",
|
|
1983
|
-
namespace: "Microsoft.Communication",
|
|
1984
|
-
});
|
|
1985
|
-
|
|
1986
2055
|
// Copyright (c) Microsoft Corporation.
|
|
1987
2056
|
/**
|
|
1988
2057
|
* Creates a new CommunicationTokenCredentialPolicy factory.
|
|
@@ -2024,43 +2093,21 @@ class ChatThreadClient {
|
|
|
2024
2093
|
* Returns the chat thread.
|
|
2025
2094
|
* @param options - Operation options.
|
|
2026
2095
|
*/
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
try {
|
|
2096
|
+
getProperties(options = {}) {
|
|
2097
|
+
return tracingClient.withSpan("ChatClient-GetProperties", options, async (updatedOptions) => {
|
|
2030
2098
|
const result = await this.client.chatThread.getChatThreadProperties(this.threadId, updatedOptions);
|
|
2031
2099
|
return mapToChatThreadPropertiesSdkModel(result);
|
|
2032
|
-
}
|
|
2033
|
-
catch (e) {
|
|
2034
|
-
span.setStatus({
|
|
2035
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2036
|
-
message: e.message,
|
|
2037
|
-
});
|
|
2038
|
-
throw e;
|
|
2039
|
-
}
|
|
2040
|
-
finally {
|
|
2041
|
-
span.end();
|
|
2042
|
-
}
|
|
2100
|
+
});
|
|
2043
2101
|
}
|
|
2044
2102
|
/**
|
|
2045
2103
|
* Updates a thread's topic.
|
|
2046
2104
|
* @param topic - The topic needs to be updated to.
|
|
2047
2105
|
* @param options - Operation options.
|
|
2048
2106
|
*/
|
|
2049
|
-
|
|
2050
|
-
|
|
2051
|
-
try {
|
|
2107
|
+
updateTopic(topic, options = {}) {
|
|
2108
|
+
return tracingClient.withSpan("ChatThreadClient-UpdateTopic", options, async (updatedOptions) => {
|
|
2052
2109
|
await this.client.chatThread.updateChatThreadProperties(this.threadId, { topic: topic }, updatedOptions);
|
|
2053
|
-
}
|
|
2054
|
-
catch (e) {
|
|
2055
|
-
span.setStatus({
|
|
2056
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2057
|
-
message: e.message,
|
|
2058
|
-
});
|
|
2059
|
-
throw e;
|
|
2060
|
-
}
|
|
2061
|
-
finally {
|
|
2062
|
-
span.end();
|
|
2063
|
-
}
|
|
2110
|
+
});
|
|
2064
2111
|
}
|
|
2065
2112
|
/**
|
|
2066
2113
|
* Sends a chat message to a thread identified by threadId.
|
|
@@ -2068,24 +2115,13 @@ class ChatThreadClient {
|
|
|
2068
2115
|
* @param request - Request for sending a message.
|
|
2069
2116
|
* @param options - Operation options.
|
|
2070
2117
|
*/
|
|
2071
|
-
|
|
2072
|
-
|
|
2073
|
-
try {
|
|
2118
|
+
sendMessage(request, options = {}) {
|
|
2119
|
+
return tracingClient.withSpan("ChatThreadClient-SendMessage", options, async (updatedOptions) => {
|
|
2074
2120
|
// reset typing notification clock
|
|
2075
2121
|
this.timeOfLastTypingRequest = undefined;
|
|
2076
2122
|
const result = await this.client.chatThread.sendChatMessage(this.threadId, Object.assign(Object.assign({}, request), options), updatedOptions);
|
|
2077
2123
|
return result;
|
|
2078
|
-
}
|
|
2079
|
-
catch (e) {
|
|
2080
|
-
span.setStatus({
|
|
2081
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2082
|
-
message: e.message,
|
|
2083
|
-
});
|
|
2084
|
-
throw e;
|
|
2085
|
-
}
|
|
2086
|
-
finally {
|
|
2087
|
-
span.end();
|
|
2088
|
-
}
|
|
2124
|
+
});
|
|
2089
2125
|
}
|
|
2090
2126
|
/**
|
|
2091
2127
|
* Gets a chat message identified by messageId.
|
|
@@ -2093,22 +2129,11 @@ class ChatThreadClient {
|
|
|
2093
2129
|
* @param messageId - The message id of the message.
|
|
2094
2130
|
* @param options - Operation options.
|
|
2095
2131
|
*/
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
try {
|
|
2132
|
+
getMessage(messageId, options = {}) {
|
|
2133
|
+
return tracingClient.withSpan("ChatThreadClient-GetMessage", options, async (updatedOptions) => {
|
|
2099
2134
|
const result = await this.client.chatThread.getChatMessage(this.threadId, messageId, updatedOptions);
|
|
2100
2135
|
return mapToChatMessageSdkModel(result);
|
|
2101
|
-
}
|
|
2102
|
-
catch (e) {
|
|
2103
|
-
span.setStatus({
|
|
2104
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2105
|
-
message: e.message,
|
|
2106
|
-
});
|
|
2107
|
-
throw e;
|
|
2108
|
-
}
|
|
2109
|
-
finally {
|
|
2110
|
-
span.end();
|
|
2111
|
-
}
|
|
2136
|
+
});
|
|
2112
2137
|
}
|
|
2113
2138
|
listMessagesPage(pageSettings, options = {}) {
|
|
2114
2139
|
return tslib.__asyncGenerator(this, arguments, function* listMessagesPage_1() {
|
|
@@ -2155,7 +2180,7 @@ class ChatThreadClient {
|
|
|
2155
2180
|
* @param options - Get messages options.
|
|
2156
2181
|
*/
|
|
2157
2182
|
listMessages(options = {}) {
|
|
2158
|
-
const { span, updatedOptions } =
|
|
2183
|
+
const { span, updatedOptions } = tracingClient.startSpan("ChatThreadClient-ListMessages", options);
|
|
2159
2184
|
try {
|
|
2160
2185
|
const iter = this.listMessagesAll(updatedOptions);
|
|
2161
2186
|
return {
|
|
@@ -2172,8 +2197,8 @@ class ChatThreadClient {
|
|
|
2172
2197
|
}
|
|
2173
2198
|
catch (e) {
|
|
2174
2199
|
span.setStatus({
|
|
2175
|
-
|
|
2176
|
-
|
|
2200
|
+
status: "error",
|
|
2201
|
+
error: e,
|
|
2177
2202
|
});
|
|
2178
2203
|
throw e;
|
|
2179
2204
|
}
|
|
@@ -2186,21 +2211,10 @@ class ChatThreadClient {
|
|
|
2186
2211
|
* @param messageId - The message id of the message.
|
|
2187
2212
|
* @param options - Operation options.
|
|
2188
2213
|
*/
|
|
2189
|
-
|
|
2190
|
-
|
|
2191
|
-
try {
|
|
2214
|
+
deleteMessage(messageId, options = {}) {
|
|
2215
|
+
return tracingClient.withSpan("ChatThreadClient-DeleteMessage", options, async (updatedOptions) => {
|
|
2192
2216
|
await this.client.chatThread.deleteChatMessage(this.threadId, messageId, updatedOptions);
|
|
2193
|
-
}
|
|
2194
|
-
catch (e) {
|
|
2195
|
-
span.setStatus({
|
|
2196
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2197
|
-
message: e.message,
|
|
2198
|
-
});
|
|
2199
|
-
throw e;
|
|
2200
|
-
}
|
|
2201
|
-
finally {
|
|
2202
|
-
span.end();
|
|
2203
|
-
}
|
|
2217
|
+
});
|
|
2204
2218
|
}
|
|
2205
2219
|
/**
|
|
2206
2220
|
* Updates a message identified by threadId and messageId
|
|
@@ -2208,20 +2222,9 @@ class ChatThreadClient {
|
|
|
2208
2222
|
* @param options - Operation options.
|
|
2209
2223
|
*/
|
|
2210
2224
|
async updateMessage(messageId, options = {}) {
|
|
2211
|
-
|
|
2212
|
-
try {
|
|
2225
|
+
return tracingClient.withSpan("ChatThreadClient-UpdateMessage", options, async (updatedOptions) => {
|
|
2213
2226
|
await this.client.chatThread.updateChatMessage(this.threadId, messageId, options, updatedOptions);
|
|
2214
|
-
}
|
|
2215
|
-
catch (e) {
|
|
2216
|
-
span.setStatus({
|
|
2217
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2218
|
-
message: e.message,
|
|
2219
|
-
});
|
|
2220
|
-
throw e;
|
|
2221
|
-
}
|
|
2222
|
-
finally {
|
|
2223
|
-
span.end();
|
|
2224
|
-
}
|
|
2227
|
+
});
|
|
2225
2228
|
}
|
|
2226
2229
|
/**
|
|
2227
2230
|
* Adds the details of chat participants belonging to the thread identified by threadId.
|
|
@@ -2229,21 +2232,10 @@ class ChatThreadClient {
|
|
|
2229
2232
|
* @param options - Operation options.
|
|
2230
2233
|
*/
|
|
2231
2234
|
async addParticipants(request, options = {}) {
|
|
2232
|
-
|
|
2233
|
-
try {
|
|
2235
|
+
return tracingClient.withSpan("ChatThreadClient-AddParticipants", options, async (updatedOptions) => {
|
|
2234
2236
|
const result = await this.client.chatThread.addChatParticipants(this.threadId, mapToAddChatParticipantsRequestRestModel(request), updatedOptions);
|
|
2235
2237
|
return result;
|
|
2236
|
-
}
|
|
2237
|
-
catch (e) {
|
|
2238
|
-
span.setStatus({
|
|
2239
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2240
|
-
message: e.message,
|
|
2241
|
-
});
|
|
2242
|
-
throw e;
|
|
2243
|
-
}
|
|
2244
|
-
finally {
|
|
2245
|
-
span.end();
|
|
2246
|
-
}
|
|
2238
|
+
});
|
|
2247
2239
|
}
|
|
2248
2240
|
listParticipantsPage(continuationState, options = {}) {
|
|
2249
2241
|
return tslib.__asyncGenerator(this, arguments, function* listParticipantsPage_1() {
|
|
@@ -2290,7 +2282,7 @@ class ChatThreadClient {
|
|
|
2290
2282
|
* @param options - Operation options.
|
|
2291
2283
|
*/
|
|
2292
2284
|
listParticipants(options = {}) {
|
|
2293
|
-
const { span, updatedOptions } =
|
|
2285
|
+
const { span, updatedOptions } = tracingClient.startSpan("ChatThreadClient-ListParticipants", options);
|
|
2294
2286
|
try {
|
|
2295
2287
|
const iter = this.listParticipantsAll(updatedOptions);
|
|
2296
2288
|
return {
|
|
@@ -2307,8 +2299,8 @@ class ChatThreadClient {
|
|
|
2307
2299
|
}
|
|
2308
2300
|
catch (e) {
|
|
2309
2301
|
span.setStatus({
|
|
2310
|
-
|
|
2311
|
-
|
|
2302
|
+
status: "error",
|
|
2303
|
+
error: e,
|
|
2312
2304
|
});
|
|
2313
2305
|
throw e;
|
|
2314
2306
|
}
|
|
@@ -2322,20 +2314,9 @@ class ChatThreadClient {
|
|
|
2322
2314
|
* @param options - Operation options.
|
|
2323
2315
|
*/
|
|
2324
2316
|
async removeParticipant(participant, options = {}) {
|
|
2325
|
-
|
|
2326
|
-
try {
|
|
2317
|
+
return tracingClient.withSpan("ChatThreadClient-RemoveParticipant", options, async (updatedOptions) => {
|
|
2327
2318
|
await this.client.chatThread.removeChatParticipant(this.threadId, communicationCommon.serializeCommunicationIdentifier(participant), updatedOptions);
|
|
2328
|
-
}
|
|
2329
|
-
catch (e) {
|
|
2330
|
-
span.setStatus({
|
|
2331
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2332
|
-
message: e.message,
|
|
2333
|
-
});
|
|
2334
|
-
throw e;
|
|
2335
|
-
}
|
|
2336
|
-
finally {
|
|
2337
|
-
span.end();
|
|
2338
|
-
}
|
|
2319
|
+
});
|
|
2339
2320
|
}
|
|
2340
2321
|
/**
|
|
2341
2322
|
* Sends a typing notification to the thread.
|
|
@@ -2344,8 +2325,7 @@ class ChatThreadClient {
|
|
|
2344
2325
|
* @returns True if the typing message notification could be sent, otherwise false.
|
|
2345
2326
|
*/
|
|
2346
2327
|
async sendTypingNotification(options = {}) {
|
|
2347
|
-
|
|
2348
|
-
try {
|
|
2328
|
+
return tracingClient.withSpan("ChatThreadClient-SendTypingNotification", options, async (updatedOptions) => {
|
|
2349
2329
|
const dateNow = new Date();
|
|
2350
2330
|
const { senderDisplayName } = updatedOptions, restOptions = tslib.__rest(updatedOptions, ["senderDisplayName"]);
|
|
2351
2331
|
if (this.canPostTypingNotification(dateNow)) {
|
|
@@ -2355,39 +2335,17 @@ class ChatThreadClient {
|
|
|
2355
2335
|
}
|
|
2356
2336
|
logger.info(`Typing Notification NOT Send. [thread_id=${this.threadId}]`);
|
|
2357
2337
|
return false;
|
|
2358
|
-
}
|
|
2359
|
-
catch (e) {
|
|
2360
|
-
span.setStatus({
|
|
2361
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2362
|
-
message: e.message,
|
|
2363
|
-
});
|
|
2364
|
-
throw e;
|
|
2365
|
-
}
|
|
2366
|
-
finally {
|
|
2367
|
-
span.end();
|
|
2368
|
-
}
|
|
2338
|
+
});
|
|
2369
2339
|
}
|
|
2370
2340
|
/**
|
|
2371
2341
|
* Sends a read receipt to the thread identified by threadId.
|
|
2372
|
-
* @param messageId - The message id of the message that user latest read.
|
|
2373
2342
|
* @param request - Request for sending a read receipt
|
|
2374
2343
|
* @param options - Operation options.
|
|
2375
2344
|
*/
|
|
2376
2345
|
async sendReadReceipt(request, options = {}) {
|
|
2377
|
-
|
|
2378
|
-
try {
|
|
2346
|
+
return tracingClient.withSpan("ChatThreadClient-SendReadReceipt", options, async (updatedOptions) => {
|
|
2379
2347
|
await this.client.chatThread.sendChatReadReceipt(this.threadId, request, updatedOptions);
|
|
2380
|
-
}
|
|
2381
|
-
catch (e) {
|
|
2382
|
-
span.setStatus({
|
|
2383
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2384
|
-
message: e.message,
|
|
2385
|
-
});
|
|
2386
|
-
throw e;
|
|
2387
|
-
}
|
|
2388
|
-
finally {
|
|
2389
|
-
span.end();
|
|
2390
|
-
}
|
|
2348
|
+
});
|
|
2391
2349
|
}
|
|
2392
2350
|
listReadReceiptsPage(continuationState, options = {}) {
|
|
2393
2351
|
return tslib.__asyncGenerator(this, arguments, function* listReadReceiptsPage_1() {
|
|
@@ -2434,7 +2392,7 @@ class ChatThreadClient {
|
|
|
2434
2392
|
* @param options - Get messages options.
|
|
2435
2393
|
*/
|
|
2436
2394
|
listReadReceipts(options = {}) {
|
|
2437
|
-
const { span, updatedOptions } =
|
|
2395
|
+
const { span, updatedOptions } = tracingClient.startSpan("ChatThreadClient-ListChatReadReceipts", options);
|
|
2438
2396
|
try {
|
|
2439
2397
|
const iter = this.listReadReceiptsAll(updatedOptions);
|
|
2440
2398
|
return {
|
|
@@ -2451,8 +2409,8 @@ class ChatThreadClient {
|
|
|
2451
2409
|
}
|
|
2452
2410
|
catch (e) {
|
|
2453
2411
|
span.setStatus({
|
|
2454
|
-
|
|
2455
|
-
|
|
2412
|
+
status: "error",
|
|
2413
|
+
error: e,
|
|
2456
2414
|
});
|
|
2457
2415
|
throw e;
|
|
2458
2416
|
}
|
|
@@ -2539,9 +2497,8 @@ class ChatClient {
|
|
|
2539
2497
|
* @param options - Operation options.
|
|
2540
2498
|
*/
|
|
2541
2499
|
async createChatThread(request, options = {}) {
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
try {
|
|
2500
|
+
return tracingClient.withSpan("ChatClient-CreateChatThread", options, async (updatedOptions) => {
|
|
2501
|
+
var _a, _b;
|
|
2545
2502
|
// We generate an UUID if the user does not provide an idempotencyToken value
|
|
2546
2503
|
updatedOptions.idempotencyToken = (_a = updatedOptions.idempotencyToken) !== null && _a !== void 0 ? _a : generateUuid();
|
|
2547
2504
|
const updatedRestModelOptions = mapToCreateChatThreadOptionsRestModel(updatedOptions);
|
|
@@ -2550,17 +2507,7 @@ class ChatClient {
|
|
|
2550
2507
|
participants: (_b = options.participants) === null || _b === void 0 ? void 0 : _b.map((participant) => mapToChatParticipantRestModel(participant)),
|
|
2551
2508
|
}, updatedRestModelOptions);
|
|
2552
2509
|
return mapToCreateChatThreadResultSdkModel(result);
|
|
2553
|
-
}
|
|
2554
|
-
catch (e) {
|
|
2555
|
-
span.setStatus({
|
|
2556
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2557
|
-
message: e.message,
|
|
2558
|
-
});
|
|
2559
|
-
throw e;
|
|
2560
|
-
}
|
|
2561
|
-
finally {
|
|
2562
|
-
span.end();
|
|
2563
|
-
}
|
|
2510
|
+
});
|
|
2564
2511
|
}
|
|
2565
2512
|
listChatThreadsPage(continuationState, options = {}) {
|
|
2566
2513
|
return tslib.__asyncGenerator(this, arguments, function* listChatThreadsPage_1() {
|
|
@@ -2606,7 +2553,7 @@ class ChatClient {
|
|
|
2606
2553
|
* @param options - List chat threads options.
|
|
2607
2554
|
*/
|
|
2608
2555
|
listChatThreads(options = {}) {
|
|
2609
|
-
const { span, updatedOptions } =
|
|
2556
|
+
const { span, updatedOptions } = tracingClient.startSpan("ChatClient-ListChatThreads", options);
|
|
2610
2557
|
try {
|
|
2611
2558
|
const iter = this.listChatThreadsAll(updatedOptions);
|
|
2612
2559
|
return {
|
|
@@ -2623,8 +2570,8 @@ class ChatClient {
|
|
|
2623
2570
|
}
|
|
2624
2571
|
catch (e) {
|
|
2625
2572
|
span.setStatus({
|
|
2626
|
-
|
|
2627
|
-
|
|
2573
|
+
error: e,
|
|
2574
|
+
status: "error",
|
|
2628
2575
|
});
|
|
2629
2576
|
throw e;
|
|
2630
2577
|
}
|
|
@@ -2638,20 +2585,9 @@ class ChatClient {
|
|
|
2638
2585
|
* @param options - Operation options.
|
|
2639
2586
|
*/
|
|
2640
2587
|
async deleteChatThread(threadId, options = {}) {
|
|
2641
|
-
|
|
2642
|
-
try {
|
|
2588
|
+
return tracingClient.withSpan("ChatClient-DeleteChatThread", options, async (updatedOptions) => {
|
|
2643
2589
|
await this.client.chat.deleteChatThread(threadId, updatedOptions);
|
|
2644
|
-
}
|
|
2645
|
-
catch (e) {
|
|
2646
|
-
span.setStatus({
|
|
2647
|
-
code: coreTracing.SpanStatusCode.ERROR,
|
|
2648
|
-
message: e.message,
|
|
2649
|
-
});
|
|
2650
|
-
throw e;
|
|
2651
|
-
}
|
|
2652
|
-
finally {
|
|
2653
|
-
span.end();
|
|
2654
|
-
}
|
|
2590
|
+
});
|
|
2655
2591
|
}
|
|
2656
2592
|
/**
|
|
2657
2593
|
* Start receiving realtime notifications.
|