@azure/web-pubsub 1.0.0-beta.3 → 1.0.1-alpha.20220103.2
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +31 -0
- package/README.md +107 -33
- package/dist/index.js +1048 -233
- package/dist/index.js.map +1 -1
- package/dist-esm/samples-dev/directMessage.js +1 -1
- package/dist-esm/samples-dev/directMessage.js.map +1 -1
- package/dist-esm/src/generated/generatedClient.js +3 -3
- package/dist-esm/src/generated/generatedClient.js.map +1 -1
- package/dist-esm/src/generated/generatedClientContext.js +8 -8
- package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
- package/dist-esm/src/generated/models/index.js +6 -1
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +368 -0
- package/dist-esm/src/generated/models/mappers.js.map +1 -0
- package/dist-esm/src/generated/models/parameters.js +105 -23
- package/dist-esm/src/generated/models/parameters.js.map +1 -1
- package/dist-esm/src/generated/operations/healthApi.js +4 -3
- package/dist-esm/src/generated/operations/healthApi.js.map +1 -1
- package/dist-esm/src/generated/operations/webPubSub.js +315 -59
- package/dist-esm/src/generated/operations/webPubSub.js.map +1 -1
- package/dist-esm/src/generated/operationsInterfaces/webPubSub.js.map +1 -1
- package/dist-esm/src/groupClient.js +32 -21
- package/dist-esm/src/groupClient.js.map +1 -1
- package/dist-esm/src/hubClient.js +162 -107
- package/dist-esm/src/hubClient.js.map +1 -1
- package/dist-esm/src/index.js +1 -1
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/logger.js +1 -1
- package/dist-esm/src/logger.js.map +1 -1
- package/dist-esm/src/parseConnectionString.js +3 -1
- package/dist-esm/src/parseConnectionString.js.map +1 -1
- package/dist-esm/src/reverseProxyPolicy.js +21 -0
- package/dist-esm/src/reverseProxyPolicy.js.map +1 -0
- package/dist-esm/src/tracing.js +1 -1
- package/dist-esm/src/tracing.js.map +1 -1
- package/dist-esm/src/utils.js +2 -0
- package/dist-esm/src/utils.js.map +1 -1
- package/dist-esm/src/webPubSubCredentialPolicy.js +2 -2
- package/dist-esm/src/webPubSubCredentialPolicy.js.map +1 -1
- package/dist-esm/test/conn.spec.js +2 -2
- package/dist-esm/test/conn.spec.js.map +1 -1
- package/dist-esm/test/groups.spec.js +14 -6
- package/dist-esm/test/groups.spec.js.map +1 -1
- package/dist-esm/test/hubs.spec.js +53 -10
- package/dist-esm/test/hubs.spec.js.map +1 -1
- package/dist-esm/test/integration.spec.js +128 -0
- package/dist-esm/test/integration.spec.js.map +1 -0
- package/dist-esm/test/testEnv.js +6 -2
- package/dist-esm/test/testEnv.js.map +1 -1
- package/package.json +32 -32
- package/types/web-pubsub.d.ts +165 -109
- package/dist-esm/src/normalizeOptions.js +0 -8
- package/dist-esm/src/normalizeOptions.js.map +0 -1
package/dist/index.js
CHANGED
@@ -8,7 +8,6 @@ var coreAuth = require('@azure/core-auth');
|
|
8
8
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
9
9
|
var coreClient = require('@azure/core-client');
|
10
10
|
var coreTracing = require('@azure/core-tracing');
|
11
|
-
var tslib = require('tslib');
|
12
11
|
var jwt = _interopDefault(require('jsonwebtoken'));
|
13
12
|
var logger$1 = require('@azure/logger');
|
14
13
|
var url = require('url');
|
@@ -20,10 +19,405 @@ var url = require('url');
|
|
20
19
|
* Code generated by Microsoft (R) AutoRest Code Generator.
|
21
20
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
22
21
|
*/
|
23
|
-
const
|
24
|
-
|
22
|
+
const ClientTokenResponse = {
|
23
|
+
type: {
|
24
|
+
name: "Composite",
|
25
|
+
className: "ClientTokenResponse",
|
26
|
+
modelProperties: {
|
27
|
+
token: {
|
28
|
+
serializedName: "token",
|
29
|
+
type: {
|
30
|
+
name: "String"
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
};
|
36
|
+
const ErrorDetail = {
|
37
|
+
type: {
|
38
|
+
name: "Composite",
|
39
|
+
className: "ErrorDetail",
|
40
|
+
modelProperties: {
|
41
|
+
code: {
|
42
|
+
serializedName: "code",
|
43
|
+
type: {
|
44
|
+
name: "String"
|
45
|
+
}
|
46
|
+
},
|
47
|
+
message: {
|
48
|
+
serializedName: "message",
|
49
|
+
type: {
|
50
|
+
name: "String"
|
51
|
+
}
|
52
|
+
},
|
53
|
+
target: {
|
54
|
+
serializedName: "target",
|
55
|
+
type: {
|
56
|
+
name: "String"
|
57
|
+
}
|
58
|
+
},
|
59
|
+
details: {
|
60
|
+
serializedName: "details",
|
61
|
+
type: {
|
62
|
+
name: "Sequence",
|
63
|
+
element: {
|
64
|
+
type: {
|
65
|
+
name: "Composite",
|
66
|
+
className: "ErrorDetail"
|
67
|
+
}
|
68
|
+
}
|
69
|
+
}
|
70
|
+
},
|
71
|
+
inner: {
|
72
|
+
serializedName: "inner",
|
73
|
+
type: {
|
74
|
+
name: "Composite",
|
75
|
+
className: "InnerError"
|
76
|
+
}
|
77
|
+
}
|
78
|
+
}
|
79
|
+
}
|
80
|
+
};
|
81
|
+
const InnerError = {
|
82
|
+
type: {
|
83
|
+
name: "Composite",
|
84
|
+
className: "InnerError",
|
85
|
+
modelProperties: {
|
86
|
+
code: {
|
87
|
+
serializedName: "code",
|
88
|
+
type: {
|
89
|
+
name: "String"
|
90
|
+
}
|
91
|
+
},
|
92
|
+
inner: {
|
93
|
+
serializedName: "inner",
|
94
|
+
type: {
|
95
|
+
name: "Composite",
|
96
|
+
className: "InnerError"
|
97
|
+
}
|
98
|
+
}
|
99
|
+
}
|
100
|
+
}
|
101
|
+
};
|
102
|
+
const WebPubSubGenerateClientTokenExceptionHeaders = {
|
103
|
+
type: {
|
104
|
+
name: "Composite",
|
105
|
+
className: "WebPubSubGenerateClientTokenExceptionHeaders",
|
106
|
+
modelProperties: {
|
107
|
+
errorCode: {
|
108
|
+
serializedName: "x-ms-error-code",
|
109
|
+
type: {
|
110
|
+
name: "String"
|
111
|
+
}
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
};
|
116
|
+
const WebPubSubCloseAllConnectionsExceptionHeaders = {
|
117
|
+
type: {
|
118
|
+
name: "Composite",
|
119
|
+
className: "WebPubSubCloseAllConnectionsExceptionHeaders",
|
120
|
+
modelProperties: {
|
121
|
+
errorCode: {
|
122
|
+
serializedName: "x-ms-error-code",
|
123
|
+
type: {
|
124
|
+
name: "String"
|
125
|
+
}
|
126
|
+
}
|
127
|
+
}
|
128
|
+
}
|
129
|
+
};
|
130
|
+
const WebPubSubSendToAllExceptionHeaders = {
|
131
|
+
type: {
|
132
|
+
name: "Composite",
|
133
|
+
className: "WebPubSubSendToAllExceptionHeaders",
|
134
|
+
modelProperties: {
|
135
|
+
errorCode: {
|
136
|
+
serializedName: "x-ms-error-code",
|
137
|
+
type: {
|
138
|
+
name: "String"
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
}
|
143
|
+
};
|
144
|
+
const WebPubSubConnectionExistsExceptionHeaders = {
|
145
|
+
type: {
|
146
|
+
name: "Composite",
|
147
|
+
className: "WebPubSubConnectionExistsExceptionHeaders",
|
148
|
+
modelProperties: {
|
149
|
+
errorCode: {
|
150
|
+
serializedName: "x-ms-error-code",
|
151
|
+
type: {
|
152
|
+
name: "String"
|
153
|
+
}
|
154
|
+
}
|
155
|
+
}
|
156
|
+
}
|
157
|
+
};
|
158
|
+
const WebPubSubCloseConnectionExceptionHeaders = {
|
159
|
+
type: {
|
160
|
+
name: "Composite",
|
161
|
+
className: "WebPubSubCloseConnectionExceptionHeaders",
|
162
|
+
modelProperties: {
|
163
|
+
errorCode: {
|
164
|
+
serializedName: "x-ms-error-code",
|
165
|
+
type: {
|
166
|
+
name: "String"
|
167
|
+
}
|
168
|
+
}
|
169
|
+
}
|
170
|
+
}
|
171
|
+
};
|
172
|
+
const WebPubSubSendToConnectionExceptionHeaders = {
|
173
|
+
type: {
|
174
|
+
name: "Composite",
|
175
|
+
className: "WebPubSubSendToConnectionExceptionHeaders",
|
176
|
+
modelProperties: {
|
177
|
+
errorCode: {
|
178
|
+
serializedName: "x-ms-error-code",
|
179
|
+
type: {
|
180
|
+
name: "String"
|
181
|
+
}
|
182
|
+
}
|
183
|
+
}
|
184
|
+
}
|
185
|
+
};
|
186
|
+
const WebPubSubGroupExistsExceptionHeaders = {
|
187
|
+
type: {
|
188
|
+
name: "Composite",
|
189
|
+
className: "WebPubSubGroupExistsExceptionHeaders",
|
190
|
+
modelProperties: {
|
191
|
+
errorCode: {
|
192
|
+
serializedName: "x-ms-error-code",
|
193
|
+
type: {
|
194
|
+
name: "String"
|
195
|
+
}
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}
|
199
|
+
};
|
200
|
+
const WebPubSubCloseGroupConnectionsExceptionHeaders = {
|
201
|
+
type: {
|
202
|
+
name: "Composite",
|
203
|
+
className: "WebPubSubCloseGroupConnectionsExceptionHeaders",
|
204
|
+
modelProperties: {
|
205
|
+
errorCode: {
|
206
|
+
serializedName: "x-ms-error-code",
|
207
|
+
type: {
|
208
|
+
name: "String"
|
209
|
+
}
|
210
|
+
}
|
211
|
+
}
|
212
|
+
}
|
213
|
+
};
|
214
|
+
const WebPubSubSendToGroupExceptionHeaders = {
|
215
|
+
type: {
|
216
|
+
name: "Composite",
|
217
|
+
className: "WebPubSubSendToGroupExceptionHeaders",
|
218
|
+
modelProperties: {
|
219
|
+
errorCode: {
|
220
|
+
serializedName: "x-ms-error-code",
|
221
|
+
type: {
|
222
|
+
name: "String"
|
223
|
+
}
|
224
|
+
}
|
225
|
+
}
|
226
|
+
}
|
227
|
+
};
|
228
|
+
const WebPubSubAddConnectionToGroupExceptionHeaders = {
|
229
|
+
type: {
|
230
|
+
name: "Composite",
|
231
|
+
className: "WebPubSubAddConnectionToGroupExceptionHeaders",
|
232
|
+
modelProperties: {
|
233
|
+
errorCode: {
|
234
|
+
serializedName: "x-ms-error-code",
|
235
|
+
type: {
|
236
|
+
name: "String"
|
237
|
+
}
|
238
|
+
}
|
239
|
+
}
|
240
|
+
}
|
241
|
+
};
|
242
|
+
const WebPubSubRemoveConnectionFromGroupExceptionHeaders = {
|
243
|
+
type: {
|
244
|
+
name: "Composite",
|
245
|
+
className: "WebPubSubRemoveConnectionFromGroupExceptionHeaders",
|
246
|
+
modelProperties: {
|
247
|
+
errorCode: {
|
248
|
+
serializedName: "x-ms-error-code",
|
249
|
+
type: {
|
250
|
+
name: "String"
|
251
|
+
}
|
252
|
+
}
|
253
|
+
}
|
254
|
+
}
|
255
|
+
};
|
256
|
+
const WebPubSubUserExistsExceptionHeaders = {
|
257
|
+
type: {
|
258
|
+
name: "Composite",
|
259
|
+
className: "WebPubSubUserExistsExceptionHeaders",
|
260
|
+
modelProperties: {
|
261
|
+
errorCode: {
|
262
|
+
serializedName: "x-ms-error-code",
|
263
|
+
type: {
|
264
|
+
name: "String"
|
265
|
+
}
|
266
|
+
}
|
267
|
+
}
|
268
|
+
}
|
269
|
+
};
|
270
|
+
const WebPubSubCloseUserConnectionsExceptionHeaders = {
|
271
|
+
type: {
|
272
|
+
name: "Composite",
|
273
|
+
className: "WebPubSubCloseUserConnectionsExceptionHeaders",
|
274
|
+
modelProperties: {
|
275
|
+
errorCode: {
|
276
|
+
serializedName: "x-ms-error-code",
|
277
|
+
type: {
|
278
|
+
name: "String"
|
279
|
+
}
|
280
|
+
}
|
281
|
+
}
|
282
|
+
}
|
283
|
+
};
|
284
|
+
const WebPubSubSendToUserExceptionHeaders = {
|
285
|
+
type: {
|
286
|
+
name: "Composite",
|
287
|
+
className: "WebPubSubSendToUserExceptionHeaders",
|
288
|
+
modelProperties: {
|
289
|
+
errorCode: {
|
290
|
+
serializedName: "x-ms-error-code",
|
291
|
+
type: {
|
292
|
+
name: "String"
|
293
|
+
}
|
294
|
+
}
|
295
|
+
}
|
296
|
+
}
|
297
|
+
};
|
298
|
+
const WebPubSubAddUserToGroupExceptionHeaders = {
|
299
|
+
type: {
|
300
|
+
name: "Composite",
|
301
|
+
className: "WebPubSubAddUserToGroupExceptionHeaders",
|
302
|
+
modelProperties: {
|
303
|
+
errorCode: {
|
304
|
+
serializedName: "x-ms-error-code",
|
305
|
+
type: {
|
306
|
+
name: "String"
|
307
|
+
}
|
308
|
+
}
|
309
|
+
}
|
310
|
+
}
|
311
|
+
};
|
312
|
+
const WebPubSubRemoveUserFromGroupExceptionHeaders = {
|
313
|
+
type: {
|
314
|
+
name: "Composite",
|
315
|
+
className: "WebPubSubRemoveUserFromGroupExceptionHeaders",
|
316
|
+
modelProperties: {
|
317
|
+
errorCode: {
|
318
|
+
serializedName: "x-ms-error-code",
|
319
|
+
type: {
|
320
|
+
name: "String"
|
321
|
+
}
|
322
|
+
}
|
323
|
+
}
|
324
|
+
}
|
325
|
+
};
|
326
|
+
const WebPubSubRemoveUserFromAllGroupsExceptionHeaders = {
|
327
|
+
type: {
|
328
|
+
name: "Composite",
|
329
|
+
className: "WebPubSubRemoveUserFromAllGroupsExceptionHeaders",
|
330
|
+
modelProperties: {
|
331
|
+
errorCode: {
|
332
|
+
serializedName: "x-ms-error-code",
|
333
|
+
type: {
|
334
|
+
name: "String"
|
335
|
+
}
|
336
|
+
}
|
337
|
+
}
|
338
|
+
}
|
339
|
+
};
|
340
|
+
const WebPubSubGrantPermissionExceptionHeaders = {
|
341
|
+
type: {
|
342
|
+
name: "Composite",
|
343
|
+
className: "WebPubSubGrantPermissionExceptionHeaders",
|
344
|
+
modelProperties: {
|
345
|
+
errorCode: {
|
346
|
+
serializedName: "x-ms-error-code",
|
347
|
+
type: {
|
348
|
+
name: "String"
|
349
|
+
}
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
};
|
354
|
+
const WebPubSubRevokePermissionExceptionHeaders = {
|
355
|
+
type: {
|
356
|
+
name: "Composite",
|
357
|
+
className: "WebPubSubRevokePermissionExceptionHeaders",
|
358
|
+
modelProperties: {
|
359
|
+
errorCode: {
|
360
|
+
serializedName: "x-ms-error-code",
|
361
|
+
type: {
|
362
|
+
name: "String"
|
363
|
+
}
|
364
|
+
}
|
365
|
+
}
|
366
|
+
}
|
367
|
+
};
|
368
|
+
const WebPubSubCheckPermissionExceptionHeaders = {
|
369
|
+
type: {
|
370
|
+
name: "Composite",
|
371
|
+
className: "WebPubSubCheckPermissionExceptionHeaders",
|
372
|
+
modelProperties: {
|
373
|
+
errorCode: {
|
374
|
+
serializedName: "x-ms-error-code",
|
375
|
+
type: {
|
376
|
+
name: "String"
|
377
|
+
}
|
378
|
+
}
|
379
|
+
}
|
380
|
+
}
|
381
|
+
};
|
382
|
+
|
383
|
+
var Mappers = /*#__PURE__*/Object.freeze({
|
384
|
+
__proto__: null,
|
385
|
+
ClientTokenResponse: ClientTokenResponse,
|
386
|
+
ErrorDetail: ErrorDetail,
|
387
|
+
InnerError: InnerError,
|
388
|
+
WebPubSubGenerateClientTokenExceptionHeaders: WebPubSubGenerateClientTokenExceptionHeaders,
|
389
|
+
WebPubSubCloseAllConnectionsExceptionHeaders: WebPubSubCloseAllConnectionsExceptionHeaders,
|
390
|
+
WebPubSubSendToAllExceptionHeaders: WebPubSubSendToAllExceptionHeaders,
|
391
|
+
WebPubSubConnectionExistsExceptionHeaders: WebPubSubConnectionExistsExceptionHeaders,
|
392
|
+
WebPubSubCloseConnectionExceptionHeaders: WebPubSubCloseConnectionExceptionHeaders,
|
393
|
+
WebPubSubSendToConnectionExceptionHeaders: WebPubSubSendToConnectionExceptionHeaders,
|
394
|
+
WebPubSubGroupExistsExceptionHeaders: WebPubSubGroupExistsExceptionHeaders,
|
395
|
+
WebPubSubCloseGroupConnectionsExceptionHeaders: WebPubSubCloseGroupConnectionsExceptionHeaders,
|
396
|
+
WebPubSubSendToGroupExceptionHeaders: WebPubSubSendToGroupExceptionHeaders,
|
397
|
+
WebPubSubAddConnectionToGroupExceptionHeaders: WebPubSubAddConnectionToGroupExceptionHeaders,
|
398
|
+
WebPubSubRemoveConnectionFromGroupExceptionHeaders: WebPubSubRemoveConnectionFromGroupExceptionHeaders,
|
399
|
+
WebPubSubUserExistsExceptionHeaders: WebPubSubUserExistsExceptionHeaders,
|
400
|
+
WebPubSubCloseUserConnectionsExceptionHeaders: WebPubSubCloseUserConnectionsExceptionHeaders,
|
401
|
+
WebPubSubSendToUserExceptionHeaders: WebPubSubSendToUserExceptionHeaders,
|
402
|
+
WebPubSubAddUserToGroupExceptionHeaders: WebPubSubAddUserToGroupExceptionHeaders,
|
403
|
+
WebPubSubRemoveUserFromGroupExceptionHeaders: WebPubSubRemoveUserFromGroupExceptionHeaders,
|
404
|
+
WebPubSubRemoveUserFromAllGroupsExceptionHeaders: WebPubSubRemoveUserFromAllGroupsExceptionHeaders,
|
405
|
+
WebPubSubGrantPermissionExceptionHeaders: WebPubSubGrantPermissionExceptionHeaders,
|
406
|
+
WebPubSubRevokePermissionExceptionHeaders: WebPubSubRevokePermissionExceptionHeaders,
|
407
|
+
WebPubSubCheckPermissionExceptionHeaders: WebPubSubCheckPermissionExceptionHeaders
|
408
|
+
});
|
409
|
+
|
410
|
+
/*
|
411
|
+
* Copyright (c) Microsoft Corporation.
|
412
|
+
* Licensed under the MIT License.
|
413
|
+
*
|
414
|
+
* Code generated by Microsoft (R) AutoRest Code Generator.
|
415
|
+
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
416
|
+
*/
|
417
|
+
const endpoint = {
|
418
|
+
parameterPath: "endpoint",
|
25
419
|
mapper: {
|
26
|
-
serializedName: "
|
420
|
+
serializedName: "Endpoint",
|
27
421
|
required: true,
|
28
422
|
type: {
|
29
423
|
name: "String"
|
@@ -34,7 +428,7 @@ const $host = {
|
|
34
428
|
const apiVersion = {
|
35
429
|
parameterPath: "apiVersion",
|
36
430
|
mapper: {
|
37
|
-
defaultValue: "2021-
|
431
|
+
defaultValue: "2021-10-01",
|
38
432
|
isConstant: true,
|
39
433
|
serializedName: "api-version",
|
40
434
|
type: {
|
@@ -42,6 +436,88 @@ const apiVersion = {
|
|
42
436
|
}
|
43
437
|
}
|
44
438
|
};
|
439
|
+
const accept = {
|
440
|
+
parameterPath: "accept",
|
441
|
+
mapper: {
|
442
|
+
defaultValue: "application/json, text/json",
|
443
|
+
isConstant: true,
|
444
|
+
serializedName: "Accept",
|
445
|
+
type: {
|
446
|
+
name: "String"
|
447
|
+
}
|
448
|
+
}
|
449
|
+
};
|
450
|
+
const hub = {
|
451
|
+
parameterPath: "hub",
|
452
|
+
mapper: {
|
453
|
+
constraints: {
|
454
|
+
Pattern: new RegExp("^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$")
|
455
|
+
},
|
456
|
+
serializedName: "hub",
|
457
|
+
required: true,
|
458
|
+
type: {
|
459
|
+
name: "String"
|
460
|
+
}
|
461
|
+
}
|
462
|
+
};
|
463
|
+
const userId = {
|
464
|
+
parameterPath: ["options", "userId"],
|
465
|
+
mapper: {
|
466
|
+
serializedName: "userId",
|
467
|
+
type: {
|
468
|
+
name: "String"
|
469
|
+
}
|
470
|
+
}
|
471
|
+
};
|
472
|
+
const roles = {
|
473
|
+
parameterPath: ["options", "roles"],
|
474
|
+
mapper: {
|
475
|
+
serializedName: "role",
|
476
|
+
type: {
|
477
|
+
name: "Sequence",
|
478
|
+
element: {
|
479
|
+
type: {
|
480
|
+
name: "String"
|
481
|
+
}
|
482
|
+
}
|
483
|
+
}
|
484
|
+
},
|
485
|
+
collectionFormat: "Multi"
|
486
|
+
};
|
487
|
+
const expirationTimeInMinutes = {
|
488
|
+
parameterPath: ["options", "expirationTimeInMinutes"],
|
489
|
+
mapper: {
|
490
|
+
defaultValue: 60,
|
491
|
+
serializedName: "minutesToExpire",
|
492
|
+
type: {
|
493
|
+
name: "Number"
|
494
|
+
}
|
495
|
+
}
|
496
|
+
};
|
497
|
+
const excluded = {
|
498
|
+
parameterPath: ["options", "excluded"],
|
499
|
+
mapper: {
|
500
|
+
serializedName: "excluded",
|
501
|
+
type: {
|
502
|
+
name: "Sequence",
|
503
|
+
element: {
|
504
|
+
type: {
|
505
|
+
name: "String"
|
506
|
+
}
|
507
|
+
}
|
508
|
+
}
|
509
|
+
},
|
510
|
+
collectionFormat: "Multi"
|
511
|
+
};
|
512
|
+
const reason = {
|
513
|
+
parameterPath: ["options", "reason"],
|
514
|
+
mapper: {
|
515
|
+
serializedName: "reason",
|
516
|
+
type: {
|
517
|
+
name: "String"
|
518
|
+
}
|
519
|
+
}
|
520
|
+
};
|
45
521
|
const contentType = {
|
46
522
|
parameterPath: "contentType",
|
47
523
|
mapper: {
|
@@ -63,6 +539,17 @@ const message = {
|
|
63
539
|
}
|
64
540
|
}
|
65
541
|
};
|
542
|
+
const accept1 = {
|
543
|
+
parameterPath: "accept",
|
544
|
+
mapper: {
|
545
|
+
defaultValue: "application/json, text/json",
|
546
|
+
isConstant: true,
|
547
|
+
serializedName: "Accept",
|
548
|
+
type: {
|
549
|
+
name: "String"
|
550
|
+
}
|
551
|
+
}
|
552
|
+
};
|
66
553
|
const contentType1 = {
|
67
554
|
parameterPath: "contentType",
|
68
555
|
mapper: {
|
@@ -84,21 +571,19 @@ const message1 = {
|
|
84
571
|
}
|
85
572
|
}
|
86
573
|
};
|
87
|
-
const
|
88
|
-
parameterPath: "
|
574
|
+
const accept2 = {
|
575
|
+
parameterPath: "accept",
|
89
576
|
mapper: {
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
serializedName: "hub",
|
94
|
-
required: true,
|
577
|
+
defaultValue: "application/json, text/json",
|
578
|
+
isConstant: true,
|
579
|
+
serializedName: "Accept",
|
95
580
|
type: {
|
96
581
|
name: "String"
|
97
582
|
}
|
98
583
|
}
|
99
584
|
};
|
100
|
-
const
|
101
|
-
parameterPath: ["options", "
|
585
|
+
const excludedConnections = {
|
586
|
+
parameterPath: ["options", "excludedConnections"],
|
102
587
|
mapper: {
|
103
588
|
serializedName: "excluded",
|
104
589
|
type: {
|
@@ -125,15 +610,6 @@ const connectionId = {
|
|
125
610
|
}
|
126
611
|
}
|
127
612
|
};
|
128
|
-
const reason = {
|
129
|
-
parameterPath: ["options", "reason"],
|
130
|
-
mapper: {
|
131
|
-
serializedName: "reason",
|
132
|
-
type: {
|
133
|
-
name: "String"
|
134
|
-
}
|
135
|
-
}
|
136
|
-
};
|
137
613
|
const group = {
|
138
614
|
parameterPath: "group",
|
139
615
|
mapper: {
|
@@ -148,7 +624,7 @@ const group = {
|
|
148
624
|
}
|
149
625
|
}
|
150
626
|
};
|
151
|
-
const
|
627
|
+
const userId1 = {
|
152
628
|
parameterPath: "userId",
|
153
629
|
mapper: {
|
154
630
|
constraints: {
|
@@ -188,7 +664,7 @@ const targetName = {
|
|
188
664
|
* Code generated by Microsoft (R) AutoRest Code Generator.
|
189
665
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
190
666
|
*/
|
191
|
-
/** Class
|
667
|
+
/** Class containing HealthApi operations. */
|
192
668
|
class HealthApiImpl {
|
193
669
|
/**
|
194
670
|
* Initialize a new instance of the class HealthApi class.
|
@@ -206,13 +682,13 @@ class HealthApiImpl {
|
|
206
682
|
}
|
207
683
|
}
|
208
684
|
// Operation Specifications
|
209
|
-
const serializer = coreClient.createSerializer(
|
685
|
+
const serializer = coreClient.createSerializer(Mappers, /* isXml */ false);
|
210
686
|
const getServiceStatusOperationSpec = {
|
211
687
|
path: "/api/health",
|
212
688
|
httpMethod: "HEAD",
|
213
689
|
responses: { 200: {}, default: {} },
|
214
690
|
queryParameters: [apiVersion],
|
215
|
-
urlParameters: [
|
691
|
+
urlParameters: [endpoint],
|
216
692
|
serializer
|
217
693
|
};
|
218
694
|
|
@@ -223,7 +699,7 @@ const getServiceStatusOperationSpec = {
|
|
223
699
|
* Code generated by Microsoft (R) AutoRest Code Generator.
|
224
700
|
* Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
225
701
|
*/
|
226
|
-
/** Class
|
702
|
+
/** Class containing WebPubSub operations. */
|
227
703
|
class WebPubSubImpl {
|
228
704
|
/**
|
229
705
|
* Initialize a new instance of the class WebPubSub class.
|
@@ -232,6 +708,24 @@ class WebPubSubImpl {
|
|
232
708
|
constructor(client) {
|
233
709
|
this.client = client;
|
234
710
|
}
|
711
|
+
/**
|
712
|
+
* Generate token for the client to connect Azure Web PubSub service.
|
713
|
+
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
714
|
+
* alpha-numeric characters or underscore.
|
715
|
+
* @param options The options parameters.
|
716
|
+
*/
|
717
|
+
generateClientToken(hub, options) {
|
718
|
+
return this.client.sendOperationRequest({ hub, options }, generateClientTokenOperationSpec);
|
719
|
+
}
|
720
|
+
/**
|
721
|
+
* Close the connections in the hub.
|
722
|
+
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
723
|
+
* alpha-numeric characters or underscore.
|
724
|
+
* @param options The options parameters.
|
725
|
+
*/
|
726
|
+
closeAllConnections(hub, options) {
|
727
|
+
return this.client.sendOperationRequest({ hub, options }, closeAllConnectionsOperationSpec);
|
728
|
+
}
|
235
729
|
/**
|
236
730
|
* Broadcast content inside request body to all the connected client connections.
|
237
731
|
* @param args Includes all the parameters for this operation.
|
@@ -284,8 +778,8 @@ class WebPubSubImpl {
|
|
284
778
|
* @param connectionId Target connection Id.
|
285
779
|
* @param options The options parameters.
|
286
780
|
*/
|
287
|
-
|
288
|
-
return this.client.sendOperationRequest({ hub, connectionId, options },
|
781
|
+
closeConnection(hub, connectionId, options) {
|
782
|
+
return this.client.sendOperationRequest({ hub, connectionId, options }, closeConnectionOperationSpec);
|
289
783
|
}
|
290
784
|
/**
|
291
785
|
* Send content inside request body to the specific connection.
|
@@ -334,6 +828,16 @@ class WebPubSubImpl {
|
|
334
828
|
groupExists(hub, group, options) {
|
335
829
|
return this.client.sendOperationRequest({ hub, group, options }, groupExistsOperationSpec);
|
336
830
|
}
|
831
|
+
/**
|
832
|
+
* Close connections in the specific group.
|
833
|
+
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
834
|
+
* alpha-numeric characters or underscore.
|
835
|
+
* @param group Target group name, which length should be greater than 0 and less than 1025.
|
836
|
+
* @param options The options parameters.
|
837
|
+
*/
|
838
|
+
closeGroupConnections(hub, group, options) {
|
839
|
+
return this.client.sendOperationRequest({ hub, group, options }, closeGroupConnectionsOperationSpec);
|
840
|
+
}
|
337
841
|
/**
|
338
842
|
* Send content inside request body to a group of connections.
|
339
843
|
* @param args Includes all the parameters for this operation.
|
@@ -403,6 +907,16 @@ class WebPubSubImpl {
|
|
403
907
|
userExists(hub, userId, options) {
|
404
908
|
return this.client.sendOperationRequest({ hub, userId, options }, userExistsOperationSpec);
|
405
909
|
}
|
910
|
+
/**
|
911
|
+
* Close connections for the specific user.
|
912
|
+
* @param hub Target hub name, which should start with alphabetic characters and only contain
|
913
|
+
* alpha-numeric characters or underscore.
|
914
|
+
* @param userId The user Id.
|
915
|
+
* @param options The options parameters.
|
916
|
+
*/
|
917
|
+
closeUserConnections(hub, userId, options) {
|
918
|
+
return this.client.sendOperationRequest({ hub, userId, options }, closeUserConnectionsOperationSpec);
|
919
|
+
}
|
406
920
|
/**
|
407
921
|
* Send content inside request body to the specific user.
|
408
922
|
* @param args Includes all the parameters for this operation.
|
@@ -507,224 +1021,441 @@ class WebPubSubImpl {
|
|
507
1021
|
}
|
508
1022
|
}
|
509
1023
|
// Operation Specifications
|
510
|
-
const serializer$1 = coreClient.createSerializer(
|
1024
|
+
const serializer$1 = coreClient.createSerializer(Mappers, /* isXml */ false);
|
1025
|
+
const generateClientTokenOperationSpec = {
|
1026
|
+
path: "/api/hubs/{hub}/:generateToken",
|
1027
|
+
httpMethod: "POST",
|
1028
|
+
responses: {
|
1029
|
+
200: {
|
1030
|
+
bodyMapper: ClientTokenResponse
|
1031
|
+
},
|
1032
|
+
default: {
|
1033
|
+
bodyMapper: ErrorDetail,
|
1034
|
+
headersMapper: WebPubSubGenerateClientTokenExceptionHeaders
|
1035
|
+
}
|
1036
|
+
},
|
1037
|
+
queryParameters: [
|
1038
|
+
apiVersion,
|
1039
|
+
userId,
|
1040
|
+
roles,
|
1041
|
+
expirationTimeInMinutes
|
1042
|
+
],
|
1043
|
+
urlParameters: [endpoint, hub],
|
1044
|
+
headerParameters: [accept],
|
1045
|
+
serializer: serializer$1
|
1046
|
+
};
|
1047
|
+
const closeAllConnectionsOperationSpec = {
|
1048
|
+
path: "/api/hubs/{hub}/:closeConnections",
|
1049
|
+
httpMethod: "POST",
|
1050
|
+
responses: {
|
1051
|
+
204: {},
|
1052
|
+
default: {
|
1053
|
+
bodyMapper: ErrorDetail,
|
1054
|
+
headersMapper: WebPubSubCloseAllConnectionsExceptionHeaders
|
1055
|
+
}
|
1056
|
+
},
|
1057
|
+
queryParameters: [
|
1058
|
+
apiVersion,
|
1059
|
+
excluded,
|
1060
|
+
reason
|
1061
|
+
],
|
1062
|
+
urlParameters: [endpoint, hub],
|
1063
|
+
headerParameters: [accept],
|
1064
|
+
serializer: serializer$1
|
1065
|
+
};
|
511
1066
|
const sendToAll$binaryOperationSpec = {
|
512
1067
|
path: "/api/hubs/{hub}/:send",
|
513
1068
|
httpMethod: "POST",
|
514
|
-
responses: {
|
1069
|
+
responses: {
|
1070
|
+
202: {},
|
1071
|
+
default: {
|
1072
|
+
bodyMapper: ErrorDetail,
|
1073
|
+
headersMapper: WebPubSubSendToAllExceptionHeaders
|
1074
|
+
}
|
1075
|
+
},
|
515
1076
|
requestBody: message,
|
516
|
-
queryParameters: [apiVersion,
|
517
|
-
urlParameters: [
|
518
|
-
headerParameters: [contentType],
|
1077
|
+
queryParameters: [apiVersion, excludedConnections],
|
1078
|
+
urlParameters: [endpoint, hub],
|
1079
|
+
headerParameters: [contentType, accept1],
|
519
1080
|
mediaType: "binary",
|
520
1081
|
serializer: serializer$1
|
521
1082
|
};
|
522
1083
|
const sendToAll$textOperationSpec = {
|
523
1084
|
path: "/api/hubs/{hub}/:send",
|
524
1085
|
httpMethod: "POST",
|
525
|
-
responses: {
|
1086
|
+
responses: {
|
1087
|
+
202: {},
|
1088
|
+
default: {
|
1089
|
+
bodyMapper: ErrorDetail,
|
1090
|
+
headersMapper: WebPubSubSendToAllExceptionHeaders
|
1091
|
+
}
|
1092
|
+
},
|
526
1093
|
requestBody: message1,
|
527
|
-
queryParameters: [apiVersion,
|
528
|
-
urlParameters: [
|
529
|
-
headerParameters: [contentType1],
|
1094
|
+
queryParameters: [apiVersion, excludedConnections],
|
1095
|
+
urlParameters: [endpoint, hub],
|
1096
|
+
headerParameters: [contentType1, accept2],
|
530
1097
|
mediaType: "text",
|
531
1098
|
serializer: serializer$1
|
532
1099
|
};
|
533
1100
|
const connectionExistsOperationSpec = {
|
534
1101
|
path: "/api/hubs/{hub}/connections/{connectionId}",
|
535
1102
|
httpMethod: "HEAD",
|
536
|
-
responses: {
|
1103
|
+
responses: {
|
1104
|
+
200: {},
|
1105
|
+
404: {},
|
1106
|
+
default: {
|
1107
|
+
bodyMapper: ErrorDetail,
|
1108
|
+
headersMapper: WebPubSubConnectionExistsExceptionHeaders
|
1109
|
+
}
|
1110
|
+
},
|
537
1111
|
queryParameters: [apiVersion],
|
538
|
-
urlParameters: [
|
1112
|
+
urlParameters: [endpoint, hub, connectionId],
|
1113
|
+
headerParameters: [accept],
|
539
1114
|
serializer: serializer$1
|
540
1115
|
};
|
541
|
-
const
|
1116
|
+
const closeConnectionOperationSpec = {
|
542
1117
|
path: "/api/hubs/{hub}/connections/{connectionId}",
|
543
1118
|
httpMethod: "DELETE",
|
544
|
-
responses: {
|
1119
|
+
responses: {
|
1120
|
+
204: {},
|
1121
|
+
default: {
|
1122
|
+
bodyMapper: ErrorDetail,
|
1123
|
+
headersMapper: WebPubSubCloseConnectionExceptionHeaders
|
1124
|
+
}
|
1125
|
+
},
|
545
1126
|
queryParameters: [apiVersion, reason],
|
546
|
-
urlParameters: [
|
1127
|
+
urlParameters: [endpoint, hub, connectionId],
|
1128
|
+
headerParameters: [accept],
|
547
1129
|
serializer: serializer$1
|
548
1130
|
};
|
549
1131
|
const sendToConnection$binaryOperationSpec = {
|
550
1132
|
path: "/api/hubs/{hub}/connections/{connectionId}/:send",
|
551
1133
|
httpMethod: "POST",
|
552
|
-
responses: {
|
1134
|
+
responses: {
|
1135
|
+
202: {},
|
1136
|
+
default: {
|
1137
|
+
bodyMapper: ErrorDetail,
|
1138
|
+
headersMapper: WebPubSubSendToConnectionExceptionHeaders
|
1139
|
+
}
|
1140
|
+
},
|
553
1141
|
requestBody: message,
|
554
1142
|
queryParameters: [apiVersion],
|
555
|
-
urlParameters: [
|
556
|
-
headerParameters: [contentType],
|
1143
|
+
urlParameters: [endpoint, hub, connectionId],
|
1144
|
+
headerParameters: [contentType, accept1],
|
557
1145
|
mediaType: "binary",
|
558
1146
|
serializer: serializer$1
|
559
1147
|
};
|
560
1148
|
const sendToConnection$textOperationSpec = {
|
561
1149
|
path: "/api/hubs/{hub}/connections/{connectionId}/:send",
|
562
1150
|
httpMethod: "POST",
|
563
|
-
responses: {
|
1151
|
+
responses: {
|
1152
|
+
202: {},
|
1153
|
+
default: {
|
1154
|
+
bodyMapper: ErrorDetail,
|
1155
|
+
headersMapper: WebPubSubSendToConnectionExceptionHeaders
|
1156
|
+
}
|
1157
|
+
},
|
564
1158
|
requestBody: message1,
|
565
1159
|
queryParameters: [apiVersion],
|
566
|
-
urlParameters: [
|
567
|
-
headerParameters: [contentType1],
|
1160
|
+
urlParameters: [endpoint, hub, connectionId],
|
1161
|
+
headerParameters: [contentType1, accept2],
|
568
1162
|
mediaType: "text",
|
569
1163
|
serializer: serializer$1
|
570
1164
|
};
|
571
1165
|
const groupExistsOperationSpec = {
|
572
1166
|
path: "/api/hubs/{hub}/groups/{group}",
|
573
1167
|
httpMethod: "HEAD",
|
574
|
-
responses: {
|
1168
|
+
responses: {
|
1169
|
+
200: {},
|
1170
|
+
404: {},
|
1171
|
+
default: {
|
1172
|
+
bodyMapper: ErrorDetail,
|
1173
|
+
headersMapper: WebPubSubGroupExistsExceptionHeaders
|
1174
|
+
}
|
1175
|
+
},
|
575
1176
|
queryParameters: [apiVersion],
|
576
|
-
urlParameters: [
|
1177
|
+
urlParameters: [endpoint, hub, group],
|
1178
|
+
headerParameters: [accept],
|
1179
|
+
serializer: serializer$1
|
1180
|
+
};
|
1181
|
+
const closeGroupConnectionsOperationSpec = {
|
1182
|
+
path: "/api/hubs/{hub}/groups/{group}/:closeConnections",
|
1183
|
+
httpMethod: "POST",
|
1184
|
+
responses: {
|
1185
|
+
204: {},
|
1186
|
+
default: {
|
1187
|
+
bodyMapper: ErrorDetail,
|
1188
|
+
headersMapper: WebPubSubCloseGroupConnectionsExceptionHeaders
|
1189
|
+
}
|
1190
|
+
},
|
1191
|
+
queryParameters: [
|
1192
|
+
apiVersion,
|
1193
|
+
excluded,
|
1194
|
+
reason
|
1195
|
+
],
|
1196
|
+
urlParameters: [endpoint, hub, group],
|
1197
|
+
headerParameters: [accept],
|
577
1198
|
serializer: serializer$1
|
578
1199
|
};
|
579
1200
|
const sendToGroup$binaryOperationSpec = {
|
580
1201
|
path: "/api/hubs/{hub}/groups/{group}/:send",
|
581
1202
|
httpMethod: "POST",
|
582
|
-
responses: {
|
1203
|
+
responses: {
|
1204
|
+
202: {},
|
1205
|
+
default: {
|
1206
|
+
bodyMapper: ErrorDetail,
|
1207
|
+
headersMapper: WebPubSubSendToGroupExceptionHeaders
|
1208
|
+
}
|
1209
|
+
},
|
583
1210
|
requestBody: message,
|
584
|
-
queryParameters: [apiVersion,
|
585
|
-
urlParameters: [
|
586
|
-
headerParameters: [contentType],
|
1211
|
+
queryParameters: [apiVersion, excludedConnections],
|
1212
|
+
urlParameters: [endpoint, hub, group],
|
1213
|
+
headerParameters: [contentType, accept1],
|
587
1214
|
mediaType: "binary",
|
588
1215
|
serializer: serializer$1
|
589
1216
|
};
|
590
1217
|
const sendToGroup$textOperationSpec = {
|
591
1218
|
path: "/api/hubs/{hub}/groups/{group}/:send",
|
592
1219
|
httpMethod: "POST",
|
593
|
-
responses: {
|
1220
|
+
responses: {
|
1221
|
+
202: {},
|
1222
|
+
default: {
|
1223
|
+
bodyMapper: ErrorDetail,
|
1224
|
+
headersMapper: WebPubSubSendToGroupExceptionHeaders
|
1225
|
+
}
|
1226
|
+
},
|
594
1227
|
requestBody: message1,
|
595
|
-
queryParameters: [apiVersion,
|
596
|
-
urlParameters: [
|
597
|
-
headerParameters: [contentType1],
|
1228
|
+
queryParameters: [apiVersion, excludedConnections],
|
1229
|
+
urlParameters: [endpoint, hub, group],
|
1230
|
+
headerParameters: [contentType1, accept2],
|
598
1231
|
mediaType: "text",
|
599
1232
|
serializer: serializer$1
|
600
1233
|
};
|
601
1234
|
const addConnectionToGroupOperationSpec = {
|
602
1235
|
path: "/api/hubs/{hub}/groups/{group}/connections/{connectionId}",
|
603
1236
|
httpMethod: "PUT",
|
604
|
-
responses: {
|
1237
|
+
responses: {
|
1238
|
+
200: {},
|
1239
|
+
404: {},
|
1240
|
+
default: {
|
1241
|
+
bodyMapper: ErrorDetail,
|
1242
|
+
headersMapper: WebPubSubAddConnectionToGroupExceptionHeaders
|
1243
|
+
}
|
1244
|
+
},
|
605
1245
|
queryParameters: [apiVersion],
|
606
1246
|
urlParameters: [
|
607
|
-
|
1247
|
+
endpoint,
|
608
1248
|
hub,
|
609
1249
|
connectionId,
|
610
1250
|
group
|
611
1251
|
],
|
1252
|
+
headerParameters: [accept],
|
612
1253
|
serializer: serializer$1
|
613
1254
|
};
|
614
1255
|
const removeConnectionFromGroupOperationSpec = {
|
615
1256
|
path: "/api/hubs/{hub}/groups/{group}/connections/{connectionId}",
|
616
1257
|
httpMethod: "DELETE",
|
617
|
-
responses: {
|
1258
|
+
responses: {
|
1259
|
+
204: {},
|
1260
|
+
default: {
|
1261
|
+
bodyMapper: ErrorDetail,
|
1262
|
+
headersMapper: WebPubSubRemoveConnectionFromGroupExceptionHeaders
|
1263
|
+
}
|
1264
|
+
},
|
618
1265
|
queryParameters: [apiVersion],
|
619
1266
|
urlParameters: [
|
620
|
-
|
1267
|
+
endpoint,
|
621
1268
|
hub,
|
622
1269
|
connectionId,
|
623
1270
|
group
|
624
1271
|
],
|
1272
|
+
headerParameters: [accept],
|
625
1273
|
serializer: serializer$1
|
626
1274
|
};
|
627
1275
|
const userExistsOperationSpec = {
|
628
1276
|
path: "/api/hubs/{hub}/users/{userId}",
|
629
1277
|
httpMethod: "HEAD",
|
630
|
-
responses: {
|
1278
|
+
responses: {
|
1279
|
+
200: {},
|
1280
|
+
404: {},
|
1281
|
+
default: {
|
1282
|
+
bodyMapper: ErrorDetail,
|
1283
|
+
headersMapper: WebPubSubUserExistsExceptionHeaders
|
1284
|
+
}
|
1285
|
+
},
|
631
1286
|
queryParameters: [apiVersion],
|
632
|
-
urlParameters: [
|
1287
|
+
urlParameters: [endpoint, hub, userId1],
|
1288
|
+
headerParameters: [accept],
|
1289
|
+
serializer: serializer$1
|
1290
|
+
};
|
1291
|
+
const closeUserConnectionsOperationSpec = {
|
1292
|
+
path: "/api/hubs/{hub}/users/{userId}/:closeConnections",
|
1293
|
+
httpMethod: "POST",
|
1294
|
+
responses: {
|
1295
|
+
204: {},
|
1296
|
+
default: {
|
1297
|
+
bodyMapper: ErrorDetail,
|
1298
|
+
headersMapper: WebPubSubCloseUserConnectionsExceptionHeaders
|
1299
|
+
}
|
1300
|
+
},
|
1301
|
+
queryParameters: [
|
1302
|
+
apiVersion,
|
1303
|
+
excluded,
|
1304
|
+
reason
|
1305
|
+
],
|
1306
|
+
urlParameters: [endpoint, hub, userId1],
|
1307
|
+
headerParameters: [accept],
|
633
1308
|
serializer: serializer$1
|
634
1309
|
};
|
635
1310
|
const sendToUser$binaryOperationSpec = {
|
636
1311
|
path: "/api/hubs/{hub}/users/{userId}/:send",
|
637
1312
|
httpMethod: "POST",
|
638
|
-
responses: {
|
1313
|
+
responses: {
|
1314
|
+
202: {},
|
1315
|
+
default: {
|
1316
|
+
bodyMapper: ErrorDetail,
|
1317
|
+
headersMapper: WebPubSubSendToUserExceptionHeaders
|
1318
|
+
}
|
1319
|
+
},
|
639
1320
|
requestBody: message,
|
640
1321
|
queryParameters: [apiVersion],
|
641
|
-
urlParameters: [
|
642
|
-
headerParameters: [contentType],
|
1322
|
+
urlParameters: [endpoint, hub, userId1],
|
1323
|
+
headerParameters: [contentType, accept1],
|
643
1324
|
mediaType: "binary",
|
644
1325
|
serializer: serializer$1
|
645
1326
|
};
|
646
1327
|
const sendToUser$textOperationSpec = {
|
647
1328
|
path: "/api/hubs/{hub}/users/{userId}/:send",
|
648
1329
|
httpMethod: "POST",
|
649
|
-
responses: {
|
1330
|
+
responses: {
|
1331
|
+
202: {},
|
1332
|
+
default: {
|
1333
|
+
bodyMapper: ErrorDetail,
|
1334
|
+
headersMapper: WebPubSubSendToUserExceptionHeaders
|
1335
|
+
}
|
1336
|
+
},
|
650
1337
|
requestBody: message1,
|
651
1338
|
queryParameters: [apiVersion],
|
652
|
-
urlParameters: [
|
653
|
-
headerParameters: [contentType1],
|
1339
|
+
urlParameters: [endpoint, hub, userId1],
|
1340
|
+
headerParameters: [contentType1, accept2],
|
654
1341
|
mediaType: "text",
|
655
1342
|
serializer: serializer$1
|
656
1343
|
};
|
657
1344
|
const addUserToGroupOperationSpec = {
|
658
1345
|
path: "/api/hubs/{hub}/users/{userId}/groups/{group}",
|
659
1346
|
httpMethod: "PUT",
|
660
|
-
responses: {
|
1347
|
+
responses: {
|
1348
|
+
200: {},
|
1349
|
+
404: {},
|
1350
|
+
default: {
|
1351
|
+
bodyMapper: ErrorDetail,
|
1352
|
+
headersMapper: WebPubSubAddUserToGroupExceptionHeaders
|
1353
|
+
}
|
1354
|
+
},
|
661
1355
|
queryParameters: [apiVersion],
|
662
1356
|
urlParameters: [
|
663
|
-
|
1357
|
+
endpoint,
|
664
1358
|
hub,
|
665
1359
|
group,
|
666
|
-
|
1360
|
+
userId1
|
667
1361
|
],
|
1362
|
+
headerParameters: [accept],
|
668
1363
|
serializer: serializer$1
|
669
1364
|
};
|
670
1365
|
const removeUserFromGroupOperationSpec = {
|
671
1366
|
path: "/api/hubs/{hub}/users/{userId}/groups/{group}",
|
672
1367
|
httpMethod: "DELETE",
|
673
|
-
responses: {
|
1368
|
+
responses: {
|
1369
|
+
204: {},
|
1370
|
+
default: {
|
1371
|
+
bodyMapper: ErrorDetail,
|
1372
|
+
headersMapper: WebPubSubRemoveUserFromGroupExceptionHeaders
|
1373
|
+
}
|
1374
|
+
},
|
674
1375
|
queryParameters: [apiVersion],
|
675
1376
|
urlParameters: [
|
676
|
-
|
1377
|
+
endpoint,
|
677
1378
|
hub,
|
678
1379
|
group,
|
679
|
-
|
1380
|
+
userId1
|
680
1381
|
],
|
1382
|
+
headerParameters: [accept],
|
681
1383
|
serializer: serializer$1
|
682
1384
|
};
|
683
1385
|
const removeUserFromAllGroupsOperationSpec = {
|
684
1386
|
path: "/api/hubs/{hub}/users/{userId}/groups",
|
685
1387
|
httpMethod: "DELETE",
|
686
|
-
responses: {
|
1388
|
+
responses: {
|
1389
|
+
204: {},
|
1390
|
+
default: {
|
1391
|
+
bodyMapper: ErrorDetail,
|
1392
|
+
headersMapper: WebPubSubRemoveUserFromAllGroupsExceptionHeaders
|
1393
|
+
}
|
1394
|
+
},
|
687
1395
|
queryParameters: [apiVersion],
|
688
|
-
urlParameters: [
|
1396
|
+
urlParameters: [endpoint, hub, userId1],
|
1397
|
+
headerParameters: [accept],
|
689
1398
|
serializer: serializer$1
|
690
1399
|
};
|
691
1400
|
const grantPermissionOperationSpec = {
|
692
1401
|
path: "/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}",
|
693
1402
|
httpMethod: "PUT",
|
694
|
-
responses: {
|
1403
|
+
responses: {
|
1404
|
+
200: {},
|
1405
|
+
default: {
|
1406
|
+
bodyMapper: ErrorDetail,
|
1407
|
+
headersMapper: WebPubSubGrantPermissionExceptionHeaders
|
1408
|
+
}
|
1409
|
+
},
|
695
1410
|
queryParameters: [apiVersion, targetName],
|
696
1411
|
urlParameters: [
|
697
|
-
|
1412
|
+
endpoint,
|
698
1413
|
hub,
|
699
1414
|
connectionId,
|
700
1415
|
permission
|
701
1416
|
],
|
1417
|
+
headerParameters: [accept],
|
702
1418
|
serializer: serializer$1
|
703
1419
|
};
|
704
1420
|
const revokePermissionOperationSpec = {
|
705
1421
|
path: "/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}",
|
706
1422
|
httpMethod: "DELETE",
|
707
|
-
responses: {
|
1423
|
+
responses: {
|
1424
|
+
204: {},
|
1425
|
+
default: {
|
1426
|
+
bodyMapper: ErrorDetail,
|
1427
|
+
headersMapper: WebPubSubRevokePermissionExceptionHeaders
|
1428
|
+
}
|
1429
|
+
},
|
708
1430
|
queryParameters: [apiVersion, targetName],
|
709
1431
|
urlParameters: [
|
710
|
-
|
1432
|
+
endpoint,
|
711
1433
|
hub,
|
712
1434
|
connectionId,
|
713
1435
|
permission
|
714
1436
|
],
|
1437
|
+
headerParameters: [accept],
|
715
1438
|
serializer: serializer$1
|
716
1439
|
};
|
717
1440
|
const checkPermissionOperationSpec = {
|
718
1441
|
path: "/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}",
|
719
1442
|
httpMethod: "HEAD",
|
720
|
-
responses: {
|
1443
|
+
responses: {
|
1444
|
+
200: {},
|
1445
|
+
404: {},
|
1446
|
+
default: {
|
1447
|
+
bodyMapper: ErrorDetail,
|
1448
|
+
headersMapper: WebPubSubCheckPermissionExceptionHeaders
|
1449
|
+
}
|
1450
|
+
},
|
721
1451
|
queryParameters: [apiVersion, targetName],
|
722
1452
|
urlParameters: [
|
723
|
-
|
1453
|
+
endpoint,
|
724
1454
|
hub,
|
725
1455
|
connectionId,
|
726
1456
|
permission
|
727
1457
|
],
|
1458
|
+
headerParameters: [accept],
|
728
1459
|
serializer: serializer$1
|
729
1460
|
};
|
730
1461
|
|
@@ -739,12 +1470,12 @@ const checkPermissionOperationSpec = {
|
|
739
1470
|
class GeneratedClientContext extends coreClient.ServiceClient {
|
740
1471
|
/**
|
741
1472
|
* Initializes a new instance of the GeneratedClientContext class.
|
742
|
-
* @param
|
1473
|
+
* @param endpoint HTTP or HTTPS endpoint for the Web PubSub service instance.
|
743
1474
|
* @param options The parameter options
|
744
1475
|
*/
|
745
|
-
constructor(
|
746
|
-
if (
|
747
|
-
throw new Error("'
|
1476
|
+
constructor(endpoint, options) {
|
1477
|
+
if (endpoint === undefined) {
|
1478
|
+
throw new Error("'endpoint' cannot be null");
|
748
1479
|
}
|
749
1480
|
// Initializing default values for options
|
750
1481
|
if (!options) {
|
@@ -753,18 +1484,18 @@ class GeneratedClientContext extends coreClient.ServiceClient {
|
|
753
1484
|
const defaults = {
|
754
1485
|
requestContentType: "application/json; charset=utf-8"
|
755
1486
|
};
|
756
|
-
const packageDetails = `azsdk-js-web-pubsub/1.0.
|
1487
|
+
const packageDetails = `azsdk-js-web-pubsub/1.0.1`;
|
757
1488
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
758
1489
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
759
1490
|
: `${packageDetails}`;
|
760
1491
|
const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
|
761
1492
|
userAgentPrefix
|
762
|
-
}, baseUri: options.endpoint || "{
|
1493
|
+
}, baseUri: options.endpoint || "{Endpoint}" });
|
763
1494
|
super(optionsWithDefaults);
|
764
1495
|
// Parameter assignments
|
765
|
-
this
|
1496
|
+
this.endpoint = endpoint;
|
766
1497
|
// Assigning values to Constant parameters
|
767
|
-
this.apiVersion = options.apiVersion || "2021-
|
1498
|
+
this.apiVersion = options.apiVersion || "2021-10-01";
|
768
1499
|
}
|
769
1500
|
}
|
770
1501
|
|
@@ -779,11 +1510,11 @@ class GeneratedClientContext extends coreClient.ServiceClient {
|
|
779
1510
|
class GeneratedClient extends GeneratedClientContext {
|
780
1511
|
/**
|
781
1512
|
* Initializes a new instance of the GeneratedClient class.
|
782
|
-
* @param
|
1513
|
+
* @param endpoint HTTP or HTTPS endpoint for the Web PubSub service instance.
|
783
1514
|
* @param options The parameter options
|
784
1515
|
*/
|
785
|
-
constructor(
|
786
|
-
super(
|
1516
|
+
constructor(endpoint, options) {
|
1517
|
+
super(endpoint, options);
|
787
1518
|
this.healthApi = new HealthApiImpl(this);
|
788
1519
|
this.webPubSub = new WebPubSubImpl(this);
|
789
1520
|
}
|
@@ -793,15 +1524,11 @@ class GeneratedClient extends GeneratedClientContext {
|
|
793
1524
|
/** @internal */
|
794
1525
|
const createSpan = coreTracing.createSpanFunction({
|
795
1526
|
namespace: "Microsoft.WebPubSub",
|
796
|
-
packagePrefix: "Azure.Messaging.WebPubSub"
|
1527
|
+
packagePrefix: "Azure.Messaging.WebPubSub",
|
797
1528
|
});
|
798
1529
|
|
799
1530
|
// Copyright (c) Microsoft Corporation.
|
800
|
-
|
801
|
-
const { excludedConnections } = options, otherOptions = tslib.__rest(options, ["excludedConnections"]);
|
802
|
-
return Object.assign(Object.assign({}, otherOptions), { excluded: excludedConnections });
|
803
|
-
}
|
804
|
-
|
1531
|
+
// Licensed under the MIT license.
|
805
1532
|
function isRequestBody(obj) {
|
806
1533
|
return (typeof obj === "function" ||
|
807
1534
|
(typeof obj === "object" &&
|
@@ -831,7 +1558,6 @@ function getPayloadForMessage(message, options) {
|
|
831
1558
|
*/
|
832
1559
|
class WebPubSubGroupImpl {
|
833
1560
|
/**
|
834
|
-
* @private
|
835
1561
|
* @internal
|
836
1562
|
*/
|
837
1563
|
constructor(client, hubName, groupName) {
|
@@ -846,25 +1572,25 @@ class WebPubSubGroupImpl {
|
|
846
1572
|
/**
|
847
1573
|
* Add a specific connection to this group
|
848
1574
|
*
|
849
|
-
* @param connectionId The connection id to add to this group
|
850
|
-
* @param options Additional options
|
1575
|
+
* @param connectionId - The connection id to add to this group
|
1576
|
+
* @param options - Additional options
|
851
1577
|
*/
|
852
1578
|
async addConnection(connectionId, options = {}) {
|
853
1579
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-addConnection", options);
|
854
|
-
|
855
|
-
|
856
|
-
|
857
|
-
|
858
|
-
|
859
|
-
updatedOptions.onResponse(rawResponse, flatResponse);
|
860
|
-
}
|
1580
|
+
let response;
|
1581
|
+
function onResponse(rawResponse, flatResponse) {
|
1582
|
+
response = rawResponse;
|
1583
|
+
if (updatedOptions.onResponse) {
|
1584
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
861
1585
|
}
|
1586
|
+
}
|
1587
|
+
try {
|
862
1588
|
await this.client.webPubSub.addConnectionToGroup(this.hubName, this.groupName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
863
|
-
if (
|
1589
|
+
if (response.status === 404) {
|
864
1590
|
throw new coreRestPipeline.RestError(`Connection id '${connectionId}' doesn't exist`, {
|
865
1591
|
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
866
1592
|
request: response === null || response === void 0 ? void 0 : response.request,
|
867
|
-
response: response
|
1593
|
+
response: response,
|
868
1594
|
});
|
869
1595
|
}
|
870
1596
|
}
|
@@ -875,8 +1601,8 @@ class WebPubSubGroupImpl {
|
|
875
1601
|
/**
|
876
1602
|
* Remove a specific connection from this group
|
877
1603
|
*
|
878
|
-
* @param connectionId The connection id to remove from this group
|
879
|
-
* @param options Additional options
|
1604
|
+
* @param connectionId - The connection id to remove from this group
|
1605
|
+
* @param options - Additional options
|
880
1606
|
*/
|
881
1607
|
async removeConnection(connectionId, options = {}) {
|
882
1608
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-removeConnection", options);
|
@@ -887,11 +1613,25 @@ class WebPubSubGroupImpl {
|
|
887
1613
|
span.end();
|
888
1614
|
}
|
889
1615
|
}
|
1616
|
+
/**
|
1617
|
+
* Close all connections to this group
|
1618
|
+
*
|
1619
|
+
* @param options - Additional options
|
1620
|
+
*/
|
1621
|
+
async closeAllConnections(options = {}) {
|
1622
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-closeAllConnections", options);
|
1623
|
+
try {
|
1624
|
+
return await this.client.webPubSub.closeGroupConnections(this.hubName, this.groupName, updatedOptions);
|
1625
|
+
}
|
1626
|
+
finally {
|
1627
|
+
span.end();
|
1628
|
+
}
|
1629
|
+
}
|
890
1630
|
/**
|
891
1631
|
* Add a user to this group
|
892
1632
|
*
|
893
|
-
* @param username The user name to add
|
894
|
-
* @param options Additional options
|
1633
|
+
* @param username - The user name to add
|
1634
|
+
* @param options - Additional options
|
895
1635
|
*/
|
896
1636
|
async addUser(username, options = {}) {
|
897
1637
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-addUser", options);
|
@@ -905,8 +1645,8 @@ class WebPubSubGroupImpl {
|
|
905
1645
|
/**
|
906
1646
|
* Remove a user from this group
|
907
1647
|
*
|
908
|
-
* @param username The user name to remove
|
909
|
-
* @param options Additional options
|
1648
|
+
* @param username - The user name to remove
|
1649
|
+
* @param options - Additional options
|
910
1650
|
*/
|
911
1651
|
async removeUser(username, options = {}) {
|
912
1652
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-removeUser", options);
|
@@ -918,8 +1658,7 @@ class WebPubSubGroupImpl {
|
|
918
1658
|
}
|
919
1659
|
}
|
920
1660
|
async sendToAll(message, options = {}) {
|
921
|
-
const
|
922
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-sendToAll", normalizedOptions);
|
1661
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-group-sendToAll", options);
|
923
1662
|
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
924
1663
|
try {
|
925
1664
|
await this.client.webPubSub.sendToGroup(this.hubName, this.groupName, contentType, payload, updatedOptions);
|
@@ -947,22 +1686,23 @@ function webPubSubKeyCredentialPolicy(credential) {
|
|
947
1686
|
const bearerToken = jwt.sign({}, credential.key, {
|
948
1687
|
audience: request.url,
|
949
1688
|
expiresIn: "1h",
|
950
|
-
algorithm: "HS256"
|
1689
|
+
algorithm: "HS256",
|
951
1690
|
});
|
952
1691
|
request.headers.set("Authorization", `Bearer ${bearerToken}`);
|
953
1692
|
return next(request);
|
954
|
-
}
|
1693
|
+
},
|
955
1694
|
};
|
956
1695
|
}
|
957
1696
|
|
958
1697
|
// Copyright (c) Microsoft Corporation.
|
959
1698
|
/**
|
960
|
-
* The
|
1699
|
+
* The `@azure/logger` configuration for this package.
|
961
1700
|
*/
|
962
1701
|
const logger = logger$1.createClientLogger("web-pubsub");
|
963
1702
|
|
1703
|
+
// Copyright (c) Microsoft Corporation.
|
964
1704
|
function parseConnectionString(conn) {
|
965
|
-
|
1705
|
+
const parsed = {};
|
966
1706
|
conn.split(";").forEach((i) => {
|
967
1707
|
const assignmentPos = i.indexOf("=");
|
968
1708
|
if (assignmentPos === -1)
|
@@ -989,22 +1729,44 @@ function parseConnectionString(conn) {
|
|
989
1729
|
return { credential, endpoint };
|
990
1730
|
}
|
991
1731
|
|
1732
|
+
// Copyright (c) Microsoft Corporation.
|
1733
|
+
// Licensed under the MIT license.
|
1734
|
+
const webPubSubReverseProxyPolicyName = "webPubSubReverseProxyPolicy";
|
1735
|
+
/**
|
1736
|
+
* Create an HTTP pipeline policy to use a reverse proxy.
|
1737
|
+
* This is generally going to be an Azure APIM endpoint.
|
1738
|
+
* @internal
|
1739
|
+
*/
|
1740
|
+
function webPubSubReverseProxyPolicy(endpoint) {
|
1741
|
+
const rpEndpointUrl = new URL(endpoint);
|
1742
|
+
return {
|
1743
|
+
name: webPubSubReverseProxyPolicyName,
|
1744
|
+
sendRequest(request, next) {
|
1745
|
+
const parsedUrl = new URL(request.url);
|
1746
|
+
parsedUrl.host = rpEndpointUrl.host;
|
1747
|
+
request.url = parsedUrl.toString();
|
1748
|
+
return next(request);
|
1749
|
+
},
|
1750
|
+
};
|
1751
|
+
}
|
1752
|
+
|
992
1753
|
// Copyright (c) Microsoft Corporation.
|
993
1754
|
/**
|
994
1755
|
* Client for connecting to a Web PubSub hub
|
995
1756
|
*/
|
996
1757
|
class WebPubSubServiceClient {
|
997
1758
|
constructor(endpointOrConnectionString, credsOrHubName, hubNameOrOpts, opts) {
|
1759
|
+
var _a, _b;
|
998
1760
|
/**
|
999
1761
|
* The Web PubSub API version being used by this client
|
1000
1762
|
*/
|
1001
|
-
this.apiVersion = "
|
1763
|
+
this.apiVersion = "2021-10-01";
|
1002
1764
|
// unpack constructor arguments
|
1003
|
-
if (typeof credsOrHubName === "object"
|
1765
|
+
if (typeof credsOrHubName === "object") {
|
1004
1766
|
this.endpoint = endpointOrConnectionString;
|
1005
|
-
this.credential = credsOrHubName;
|
1006
1767
|
this.hubName = hubNameOrOpts;
|
1007
1768
|
this.clientOptions = opts;
|
1769
|
+
this.credential = credsOrHubName;
|
1008
1770
|
}
|
1009
1771
|
else {
|
1010
1772
|
const parsedCs = parseConnectionString(endpointOrConnectionString);
|
@@ -1013,52 +1775,34 @@ class WebPubSubServiceClient {
|
|
1013
1775
|
this.hubName = credsOrHubName;
|
1014
1776
|
this.clientOptions = hubNameOrOpts;
|
1015
1777
|
}
|
1016
|
-
const internalPipelineOptions = Object.assign(Object.assign({}, this.clientOptions), {
|
1778
|
+
const internalPipelineOptions = Object.assign(Object.assign(Object.assign({}, this.clientOptions), {
|
1779
|
+
apiVersion: this.apiVersion,
|
1017
1780
|
loggingOptions: {
|
1018
|
-
logger: logger.info
|
1781
|
+
logger: logger.info,
|
1782
|
+
},
|
1783
|
+
}), (coreAuth.isTokenCredential(this.credential)
|
1784
|
+
? {
|
1785
|
+
credential: this.credential,
|
1786
|
+
credentialScopes: ["https://webpubsub.azure.com/.default"],
|
1019
1787
|
}
|
1020
|
-
|
1788
|
+
: {}));
|
1021
1789
|
this.client = new GeneratedClient(this.endpoint, internalPipelineOptions);
|
1022
|
-
|
1023
|
-
|
1024
|
-
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
async getAuthenticationToken(options) {
|
1029
|
-
const endpoint = this.endpoint.endsWith("/") ? this.endpoint : this.endpoint + "/";
|
1030
|
-
const key = this.credential.key;
|
1031
|
-
const hub = this.hubName;
|
1032
|
-
const clientEndpoint = endpoint.replace(/(http)(s?:\/\/)/gi, "ws$2");
|
1033
|
-
const clientUrl = `${clientEndpoint}client/hubs/${hub}`;
|
1034
|
-
const audience = `${endpoint}client/hubs/${hub}`;
|
1035
|
-
const payload = { role: options === null || options === void 0 ? void 0 : options.roles };
|
1036
|
-
const signOptions = {
|
1037
|
-
audience: audience,
|
1038
|
-
expiresIn: (options === null || options === void 0 ? void 0 : options.ttl) === undefined ? "1h" : `${options.ttl}m`,
|
1039
|
-
algorithm: "HS256"
|
1040
|
-
};
|
1041
|
-
if (options === null || options === void 0 ? void 0 : options.userId) {
|
1042
|
-
signOptions.subject = options === null || options === void 0 ? void 0 : options.userId;
|
1043
|
-
}
|
1044
|
-
const token = jwt.sign(payload, key, signOptions);
|
1045
|
-
const url = `${clientUrl}?access_token=${token}`;
|
1046
|
-
return {
|
1047
|
-
baseUrl: clientUrl,
|
1048
|
-
token: jwt.sign(payload, key, signOptions),
|
1049
|
-
url: url
|
1050
|
-
};
|
1790
|
+
if (!coreAuth.isTokenCredential(this.credential)) {
|
1791
|
+
this.client.pipeline.addPolicy(webPubSubKeyCredentialPolicy(this.credential));
|
1792
|
+
}
|
1793
|
+
if ((_a = this.clientOptions) === null || _a === void 0 ? void 0 : _a.reverseProxyEndpoint) {
|
1794
|
+
this.client.pipeline.addPolicy(webPubSubReverseProxyPolicy((_b = this.clientOptions) === null || _b === void 0 ? void 0 : _b.reverseProxyEndpoint));
|
1795
|
+
}
|
1051
1796
|
}
|
1052
1797
|
/**
|
1053
1798
|
* Get a client for a group
|
1054
|
-
* @param groupName The name of the group to connect to.
|
1799
|
+
* @param groupName - The name of the group to connect to.
|
1055
1800
|
*/
|
1056
1801
|
group(groupName) {
|
1057
1802
|
return new WebPubSubGroupImpl(this.client, this.hubName, groupName);
|
1058
1803
|
}
|
1059
1804
|
async sendToAll(message, options = {}) {
|
1060
|
-
const
|
1061
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-sendToAll", normalizedOptions);
|
1805
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-sendToAll", options);
|
1062
1806
|
const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
|
1063
1807
|
try {
|
1064
1808
|
return await this.client.webPubSub.sendToAll(this.hubName, contentType, payload, updatedOptions);
|
@@ -1090,32 +1834,32 @@ class WebPubSubServiceClient {
|
|
1090
1834
|
/**
|
1091
1835
|
* Check if a specific connection is connected to this hub
|
1092
1836
|
*
|
1093
|
-
* @param connectionId Connection id to check
|
1094
|
-
* @param options Additional options
|
1837
|
+
* @param connectionId - Connection id to check
|
1838
|
+
* @param options - Additional options
|
1095
1839
|
*/
|
1096
|
-
async
|
1840
|
+
async connectionExists(connectionId, options = {}) {
|
1097
1841
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasConnection", options);
|
1098
|
-
|
1099
|
-
|
1100
|
-
|
1101
|
-
|
1102
|
-
|
1103
|
-
updatedOptions.onResponse(rawResponse, flatResponse);
|
1104
|
-
}
|
1842
|
+
let response;
|
1843
|
+
function onResponse(rawResponse, flatResponse) {
|
1844
|
+
response = rawResponse;
|
1845
|
+
if (updatedOptions.onResponse) {
|
1846
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
1105
1847
|
}
|
1848
|
+
}
|
1849
|
+
try {
|
1106
1850
|
await this.client.webPubSub.connectionExists(this.hubName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1107
|
-
if (
|
1851
|
+
if (response.status === 200) {
|
1108
1852
|
return true;
|
1109
1853
|
}
|
1110
|
-
else if (
|
1854
|
+
else if (response.status === 404) {
|
1111
1855
|
return false;
|
1112
1856
|
}
|
1113
1857
|
else {
|
1114
1858
|
// this is sad - wish this was handled by autorest.
|
1115
|
-
throw new coreRestPipeline.RestError(response
|
1859
|
+
throw new coreRestPipeline.RestError(response.bodyAsText, {
|
1116
1860
|
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
1117
1861
|
request: response === null || response === void 0 ? void 0 : response.request,
|
1118
|
-
response: response
|
1862
|
+
response: response,
|
1119
1863
|
});
|
1120
1864
|
}
|
1121
1865
|
}
|
@@ -1126,13 +1870,42 @@ class WebPubSubServiceClient {
|
|
1126
1870
|
/**
|
1127
1871
|
* Close a specific connection to this hub
|
1128
1872
|
*
|
1129
|
-
* @param connectionId Connection id to close
|
1130
|
-
* @param options Additional options
|
1873
|
+
* @param connectionId - Connection id to close
|
1874
|
+
* @param options - Additional options
|
1131
1875
|
*/
|
1132
1876
|
async closeConnection(connectionId, options = {}) {
|
1133
|
-
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-
|
1877
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-closeConnection", options);
|
1134
1878
|
try {
|
1135
|
-
return await this.client.webPubSub.
|
1879
|
+
return await this.client.webPubSub.closeConnection(this.hubName, connectionId, updatedOptions);
|
1880
|
+
}
|
1881
|
+
finally {
|
1882
|
+
span.end();
|
1883
|
+
}
|
1884
|
+
}
|
1885
|
+
/**
|
1886
|
+
* Close all connections to this hub
|
1887
|
+
*
|
1888
|
+
* @param options - Additional options
|
1889
|
+
*/
|
1890
|
+
async closeAllConnections(options = {}) {
|
1891
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-closeAllConnections", options);
|
1892
|
+
try {
|
1893
|
+
return await this.client.webPubSub.closeAllConnections(this.hubName, updatedOptions);
|
1894
|
+
}
|
1895
|
+
finally {
|
1896
|
+
span.end();
|
1897
|
+
}
|
1898
|
+
}
|
1899
|
+
/**
|
1900
|
+
* Close all connections with the given user id
|
1901
|
+
*
|
1902
|
+
* @param user - User id to close
|
1903
|
+
* @param options - Additional options
|
1904
|
+
*/
|
1905
|
+
async closeUserConnections(userId, options = {}) {
|
1906
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-closeUserConnections", options);
|
1907
|
+
try {
|
1908
|
+
return await this.client.webPubSub.closeUserConnections(this.hubName, userId, updatedOptions);
|
1136
1909
|
}
|
1137
1910
|
finally {
|
1138
1911
|
span.end();
|
@@ -1140,8 +1913,8 @@ class WebPubSubServiceClient {
|
|
1140
1913
|
}
|
1141
1914
|
/**
|
1142
1915
|
* Remove a specific user from all groups they are joined to
|
1143
|
-
* @param userId The user id to remove from all groups
|
1144
|
-
* @param options Additional options
|
1916
|
+
* @param userId - The user id to remove from all groups
|
1917
|
+
* @param options - Additional options
|
1145
1918
|
*/
|
1146
1919
|
async removeUserFromAllGroups(userId, options = {}) {
|
1147
1920
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-removeUserFromAllGroups", options);
|
@@ -1155,31 +1928,31 @@ class WebPubSubServiceClient {
|
|
1155
1928
|
/**
|
1156
1929
|
* Check if a particular group exists (i.e. has active connections).
|
1157
1930
|
*
|
1158
|
-
* @param groupName The group name to check for
|
1159
|
-
* @param options Additional options
|
1931
|
+
* @param groupName - The group name to check for
|
1932
|
+
* @param options - Additional options
|
1160
1933
|
*/
|
1161
|
-
async
|
1934
|
+
async groupExists(groupName, options = {}) {
|
1162
1935
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasGroup", options);
|
1163
|
-
|
1164
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
updatedOptions.onResponse(rawResponse, flatResponse);
|
1169
|
-
}
|
1936
|
+
let response;
|
1937
|
+
function onResponse(rawResponse, flatResponse) {
|
1938
|
+
response = rawResponse;
|
1939
|
+
if (updatedOptions.onResponse) {
|
1940
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
1170
1941
|
}
|
1942
|
+
}
|
1943
|
+
try {
|
1171
1944
|
await this.client.webPubSub.groupExists(this.hubName, groupName, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1172
|
-
if (
|
1945
|
+
if (response.status === 200) {
|
1173
1946
|
return true;
|
1174
1947
|
}
|
1175
|
-
else if (
|
1948
|
+
else if (response.status === 404) {
|
1176
1949
|
return false;
|
1177
1950
|
}
|
1178
1951
|
else {
|
1179
|
-
throw new coreRestPipeline.RestError(response
|
1952
|
+
throw new coreRestPipeline.RestError(response.bodyAsText, {
|
1180
1953
|
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
1181
1954
|
request: response === null || response === void 0 ? void 0 : response.request,
|
1182
|
-
response: response
|
1955
|
+
response: response,
|
1183
1956
|
});
|
1184
1957
|
}
|
1185
1958
|
}
|
@@ -1190,32 +1963,32 @@ class WebPubSubServiceClient {
|
|
1190
1963
|
/**
|
1191
1964
|
* Check if a particular user is connected to this hub.
|
1192
1965
|
*
|
1193
|
-
* @param username The user name to check for
|
1194
|
-
* @param options Additional options
|
1966
|
+
* @param username - The user name to check for
|
1967
|
+
* @param options - Additional options
|
1195
1968
|
*/
|
1196
|
-
async
|
1969
|
+
async userExists(username, options = {}) {
|
1197
1970
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasUser", options);
|
1198
|
-
|
1199
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
updatedOptions.onResponse(rawResponse, flatResponse);
|
1204
|
-
}
|
1971
|
+
let response;
|
1972
|
+
function onResponse(rawResponse, flatResponse) {
|
1973
|
+
response = rawResponse;
|
1974
|
+
if (updatedOptions.onResponse) {
|
1975
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
1205
1976
|
}
|
1977
|
+
}
|
1978
|
+
try {
|
1206
1979
|
await this.client.webPubSub.userExists(this.hubName, username, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1207
|
-
if (
|
1980
|
+
if (response.status === 200) {
|
1208
1981
|
return true;
|
1209
1982
|
}
|
1210
|
-
else if (
|
1983
|
+
else if (response.status === 404) {
|
1211
1984
|
return false;
|
1212
1985
|
}
|
1213
1986
|
else {
|
1214
1987
|
// this is sad - wish this was handled by autorest.
|
1215
|
-
throw new coreRestPipeline.RestError(response
|
1988
|
+
throw new coreRestPipeline.RestError(response.bodyAsText, {
|
1216
1989
|
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
1217
1990
|
request: response === null || response === void 0 ? void 0 : response.request,
|
1218
|
-
response: response
|
1991
|
+
response: response,
|
1219
1992
|
});
|
1220
1993
|
}
|
1221
1994
|
}
|
@@ -1226,9 +1999,9 @@ class WebPubSubServiceClient {
|
|
1226
1999
|
/**
|
1227
2000
|
* Grant permissions to a connection
|
1228
2001
|
*
|
1229
|
-
* @param connectionId The connection id to grant permissions to
|
1230
|
-
* @param Permission The permission to grant
|
1231
|
-
* @param options Additional options
|
2002
|
+
* @param connectionId - The connection id to grant permissions to
|
2003
|
+
* @param Permission - The permission to grant
|
2004
|
+
* @param options - Additional options
|
1232
2005
|
*/
|
1233
2006
|
async grantPermission(connectionId, permission, options = {}) {
|
1234
2007
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-grantPermission", options);
|
@@ -1242,9 +2015,9 @@ class WebPubSubServiceClient {
|
|
1242
2015
|
/**
|
1243
2016
|
* Revoke permissions from a connection
|
1244
2017
|
*
|
1245
|
-
* @param connectionId The connection id to revoke permissions from
|
1246
|
-
* @param Permission The permission to revoke
|
1247
|
-
* @param options Additional options
|
2018
|
+
* @param connectionId - The connection id to revoke permissions from
|
2019
|
+
* @param Permission - The permission to revoke
|
2020
|
+
* @param options - Additional options
|
1248
2021
|
*/
|
1249
2022
|
async revokePermission(connectionId, permission, options = {}) {
|
1250
2023
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-revokePermission", options);
|
@@ -1258,33 +2031,33 @@ class WebPubSubServiceClient {
|
|
1258
2031
|
/**
|
1259
2032
|
* Check if the connection has the specified permission
|
1260
2033
|
*
|
1261
|
-
* @param connectionId The connection id to check permission
|
1262
|
-
* @param Permission The permission to check
|
1263
|
-
* @param options Additional options
|
2034
|
+
* @param connectionId - The connection id to check permission
|
2035
|
+
* @param Permission - The permission to check
|
2036
|
+
* @param options - Additional options
|
1264
2037
|
*/
|
1265
2038
|
async hasPermission(connectionId, permission, options = {}) {
|
1266
2039
|
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-hasPermission", options);
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
1272
|
-
updatedOptions.onResponse(rawResponse, flatResponse);
|
1273
|
-
}
|
2040
|
+
let response;
|
2041
|
+
function onResponse(rawResponse, flatResponse) {
|
2042
|
+
response = rawResponse;
|
2043
|
+
if (updatedOptions.onResponse) {
|
2044
|
+
updatedOptions.onResponse(rawResponse, flatResponse);
|
1274
2045
|
}
|
2046
|
+
}
|
2047
|
+
try {
|
1275
2048
|
await this.client.webPubSub.checkPermission(this.hubName, permission, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
|
1276
|
-
if (
|
2049
|
+
if (response.status === 200) {
|
1277
2050
|
return true;
|
1278
2051
|
}
|
1279
|
-
else if (
|
2052
|
+
else if (response.status === 404) {
|
1280
2053
|
return false;
|
1281
2054
|
}
|
1282
2055
|
else {
|
1283
2056
|
// this is sad - wish this was handled by autorest.
|
1284
|
-
throw new coreRestPipeline.RestError(response
|
2057
|
+
throw new coreRestPipeline.RestError(response.bodyAsText, {
|
1285
2058
|
statusCode: response === null || response === void 0 ? void 0 : response.status,
|
1286
2059
|
request: response === null || response === void 0 ? void 0 : response.request,
|
1287
|
-
response: response
|
2060
|
+
response: response,
|
1288
2061
|
});
|
1289
2062
|
}
|
1290
2063
|
}
|
@@ -1292,6 +2065,48 @@ class WebPubSubServiceClient {
|
|
1292
2065
|
span.end();
|
1293
2066
|
}
|
1294
2067
|
}
|
2068
|
+
/**
|
2069
|
+
* Generate a token for a client to connect to the Azure Web PubSub service.
|
2070
|
+
*
|
2071
|
+
* @param options - Additional options
|
2072
|
+
*/
|
2073
|
+
async getClientAccessToken(options = {}) {
|
2074
|
+
const { span, updatedOptions } = createSpan("WebPubSubServiceClient-hub-generateClientToken", options);
|
2075
|
+
try {
|
2076
|
+
const endpoint = this.endpoint.endsWith("/") ? this.endpoint : this.endpoint + "/";
|
2077
|
+
const clientEndpoint = endpoint.replace(/(http)(s?:\/\/)/gi, "ws$2");
|
2078
|
+
const baseUrl = `${clientEndpoint}client/hubs/${this.hubName}`;
|
2079
|
+
let token;
|
2080
|
+
if (coreAuth.isTokenCredential(this.credential)) {
|
2081
|
+
const response = await this.client.webPubSub.generateClientToken(this.hubName, updatedOptions);
|
2082
|
+
token = response.token;
|
2083
|
+
}
|
2084
|
+
else {
|
2085
|
+
const key = this.credential.key;
|
2086
|
+
const audience = `${endpoint}client/hubs/${this.hubName}`;
|
2087
|
+
const payload = { role: options === null || options === void 0 ? void 0 : options.roles };
|
2088
|
+
const signOptions = {
|
2089
|
+
audience: audience,
|
2090
|
+
expiresIn: (options === null || options === void 0 ? void 0 : options.expirationTimeInMinutes) === undefined
|
2091
|
+
? "1h"
|
2092
|
+
: `${options.expirationTimeInMinutes}m`,
|
2093
|
+
algorithm: "HS256",
|
2094
|
+
};
|
2095
|
+
if (options === null || options === void 0 ? void 0 : options.userId) {
|
2096
|
+
signOptions.subject = options === null || options === void 0 ? void 0 : options.userId;
|
2097
|
+
}
|
2098
|
+
token = jwt.sign(payload, key, signOptions);
|
2099
|
+
}
|
2100
|
+
return {
|
2101
|
+
token,
|
2102
|
+
baseUrl,
|
2103
|
+
url: `${baseUrl}?access_token=${token}`,
|
2104
|
+
};
|
2105
|
+
}
|
2106
|
+
finally {
|
2107
|
+
span.end();
|
2108
|
+
}
|
2109
|
+
}
|
1295
2110
|
}
|
1296
2111
|
|
1297
2112
|
Object.defineProperty(exports, 'AzureKeyCredential', {
|