@azure/communication-chat 1.1.1 → 1.1.2-alpha.20220113.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/CHANGELOG.md +12 -0
- package/dist/index.js +71 -61
- package/dist/index.js.map +1 -1
- package/dist-esm/src/chatClient.js +24 -14
- package/dist-esm/src/chatClient.js.map +1 -1
- package/dist-esm/src/chatThreadClient.js +21 -21
- package/dist-esm/src/chatThreadClient.js.map +1 -1
- package/dist-esm/src/credential/communicationTokenCredentialPolicy.js +3 -3
- package/dist-esm/src/credential/communicationTokenCredentialPolicy.js.map +1 -1
- package/dist-esm/src/generated/src/chatApiClientContext.js +1 -1
- package/dist-esm/src/generated/src/chatApiClientContext.js.map +1 -1
- package/dist-esm/src/models/events.js.map +1 -1
- package/dist-esm/src/models/mappers.js +2 -2
- package/dist-esm/src/models/mappers.js.map +1 -1
- package/dist-esm/src/models/models.js.map +1 -1
- package/dist-esm/src/models/options.js.map +1 -1
- package/dist-esm/src/signaling/signalingClient.browser.js +1 -1
- package/dist-esm/src/signaling/signalingClient.browser.js.map +1 -1
- package/dist-esm/src/signaling/signalingClient.js +1 -1
- package/dist-esm/src/signaling/signalingClient.js.map +1 -1
- package/dist-esm/src/tracing.js +1 -1
- package/dist-esm/src/tracing.js.map +1 -1
- package/package.json +11 -14
- package/types/communication-chat.d.ts +13 -2
- package/types/src/chatClient.d.ts +17 -5
- package/types/src/chatClient.d.ts.map +1 -1
- package/types/src/chatThreadClient.d.ts.map +1 -1
- package/types/src/models/events.d.ts +3 -2
- package/types/src/models/events.d.ts.map +1 -1
- package/types/src/models/models.d.ts +1 -1
- package/types/src/models/models.d.ts.map +1 -1
- package/types/src/models/options.d.ts +1 -1
- package/types/src/models/options.d.ts.map +1 -1
- package/types/tsdoc-metadata.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,20 @@
|
|
|
1
1
|
# Release History
|
|
2
2
|
|
|
3
|
+
## 1.1.2 (Unreleased)
|
|
4
|
+
|
|
5
|
+
### Breaking Changes
|
|
6
|
+
|
|
7
|
+
- Prohibit sending the typing notification request within 8 seconds of the previous request.
|
|
8
|
+
|
|
9
|
+
### Features Added
|
|
10
|
+
|
|
11
|
+
- Updated to @azure/communication-signaling@1.0.0-beta.12.
|
|
12
|
+
- Added two new events realTimeNotificationConnected and realTimeNotificationDisconnected that allow the developer to know when the connection to the call server is active
|
|
13
|
+
|
|
3
14
|
## 1.1.1 (2021-10-19)
|
|
4
15
|
|
|
5
16
|
### Features Added
|
|
17
|
+
|
|
6
18
|
- Updated to @azure/communication-signaling@1.0.0-beta.11.
|
|
7
19
|
- Added `signalingClientOptions` in `ClientOptions`.
|
|
8
20
|
|
package/dist/index.js
CHANGED
|
@@ -3,40 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var tslib = require('tslib');
|
|
6
|
-
var logger$1 = require('@azure/logger');
|
|
7
|
-
var events = require('events');
|
|
8
|
-
var communicationSignaling = require('@azure/communication-signaling');
|
|
9
|
-
var coreTracing = require('@azure/core-tracing');
|
|
10
6
|
var communicationCommon = require('@azure/communication-common');
|
|
11
7
|
var coreClient = require('@azure/core-client');
|
|
8
|
+
var logger$1 = require('@azure/logger');
|
|
9
|
+
var coreTracing = require('@azure/core-tracing');
|
|
12
10
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
|
11
|
+
var events = require('events');
|
|
13
12
|
var uuid = require('uuid');
|
|
14
|
-
|
|
15
|
-
// Copyright (c) Microsoft Corporation.
|
|
16
|
-
const logger = logger$1.createClientLogger("communication-chat");
|
|
17
|
-
|
|
18
|
-
// Copyright (c) Microsoft Corporation.
|
|
19
|
-
const getSignalingClient = (credential, logger, options) => {
|
|
20
|
-
var _a;
|
|
21
|
-
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
22
|
-
// In React Native
|
|
23
|
-
return new communicationSignaling.CommunicationSignalingClient(credential, logger, {
|
|
24
|
-
environment: (_a = options === null || options === void 0 ? void 0 : options.environment) !== null && _a !== void 0 ? _a : undefined
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
// In node js
|
|
28
|
-
return undefined;
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
// Copyright (c) Microsoft Corporation.
|
|
32
|
-
/**
|
|
33
|
-
* Creates a span using the global tracer.
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
const createSpan = coreTracing.createSpanFunction({
|
|
37
|
-
packagePrefix: "Azure.Communication",
|
|
38
|
-
namespace: "Microsoft.Communication"
|
|
39
|
-
});
|
|
13
|
+
var communicationSignaling = require('@azure/communication-signaling');
|
|
40
14
|
|
|
41
15
|
// Copyright (c) Microsoft Corporation.
|
|
42
16
|
const mapToCreateChatThreadOptionsRestModel = (options) => {
|
|
@@ -58,7 +32,7 @@ const mapToChatParticipantRestModel = (chatParticipant) => {
|
|
|
58
32
|
const mapToAddChatParticipantsRequestRestModel = (addParticipantsRequest) => {
|
|
59
33
|
var _a;
|
|
60
34
|
return {
|
|
61
|
-
participants: (_a = addParticipantsRequest.participants) === null || _a === void 0 ? void 0 : _a.map((participant) => mapToChatParticipantRestModel(participant))
|
|
35
|
+
participants: (_a = addParticipantsRequest.participants) === null || _a === void 0 ? void 0 : _a.map((participant) => mapToChatParticipantRestModel(participant)),
|
|
62
36
|
};
|
|
63
37
|
};
|
|
64
38
|
/**
|
|
@@ -1958,7 +1932,7 @@ class ChatApiClientContext extends coreClient.ServiceClient {
|
|
|
1958
1932
|
const defaults = {
|
|
1959
1933
|
requestContentType: "application/json; charset=utf-8"
|
|
1960
1934
|
};
|
|
1961
|
-
const packageDetails = `azsdk-js-azure-communication-chat/1.1.
|
|
1935
|
+
const packageDetails = `azsdk-js-azure-communication-chat/1.1.2`;
|
|
1962
1936
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
|
1963
1937
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
|
1964
1938
|
: `${packageDetails}`;
|
|
@@ -1993,6 +1967,19 @@ class ChatApiClient extends ChatApiClientContext {
|
|
|
1993
1967
|
}
|
|
1994
1968
|
}
|
|
1995
1969
|
|
|
1970
|
+
// Copyright (c) Microsoft Corporation.
|
|
1971
|
+
const logger = logger$1.createClientLogger("communication-chat");
|
|
1972
|
+
|
|
1973
|
+
// Copyright (c) Microsoft Corporation.
|
|
1974
|
+
/**
|
|
1975
|
+
* Creates a span using the global tracer.
|
|
1976
|
+
* @internal
|
|
1977
|
+
*/
|
|
1978
|
+
const createSpan = coreTracing.createSpanFunction({
|
|
1979
|
+
packagePrefix: "Azure.Communication",
|
|
1980
|
+
namespace: "Microsoft.Communication",
|
|
1981
|
+
});
|
|
1982
|
+
|
|
1996
1983
|
// Copyright (c) Microsoft Corporation.
|
|
1997
1984
|
/**
|
|
1998
1985
|
* Creates a new CommunicationTokenCredentialPolicy factory.
|
|
@@ -2002,9 +1989,9 @@ class ChatApiClient extends ChatApiClientContext {
|
|
|
2002
1989
|
const createCommunicationTokenCredentialPolicy = (credential) => {
|
|
2003
1990
|
const policyOptions = {
|
|
2004
1991
|
credential: {
|
|
2005
|
-
getToken: (_scopes, options) => credential.getToken({ abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal })
|
|
1992
|
+
getToken: (_scopes, options) => credential.getToken({ abortSignal: options === null || options === void 0 ? void 0 : options.abortSignal }),
|
|
2006
1993
|
},
|
|
2007
|
-
scopes: []
|
|
1994
|
+
scopes: [],
|
|
2008
1995
|
};
|
|
2009
1996
|
return coreRestPipeline.bearerTokenAuthenticationPolicy(policyOptions);
|
|
2010
1997
|
};
|
|
@@ -2022,8 +2009,8 @@ class ChatThreadClient {
|
|
|
2022
2009
|
this.tokenCredential = credential;
|
|
2023
2010
|
const internalPipelineOptions = Object.assign(Object.assign({}, options), {
|
|
2024
2011
|
loggingOptions: {
|
|
2025
|
-
logger: logger.info
|
|
2026
|
-
}
|
|
2012
|
+
logger: logger.info,
|
|
2013
|
+
},
|
|
2027
2014
|
});
|
|
2028
2015
|
this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
|
|
2029
2016
|
const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);
|
|
@@ -2043,7 +2030,7 @@ class ChatThreadClient {
|
|
|
2043
2030
|
catch (e) {
|
|
2044
2031
|
span.setStatus({
|
|
2045
2032
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2046
|
-
message: e.message
|
|
2033
|
+
message: e.message,
|
|
2047
2034
|
});
|
|
2048
2035
|
throw e;
|
|
2049
2036
|
}
|
|
@@ -2064,7 +2051,7 @@ class ChatThreadClient {
|
|
|
2064
2051
|
catch (e) {
|
|
2065
2052
|
span.setStatus({
|
|
2066
2053
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2067
|
-
message: e.message
|
|
2054
|
+
message: e.message,
|
|
2068
2055
|
});
|
|
2069
2056
|
throw e;
|
|
2070
2057
|
}
|
|
@@ -2089,7 +2076,7 @@ class ChatThreadClient {
|
|
|
2089
2076
|
catch (e) {
|
|
2090
2077
|
span.setStatus({
|
|
2091
2078
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2092
|
-
message: e.message
|
|
2079
|
+
message: e.message,
|
|
2093
2080
|
});
|
|
2094
2081
|
throw e;
|
|
2095
2082
|
}
|
|
@@ -2112,7 +2099,7 @@ class ChatThreadClient {
|
|
|
2112
2099
|
catch (e) {
|
|
2113
2100
|
span.setStatus({
|
|
2114
2101
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2115
|
-
message: e.message
|
|
2102
|
+
message: e.message,
|
|
2116
2103
|
});
|
|
2117
2104
|
throw e;
|
|
2118
2105
|
}
|
|
@@ -2177,13 +2164,13 @@ class ChatThreadClient {
|
|
|
2177
2164
|
},
|
|
2178
2165
|
byPage: (settings = {}) => {
|
|
2179
2166
|
return this.listMessagesPage(settings, updatedOptions);
|
|
2180
|
-
}
|
|
2167
|
+
},
|
|
2181
2168
|
};
|
|
2182
2169
|
}
|
|
2183
2170
|
catch (e) {
|
|
2184
2171
|
span.setStatus({
|
|
2185
2172
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2186
|
-
message: e.message
|
|
2173
|
+
message: e.message,
|
|
2187
2174
|
});
|
|
2188
2175
|
throw e;
|
|
2189
2176
|
}
|
|
@@ -2204,7 +2191,7 @@ class ChatThreadClient {
|
|
|
2204
2191
|
catch (e) {
|
|
2205
2192
|
span.setStatus({
|
|
2206
2193
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2207
|
-
message: e.message
|
|
2194
|
+
message: e.message,
|
|
2208
2195
|
});
|
|
2209
2196
|
throw e;
|
|
2210
2197
|
}
|
|
@@ -2225,7 +2212,7 @@ class ChatThreadClient {
|
|
|
2225
2212
|
catch (e) {
|
|
2226
2213
|
span.setStatus({
|
|
2227
2214
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2228
|
-
message: e.message
|
|
2215
|
+
message: e.message,
|
|
2229
2216
|
});
|
|
2230
2217
|
throw e;
|
|
2231
2218
|
}
|
|
@@ -2247,7 +2234,7 @@ class ChatThreadClient {
|
|
|
2247
2234
|
catch (e) {
|
|
2248
2235
|
span.setStatus({
|
|
2249
2236
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2250
|
-
message: e.message
|
|
2237
|
+
message: e.message,
|
|
2251
2238
|
});
|
|
2252
2239
|
throw e;
|
|
2253
2240
|
}
|
|
@@ -2312,13 +2299,13 @@ class ChatThreadClient {
|
|
|
2312
2299
|
},
|
|
2313
2300
|
byPage: (settings = {}) => {
|
|
2314
2301
|
return this.listParticipantsPage(settings, updatedOptions);
|
|
2315
|
-
}
|
|
2302
|
+
},
|
|
2316
2303
|
};
|
|
2317
2304
|
}
|
|
2318
2305
|
catch (e) {
|
|
2319
2306
|
span.setStatus({
|
|
2320
2307
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2321
|
-
message: e.message
|
|
2308
|
+
message: e.message,
|
|
2322
2309
|
});
|
|
2323
2310
|
throw e;
|
|
2324
2311
|
}
|
|
@@ -2339,7 +2326,7 @@ class ChatThreadClient {
|
|
|
2339
2326
|
catch (e) {
|
|
2340
2327
|
span.setStatus({
|
|
2341
2328
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2342
|
-
message: e.message
|
|
2329
|
+
message: e.message,
|
|
2343
2330
|
});
|
|
2344
2331
|
throw e;
|
|
2345
2332
|
}
|
|
@@ -2359,8 +2346,8 @@ class ChatThreadClient {
|
|
|
2359
2346
|
const dateNow = new Date();
|
|
2360
2347
|
const { senderDisplayName } = updatedOptions, restOptions = tslib.__rest(updatedOptions, ["senderDisplayName"]);
|
|
2361
2348
|
if (this.canPostTypingNotification(dateNow)) {
|
|
2362
|
-
await this.client.chatThread.sendTypingNotification(this.threadId, Object.assign({ sendTypingNotificationRequest: { senderDisplayName: senderDisplayName } }, restOptions));
|
|
2363
2349
|
this.timeOfLastTypingRequest = dateNow;
|
|
2350
|
+
await this.client.chatThread.sendTypingNotification(this.threadId, Object.assign({ sendTypingNotificationRequest: { senderDisplayName: senderDisplayName } }, restOptions));
|
|
2364
2351
|
return true;
|
|
2365
2352
|
}
|
|
2366
2353
|
logger.info(`Typing Notification NOT Send. [thread_id=${this.threadId}]`);
|
|
@@ -2369,7 +2356,7 @@ class ChatThreadClient {
|
|
|
2369
2356
|
catch (e) {
|
|
2370
2357
|
span.setStatus({
|
|
2371
2358
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2372
|
-
message: e.message
|
|
2359
|
+
message: e.message,
|
|
2373
2360
|
});
|
|
2374
2361
|
throw e;
|
|
2375
2362
|
}
|
|
@@ -2391,7 +2378,7 @@ class ChatThreadClient {
|
|
|
2391
2378
|
catch (e) {
|
|
2392
2379
|
span.setStatus({
|
|
2393
2380
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2394
|
-
message: e.message
|
|
2381
|
+
message: e.message,
|
|
2395
2382
|
});
|
|
2396
2383
|
throw e;
|
|
2397
2384
|
}
|
|
@@ -2456,13 +2443,13 @@ class ChatThreadClient {
|
|
|
2456
2443
|
},
|
|
2457
2444
|
byPage: (settings = {}) => {
|
|
2458
2445
|
return this.listReadReceiptsPage(settings, updatedOptions);
|
|
2459
|
-
}
|
|
2446
|
+
},
|
|
2460
2447
|
};
|
|
2461
2448
|
}
|
|
2462
2449
|
catch (e) {
|
|
2463
2450
|
span.setStatus({
|
|
2464
2451
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2465
|
-
message: e.message
|
|
2452
|
+
message: e.message,
|
|
2466
2453
|
});
|
|
2467
2454
|
throw e;
|
|
2468
2455
|
}
|
|
@@ -2493,6 +2480,19 @@ function generateUuid() {
|
|
|
2493
2480
|
return uuid.v4();
|
|
2494
2481
|
}
|
|
2495
2482
|
|
|
2483
|
+
// Copyright (c) Microsoft Corporation.
|
|
2484
|
+
const getSignalingClient = (credential, logger, options) => {
|
|
2485
|
+
var _a;
|
|
2486
|
+
if (typeof navigator !== "undefined" && navigator.product === "ReactNative") {
|
|
2487
|
+
// In React Native
|
|
2488
|
+
return new communicationSignaling.CommunicationSignalingClient(credential, logger, {
|
|
2489
|
+
environment: (_a = options === null || options === void 0 ? void 0 : options.environment) !== null && _a !== void 0 ? _a : undefined,
|
|
2490
|
+
});
|
|
2491
|
+
}
|
|
2492
|
+
// In node js
|
|
2493
|
+
return undefined;
|
|
2494
|
+
};
|
|
2495
|
+
|
|
2496
2496
|
// Copyright (c) Microsoft Corporation.
|
|
2497
2497
|
/**
|
|
2498
2498
|
* The client to do chat operations
|
|
@@ -2514,8 +2514,8 @@ class ChatClient {
|
|
|
2514
2514
|
this.clientOptions = Object.assign({}, options);
|
|
2515
2515
|
const internalPipelineOptions = Object.assign(Object.assign({}, options), {
|
|
2516
2516
|
loggingOptions: {
|
|
2517
|
-
logger: logger.info
|
|
2518
|
-
}
|
|
2517
|
+
logger: logger.info,
|
|
2518
|
+
},
|
|
2519
2519
|
});
|
|
2520
2520
|
this.client = new ChatApiClient(this.endpoint, Object.assign({ endpoint: this.endpoint }, internalPipelineOptions));
|
|
2521
2521
|
const authPolicy = createCommunicationTokenCredentialPolicy(this.tokenCredential);
|
|
@@ -2544,14 +2544,14 @@ class ChatClient {
|
|
|
2544
2544
|
const updatedRestModelOptions = mapToCreateChatThreadOptionsRestModel(updatedOptions);
|
|
2545
2545
|
const result = await this.client.chat.createChatThread({
|
|
2546
2546
|
topic: request.topic,
|
|
2547
|
-
participants: (_b = options.participants) === null || _b === void 0 ? void 0 : _b.map((participant) => mapToChatParticipantRestModel(participant))
|
|
2547
|
+
participants: (_b = options.participants) === null || _b === void 0 ? void 0 : _b.map((participant) => mapToChatParticipantRestModel(participant)),
|
|
2548
2548
|
}, updatedRestModelOptions);
|
|
2549
2549
|
return mapToCreateChatThreadResultSdkModel(result);
|
|
2550
2550
|
}
|
|
2551
2551
|
catch (e) {
|
|
2552
2552
|
span.setStatus({
|
|
2553
2553
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2554
|
-
message: e.message
|
|
2554
|
+
message: e.message,
|
|
2555
2555
|
});
|
|
2556
2556
|
throw e;
|
|
2557
2557
|
}
|
|
@@ -2615,13 +2615,13 @@ class ChatClient {
|
|
|
2615
2615
|
},
|
|
2616
2616
|
byPage: (settings = {}) => {
|
|
2617
2617
|
return this.listChatThreadsPage(settings, updatedOptions);
|
|
2618
|
-
}
|
|
2618
|
+
},
|
|
2619
2619
|
};
|
|
2620
2620
|
}
|
|
2621
2621
|
catch (e) {
|
|
2622
2622
|
span.setStatus({
|
|
2623
2623
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2624
|
-
message: e.message
|
|
2624
|
+
message: e.message,
|
|
2625
2625
|
});
|
|
2626
2626
|
throw e;
|
|
2627
2627
|
}
|
|
@@ -2642,7 +2642,7 @@ class ChatClient {
|
|
|
2642
2642
|
catch (e) {
|
|
2643
2643
|
span.setStatus({
|
|
2644
2644
|
code: coreTracing.SpanStatusCode.ERROR,
|
|
2645
|
-
message: e.message
|
|
2645
|
+
message: e.message,
|
|
2646
2646
|
});
|
|
2647
2647
|
throw e;
|
|
2648
2648
|
}
|
|
@@ -2681,7 +2681,9 @@ class ChatClient {
|
|
|
2681
2681
|
if (this.signalingClient === undefined) {
|
|
2682
2682
|
throw new Error("Realtime notifications are only supported in the browser.");
|
|
2683
2683
|
}
|
|
2684
|
-
if (!this.isRealtimeNotificationsStarted
|
|
2684
|
+
if (!this.isRealtimeNotificationsStarted &&
|
|
2685
|
+
event !== "realTimeNotificationConnected" &&
|
|
2686
|
+
event !== "realTimeNotificationDisconnected") {
|
|
2685
2687
|
throw new Error("You must call startRealtimeNotifications before you can subscribe to events.");
|
|
2686
2688
|
}
|
|
2687
2689
|
this.emitter.on(event, listener);
|
|
@@ -2696,6 +2698,14 @@ class ChatClient {
|
|
|
2696
2698
|
if (this.signalingClient === undefined) {
|
|
2697
2699
|
throw new Error("Realtime notifications are only supported in the browser.");
|
|
2698
2700
|
}
|
|
2701
|
+
this.signalingClient.on("connectionChanged", (payload) => {
|
|
2702
|
+
if (payload === 2 /* Connected */) {
|
|
2703
|
+
this.emitter.emit("realTimeNotificationConnected");
|
|
2704
|
+
}
|
|
2705
|
+
else if (payload === 3 /* Disconnected */) {
|
|
2706
|
+
this.emitter.emit("realTimeNotificationDisconnected");
|
|
2707
|
+
}
|
|
2708
|
+
});
|
|
2699
2709
|
this.signalingClient.on("chatMessageReceived", (payload) => {
|
|
2700
2710
|
this.emitter.emit("chatMessageReceived", payload);
|
|
2701
2711
|
});
|