@azure/web-pubsub 1.1.4-alpha.20241119.1 → 1.1.4-alpha.20241120.2
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/commonjs/generated/generatedClient.d.ts +19 -0
- package/dist/commonjs/generated/generatedClient.d.ts.map +1 -0
- package/dist/commonjs/generated/generatedClient.js +76 -0
- package/dist/commonjs/generated/generatedClient.js.map +1 -0
- package/dist/commonjs/generated/generatedClientContext.d.ts +14 -0
- package/dist/commonjs/generated/generatedClientContext.d.ts.map +1 -0
- package/dist/commonjs/generated/generatedClientContext.js +46 -0
- package/dist/commonjs/generated/generatedClientContext.js.map +1 -0
- package/dist/commonjs/generated/index.d.ts +4 -0
- package/dist/commonjs/generated/index.d.ts.map +1 -0
- package/dist/commonjs/generated/index.js +16 -0
- package/dist/commonjs/generated/index.js.map +1 -0
- package/dist/commonjs/generated/models/index.d.ts +323 -0
- package/dist/commonjs/generated/models/index.d.ts.map +1 -0
- package/dist/commonjs/generated/models/index.js +27 -0
- package/dist/commonjs/generated/models/index.js.map +1 -0
- package/dist/commonjs/generated/models/mappers.d.ts +30 -0
- package/dist/commonjs/generated/models/mappers.d.ts.map +1 -0
- package/dist/commonjs/generated/models/mappers.js +463 -0
- package/dist/commonjs/generated/models/mappers.js.map +1 -0
- package/dist/commonjs/generated/models/parameters.d.ts +31 -0
- package/dist/commonjs/generated/models/parameters.d.ts.map +1 -0
- package/dist/commonjs/generated/models/parameters.js +335 -0
- package/dist/commonjs/generated/models/parameters.js.map +1 -0
- package/dist/commonjs/generated/operations/healthApi.d.ts +18 -0
- package/dist/commonjs/generated/operations/healthApi.d.ts.map +1 -0
- package/dist/commonjs/generated/operations/healthApi.js +43 -0
- package/dist/commonjs/generated/operations/healthApi.js.map +1 -0
- package/dist/commonjs/generated/operations/index.d.ts +3 -0
- package/dist/commonjs/generated/operations/index.d.ts.map +1 -0
- package/dist/commonjs/generated/operations/index.js +13 -0
- package/dist/commonjs/generated/operations/index.js.map +1 -0
- package/dist/commonjs/generated/operations/webPubSub.d.ts +249 -0
- package/dist/commonjs/generated/operations/webPubSub.d.ts.map +1 -0
- package/dist/commonjs/generated/operations/webPubSub.js +874 -0
- package/dist/commonjs/generated/operations/webPubSub.js.map +1 -0
- package/dist/commonjs/generated/operationsInterfaces/healthApi.d.ts +10 -0
- package/dist/commonjs/generated/operationsInterfaces/healthApi.d.ts.map +1 -0
- package/dist/commonjs/generated/operationsInterfaces/healthApi.js +10 -0
- package/dist/commonjs/generated/operationsInterfaces/healthApi.js.map +1 -0
- package/dist/commonjs/generated/operationsInterfaces/index.d.ts +3 -0
- package/dist/commonjs/generated/operationsInterfaces/index.d.ts.map +1 -0
- package/dist/commonjs/generated/operationsInterfaces/index.js +13 -0
- package/dist/commonjs/generated/operationsInterfaces/index.js.map +1 -0
- package/dist/commonjs/generated/operationsInterfaces/webPubSub.d.ts +224 -0
- package/dist/commonjs/generated/operationsInterfaces/webPubSub.d.ts.map +1 -0
- package/dist/commonjs/generated/operationsInterfaces/webPubSub.js +10 -0
- package/dist/commonjs/generated/operationsInterfaces/webPubSub.js.map +1 -0
- package/dist/commonjs/groupClient.d.ts +232 -0
- package/dist/commonjs/groupClient.d.ts.map +1 -0
- package/dist/commonjs/groupClient.js +101 -0
- package/dist/commonjs/groupClient.js.map +1 -0
- package/dist/commonjs/hubClient.d.ts +478 -0
- package/dist/commonjs/hubClient.d.ts.map +1 -0
- package/dist/commonjs/hubClient.js +372 -0
- package/dist/commonjs/hubClient.js.map +1 -0
- package/dist/commonjs/index.d.ts +5 -0
- package/dist/commonjs/index.d.ts.map +1 -0
- package/dist/commonjs/index.js +12 -0
- package/dist/commonjs/index.js.map +1 -0
- package/dist/commonjs/logger.d.ts +5 -0
- package/dist/commonjs/logger.d.ts.map +1 -0
- package/dist/commonjs/logger.js +11 -0
- package/dist/commonjs/logger.js.map +1 -0
- package/dist/commonjs/package.json +3 -0
- package/dist/commonjs/parseConnectionString.d.ts +8 -0
- package/dist/commonjs/parseConnectionString.d.ts.map +1 -0
- package/dist/commonjs/parseConnectionString.js +34 -0
- package/dist/commonjs/parseConnectionString.js.map +1 -0
- package/dist/commonjs/reverseProxyPolicy.d.ts +9 -0
- package/dist/commonjs/reverseProxyPolicy.d.ts.map +1 -0
- package/dist/commonjs/reverseProxyPolicy.js +25 -0
- package/dist/commonjs/reverseProxyPolicy.js.map +1 -0
- package/dist/commonjs/tracing.d.ts +3 -0
- package/dist/commonjs/tracing.d.ts.map +1 -0
- package/dist/commonjs/tracing.js +12 -0
- package/dist/commonjs/tracing.js.map +1 -0
- package/dist/commonjs/tsdoc-metadata.json +11 -0
- package/dist/commonjs/utils.d.ts +29 -0
- package/dist/commonjs/utils.d.ts.map +1 -0
- package/dist/commonjs/utils.js +73 -0
- package/dist/commonjs/utils.js.map +1 -0
- package/dist/commonjs/webPubSubCredentialPolicy.d.ts +13 -0
- package/dist/commonjs/webPubSubCredentialPolicy.d.ts.map +1 -0
- package/dist/commonjs/webPubSubCredentialPolicy.js +32 -0
- package/dist/commonjs/webPubSubCredentialPolicy.js.map +1 -0
- package/dist/esm/generated/generatedClient.d.ts +19 -0
- package/dist/esm/generated/generatedClient.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/generated/generatedClient.js +1 -1
- package/dist/esm/generated/generatedClient.js.map +1 -0
- package/dist/esm/generated/generatedClientContext.d.ts +14 -0
- package/dist/esm/generated/generatedClientContext.d.ts.map +1 -0
- package/dist/esm/generated/generatedClientContext.js.map +1 -0
- package/dist/esm/generated/index.d.ts +4 -0
- package/dist/esm/generated/index.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/generated/index.js +3 -3
- package/dist/esm/generated/index.js.map +1 -0
- package/dist/esm/generated/models/index.d.ts +323 -0
- package/dist/esm/generated/models/index.d.ts.map +1 -0
- package/dist/esm/generated/models/mappers.d.ts +30 -0
- package/dist/esm/generated/models/mappers.d.ts.map +1 -0
- package/dist/esm/generated/models/parameters.d.ts +31 -0
- package/dist/esm/generated/models/parameters.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/generated/models/parameters.js +1 -1
- package/dist/esm/generated/models/parameters.js.map +1 -0
- package/dist/esm/generated/operations/healthApi.d.ts +18 -0
- package/dist/esm/generated/operations/healthApi.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/generated/operations/healthApi.js +2 -2
- package/dist/esm/generated/operations/healthApi.js.map +1 -0
- package/dist/esm/generated/operations/index.d.ts +3 -0
- package/dist/esm/generated/operations/index.d.ts.map +1 -0
- package/{dist-esm/src/generated/operationsInterfaces → dist/esm/generated/operations}/index.js +2 -2
- package/dist/esm/generated/operations/index.js.map +1 -0
- package/dist/esm/generated/operations/webPubSub.d.ts +249 -0
- package/dist/esm/generated/operations/webPubSub.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/generated/operations/webPubSub.js +2 -2
- package/dist/esm/generated/operations/webPubSub.js.map +1 -0
- package/dist/esm/generated/operationsInterfaces/healthApi.d.ts +10 -0
- package/dist/esm/generated/operationsInterfaces/healthApi.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/generated/operationsInterfaces/healthApi.js.map +1 -1
- package/dist/esm/generated/operationsInterfaces/index.d.ts +3 -0
- package/dist/esm/generated/operationsInterfaces/index.d.ts.map +1 -0
- package/{dist-esm/src/generated/operations → dist/esm/generated/operationsInterfaces}/index.js +2 -2
- package/dist/esm/generated/operationsInterfaces/index.js.map +1 -0
- package/dist/esm/generated/operationsInterfaces/webPubSub.d.ts +224 -0
- package/dist/esm/generated/operationsInterfaces/webPubSub.d.ts.map +1 -0
- package/dist/esm/generated/operationsInterfaces/webPubSub.js.map +1 -0
- package/dist/esm/groupClient.d.ts +232 -0
- package/dist/esm/groupClient.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/groupClient.js +2 -2
- package/dist/esm/groupClient.js.map +1 -0
- package/dist/esm/hubClient.d.ts +478 -0
- package/dist/esm/hubClient.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/hubClient.js +9 -9
- package/dist/esm/hubClient.js.map +1 -0
- package/dist/esm/index.d.ts +5 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/{dist-esm/src → dist/esm}/index.js +2 -2
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/logger.d.ts +5 -0
- package/dist/esm/logger.d.ts.map +1 -0
- package/dist/esm/package.json +3 -0
- package/dist/esm/parseConnectionString.d.ts +8 -0
- package/dist/esm/parseConnectionString.d.ts.map +1 -0
- package/dist/esm/reverseProxyPolicy.d.ts +9 -0
- package/dist/esm/reverseProxyPolicy.d.ts.map +1 -0
- package/dist/esm/tracing.d.ts +3 -0
- package/dist/esm/tracing.d.ts.map +1 -0
- package/dist/esm/utils.d.ts +29 -0
- package/dist/esm/utils.d.ts.map +1 -0
- package/dist/esm/webPubSubCredentialPolicy.d.ts +13 -0
- package/dist/esm/webPubSubCredentialPolicy.d.ts.map +1 -0
- package/package.json +56 -52
- package/dist/index.js +0 -2441
- package/dist/index.js.map +0 -1
- package/dist-esm/samples-dev/broadcasting.js +0 -27
- package/dist-esm/samples-dev/broadcasting.js.map +0 -1
- package/dist-esm/samples-dev/directMessage.js +0 -20
- package/dist-esm/samples-dev/directMessage.js.map +0 -1
- package/dist-esm/samples-dev/managingGroups.js +0 -23
- package/dist-esm/samples-dev/managingGroups.js.map +0 -1
- package/dist-esm/src/generated/generatedClient.js.map +0 -1
- package/dist-esm/src/generated/generatedClientContext.js.map +0 -1
- package/dist-esm/src/generated/index.js.map +0 -1
- package/dist-esm/src/generated/models/parameters.js.map +0 -1
- package/dist-esm/src/generated/operations/healthApi.js.map +0 -1
- package/dist-esm/src/generated/operations/index.js.map +0 -1
- package/dist-esm/src/generated/operations/webPubSub.js.map +0 -1
- package/dist-esm/src/generated/operationsInterfaces/index.js.map +0 -1
- package/dist-esm/src/generated/operationsInterfaces/webPubSub.js.map +0 -1
- package/dist-esm/src/groupClient.js.map +0 -1
- package/dist-esm/src/hubClient.js.map +0 -1
- package/dist-esm/src/index.js.map +0 -1
- package/dist-esm/test/conn.spec.js +0 -23
- package/dist-esm/test/conn.spec.js.map +0 -1
- package/dist-esm/test/groups.spec.js +0 -138
- package/dist-esm/test/groups.spec.js.map +0 -1
- package/dist-esm/test/hubs.spec.js +0 -270
- package/dist-esm/test/hubs.spec.js.map +0 -1
- package/dist-esm/test/integration.spec.js +0 -299
- package/dist-esm/test/integration.spec.js.map +0 -1
- package/dist-esm/test/odata.spec.js +0 -15
- package/dist-esm/test/odata.spec.js.map +0 -1
- package/dist-esm/test/testEnv.js +0 -23
- package/dist-esm/test/testEnv.js.map +0 -1
- /package/{dist-esm/src → dist/esm}/generated/generatedClientContext.js +0 -0
- /package/{dist-esm/src → dist/esm}/generated/models/index.js +0 -0
- /package/{dist-esm/src → dist/esm}/generated/models/index.js.map +0 -0
- /package/{dist-esm/src → dist/esm}/generated/models/mappers.js +0 -0
- /package/{dist-esm/src → dist/esm}/generated/models/mappers.js.map +0 -0
- /package/{dist-esm/src → dist/esm}/generated/operationsInterfaces/healthApi.js +0 -0
- /package/{dist-esm/src → dist/esm}/generated/operationsInterfaces/webPubSub.js +0 -0
- /package/{dist-esm/src → dist/esm}/logger.js +0 -0
- /package/{dist-esm/src → dist/esm}/logger.js.map +0 -0
- /package/{dist-esm/src → dist/esm}/parseConnectionString.js +0 -0
- /package/{dist-esm/src → dist/esm}/parseConnectionString.js.map +0 -0
- /package/{dist-esm/src → dist/esm}/reverseProxyPolicy.js +0 -0
- /package/{dist-esm/src → dist/esm}/reverseProxyPolicy.js.map +0 -0
- /package/{dist-esm/src → dist/esm}/tracing.js +0 -0
- /package/{dist-esm/src → dist/esm}/tracing.js.map +0 -0
- /package/{dist-esm/src → dist/esm}/utils.js +0 -0
- /package/{dist-esm/src → dist/esm}/utils.js.map +0 -0
- /package/{dist-esm/src → dist/esm}/webPubSubCredentialPolicy.js +0 -0
- /package/{dist-esm/src → dist/esm}/webPubSubCredentialPolicy.js.map +0 -0
- /package/{types → dist}/web-pubsub.d.ts +0 -0
@@ -0,0 +1,232 @@
|
|
1
|
+
import type { CommonClientOptions, OperationOptions } from "@azure/core-client";
|
2
|
+
import type { RequestBodyType } from "@azure/core-rest-pipeline";
|
3
|
+
import type { GeneratedClient } from "./generated/generatedClient.js";
|
4
|
+
import type { JSONTypes } from "./hubClient.js";
|
5
|
+
/**
|
6
|
+
* Options for constructing a GroupAdmin client.
|
7
|
+
*/
|
8
|
+
export interface GroupAdminClientOptions extends CommonClientOptions {
|
9
|
+
}
|
10
|
+
/**
|
11
|
+
* Options for adding a connection to a group.
|
12
|
+
*/
|
13
|
+
export interface GroupAddConnectionOptions extends OperationOptions {
|
14
|
+
}
|
15
|
+
/**
|
16
|
+
* Options for adding a user to a group.
|
17
|
+
*/
|
18
|
+
export interface GroupAddUserOptions extends OperationOptions {
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* Options for checking if a user is in a group
|
22
|
+
*/
|
23
|
+
export interface GroupHasUserOptions extends OperationOptions {
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* Options for removing a user from a group
|
27
|
+
*/
|
28
|
+
export interface GroupRemoveUserOptions extends OperationOptions {
|
29
|
+
}
|
30
|
+
/**
|
31
|
+
* Options for removing a connection from a group
|
32
|
+
*/
|
33
|
+
export interface GroupRemoveConnectionOptions extends OperationOptions {
|
34
|
+
}
|
35
|
+
/**
|
36
|
+
* Options for sending messages to a group.
|
37
|
+
*/
|
38
|
+
export interface GroupSendToAllOptions extends OperationOptions {
|
39
|
+
/**
|
40
|
+
* Connection ids to exclude from receiving this message.
|
41
|
+
*/
|
42
|
+
excludedConnections?: string[];
|
43
|
+
/**
|
44
|
+
* The filter syntax to filter out the connections to send the messages to following OData filter syntax.
|
45
|
+
* Examples:
|
46
|
+
* * Exclude connections from `user1` and `user2`: `userId ne 'user1' and userId ne 'user2'`
|
47
|
+
* * Exclude connections in `group1`: `not('group1' in groups)`
|
48
|
+
* Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).
|
49
|
+
*/
|
50
|
+
filter?: string;
|
51
|
+
/**
|
52
|
+
* The time-to-live (TTL) value in seconds for messages sent to the service.
|
53
|
+
* 0 is the default value, which means the message never expires.
|
54
|
+
* 300 is the maximum value.
|
55
|
+
* If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.
|
56
|
+
* This parameter can help when the client's bandwidth is limited.
|
57
|
+
*/
|
58
|
+
messageTtlSeconds?: number;
|
59
|
+
}
|
60
|
+
/**
|
61
|
+
* Options for sending text messages to a group..
|
62
|
+
*/
|
63
|
+
export interface GroupSendTextToAllOptions extends GroupSendToAllOptions {
|
64
|
+
/**
|
65
|
+
* The content will be sent to the clients in plain text.
|
66
|
+
*/
|
67
|
+
contentType: "text/plain";
|
68
|
+
}
|
69
|
+
/**
|
70
|
+
* Options for closing all connections to a group.
|
71
|
+
*/
|
72
|
+
export interface GroupCloseAllConnectionsOptions extends OperationOptions {
|
73
|
+
/**
|
74
|
+
* Reason the connection is being closed.
|
75
|
+
*/
|
76
|
+
reason?: string;
|
77
|
+
}
|
78
|
+
export interface WebPubSubGroup {
|
79
|
+
/**
|
80
|
+
* The name of this group
|
81
|
+
*/
|
82
|
+
readonly groupName: string;
|
83
|
+
/**
|
84
|
+
* The name of the hub this group belongs to
|
85
|
+
*/
|
86
|
+
readonly hubName: string;
|
87
|
+
/**
|
88
|
+
* The Web PubSub API version being used by this client
|
89
|
+
*/
|
90
|
+
readonly apiVersion: string;
|
91
|
+
/**
|
92
|
+
* The Web PubSub endpoint this client is connected to
|
93
|
+
*/
|
94
|
+
readonly endpoint: string;
|
95
|
+
/**
|
96
|
+
* Add a specific connection to this group
|
97
|
+
*
|
98
|
+
* @param connectionId - The connection id to add to this group
|
99
|
+
* @param options - Additional options
|
100
|
+
*/
|
101
|
+
addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise<void>;
|
102
|
+
/**
|
103
|
+
* Remove a specific connection from this group
|
104
|
+
*
|
105
|
+
* @param connectionId - The connection id to remove from this group
|
106
|
+
* @param options - Additional options
|
107
|
+
*/
|
108
|
+
removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise<void>;
|
109
|
+
/**
|
110
|
+
* Close all connections to the group
|
111
|
+
*
|
112
|
+
* @param options - Additional options
|
113
|
+
*/
|
114
|
+
closeAllConnections(options?: GroupCloseAllConnectionsOptions): Promise<void>;
|
115
|
+
/**
|
116
|
+
* Add a user to this group
|
117
|
+
*
|
118
|
+
* @param username - The user name to add
|
119
|
+
* @param options - Additional options
|
120
|
+
*/
|
121
|
+
addUser(username: string, options?: GroupAddUserOptions): Promise<void>;
|
122
|
+
/**
|
123
|
+
* Remove a user from this group
|
124
|
+
*
|
125
|
+
* @param username - The user name to remove
|
126
|
+
* @param options - Additional options
|
127
|
+
*/
|
128
|
+
removeUser(username: string, options?: GroupRemoveUserOptions): Promise<void>;
|
129
|
+
/**
|
130
|
+
* Send a text message to every connection in this group
|
131
|
+
*
|
132
|
+
* @param message - The message to send
|
133
|
+
* @param options - Additional options
|
134
|
+
*/
|
135
|
+
sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;
|
136
|
+
/**
|
137
|
+
* Send a json message to every connection in this group
|
138
|
+
*
|
139
|
+
* @param message - The message to send
|
140
|
+
* @param options - Additional options
|
141
|
+
*/
|
142
|
+
sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;
|
143
|
+
/**
|
144
|
+
* Send a binary message to every connection in this group
|
145
|
+
*
|
146
|
+
* @param message - The binary message to send
|
147
|
+
* @param options - Additional options
|
148
|
+
*/
|
149
|
+
sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;
|
150
|
+
}
|
151
|
+
/**
|
152
|
+
* @hidden
|
153
|
+
*/
|
154
|
+
export declare class WebPubSubGroupImpl implements WebPubSubGroup {
|
155
|
+
private client;
|
156
|
+
/**
|
157
|
+
* The name of this group
|
158
|
+
*/
|
159
|
+
readonly groupName: string;
|
160
|
+
/**
|
161
|
+
* The name of the hub this group belongs to
|
162
|
+
*/
|
163
|
+
readonly hubName: string;
|
164
|
+
/**
|
165
|
+
* The Web PubSub API version being used by this client
|
166
|
+
*/
|
167
|
+
readonly apiVersion: string;
|
168
|
+
/**
|
169
|
+
* The Web PubSub endpoint this client is connected to
|
170
|
+
*/
|
171
|
+
endpoint: string;
|
172
|
+
/**
|
173
|
+
* @internal
|
174
|
+
*/
|
175
|
+
constructor(client: GeneratedClient, hubName: string, groupName: string);
|
176
|
+
/**
|
177
|
+
* Add a specific connection to this group
|
178
|
+
*
|
179
|
+
* @param connectionId - The connection id to add to this group
|
180
|
+
* @param options - Additional options
|
181
|
+
*/
|
182
|
+
addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise<void>;
|
183
|
+
/**
|
184
|
+
* Remove a specific connection from this group
|
185
|
+
*
|
186
|
+
* @param connectionId - The connection id to remove from this group
|
187
|
+
* @param options - Additional options
|
188
|
+
*/
|
189
|
+
removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise<void>;
|
190
|
+
/**
|
191
|
+
* Close all connections to this group
|
192
|
+
*
|
193
|
+
* @param options - Additional options
|
194
|
+
*/
|
195
|
+
closeAllConnections(options?: GroupCloseAllConnectionsOptions): Promise<void>;
|
196
|
+
/**
|
197
|
+
* Add a user to this group
|
198
|
+
*
|
199
|
+
* @param username - The user name to add
|
200
|
+
* @param options - Additional options
|
201
|
+
*/
|
202
|
+
addUser(username: string, options?: GroupAddUserOptions): Promise<void>;
|
203
|
+
/**
|
204
|
+
* Remove a user from this group
|
205
|
+
*
|
206
|
+
* @param username - The user name to remove
|
207
|
+
* @param options - Additional options
|
208
|
+
*/
|
209
|
+
removeUser(username: string, options?: GroupRemoveUserOptions): Promise<void>;
|
210
|
+
/**
|
211
|
+
* Send a text message to every connection in this group
|
212
|
+
*
|
213
|
+
* @param message - The message to send
|
214
|
+
* @param options - Additional options
|
215
|
+
*/
|
216
|
+
sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;
|
217
|
+
/**
|
218
|
+
* Send a json message to every connection in this group
|
219
|
+
*
|
220
|
+
* @param message - The message to send
|
221
|
+
* @param options - Additional options
|
222
|
+
*/
|
223
|
+
sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;
|
224
|
+
/**
|
225
|
+
* Send a binary message to every connection in this group
|
226
|
+
*
|
227
|
+
* @param message - The binary message to send
|
228
|
+
* @param options - Additional options
|
229
|
+
*/
|
230
|
+
sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;
|
231
|
+
}
|
232
|
+
//# sourceMappingURL=groupClient.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"groupClient.d.ts","sourceRoot":"","sources":["../../src/groupClient.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,mBAAmB,EAEnB,gBAAgB,EACjB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAEjE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AAGtE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,mBAAmB;CAAG;AAEvE;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,gBAAgB;CAAG;AAEtE;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;CAAG;AAEhE;;GAEG;AACH,MAAM,WAAW,mBAAoB,SAAQ,gBAAgB;CAAG;AAEhE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,gBAAgB;CAAG;AAEnE;;GAEG;AACH,MAAM,WAAW,4BAA6B,SAAQ,gBAAgB;CAAG;AAEzE;;GAEG;AACH,MAAM,WAAW,qBAAsB,SAAQ,gBAAgB;IAC7D;;OAEG;IACH,mBAAmB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC/B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,MAAM,CA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AI,CAAC;IAC1F;;;;;OAKG;IACU,SAAS,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;IAC1F;;;;;OAKG;IACU,SAAS,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,CAAC,EAAE,qBAAqB,GAAG,OAAO,CAAC,IAAI,CAAC;CAiBjG"}
|
@@ -0,0 +1,101 @@
|
|
1
|
+
"use strict";
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
3
|
+
// Licensed under the MIT License.
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
5
|
+
exports.WebPubSubGroupImpl = void 0;
|
6
|
+
const core_rest_pipeline_1 = require("@azure/core-rest-pipeline");
|
7
|
+
const tracing_js_1 = require("./tracing.js");
|
8
|
+
const utils_js_1 = require("./utils.js");
|
9
|
+
/**
|
10
|
+
* @hidden
|
11
|
+
*/
|
12
|
+
class WebPubSubGroupImpl {
|
13
|
+
/**
|
14
|
+
* @internal
|
15
|
+
*/
|
16
|
+
constructor(client, hubName, groupName) {
|
17
|
+
/**
|
18
|
+
* The Web PubSub API version being used by this client
|
19
|
+
*/
|
20
|
+
this.apiVersion = "2020-10-01";
|
21
|
+
this.client = client;
|
22
|
+
this.groupName = groupName;
|
23
|
+
this.hubName = hubName;
|
24
|
+
}
|
25
|
+
/**
|
26
|
+
* Add a specific connection to this group
|
27
|
+
*
|
28
|
+
* @param connectionId - The connection id to add to this group
|
29
|
+
* @param options - Additional options
|
30
|
+
*/
|
31
|
+
async addConnection(connectionId, options = {}) {
|
32
|
+
let response;
|
33
|
+
function onResponse(rawResponse, flatResponse) {
|
34
|
+
response = rawResponse;
|
35
|
+
if (options.onResponse) {
|
36
|
+
options.onResponse(rawResponse, flatResponse);
|
37
|
+
}
|
38
|
+
}
|
39
|
+
return tracing_js_1.tracingClient.withSpan("WebPubSubGroupClient.addConnection", options, async (updatedOptions) => {
|
40
|
+
await this.client.webPubSub.addConnectionToGroup(this.hubName, this.groupName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
41
|
+
if (response.status === 404) {
|
42
|
+
throw new core_rest_pipeline_1.RestError(`Connection id '${connectionId}' doesn't exist`, {
|
43
|
+
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
44
|
+
request: response === null || response === void 0 ? void 0 : response.request,
|
45
|
+
response: response,
|
46
|
+
});
|
47
|
+
}
|
48
|
+
});
|
49
|
+
}
|
50
|
+
/**
|
51
|
+
* Remove a specific connection from this group
|
52
|
+
*
|
53
|
+
* @param connectionId - The connection id to remove from this group
|
54
|
+
* @param options - Additional options
|
55
|
+
*/
|
56
|
+
async removeConnection(connectionId, options = {}) {
|
57
|
+
return tracing_js_1.tracingClient.withSpan("WebPubSubGroupClient.removeConnection", options, (updatedOptions) => {
|
58
|
+
return this.client.webPubSub.removeConnectionFromGroup(this.hubName, this.groupName, connectionId, updatedOptions);
|
59
|
+
});
|
60
|
+
}
|
61
|
+
/**
|
62
|
+
* Close all connections to this group
|
63
|
+
*
|
64
|
+
* @param options - Additional options
|
65
|
+
*/
|
66
|
+
async closeAllConnections(options = {}) {
|
67
|
+
return tracing_js_1.tracingClient.withSpan("WebPubSubGroupClient.closeAllConnections", options, (updatedOptions) => {
|
68
|
+
return this.client.webPubSub.closeGroupConnections(this.hubName, this.groupName, updatedOptions);
|
69
|
+
});
|
70
|
+
}
|
71
|
+
/**
|
72
|
+
* Add a user to this group
|
73
|
+
*
|
74
|
+
* @param username - The user name to add
|
75
|
+
* @param options - Additional options
|
76
|
+
*/
|
77
|
+
async addUser(username, options = {}) {
|
78
|
+
return tracing_js_1.tracingClient.withSpan("WebPubSubGroupClient.addUser", options, (updatedOptions) => {
|
79
|
+
return this.client.webPubSub.addUserToGroup(this.hubName, this.groupName, username, updatedOptions);
|
80
|
+
});
|
81
|
+
}
|
82
|
+
/**
|
83
|
+
* Remove a user from this group
|
84
|
+
*
|
85
|
+
* @param username - The user name to remove
|
86
|
+
* @param options - Additional options
|
87
|
+
*/
|
88
|
+
async removeUser(username, options = {}) {
|
89
|
+
return tracing_js_1.tracingClient.withSpan("WebPubSubGroupClient.removeUser", options, (updatedOptions) => {
|
90
|
+
return this.client.webPubSub.removeUserFromGroup(this.hubName, this.groupName, username, updatedOptions);
|
91
|
+
});
|
92
|
+
}
|
93
|
+
async sendToAll(message, options = {}) {
|
94
|
+
return tracing_js_1.tracingClient.withSpan("WebPubSubGroupClient.sendToAll", options, (updatedOptions) => {
|
95
|
+
const { contentType, payload } = (0, utils_js_1.getPayloadForMessage)(message, updatedOptions);
|
96
|
+
return this.client.webPubSub.sendToGroup(this.hubName, this.groupName, contentType, payload, updatedOptions);
|
97
|
+
});
|
98
|
+
}
|
99
|
+
}
|
100
|
+
exports.WebPubSubGroupImpl = WebPubSubGroupImpl;
|
101
|
+
//# sourceMappingURL=groupClient.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"groupClient.js","sourceRoot":"","sources":["../../src/groupClient.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAQlC,kEAAsD;AAEtD,6CAA6C;AAC7C,yCAAkD;AAkKlD;;GAEG;AACH,MAAa,kBAAkB;IAuB7B;;OAEG;IACH,YAAY,MAAuB,EAAE,OAAe,EAAE,SAAiB;QAbvE;;WAEG;QACa,eAAU,GAAW,YAAY,CAAC;QAWhD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IACD;;;;;OAKG;IACI,KAAK,CAAC,aAAa,CACxB,YAAoB,EACpB,UAAqC,EAAE;QAEvC,IAAI,QAA2C,CAAC;QAChD,SAAS,UAAU,CAAC,WAAkC,EAAE,YAAqB;YAC3E,QAAQ,GAAG,WAAW,CAAC;YACvB,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;gBACvB,OAAO,CAA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ed under the MIT License.\n\nimport type {\n CommonClientOptions,\n FullOperationResponse,\n OperationOptions,\n} from \"@azure/core-client\";\nimport type { RequestBodyType } from \"@azure/core-rest-pipeline\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport type { GeneratedClient } from \"./generated/generatedClient.js\";\nimport { tracingClient } from \"./tracing.js\";\nimport { getPayloadForMessage } from \"./utils.js\";\nimport type { JSONTypes } from \"./hubClient.js\";\n\n/**\n * Options for constructing a GroupAdmin client.\n */\nexport interface GroupAdminClientOptions extends CommonClientOptions {}\n\n/**\n * Options for adding a connection to a group.\n */\nexport interface GroupAddConnectionOptions extends OperationOptions {}\n\n/**\n * Options for adding a user to a group.\n */\nexport interface GroupAddUserOptions extends OperationOptions {}\n\n/**\n * Options for checking if a user is in a group\n */\nexport interface GroupHasUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a user from a group\n */\nexport interface GroupRemoveUserOptions extends OperationOptions {}\n\n/**\n * Options for removing a connection from a group\n */\nexport interface GroupRemoveConnectionOptions extends OperationOptions {}\n\n/**\n * Options for sending messages to a group.\n */\nexport interface GroupSendToAllOptions extends OperationOptions {\n /**\n * Connection ids to exclude from receiving this message.\n */\n excludedConnections?: string[];\n /**\n * The filter syntax to filter out the connections to send the messages to following OData filter syntax.\n * Examples:\n * * Exclude connections from `user1` and `user2`: `userId ne 'user1' and userId ne 'user2'`\n * * Exclude connections in `group1`: `not('group1' in groups)`\n * Details about `filter` syntax please see [OData filter syntax for Azure Web PubSub](https://aka.ms/awps/filter-syntax).\n */\n filter?: string;\n /**\n * The time-to-live (TTL) value in seconds for messages sent to the service.\n * 0 is the default value, which means the message never expires.\n * 300 is the maximum value.\n * If this parameter is non-zero, messages that are not consumed by the client within the specified TTL will be dropped by the service.\n * This parameter can help when the client's bandwidth is limited.\n */\n messageTtlSeconds?: number;\n}\n\n/**\n * Options for sending text messages to a group..\n */\nexport interface GroupSendTextToAllOptions extends GroupSendToAllOptions {\n /**\n * The content will be sent to the clients in plain text.\n */\n contentType: \"text/plain\";\n}\n\n/**\n * Options for closing all connections to a group.\n */\nexport interface GroupCloseAllConnectionsOptions extends OperationOptions {\n /**\n * Reason the connection is being closed.\n */\n reason?: string;\n}\n\nexport interface WebPubSubGroup {\n /**\n * The name of this group\n */\n readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n readonly apiVersion: string;\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n readonly endpoint: string;\n\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n addConnection(connectionId: string, options?: GroupAddConnectionOptions): Promise<void>;\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n removeConnection(connectionId: string, options?: GroupRemoveConnectionOptions): Promise<void>;\n\n /**\n * Close all connections to the group\n *\n * @param options - Additional options\n */\n closeAllConnections(options?: GroupCloseAllConnectionsOptions): Promise<void>;\n\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n addUser(username: string, options?: GroupAddUserOptions): Promise<void>;\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n removeUser(username: string, options?: GroupRemoveUserOptions): Promise<void>;\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n}\n\n/**\n * @hidden\n */\nexport class WebPubSubGroupImpl implements WebPubSubGroup {\n private client!: GeneratedClient;\n\n /**\n * The name of this group\n */\n public readonly groupName: string;\n\n /**\n * The name of the hub this group belongs to\n */\n public readonly hubName: string;\n\n /**\n * The Web PubSub API version being used by this client\n */\n public readonly apiVersion: string = \"2020-10-01\";\n\n /**\n * The Web PubSub endpoint this client is connected to\n */\n public endpoint!: string;\n\n /**\n * @internal\n */\n constructor(client: GeneratedClient, hubName: string, groupName: string) {\n this.client = client;\n this.groupName = groupName;\n this.hubName = hubName;\n }\n /**\n * Add a specific connection to this group\n *\n * @param connectionId - The connection id to add to this group\n * @param options - Additional options\n */\n public async addConnection(\n connectionId: string,\n options: GroupAddConnectionOptions = {},\n ): Promise<void> {\n let response: FullOperationResponse | undefined;\n function onResponse(rawResponse: FullOperationResponse, flatResponse: unknown): void {\n response = rawResponse;\n if (options.onResponse) {\n options.onResponse(rawResponse, flatResponse);\n }\n }\n\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.addConnection\",\n options,\n async (updatedOptions) => {\n await this.client.webPubSub.addConnectionToGroup(\n this.hubName,\n this.groupName,\n connectionId,\n {\n ...updatedOptions,\n onResponse,\n },\n );\n\n if (response!.status === 404) {\n throw new RestError(`Connection id '${connectionId}' doesn't exist`, {\n statusCode: response?.status,\n request: response?.request,\n response: response,\n });\n }\n },\n );\n }\n\n /**\n * Remove a specific connection from this group\n *\n * @param connectionId - The connection id to remove from this group\n * @param options - Additional options\n */\n public async removeConnection(\n connectionId: string,\n options: GroupRemoveConnectionOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.removeConnection\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.removeConnectionFromGroup(\n this.hubName,\n this.groupName,\n connectionId,\n updatedOptions,\n );\n },\n );\n }\n\n /**\n * Close all connections to this group\n *\n * @param options - Additional options\n */\n public async closeAllConnections(options: GroupCloseAllConnectionsOptions = {}): Promise<void> {\n return tracingClient.withSpan(\n \"WebPubSubGroupClient.closeAllConnections\",\n options,\n (updatedOptions) => {\n return this.client.webPubSub.closeGroupConnections(\n this.hubName,\n this.groupName,\n updatedOptions,\n );\n },\n );\n }\n /**\n * Add a user to this group\n *\n * @param username - The user name to add\n * @param options - Additional options\n */\n public async addUser(username: string, options: GroupAddUserOptions = {}): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.addUser\", options, (updatedOptions) => {\n return this.client.webPubSub.addUserToGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions,\n );\n });\n }\n\n /**\n * Remove a user from this group\n *\n * @param username - The user name to remove\n * @param options - Additional options\n */\n public async removeUser(username: string, options: GroupRemoveUserOptions = {}): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.removeUser\", options, (updatedOptions) => {\n return this.client.webPubSub.removeUserFromGroup(\n this.hubName,\n this.groupName,\n username,\n updatedOptions,\n );\n });\n }\n\n /**\n * Send a text message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: string, options: GroupSendTextToAllOptions): Promise<void>;\n /**\n * Send a json message to every connection in this group\n *\n * @param message - The message to send\n * @param options - Additional options\n */\n public async sendToAll(message: JSONTypes, options?: GroupSendToAllOptions): Promise<void>;\n /**\n * Send a binary message to every connection in this group\n *\n * @param message - The binary message to send\n * @param options - Additional options\n */\n public async sendToAll(message: RequestBodyType, options?: GroupSendToAllOptions): Promise<void>;\n\n public async sendToAll(\n message: JSONTypes | RequestBodyType,\n options: GroupSendToAllOptions | GroupSendTextToAllOptions = {},\n ): Promise<void> {\n return tracingClient.withSpan(\"WebPubSubGroupClient.sendToAll\", options, (updatedOptions) => {\n const { contentType, payload } = getPayloadForMessage(message, updatedOptions);\n return this.client.webPubSub.sendToGroup(\n this.hubName,\n this.groupName,\n contentType,\n payload as any,\n updatedOptions,\n );\n });\n }\n}\n"]}
|