@azure/web-pubsub 1.0.1-alpha.20220330.1 → 1.1.0-alpha.20220414.1
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +5 -1
- package/dist/index.js +71 -151
- package/dist/index.js.map +1 -1
- package/dist-esm/src/generated/generatedClientContext.js +1 -1
- package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
- package/dist-esm/src/groupClient.js +21 -45
- package/dist-esm/src/groupClient.js.map +1 -1
- package/dist-esm/src/hubClient.js +49 -105
- package/dist-esm/src/hubClient.js.map +1 -1
- package/dist-esm/src/tracing.js +3 -3
- package/dist-esm/src/tracing.js.map +1 -1
- package/dist-esm/test/hubs.spec.js +38 -1
- package/dist-esm/test/hubs.spec.js.map +1 -1
- package/package.json +4 -3
package/CHANGELOG.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Release History
|
2
2
|
|
3
|
-
## 1.0
|
3
|
+
## 1.1.0 (Unreleased)
|
4
4
|
|
5
5
|
### Features Added
|
6
6
|
|
@@ -10,6 +10,10 @@
|
|
10
10
|
|
11
11
|
### Other Changes
|
12
12
|
|
13
|
+
- Updated our `@azure/core-tracing` dependency to the latest version (1.0.0).
|
14
|
+
- Notable changes include Removal of `@opentelemetry/api` as a transitive dependency and ensuring that the active context is properly propagated.
|
15
|
+
- Customers who would like to continue using OpenTelemetry driven tracing should visit our [OpenTelemetry Instrumentation](https://www.npmjs.com/package/@azure/opentelemetry-instrumentation-azure-sdk) package for instructions.
|
16
|
+
|
13
17
|
## 1.0.0 (2021-11-11)
|
14
18
|
|
15
19
|
No changes.
|
package/dist/index.js
CHANGED
@@ -1505,7 +1505,7 @@ class GeneratedClientContext extends coreClient__namespace.ServiceClient {
|
|
1505
1505
|
const defaults = {
|
1506
1506
|
requestContentType: "application/json; charset=utf-8"
|
1507
1507
|
};
|
1508
|
-
const packageDetails = `azsdk-js-web-pubsub/1.0
|
1508
|
+
const packageDetails = `azsdk-js-web-pubsub/1.1.0`;
|
1509
1509
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
1510
1510
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
1511
1511
|
: `${packageDetails}`;
|
@@ -1543,9 +1543,9 @@ class GeneratedClient extends GeneratedClientContext {
|
|
1543
1543
|
|
1544
1544
|
// Copyright (c) Microsoft Corporation.
|
1545
1545
|
/** @internal */
|
1546
|
-
const
|
1546
|
+
const tracingClient = coreTracing.createTracingClient({
|
1547
1547
|
namespace: "Microsoft.WebPubSub",
|
1548
|
-
|
1548
|
+
packageName: "@azure/web-pubsub",
|
1549
1549
|
});
|
1550
1550
|
|
1551
1551
|
// Copyright (c) Microsoft Corporation.
|
@@ -1597,15 +1597,14 @@ class WebPubSubGroupImpl {
|
|
1597
1597
|
* @param options - Additional options
|
1598
1598
|
*/
|
1599
1599
|
async addConnection(connectionId, options = {}) {
|
1600
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-addConnection", options);
|
1601
1600
|
let response;
|
1602
1601
|
function onResponse(rawResponse, flatResponse) {
|
1603
1602
|
response = rawResponse;
|
1604
|
-
if (
|
1605
|
-
|
1603
|
+
if (options.onResponse) {
|
1604
|
+
options.onResponse(rawResponse, flatResponse);
|
1606
1605
|
}
|
1607
1606
|
}
|
1608
|
-
|
1607
|
+
return tracingClient.withSpan("WebPubSubGroupClient.addConnection", options, async (updatedOptions) => {
|
1609
1608
|
await this.client.webPubSub.addConnectionToGroup(this.hubName, this.groupName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1610
1609
|
if (response.status === 404) {
|
1611
1610
|
throw new coreRestPipeline.RestError(`Connection id '${connectionId}' doesn't exist`, {
|
@@ -1614,10 +1613,7 @@ class WebPubSubGroupImpl {
|
|
1614
1613
|
response: response,
|
1615
1614
|
});
|
1616
1615
|
}
|
1617
|
-
}
|
1618
|
-
finally {
|
1619
|
-
span.end();
|
1620
|
-
}
|
1616
|
+
});
|
1621
1617
|
}
|
1622
1618
|
/**
|
1623
1619
|
* Remove a specific connection from this group
|
@@ -1626,13 +1622,9 @@ class WebPubSubGroupImpl {
|
|
1626
1622
|
* @param options - Additional options
|
1627
1623
|
*/
|
1628
1624
|
async removeConnection(connectionId, options = {}) {
|
1629
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
}
|
1633
|
-
finally {
|
1634
|
-
span.end();
|
1635
|
-
}
|
1625
|
+
return tracingClient.withSpan("WebPubSubGroupClient.removeConnection", options, (updatedOptions) => {
|
1626
|
+
return this.client.webPubSub.removeConnectionFromGroup(this.hubName, this.groupName, connectionId, updatedOptions);
|
1627
|
+
});
|
1636
1628
|
}
|
1637
1629
|
/**
|
1638
1630
|
* Close all connections to this group
|
@@ -1640,13 +1632,9 @@ class WebPubSubGroupImpl {
|
|
1640
1632
|
* @param options - Additional options
|
1641
1633
|
*/
|
1642
1634
|
async closeAllConnections(options = {}) {
|
1643
|
-
|
1644
|
-
|
1645
|
-
|
1646
|
-
}
|
1647
|
-
finally {
|
1648
|
-
span.end();
|
1649
|
-
}
|
1635
|
+
return tracingClient.withSpan("WebPubSubGroupClient.closeAllConnections", options, (updatedOptions) => {
|
1636
|
+
return this.client.webPubSub.closeGroupConnections(this.hubName, this.groupName, updatedOptions);
|
1637
|
+
});
|
1650
1638
|
}
|
1651
1639
|
/**
|
1652
1640
|
* Add a user to this group
|
@@ -1655,13 +1643,9 @@ class WebPubSubGroupImpl {
|
|
1655
1643
|
* @param options - Additional options
|
1656
1644
|
*/
|
1657
1645
|
async addUser(username, options = {}) {
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
}
|
1662
|
-
finally {
|
1663
|
-
span.end();
|
1664
|
-
}
|
1646
|
+
return tracingClient.withSpan("WebPubSubGroupClient.addUser", options, (updatedOptions) => {
|
1647
|
+
return this.client.webPubSub.addUserToGroup(this.hubName, this.groupName, username, updatedOptions);
|
1648
|
+
});
|
1665
1649
|
}
|
1666
1650
|
/**
|
1667
1651
|
* Remove a user from this group
|
@@ -1670,23 +1654,15 @@ class WebPubSubGroupImpl {
|
|
1670
1654
|
* @param options - Additional options
|
1671
1655
|
*/
|
1672
1656
|
async removeUser(username, options = {}) {
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
}
|
1677
|
-
finally {
|
1678
|
-
span.end();
|
1679
|
-
}
|
1657
|
+
return tracingClient.withSpan("WebPubSubGroupClient.removeUser", options, (updatedOptions) => {
|
1658
|
+
return this.client.webPubSub.removeUserFromGroup(this.hubName, this.groupName, username, updatedOptions);
|
1659
|
+
});
|
1680
1660
|
}
|
1681
1661
|
async sendToAll(message, options = {}) {
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
}
|
1687
|
-
finally {
|
1688
|
-
span.end();
|
1689
|
-
}
|
1662
|
+
return tracingClient.withSpan("WebPubSubGroupClient.sendToAll", options, (updatedOptions) => {
|
1663
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
1664
|
+
return this.client.webPubSub.sendToGroup(this.hubName, this.groupName, contentType, payload, updatedOptions);
|
1665
|
+
});
|
1690
1666
|
}
|
1691
1667
|
}
|
1692
1668
|
|
@@ -1823,34 +1799,22 @@ class WebPubSubServiceClient {
|
|
1823
1799
|
return new WebPubSubGroupImpl(this.client, this.hubName, groupName);
|
1824
1800
|
}
|
1825
1801
|
async sendToAll(message, options = {}) {
|
1826
|
-
|
1827
|
-
|
1828
|
-
|
1829
|
-
|
1830
|
-
}
|
1831
|
-
finally {
|
1832
|
-
span.end();
|
1833
|
-
}
|
1802
|
+
return tracingClient.withSpan("WebPubSubServiceClient.sendToAll", options, (updatedOptions) => {
|
1803
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
1804
|
+
return this.client.webPubSub.sendToAll(this.hubName, contentType, payload, updatedOptions);
|
1805
|
+
});
|
1834
1806
|
}
|
1835
1807
|
async sendToUser(username, message, options = {}) {
|
1836
|
-
|
1837
|
-
|
1838
|
-
|
1839
|
-
|
1840
|
-
}
|
1841
|
-
finally {
|
1842
|
-
span.end();
|
1843
|
-
}
|
1808
|
+
return tracingClient.withSpan("WebPubSubServiceClient.sendToUser", options, (updatedOptions) => {
|
1809
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
1810
|
+
return this.client.webPubSub.sendToUser(this.hubName, username, contentType, payload, updatedOptions);
|
1811
|
+
});
|
1844
1812
|
}
|
1845
1813
|
async sendToConnection(connectionId, message, options = {}) {
|
1846
|
-
|
1847
|
-
|
1848
|
-
|
1849
|
-
|
1850
|
-
}
|
1851
|
-
finally {
|
1852
|
-
span.end();
|
1853
|
-
}
|
1814
|
+
return tracingClient.withSpan("WebPubSubServiceClient.sendToConnection", options, (updatedOptions) => {
|
1815
|
+
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
1816
|
+
return this.client.webPubSub.sendToConnection(this.hubName, connectionId, contentType, payload, updatedOptions);
|
1817
|
+
});
|
1854
1818
|
}
|
1855
1819
|
/**
|
1856
1820
|
* Check if a specific connection is connected to this hub
|
@@ -1859,15 +1823,14 @@ class WebPubSubServiceClient {
|
|
1859
1823
|
* @param options - Additional options
|
1860
1824
|
*/
|
1861
1825
|
async connectionExists(connectionId, options = {}) {
|
1862
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasConnection", options);
|
1863
1826
|
let response;
|
1864
1827
|
function onResponse(rawResponse, flatResponse) {
|
1865
1828
|
response = rawResponse;
|
1866
|
-
if (
|
1867
|
-
|
1829
|
+
if (options.onResponse) {
|
1830
|
+
options.onResponse(rawResponse, flatResponse);
|
1868
1831
|
}
|
1869
1832
|
}
|
1870
|
-
|
1833
|
+
return tracingClient.withSpan("WebPubSubServiceClient.connectionExists", options, async (updatedOptions) => {
|
1871
1834
|
await this.client.webPubSub.connectionExists(this.hubName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1872
1835
|
if (response.status === 200) {
|
1873
1836
|
return true;
|
@@ -1883,10 +1846,7 @@ class WebPubSubServiceClient {
|
|
1883
1846
|
response: response,
|
1884
1847
|
});
|
1885
1848
|
}
|
1886
|
-
}
|
1887
|
-
finally {
|
1888
|
-
span.end();
|
1889
|
-
}
|
1849
|
+
});
|
1890
1850
|
}
|
1891
1851
|
/**
|
1892
1852
|
* Close a specific connection to this hub
|
@@ -1895,13 +1855,9 @@ class WebPubSubServiceClient {
|
|
1895
1855
|
* @param options - Additional options
|
1896
1856
|
*/
|
1897
1857
|
async closeConnection(connectionId, options = {}) {
|
1898
|
-
|
1899
|
-
|
1900
|
-
|
1901
|
-
}
|
1902
|
-
finally {
|
1903
|
-
span.end();
|
1904
|
-
}
|
1858
|
+
return tracingClient.withSpan("WebPubSubServiceClient.closeConnection", options, (updatedOptions) => {
|
1859
|
+
return this.client.webPubSub.closeConnection(this.hubName, connectionId, updatedOptions);
|
1860
|
+
});
|
1905
1861
|
}
|
1906
1862
|
/**
|
1907
1863
|
* Close all connections to this hub
|
@@ -1909,13 +1865,9 @@ class WebPubSubServiceClient {
|
|
1909
1865
|
* @param options - Additional options
|
1910
1866
|
*/
|
1911
1867
|
async closeAllConnections(options = {}) {
|
1912
|
-
|
1913
|
-
|
1914
|
-
|
1915
|
-
}
|
1916
|
-
finally {
|
1917
|
-
span.end();
|
1918
|
-
}
|
1868
|
+
return tracingClient.withSpan("WebPubSubServiceClient.closeAllConnections", options, (updatedOptions) => {
|
1869
|
+
return this.client.webPubSub.closeAllConnections(this.hubName, updatedOptions);
|
1870
|
+
});
|
1919
1871
|
}
|
1920
1872
|
/**
|
1921
1873
|
* Close all connections with the given user id
|
@@ -1924,13 +1876,9 @@ class WebPubSubServiceClient {
|
|
1924
1876
|
* @param options - Additional options
|
1925
1877
|
*/
|
1926
1878
|
async closeUserConnections(userId, options = {}) {
|
1927
|
-
|
1928
|
-
|
1929
|
-
|
1930
|
-
}
|
1931
|
-
finally {
|
1932
|
-
span.end();
|
1933
|
-
}
|
1879
|
+
return tracingClient.withSpan("WebPubSubServiceClient.closeUserConnections", options, (updatedOptions) => {
|
1880
|
+
return this.client.webPubSub.closeUserConnections(this.hubName, userId, updatedOptions);
|
1881
|
+
});
|
1934
1882
|
}
|
1935
1883
|
/**
|
1936
1884
|
* Remove a specific user from all groups they are joined to
|
@@ -1938,13 +1886,9 @@ class WebPubSubServiceClient {
|
|
1938
1886
|
* @param options - Additional options
|
1939
1887
|
*/
|
1940
1888
|
async removeUserFromAllGroups(userId, options = {}) {
|
1941
|
-
|
1942
|
-
|
1943
|
-
|
1944
|
-
}
|
1945
|
-
finally {
|
1946
|
-
span.end();
|
1947
|
-
}
|
1889
|
+
return tracingClient.withSpan("WebPubSubServiceClient.removeUserFromAllGroups", options, (updatedOptions) => {
|
1890
|
+
return this.client.webPubSub.removeUserFromAllGroups(this.hubName, userId, updatedOptions);
|
1891
|
+
});
|
1948
1892
|
}
|
1949
1893
|
/**
|
1950
1894
|
* Check if a particular group exists (i.e. has active connections).
|
@@ -1953,15 +1897,14 @@ class WebPubSubServiceClient {
|
|
1953
1897
|
* @param options - Additional options
|
1954
1898
|
*/
|
1955
1899
|
async groupExists(groupName, options = {}) {
|
1956
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasGroup", options);
|
1957
1900
|
let response;
|
1958
1901
|
function onResponse(rawResponse, flatResponse) {
|
1959
1902
|
response = rawResponse;
|
1960
|
-
if (
|
1961
|
-
|
1903
|
+
if (options.onResponse) {
|
1904
|
+
options.onResponse(rawResponse, flatResponse);
|
1962
1905
|
}
|
1963
1906
|
}
|
1964
|
-
|
1907
|
+
return tracingClient.withSpan("WebPubSubServiceClient.groupExists", options, async (updatedOptions) => {
|
1965
1908
|
await this.client.webPubSub.groupExists(this.hubName, groupName, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1966
1909
|
if (response.status === 200) {
|
1967
1910
|
return true;
|
@@ -1976,10 +1919,7 @@ class WebPubSubServiceClient {
|
|
1976
1919
|
response: response,
|
1977
1920
|
});
|
1978
1921
|
}
|
1979
|
-
}
|
1980
|
-
finally {
|
1981
|
-
span.end();
|
1982
|
-
}
|
1922
|
+
});
|
1983
1923
|
}
|
1984
1924
|
/**
|
1985
1925
|
* Check if a particular user is connected to this hub.
|
@@ -1988,15 +1928,14 @@ class WebPubSubServiceClient {
|
|
1988
1928
|
* @param options - Additional options
|
1989
1929
|
*/
|
1990
1930
|
async userExists(username, options = {}) {
|
1991
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasUser", options);
|
1992
1931
|
let response;
|
1993
1932
|
function onResponse(rawResponse, flatResponse) {
|
1994
1933
|
response = rawResponse;
|
1995
|
-
if (
|
1996
|
-
|
1934
|
+
if (options.onResponse) {
|
1935
|
+
options.onResponse(rawResponse, flatResponse);
|
1997
1936
|
}
|
1998
1937
|
}
|
1999
|
-
|
1938
|
+
return tracingClient.withSpan("WebPubSubServiceClient.userExists", options, async (updatedOptions) => {
|
2000
1939
|
await this.client.webPubSub.userExists(this.hubName, username, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
2001
1940
|
if (response.status === 200) {
|
2002
1941
|
return true;
|
@@ -2012,10 +1951,7 @@ class WebPubSubServiceClient {
|
|
2012
1951
|
response: response,
|
2013
1952
|
});
|
2014
1953
|
}
|
2015
|
-
}
|
2016
|
-
finally {
|
2017
|
-
span.end();
|
2018
|
-
}
|
1954
|
+
});
|
2019
1955
|
}
|
2020
1956
|
/**
|
2021
1957
|
* Grant permissions to a connection
|
@@ -2025,13 +1961,9 @@ class WebPubSubServiceClient {
|
|
2025
1961
|
* @param options - Additional options
|
2026
1962
|
*/
|
2027
1963
|
async grantPermission(connectionId, permission, options = {}) {
|
2028
|
-
|
2029
|
-
|
2030
|
-
|
2031
|
-
}
|
2032
|
-
finally {
|
2033
|
-
span.end();
|
2034
|
-
}
|
1964
|
+
return tracingClient.withSpan("WebPubSubServiceClient.grantPermission", options, (updatedOptions) => {
|
1965
|
+
return this.client.webPubSub.grantPermission(this.hubName, permission, connectionId, updatedOptions);
|
1966
|
+
});
|
2035
1967
|
}
|
2036
1968
|
/**
|
2037
1969
|
* Revoke permissions from a connection
|
@@ -2041,13 +1973,9 @@ class WebPubSubServiceClient {
|
|
2041
1973
|
* @param options - Additional options
|
2042
1974
|
*/
|
2043
1975
|
async revokePermission(connectionId, permission, options = {}) {
|
2044
|
-
|
2045
|
-
|
2046
|
-
|
2047
|
-
}
|
2048
|
-
finally {
|
2049
|
-
span.end();
|
2050
|
-
}
|
1976
|
+
return tracingClient.withSpan("WebPubSubServiceClient.revokePermission", options, (updatedOptions) => {
|
1977
|
+
return this.client.webPubSub.revokePermission(this.hubName, permission, connectionId, updatedOptions);
|
1978
|
+
});
|
2051
1979
|
}
|
2052
1980
|
/**
|
2053
1981
|
* Check if the connection has the specified permission
|
@@ -2057,15 +1985,14 @@ class WebPubSubServiceClient {
|
|
2057
1985
|
* @param options - Additional options
|
2058
1986
|
*/
|
2059
1987
|
async hasPermission(connectionId, permission, options = {}) {
|
2060
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasPermission", options);
|
2061
1988
|
let response;
|
2062
1989
|
function onResponse(rawResponse, flatResponse) {
|
2063
1990
|
response = rawResponse;
|
2064
|
-
if (
|
2065
|
-
|
1991
|
+
if (options.onResponse) {
|
1992
|
+
options.onResponse(rawResponse, flatResponse);
|
2066
1993
|
}
|
2067
1994
|
}
|
2068
|
-
|
1995
|
+
return tracingClient.withSpan("WebPubSubServiceClient.hasPermission", options, async (updatedOptions) => {
|
2069
1996
|
await this.client.webPubSub.checkPermission(this.hubName, permission, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
2070
1997
|
if (response.status === 200) {
|
2071
1998
|
return true;
|
@@ -2081,10 +2008,7 @@ class WebPubSubServiceClient {
|
|
2081
2008
|
response: response,
|
2082
2009
|
});
|
2083
2010
|
}
|
2084
|
-
}
|
2085
|
-
finally {
|
2086
|
-
span.end();
|
2087
|
-
}
|
2011
|
+
});
|
2088
2012
|
}
|
2089
2013
|
/**
|
2090
2014
|
* Generate a token for a client to connect to the Azure Web PubSub service.
|
@@ -2092,8 +2016,7 @@ class WebPubSubServiceClient {
|
|
2092
2016
|
* @param options - Additional options
|
2093
2017
|
*/
|
2094
2018
|
async getClientAccessToken(options = {}) {
|
2095
|
-
|
2096
|
-
try {
|
2019
|
+
return tracingClient.withSpan("WebPubSubServiceClient.getClientAccessToken", options, async (updatedOptions) => {
|
2097
2020
|
const endpoint = this.endpoint.endsWith("/") ? this.endpoint : this.endpoint + "/";
|
2098
2021
|
const clientEndpoint = endpoint.replace(/(http)(s?:\/\/)/gi, "ws$2");
|
2099
2022
|
const baseUrl = `${clientEndpoint}client/hubs/${this.hubName}`;
|
@@ -2123,10 +2046,7 @@ class WebPubSubServiceClient {
|
|
2123
2046
|
baseUrl,
|
2124
2047
|
url: `${baseUrl}?access_token=${token}`,
|
2125
2048
|
};
|
2126
|
-
}
|
2127
|
-
finally {
|
2128
|
-
span.end();
|
2129
|
-
}
|
2049
|
+
});
|
2130
2050
|
}
|
2131
2051
|
}
|
2132
2052
|
|