@azure/web-pubsub 1.1.4-alpha.20241119.1 → 1.1.4-alpha.20241121.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. package/dist/commonjs/generated/generatedClient.d.ts +19 -0
  2. package/dist/commonjs/generated/generatedClient.d.ts.map +1 -0
  3. package/dist/commonjs/generated/generatedClient.js +76 -0
  4. package/dist/commonjs/generated/generatedClient.js.map +1 -0
  5. package/dist/commonjs/generated/generatedClientContext.d.ts +14 -0
  6. package/dist/commonjs/generated/generatedClientContext.d.ts.map +1 -0
  7. package/dist/commonjs/generated/generatedClientContext.js +46 -0
  8. package/dist/commonjs/generated/generatedClientContext.js.map +1 -0
  9. package/dist/commonjs/generated/index.d.ts +4 -0
  10. package/dist/commonjs/generated/index.d.ts.map +1 -0
  11. package/dist/commonjs/generated/index.js +16 -0
  12. package/dist/commonjs/generated/index.js.map +1 -0
  13. package/dist/commonjs/generated/models/index.d.ts +323 -0
  14. package/dist/commonjs/generated/models/index.d.ts.map +1 -0
  15. package/dist/commonjs/generated/models/index.js +27 -0
  16. package/dist/commonjs/generated/models/index.js.map +1 -0
  17. package/dist/commonjs/generated/models/mappers.d.ts +30 -0
  18. package/dist/commonjs/generated/models/mappers.d.ts.map +1 -0
  19. package/dist/commonjs/generated/models/mappers.js +463 -0
  20. package/dist/commonjs/generated/models/mappers.js.map +1 -0
  21. package/dist/commonjs/generated/models/parameters.d.ts +31 -0
  22. package/dist/commonjs/generated/models/parameters.d.ts.map +1 -0
  23. package/dist/commonjs/generated/models/parameters.js +335 -0
  24. package/dist/commonjs/generated/models/parameters.js.map +1 -0
  25. package/dist/commonjs/generated/operations/healthApi.d.ts +18 -0
  26. package/dist/commonjs/generated/operations/healthApi.d.ts.map +1 -0
  27. package/dist/commonjs/generated/operations/healthApi.js +43 -0
  28. package/dist/commonjs/generated/operations/healthApi.js.map +1 -0
  29. package/dist/commonjs/generated/operations/index.d.ts +3 -0
  30. package/dist/commonjs/generated/operations/index.d.ts.map +1 -0
  31. package/dist/commonjs/generated/operations/index.js +13 -0
  32. package/dist/commonjs/generated/operations/index.js.map +1 -0
  33. package/dist/commonjs/generated/operations/webPubSub.d.ts +249 -0
  34. package/dist/commonjs/generated/operations/webPubSub.d.ts.map +1 -0
  35. package/dist/commonjs/generated/operations/webPubSub.js +874 -0
  36. package/dist/commonjs/generated/operations/webPubSub.js.map +1 -0
  37. package/dist/commonjs/generated/operationsInterfaces/healthApi.d.ts +10 -0
  38. package/dist/commonjs/generated/operationsInterfaces/healthApi.d.ts.map +1 -0
  39. package/dist/commonjs/generated/operationsInterfaces/healthApi.js +10 -0
  40. package/dist/commonjs/generated/operationsInterfaces/healthApi.js.map +1 -0
  41. package/dist/commonjs/generated/operationsInterfaces/index.d.ts +3 -0
  42. package/dist/commonjs/generated/operationsInterfaces/index.d.ts.map +1 -0
  43. package/dist/commonjs/generated/operationsInterfaces/index.js +13 -0
  44. package/dist/commonjs/generated/operationsInterfaces/index.js.map +1 -0
  45. package/dist/commonjs/generated/operationsInterfaces/webPubSub.d.ts +224 -0
  46. package/dist/commonjs/generated/operationsInterfaces/webPubSub.d.ts.map +1 -0
  47. package/dist/commonjs/generated/operationsInterfaces/webPubSub.js +10 -0
  48. package/dist/commonjs/generated/operationsInterfaces/webPubSub.js.map +1 -0
  49. package/dist/commonjs/groupClient.d.ts +232 -0
  50. package/dist/commonjs/groupClient.d.ts.map +1 -0
  51. package/dist/commonjs/groupClient.js +101 -0
  52. package/dist/commonjs/groupClient.js.map +1 -0
  53. package/dist/commonjs/hubClient.d.ts +478 -0
  54. package/dist/commonjs/hubClient.d.ts.map +1 -0
  55. package/dist/commonjs/hubClient.js +372 -0
  56. package/dist/commonjs/hubClient.js.map +1 -0
  57. package/dist/commonjs/index.d.ts +5 -0
  58. package/dist/commonjs/index.d.ts.map +1 -0
  59. package/dist/commonjs/index.js +12 -0
  60. package/dist/commonjs/index.js.map +1 -0
  61. package/dist/commonjs/logger.d.ts +5 -0
  62. package/dist/commonjs/logger.d.ts.map +1 -0
  63. package/dist/commonjs/logger.js +11 -0
  64. package/dist/commonjs/logger.js.map +1 -0
  65. package/dist/commonjs/package.json +3 -0
  66. package/dist/commonjs/parseConnectionString.d.ts +8 -0
  67. package/dist/commonjs/parseConnectionString.d.ts.map +1 -0
  68. package/dist/commonjs/parseConnectionString.js +34 -0
  69. package/dist/commonjs/parseConnectionString.js.map +1 -0
  70. package/dist/commonjs/reverseProxyPolicy.d.ts +9 -0
  71. package/dist/commonjs/reverseProxyPolicy.d.ts.map +1 -0
  72. package/dist/commonjs/reverseProxyPolicy.js +25 -0
  73. package/dist/commonjs/reverseProxyPolicy.js.map +1 -0
  74. package/dist/commonjs/tracing.d.ts +3 -0
  75. package/dist/commonjs/tracing.d.ts.map +1 -0
  76. package/dist/commonjs/tracing.js +12 -0
  77. package/dist/commonjs/tracing.js.map +1 -0
  78. package/dist/commonjs/tsdoc-metadata.json +11 -0
  79. package/dist/commonjs/utils.d.ts +29 -0
  80. package/dist/commonjs/utils.d.ts.map +1 -0
  81. package/dist/commonjs/utils.js +73 -0
  82. package/dist/commonjs/utils.js.map +1 -0
  83. package/dist/commonjs/webPubSubCredentialPolicy.d.ts +13 -0
  84. package/dist/commonjs/webPubSubCredentialPolicy.d.ts.map +1 -0
  85. package/dist/commonjs/webPubSubCredentialPolicy.js +32 -0
  86. package/dist/commonjs/webPubSubCredentialPolicy.js.map +1 -0
  87. package/dist/esm/generated/generatedClient.d.ts +19 -0
  88. package/dist/esm/generated/generatedClient.d.ts.map +1 -0
  89. package/{dist-esm/src → dist/esm}/generated/generatedClient.js +1 -1
  90. package/dist/esm/generated/generatedClient.js.map +1 -0
  91. package/dist/esm/generated/generatedClientContext.d.ts +14 -0
  92. package/dist/esm/generated/generatedClientContext.d.ts.map +1 -0
  93. package/dist/esm/generated/generatedClientContext.js.map +1 -0
  94. package/dist/esm/generated/index.d.ts +4 -0
  95. package/dist/esm/generated/index.d.ts.map +1 -0
  96. package/{dist-esm/src → dist/esm}/generated/index.js +3 -3
  97. package/dist/esm/generated/index.js.map +1 -0
  98. package/dist/esm/generated/models/index.d.ts +323 -0
  99. package/dist/esm/generated/models/index.d.ts.map +1 -0
  100. package/dist/esm/generated/models/mappers.d.ts +30 -0
  101. package/dist/esm/generated/models/mappers.d.ts.map +1 -0
  102. package/dist/esm/generated/models/parameters.d.ts +31 -0
  103. package/dist/esm/generated/models/parameters.d.ts.map +1 -0
  104. package/{dist-esm/src → dist/esm}/generated/models/parameters.js +1 -1
  105. package/dist/esm/generated/models/parameters.js.map +1 -0
  106. package/dist/esm/generated/operations/healthApi.d.ts +18 -0
  107. package/dist/esm/generated/operations/healthApi.d.ts.map +1 -0
  108. package/{dist-esm/src → dist/esm}/generated/operations/healthApi.js +2 -2
  109. package/dist/esm/generated/operations/healthApi.js.map +1 -0
  110. package/dist/esm/generated/operations/index.d.ts +3 -0
  111. package/dist/esm/generated/operations/index.d.ts.map +1 -0
  112. package/{dist-esm/src/generated/operationsInterfaces → dist/esm/generated/operations}/index.js +2 -2
  113. package/dist/esm/generated/operations/index.js.map +1 -0
  114. package/dist/esm/generated/operations/webPubSub.d.ts +249 -0
  115. package/dist/esm/generated/operations/webPubSub.d.ts.map +1 -0
  116. package/{dist-esm/src → dist/esm}/generated/operations/webPubSub.js +2 -2
  117. package/dist/esm/generated/operations/webPubSub.js.map +1 -0
  118. package/dist/esm/generated/operationsInterfaces/healthApi.d.ts +10 -0
  119. package/dist/esm/generated/operationsInterfaces/healthApi.d.ts.map +1 -0
  120. package/{dist-esm/src → dist/esm}/generated/operationsInterfaces/healthApi.js.map +1 -1
  121. package/dist/esm/generated/operationsInterfaces/index.d.ts +3 -0
  122. package/dist/esm/generated/operationsInterfaces/index.d.ts.map +1 -0
  123. package/{dist-esm/src/generated/operations → dist/esm/generated/operationsInterfaces}/index.js +2 -2
  124. package/dist/esm/generated/operationsInterfaces/index.js.map +1 -0
  125. package/dist/esm/generated/operationsInterfaces/webPubSub.d.ts +224 -0
  126. package/dist/esm/generated/operationsInterfaces/webPubSub.d.ts.map +1 -0
  127. package/dist/esm/generated/operationsInterfaces/webPubSub.js.map +1 -0
  128. package/dist/esm/groupClient.d.ts +232 -0
  129. package/dist/esm/groupClient.d.ts.map +1 -0
  130. package/{dist-esm/src → dist/esm}/groupClient.js +2 -2
  131. package/dist/esm/groupClient.js.map +1 -0
  132. package/dist/esm/hubClient.d.ts +478 -0
  133. package/dist/esm/hubClient.d.ts.map +1 -0
  134. package/{dist-esm/src → dist/esm}/hubClient.js +9 -9
  135. package/dist/esm/hubClient.js.map +1 -0
  136. package/dist/esm/index.d.ts +5 -0
  137. package/dist/esm/index.d.ts.map +1 -0
  138. package/{dist-esm/src → dist/esm}/index.js +2 -2
  139. package/dist/esm/index.js.map +1 -0
  140. package/dist/esm/logger.d.ts +5 -0
  141. package/dist/esm/logger.d.ts.map +1 -0
  142. package/dist/esm/package.json +3 -0
  143. package/dist/esm/parseConnectionString.d.ts +8 -0
  144. package/dist/esm/parseConnectionString.d.ts.map +1 -0
  145. package/dist/esm/reverseProxyPolicy.d.ts +9 -0
  146. package/dist/esm/reverseProxyPolicy.d.ts.map +1 -0
  147. package/dist/esm/tracing.d.ts +3 -0
  148. package/dist/esm/tracing.d.ts.map +1 -0
  149. package/dist/esm/utils.d.ts +29 -0
  150. package/dist/esm/utils.d.ts.map +1 -0
  151. package/dist/esm/webPubSubCredentialPolicy.d.ts +13 -0
  152. package/dist/esm/webPubSubCredentialPolicy.d.ts.map +1 -0
  153. package/package.json +56 -52
  154. package/dist/index.js +0 -2441
  155. package/dist/index.js.map +0 -1
  156. package/dist-esm/samples-dev/broadcasting.js +0 -27
  157. package/dist-esm/samples-dev/broadcasting.js.map +0 -1
  158. package/dist-esm/samples-dev/directMessage.js +0 -20
  159. package/dist-esm/samples-dev/directMessage.js.map +0 -1
  160. package/dist-esm/samples-dev/managingGroups.js +0 -23
  161. package/dist-esm/samples-dev/managingGroups.js.map +0 -1
  162. package/dist-esm/src/generated/generatedClient.js.map +0 -1
  163. package/dist-esm/src/generated/generatedClientContext.js.map +0 -1
  164. package/dist-esm/src/generated/index.js.map +0 -1
  165. package/dist-esm/src/generated/models/parameters.js.map +0 -1
  166. package/dist-esm/src/generated/operations/healthApi.js.map +0 -1
  167. package/dist-esm/src/generated/operations/index.js.map +0 -1
  168. package/dist-esm/src/generated/operations/webPubSub.js.map +0 -1
  169. package/dist-esm/src/generated/operationsInterfaces/index.js.map +0 -1
  170. package/dist-esm/src/generated/operationsInterfaces/webPubSub.js.map +0 -1
  171. package/dist-esm/src/groupClient.js.map +0 -1
  172. package/dist-esm/src/hubClient.js.map +0 -1
  173. package/dist-esm/src/index.js.map +0 -1
  174. package/dist-esm/test/conn.spec.js +0 -23
  175. package/dist-esm/test/conn.spec.js.map +0 -1
  176. package/dist-esm/test/groups.spec.js +0 -138
  177. package/dist-esm/test/groups.spec.js.map +0 -1
  178. package/dist-esm/test/hubs.spec.js +0 -270
  179. package/dist-esm/test/hubs.spec.js.map +0 -1
  180. package/dist-esm/test/integration.spec.js +0 -299
  181. package/dist-esm/test/integration.spec.js.map +0 -1
  182. package/dist-esm/test/odata.spec.js +0 -15
  183. package/dist-esm/test/odata.spec.js.map +0 -1
  184. package/dist-esm/test/testEnv.js +0 -23
  185. package/dist-esm/test/testEnv.js.map +0 -1
  186. /package/{dist-esm/src → dist/esm}/generated/generatedClientContext.js +0 -0
  187. /package/{dist-esm/src → dist/esm}/generated/models/index.js +0 -0
  188. /package/{dist-esm/src → dist/esm}/generated/models/index.js.map +0 -0
  189. /package/{dist-esm/src → dist/esm}/generated/models/mappers.js +0 -0
  190. /package/{dist-esm/src → dist/esm}/generated/models/mappers.js.map +0 -0
  191. /package/{dist-esm/src → dist/esm}/generated/operationsInterfaces/healthApi.js +0 -0
  192. /package/{dist-esm/src → dist/esm}/generated/operationsInterfaces/webPubSub.js +0 -0
  193. /package/{dist-esm/src → dist/esm}/logger.js +0 -0
  194. /package/{dist-esm/src → dist/esm}/logger.js.map +0 -0
  195. /package/{dist-esm/src → dist/esm}/parseConnectionString.js +0 -0
  196. /package/{dist-esm/src → dist/esm}/parseConnectionString.js.map +0 -0
  197. /package/{dist-esm/src → dist/esm}/reverseProxyPolicy.js +0 -0
  198. /package/{dist-esm/src → dist/esm}/reverseProxyPolicy.js.map +0 -0
  199. /package/{dist-esm/src → dist/esm}/tracing.js +0 -0
  200. /package/{dist-esm/src → dist/esm}/tracing.js.map +0 -0
  201. /package/{dist-esm/src → dist/esm}/utils.js +0 -0
  202. /package/{dist-esm/src → dist/esm}/utils.js.map +0 -0
  203. /package/{dist-esm/src → dist/esm}/webPubSubCredentialPolicy.js +0 -0
  204. /package/{dist-esm/src → dist/esm}/webPubSubCredentialPolicy.js.map +0 -0
  205. /package/{types → dist}/web-pubsub.d.ts +0 -0
package/dist/index.js DELETED
@@ -1,2441 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', { value: true });
4
-
5
- var coreAuth = require('@azure/core-auth');
6
- var coreRestPipeline = require('@azure/core-rest-pipeline');
7
- var coreClient = require('@azure/core-client');
8
- var coreTracing = require('@azure/core-tracing');
9
- var jwt = require('jsonwebtoken');
10
- var logger$1 = require('@azure/logger');
11
-
12
- function _interopNamespaceDefault(e) {
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n.default = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var coreClient__namespace = /*#__PURE__*/_interopNamespaceDefault(coreClient);
30
-
31
- /*
32
- * Copyright (c) Microsoft Corporation.
33
- * Licensed under the MIT License.
34
- *
35
- * Code generated by Microsoft (R) AutoRest Code Generator.
36
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
37
- */
38
- const AddToGroupsRequest = {
39
- type: {
40
- name: "Composite",
41
- className: "AddToGroupsRequest",
42
- modelProperties: {
43
- groups: {
44
- serializedName: "groups",
45
- type: {
46
- name: "Sequence",
47
- element: {
48
- type: {
49
- name: "String",
50
- },
51
- },
52
- },
53
- },
54
- filter: {
55
- serializedName: "filter",
56
- type: {
57
- name: "String",
58
- },
59
- },
60
- },
61
- },
62
- };
63
- const ErrorDetail = {
64
- type: {
65
- name: "Composite",
66
- className: "ErrorDetail",
67
- modelProperties: {
68
- code: {
69
- serializedName: "code",
70
- type: {
71
- name: "String",
72
- },
73
- },
74
- message: {
75
- serializedName: "message",
76
- type: {
77
- name: "String",
78
- },
79
- },
80
- target: {
81
- serializedName: "target",
82
- type: {
83
- name: "String",
84
- },
85
- },
86
- details: {
87
- serializedName: "details",
88
- type: {
89
- name: "Sequence",
90
- element: {
91
- type: {
92
- name: "Composite",
93
- className: "ErrorDetail",
94
- },
95
- },
96
- },
97
- },
98
- inner: {
99
- serializedName: "inner",
100
- type: {
101
- name: "Composite",
102
- className: "InnerError",
103
- },
104
- },
105
- },
106
- },
107
- };
108
- const InnerError = {
109
- type: {
110
- name: "Composite",
111
- className: "InnerError",
112
- modelProperties: {
113
- code: {
114
- serializedName: "code",
115
- type: {
116
- name: "String",
117
- },
118
- },
119
- inner: {
120
- serializedName: "inner",
121
- type: {
122
- name: "Composite",
123
- className: "InnerError",
124
- },
125
- },
126
- },
127
- },
128
- };
129
- const ClientTokenResponse = {
130
- type: {
131
- name: "Composite",
132
- className: "ClientTokenResponse",
133
- modelProperties: {
134
- token: {
135
- serializedName: "token",
136
- type: {
137
- name: "String",
138
- },
139
- },
140
- },
141
- },
142
- };
143
- const RemoveFromGroupsRequest = {
144
- type: {
145
- name: "Composite",
146
- className: "RemoveFromGroupsRequest",
147
- modelProperties: {
148
- groups: {
149
- serializedName: "groups",
150
- type: {
151
- name: "Sequence",
152
- element: {
153
- type: {
154
- name: "String",
155
- },
156
- },
157
- },
158
- },
159
- filter: {
160
- serializedName: "filter",
161
- type: {
162
- name: "String",
163
- },
164
- },
165
- },
166
- },
167
- };
168
- const WebPubSubAddConnectionsToGroupsExceptionHeaders = {
169
- type: {
170
- name: "Composite",
171
- className: "WebPubSubAddConnectionsToGroupsExceptionHeaders",
172
- modelProperties: {
173
- errorCode: {
174
- serializedName: "x-ms-error-code",
175
- type: {
176
- name: "String",
177
- },
178
- },
179
- },
180
- },
181
- };
182
- const WebPubSubCloseAllConnectionsExceptionHeaders = {
183
- type: {
184
- name: "Composite",
185
- className: "WebPubSubCloseAllConnectionsExceptionHeaders",
186
- modelProperties: {
187
- errorCode: {
188
- serializedName: "x-ms-error-code",
189
- type: {
190
- name: "String",
191
- },
192
- },
193
- },
194
- },
195
- };
196
- const WebPubSubGenerateClientTokenExceptionHeaders = {
197
- type: {
198
- name: "Composite",
199
- className: "WebPubSubGenerateClientTokenExceptionHeaders",
200
- modelProperties: {
201
- errorCode: {
202
- serializedName: "x-ms-error-code",
203
- type: {
204
- name: "String",
205
- },
206
- },
207
- },
208
- },
209
- };
210
- const WebPubSubRemoveConnectionsFromGroupsExceptionHeaders = {
211
- type: {
212
- name: "Composite",
213
- className: "WebPubSubRemoveConnectionsFromGroupsExceptionHeaders",
214
- modelProperties: {
215
- errorCode: {
216
- serializedName: "x-ms-error-code",
217
- type: {
218
- name: "String",
219
- },
220
- },
221
- },
222
- },
223
- };
224
- const WebPubSubSendToAllExceptionHeaders = {
225
- type: {
226
- name: "Composite",
227
- className: "WebPubSubSendToAllExceptionHeaders",
228
- modelProperties: {
229
- errorCode: {
230
- serializedName: "x-ms-error-code",
231
- type: {
232
- name: "String",
233
- },
234
- },
235
- },
236
- },
237
- };
238
- const WebPubSubCloseConnectionExceptionHeaders = {
239
- type: {
240
- name: "Composite",
241
- className: "WebPubSubCloseConnectionExceptionHeaders",
242
- modelProperties: {
243
- errorCode: {
244
- serializedName: "x-ms-error-code",
245
- type: {
246
- name: "String",
247
- },
248
- },
249
- },
250
- },
251
- };
252
- const WebPubSubConnectionExistsExceptionHeaders = {
253
- type: {
254
- name: "Composite",
255
- className: "WebPubSubConnectionExistsExceptionHeaders",
256
- modelProperties: {
257
- errorCode: {
258
- serializedName: "x-ms-error-code",
259
- type: {
260
- name: "String",
261
- },
262
- },
263
- },
264
- },
265
- };
266
- const WebPubSubSendToConnectionExceptionHeaders = {
267
- type: {
268
- name: "Composite",
269
- className: "WebPubSubSendToConnectionExceptionHeaders",
270
- modelProperties: {
271
- errorCode: {
272
- serializedName: "x-ms-error-code",
273
- type: {
274
- name: "String",
275
- },
276
- },
277
- },
278
- },
279
- };
280
- const WebPubSubRemoveConnectionFromAllGroupsExceptionHeaders = {
281
- type: {
282
- name: "Composite",
283
- className: "WebPubSubRemoveConnectionFromAllGroupsExceptionHeaders",
284
- modelProperties: {
285
- errorCode: {
286
- serializedName: "x-ms-error-code",
287
- type: {
288
- name: "String",
289
- },
290
- },
291
- },
292
- },
293
- };
294
- const WebPubSubGroupExistsExceptionHeaders = {
295
- type: {
296
- name: "Composite",
297
- className: "WebPubSubGroupExistsExceptionHeaders",
298
- modelProperties: {
299
- errorCode: {
300
- serializedName: "x-ms-error-code",
301
- type: {
302
- name: "String",
303
- },
304
- },
305
- },
306
- },
307
- };
308
- const WebPubSubCloseGroupConnectionsExceptionHeaders = {
309
- type: {
310
- name: "Composite",
311
- className: "WebPubSubCloseGroupConnectionsExceptionHeaders",
312
- modelProperties: {
313
- errorCode: {
314
- serializedName: "x-ms-error-code",
315
- type: {
316
- name: "String",
317
- },
318
- },
319
- },
320
- },
321
- };
322
- const WebPubSubSendToGroupExceptionHeaders = {
323
- type: {
324
- name: "Composite",
325
- className: "WebPubSubSendToGroupExceptionHeaders",
326
- modelProperties: {
327
- errorCode: {
328
- serializedName: "x-ms-error-code",
329
- type: {
330
- name: "String",
331
- },
332
- },
333
- },
334
- },
335
- };
336
- const WebPubSubRemoveConnectionFromGroupExceptionHeaders = {
337
- type: {
338
- name: "Composite",
339
- className: "WebPubSubRemoveConnectionFromGroupExceptionHeaders",
340
- modelProperties: {
341
- errorCode: {
342
- serializedName: "x-ms-error-code",
343
- type: {
344
- name: "String",
345
- },
346
- },
347
- },
348
- },
349
- };
350
- const WebPubSubAddConnectionToGroupExceptionHeaders = {
351
- type: {
352
- name: "Composite",
353
- className: "WebPubSubAddConnectionToGroupExceptionHeaders",
354
- modelProperties: {
355
- errorCode: {
356
- serializedName: "x-ms-error-code",
357
- type: {
358
- name: "String",
359
- },
360
- },
361
- },
362
- },
363
- };
364
- const WebPubSubRevokePermissionExceptionHeaders = {
365
- type: {
366
- name: "Composite",
367
- className: "WebPubSubRevokePermissionExceptionHeaders",
368
- modelProperties: {
369
- errorCode: {
370
- serializedName: "x-ms-error-code",
371
- type: {
372
- name: "String",
373
- },
374
- },
375
- },
376
- },
377
- };
378
- const WebPubSubCheckPermissionExceptionHeaders = {
379
- type: {
380
- name: "Composite",
381
- className: "WebPubSubCheckPermissionExceptionHeaders",
382
- modelProperties: {
383
- errorCode: {
384
- serializedName: "x-ms-error-code",
385
- type: {
386
- name: "String",
387
- },
388
- },
389
- },
390
- },
391
- };
392
- const WebPubSubGrantPermissionExceptionHeaders = {
393
- type: {
394
- name: "Composite",
395
- className: "WebPubSubGrantPermissionExceptionHeaders",
396
- modelProperties: {
397
- errorCode: {
398
- serializedName: "x-ms-error-code",
399
- type: {
400
- name: "String",
401
- },
402
- },
403
- },
404
- },
405
- };
406
- const WebPubSubUserExistsExceptionHeaders = {
407
- type: {
408
- name: "Composite",
409
- className: "WebPubSubUserExistsExceptionHeaders",
410
- modelProperties: {
411
- errorCode: {
412
- serializedName: "x-ms-error-code",
413
- type: {
414
- name: "String",
415
- },
416
- },
417
- },
418
- },
419
- };
420
- const WebPubSubCloseUserConnectionsExceptionHeaders = {
421
- type: {
422
- name: "Composite",
423
- className: "WebPubSubCloseUserConnectionsExceptionHeaders",
424
- modelProperties: {
425
- errorCode: {
426
- serializedName: "x-ms-error-code",
427
- type: {
428
- name: "String",
429
- },
430
- },
431
- },
432
- },
433
- };
434
- const WebPubSubSendToUserExceptionHeaders = {
435
- type: {
436
- name: "Composite",
437
- className: "WebPubSubSendToUserExceptionHeaders",
438
- modelProperties: {
439
- errorCode: {
440
- serializedName: "x-ms-error-code",
441
- type: {
442
- name: "String",
443
- },
444
- },
445
- },
446
- },
447
- };
448
- const WebPubSubRemoveUserFromAllGroupsExceptionHeaders = {
449
- type: {
450
- name: "Composite",
451
- className: "WebPubSubRemoveUserFromAllGroupsExceptionHeaders",
452
- modelProperties: {
453
- errorCode: {
454
- serializedName: "x-ms-error-code",
455
- type: {
456
- name: "String",
457
- },
458
- },
459
- },
460
- },
461
- };
462
- const WebPubSubRemoveUserFromGroupExceptionHeaders = {
463
- type: {
464
- name: "Composite",
465
- className: "WebPubSubRemoveUserFromGroupExceptionHeaders",
466
- modelProperties: {
467
- errorCode: {
468
- serializedName: "x-ms-error-code",
469
- type: {
470
- name: "String",
471
- },
472
- },
473
- },
474
- },
475
- };
476
- const WebPubSubAddUserToGroupExceptionHeaders = {
477
- type: {
478
- name: "Composite",
479
- className: "WebPubSubAddUserToGroupExceptionHeaders",
480
- modelProperties: {
481
- errorCode: {
482
- serializedName: "x-ms-error-code",
483
- type: {
484
- name: "String",
485
- },
486
- },
487
- },
488
- },
489
- };
490
-
491
- var Mappers = /*#__PURE__*/Object.freeze({
492
- __proto__: null,
493
- AddToGroupsRequest: AddToGroupsRequest,
494
- ClientTokenResponse: ClientTokenResponse,
495
- ErrorDetail: ErrorDetail,
496
- InnerError: InnerError,
497
- RemoveFromGroupsRequest: RemoveFromGroupsRequest,
498
- WebPubSubAddConnectionToGroupExceptionHeaders: WebPubSubAddConnectionToGroupExceptionHeaders,
499
- WebPubSubAddConnectionsToGroupsExceptionHeaders: WebPubSubAddConnectionsToGroupsExceptionHeaders,
500
- WebPubSubAddUserToGroupExceptionHeaders: WebPubSubAddUserToGroupExceptionHeaders,
501
- WebPubSubCheckPermissionExceptionHeaders: WebPubSubCheckPermissionExceptionHeaders,
502
- WebPubSubCloseAllConnectionsExceptionHeaders: WebPubSubCloseAllConnectionsExceptionHeaders,
503
- WebPubSubCloseConnectionExceptionHeaders: WebPubSubCloseConnectionExceptionHeaders,
504
- WebPubSubCloseGroupConnectionsExceptionHeaders: WebPubSubCloseGroupConnectionsExceptionHeaders,
505
- WebPubSubCloseUserConnectionsExceptionHeaders: WebPubSubCloseUserConnectionsExceptionHeaders,
506
- WebPubSubConnectionExistsExceptionHeaders: WebPubSubConnectionExistsExceptionHeaders,
507
- WebPubSubGenerateClientTokenExceptionHeaders: WebPubSubGenerateClientTokenExceptionHeaders,
508
- WebPubSubGrantPermissionExceptionHeaders: WebPubSubGrantPermissionExceptionHeaders,
509
- WebPubSubGroupExistsExceptionHeaders: WebPubSubGroupExistsExceptionHeaders,
510
- WebPubSubRemoveConnectionFromAllGroupsExceptionHeaders: WebPubSubRemoveConnectionFromAllGroupsExceptionHeaders,
511
- WebPubSubRemoveConnectionFromGroupExceptionHeaders: WebPubSubRemoveConnectionFromGroupExceptionHeaders,
512
- WebPubSubRemoveConnectionsFromGroupsExceptionHeaders: WebPubSubRemoveConnectionsFromGroupsExceptionHeaders,
513
- WebPubSubRemoveUserFromAllGroupsExceptionHeaders: WebPubSubRemoveUserFromAllGroupsExceptionHeaders,
514
- WebPubSubRemoveUserFromGroupExceptionHeaders: WebPubSubRemoveUserFromGroupExceptionHeaders,
515
- WebPubSubRevokePermissionExceptionHeaders: WebPubSubRevokePermissionExceptionHeaders,
516
- WebPubSubSendToAllExceptionHeaders: WebPubSubSendToAllExceptionHeaders,
517
- WebPubSubSendToConnectionExceptionHeaders: WebPubSubSendToConnectionExceptionHeaders,
518
- WebPubSubSendToGroupExceptionHeaders: WebPubSubSendToGroupExceptionHeaders,
519
- WebPubSubSendToUserExceptionHeaders: WebPubSubSendToUserExceptionHeaders,
520
- WebPubSubUserExistsExceptionHeaders: WebPubSubUserExistsExceptionHeaders
521
- });
522
-
523
- /*
524
- * Copyright (c) Microsoft Corporation.
525
- * Licensed under the MIT License.
526
- *
527
- * Code generated by Microsoft (R) AutoRest Code Generator.
528
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
529
- */
530
- const endpoint = {
531
- parameterPath: "endpoint",
532
- mapper: {
533
- serializedName: "endpoint",
534
- required: true,
535
- type: {
536
- name: "String",
537
- },
538
- },
539
- skipEncoding: true,
540
- };
541
- const apiVersion = {
542
- parameterPath: "apiVersion",
543
- mapper: {
544
- defaultValue: "2024-01-01",
545
- isConstant: true,
546
- serializedName: "api-version",
547
- type: {
548
- name: "String",
549
- },
550
- },
551
- };
552
- const contentType = {
553
- parameterPath: ["options", "contentType"],
554
- mapper: {
555
- defaultValue: "application/json",
556
- isConstant: true,
557
- serializedName: "Content-Type",
558
- type: {
559
- name: "String",
560
- },
561
- },
562
- };
563
- const groupsToAdd = {
564
- parameterPath: "groupsToAdd",
565
- mapper: AddToGroupsRequest,
566
- };
567
- const accept = {
568
- parameterPath: "accept",
569
- mapper: {
570
- defaultValue: "application/json",
571
- isConstant: true,
572
- serializedName: "Accept",
573
- type: {
574
- name: "String",
575
- },
576
- },
577
- };
578
- const hub = {
579
- parameterPath: "hub",
580
- mapper: {
581
- constraints: {
582
- Pattern: new RegExp("^[A-Za-z][A-Za-z0-9_`,.[\\]]{0,127}$"),
583
- },
584
- serializedName: "hub",
585
- required: true,
586
- type: {
587
- name: "String",
588
- },
589
- },
590
- };
591
- const excluded = {
592
- parameterPath: ["options", "excluded"],
593
- mapper: {
594
- serializedName: "excluded",
595
- type: {
596
- name: "Sequence",
597
- element: {
598
- type: {
599
- name: "String",
600
- },
601
- },
602
- },
603
- },
604
- collectionFormat: "Multi",
605
- };
606
- const reason = {
607
- parameterPath: ["options", "reason"],
608
- mapper: {
609
- serializedName: "reason",
610
- type: {
611
- name: "String",
612
- },
613
- },
614
- };
615
- const accept1 = {
616
- parameterPath: "accept",
617
- mapper: {
618
- defaultValue: "application/json, text/json",
619
- isConstant: true,
620
- serializedName: "Accept",
621
- type: {
622
- name: "String",
623
- },
624
- },
625
- };
626
- const userId = {
627
- parameterPath: ["options", "userId"],
628
- mapper: {
629
- serializedName: "userId",
630
- type: {
631
- name: "String",
632
- },
633
- },
634
- };
635
- const roles = {
636
- parameterPath: ["options", "roles"],
637
- mapper: {
638
- serializedName: "role",
639
- type: {
640
- name: "Sequence",
641
- element: {
642
- type: {
643
- name: "String",
644
- },
645
- },
646
- },
647
- },
648
- collectionFormat: "Multi",
649
- };
650
- const expirationTimeInMinutes = {
651
- parameterPath: ["options", "expirationTimeInMinutes"],
652
- mapper: {
653
- defaultValue: 60,
654
- constraints: {
655
- InclusiveMinimum: 1,
656
- },
657
- serializedName: "minutesToExpire",
658
- type: {
659
- name: "Number",
660
- },
661
- },
662
- };
663
- const groups = {
664
- parameterPath: ["options", "groups"],
665
- mapper: {
666
- serializedName: "group",
667
- type: {
668
- name: "Sequence",
669
- element: {
670
- type: {
671
- name: "String",
672
- },
673
- },
674
- },
675
- },
676
- collectionFormat: "Multi",
677
- };
678
- const clientType = {
679
- parameterPath: ["options", "clientType"],
680
- mapper: {
681
- defaultValue: "Default",
682
- serializedName: "clientType",
683
- type: {
684
- name: "String",
685
- },
686
- },
687
- };
688
- const groupsToRemove = {
689
- parameterPath: "groupsToRemove",
690
- mapper: RemoveFromGroupsRequest,
691
- };
692
- const contentType1 = {
693
- parameterPath: "contentType",
694
- mapper: {
695
- serializedName: "Content-Type",
696
- required: true,
697
- type: {
698
- name: "Enum",
699
- allowedValues: ["application/json", "application/octet-stream"],
700
- },
701
- },
702
- };
703
- const message = {
704
- parameterPath: "message",
705
- mapper: {
706
- serializedName: "message",
707
- required: true,
708
- type: {
709
- name: "Stream",
710
- },
711
- },
712
- };
713
- const accept2 = {
714
- parameterPath: "accept",
715
- mapper: {
716
- defaultValue: "application/json",
717
- isConstant: true,
718
- serializedName: "Accept",
719
- type: {
720
- name: "String",
721
- },
722
- },
723
- };
724
- const contentType2 = {
725
- parameterPath: "contentType",
726
- mapper: {
727
- defaultValue: "text/plain",
728
- isConstant: true,
729
- serializedName: "Content-Type",
730
- type: {
731
- name: "String",
732
- },
733
- },
734
- };
735
- const message1 = {
736
- parameterPath: "message",
737
- mapper: {
738
- serializedName: "message",
739
- required: true,
740
- type: {
741
- name: "String",
742
- },
743
- },
744
- };
745
- const accept3 = {
746
- parameterPath: "accept",
747
- mapper: {
748
- defaultValue: "application/json",
749
- isConstant: true,
750
- serializedName: "Accept",
751
- type: {
752
- name: "String",
753
- },
754
- },
755
- };
756
- const excludedConnections = {
757
- parameterPath: ["options", "excludedConnections"],
758
- mapper: {
759
- serializedName: "excluded",
760
- type: {
761
- name: "Sequence",
762
- element: {
763
- type: {
764
- name: "String",
765
- },
766
- },
767
- },
768
- },
769
- collectionFormat: "Multi",
770
- };
771
- const filter = {
772
- parameterPath: ["options", "filter"],
773
- mapper: {
774
- serializedName: "filter",
775
- type: {
776
- name: "String",
777
- },
778
- },
779
- };
780
- const messageTtlSeconds = {
781
- parameterPath: ["options", "messageTtlSeconds"],
782
- mapper: {
783
- constraints: {
784
- InclusiveMaximum: 300,
785
- InclusiveMinimum: 0,
786
- },
787
- serializedName: "messageTtlSeconds",
788
- type: {
789
- name: "Number",
790
- },
791
- },
792
- };
793
- const connectionId = {
794
- parameterPath: "connectionId",
795
- mapper: {
796
- constraints: {
797
- MinLength: 1,
798
- },
799
- serializedName: "connectionId",
800
- required: true,
801
- type: {
802
- name: "String",
803
- },
804
- },
805
- };
806
- const group = {
807
- parameterPath: "group",
808
- mapper: {
809
- constraints: {
810
- Pattern: new RegExp("^(?!\\s+$).+$"),
811
- MaxLength: 1024,
812
- MinLength: 1,
813
- },
814
- serializedName: "group",
815
- required: true,
816
- type: {
817
- name: "String",
818
- },
819
- },
820
- };
821
- const permission = {
822
- parameterPath: "permission",
823
- mapper: {
824
- serializedName: "permission",
825
- required: true,
826
- type: {
827
- name: "String",
828
- },
829
- },
830
- };
831
- const targetName = {
832
- parameterPath: ["options", "targetName"],
833
- mapper: {
834
- serializedName: "targetName",
835
- type: {
836
- name: "String",
837
- },
838
- },
839
- };
840
- const userId1 = {
841
- parameterPath: "userId",
842
- mapper: {
843
- constraints: {
844
- MinLength: 1,
845
- },
846
- serializedName: "userId",
847
- required: true,
848
- type: {
849
- name: "String",
850
- },
851
- },
852
- };
853
-
854
- /*
855
- * Copyright (c) Microsoft Corporation.
856
- * Licensed under the MIT License.
857
- *
858
- * Code generated by Microsoft (R) AutoRest Code Generator.
859
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
860
- */
861
- /** Class containing HealthApi operations. */
862
- class HealthApiImpl {
863
- /**
864
- * Initialize a new instance of the class HealthApi class.
865
- * @param client Reference to the service client
866
- */
867
- constructor(client) {
868
- this.client = client;
869
- }
870
- /**
871
- * Get service health status.
872
- * @param options The options parameters.
873
- */
874
- getServiceStatus(options) {
875
- return this.client.sendOperationRequest({ options }, getServiceStatusOperationSpec);
876
- }
877
- }
878
- // Operation Specifications
879
- const serializer$1 = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
880
- const getServiceStatusOperationSpec = {
881
- path: "/api/health",
882
- httpMethod: "HEAD",
883
- responses: { 200: {}, default: {} },
884
- queryParameters: [apiVersion],
885
- urlParameters: [endpoint],
886
- serializer: serializer$1,
887
- };
888
-
889
- /*
890
- * Copyright (c) Microsoft Corporation.
891
- * Licensed under the MIT License.
892
- *
893
- * Code generated by Microsoft (R) AutoRest Code Generator.
894
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
895
- */
896
- /** Class containing WebPubSub operations. */
897
- class WebPubSubImpl {
898
- /**
899
- * Initialize a new instance of the class WebPubSub class.
900
- * @param client Reference to the service client
901
- */
902
- constructor(client) {
903
- this.client = client;
904
- }
905
- /**
906
- * Add filtered connections to multiple groups.
907
- * @param hub Target hub name, which should start with alphabetic characters and only contain
908
- * alpha-numeric characters or underscore.
909
- * @param groupsToAdd Target groups and connection filter.
910
- * @param options The options parameters.
911
- */
912
- addConnectionsToGroups(hub, groupsToAdd, options) {
913
- return this.client.sendOperationRequest({ hub, groupsToAdd, options }, addConnectionsToGroupsOperationSpec);
914
- }
915
- /**
916
- * Close the connections in the hub.
917
- * @param hub Target hub name, which should start with alphabetic characters and only contain
918
- * alpha-numeric characters or underscore.
919
- * @param options The options parameters.
920
- */
921
- closeAllConnections(hub, options) {
922
- return this.client.sendOperationRequest({ hub, options }, closeAllConnectionsOperationSpec);
923
- }
924
- /**
925
- * Generate token for the client to connect Azure Web PubSub service.
926
- * @param hub Target hub name, which should start with alphabetic characters and only contain
927
- * alpha-numeric characters or underscore.
928
- * @param options The options parameters.
929
- */
930
- generateClientToken(hub, options) {
931
- return this.client.sendOperationRequest({ hub, options }, generateClientTokenOperationSpec);
932
- }
933
- /**
934
- * Remove filtered connections from multiple groups.
935
- * @param hub Target hub name, which should start with alphabetic characters and only contain
936
- * alpha-numeric characters or underscore.
937
- * @param groupsToRemove Target groups and connection filter.
938
- * @param options The options parameters.
939
- */
940
- removeConnectionsFromGroups(hub, groupsToRemove, options) {
941
- return this.client.sendOperationRequest({ hub, groupsToRemove, options }, removeConnectionsFromGroupsOperationSpec);
942
- }
943
- /**
944
- * Broadcast content inside request body to all the connected client connections.
945
- * @param args Includes all the parameters for this operation.
946
- */
947
- sendToAll(...args) {
948
- let operationSpec;
949
- let operationArguments;
950
- let options;
951
- if (args[1] === "application/json" ||
952
- args[1] === "application/octet-stream") {
953
- operationSpec = sendToAll$binaryOperationSpec;
954
- operationArguments = {
955
- hub: args[0],
956
- contentType: args[1],
957
- message: args[2],
958
- options: args[3],
959
- };
960
- options = args[3];
961
- }
962
- else if (args[1] === "text/plain") {
963
- operationSpec = sendToAll$textOperationSpec;
964
- operationArguments = {
965
- hub: args[0],
966
- contentType: args[1],
967
- message: args[2],
968
- options: args[3],
969
- };
970
- options = args[3];
971
- }
972
- else {
973
- throw new TypeError(`"contentType" must be a valid value but instead was "${args[1]}".`);
974
- }
975
- operationArguments.options = options || {};
976
- return this.client.sendOperationRequest(operationArguments, operationSpec);
977
- }
978
- /**
979
- * Close the client connection.
980
- * @param hub Target hub name, which should start with alphabetic characters and only contain
981
- * alpha-numeric characters or underscore.
982
- * @param connectionId Target connection Id.
983
- * @param options The options parameters.
984
- */
985
- closeConnection(hub, connectionId, options) {
986
- return this.client.sendOperationRequest({ hub, connectionId, options }, closeConnectionOperationSpec);
987
- }
988
- /**
989
- * Check if the connection with the given connectionId exists.
990
- * @param hub Target hub name, which should start with alphabetic characters and only contain
991
- * alpha-numeric characters or underscore.
992
- * @param connectionId The connection Id.
993
- * @param options The options parameters.
994
- */
995
- connectionExists(hub, connectionId, options) {
996
- return this.client.sendOperationRequest({ hub, connectionId, options }, connectionExistsOperationSpec);
997
- }
998
- /**
999
- * Send content inside request body to the specific connection.
1000
- * @param args Includes all the parameters for this operation.
1001
- */
1002
- sendToConnection(...args) {
1003
- let operationSpec;
1004
- let operationArguments;
1005
- let options;
1006
- if (args[2] === "application/json" ||
1007
- args[2] === "application/octet-stream") {
1008
- operationSpec = sendToConnection$binaryOperationSpec;
1009
- operationArguments = {
1010
- hub: args[0],
1011
- connectionId: args[1],
1012
- contentType: args[2],
1013
- message: args[3],
1014
- options: args[4],
1015
- };
1016
- options = args[4];
1017
- }
1018
- else if (args[2] === "text/plain") {
1019
- operationSpec = sendToConnection$textOperationSpec;
1020
- operationArguments = {
1021
- hub: args[0],
1022
- connectionId: args[1],
1023
- contentType: args[2],
1024
- message: args[3],
1025
- options: args[4],
1026
- };
1027
- options = args[4];
1028
- }
1029
- else {
1030
- throw new TypeError(`"contentType" must be a valid value but instead was "${args[2]}".`);
1031
- }
1032
- operationArguments.options = options || {};
1033
- return this.client.sendOperationRequest(operationArguments, operationSpec);
1034
- }
1035
- /**
1036
- * Remove a connection from all groups.
1037
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1038
- * alpha-numeric characters or underscore.
1039
- * @param connectionId Target connection Id.
1040
- * @param options The options parameters.
1041
- */
1042
- removeConnectionFromAllGroups(hub, connectionId, options) {
1043
- return this.client.sendOperationRequest({ hub, connectionId, options }, removeConnectionFromAllGroupsOperationSpec);
1044
- }
1045
- /**
1046
- * Check if there are any client connections inside the given group
1047
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1048
- * alpha-numeric characters or underscore.
1049
- * @param group Target group name, which length should be greater than 0 and less than 1025.
1050
- * @param options The options parameters.
1051
- */
1052
- groupExists(hub, group, options) {
1053
- return this.client.sendOperationRequest({ hub, group, options }, groupExistsOperationSpec);
1054
- }
1055
- /**
1056
- * Close connections in the specific group.
1057
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1058
- * alpha-numeric characters or underscore.
1059
- * @param group Target group name, which length should be greater than 0 and less than 1025.
1060
- * @param options The options parameters.
1061
- */
1062
- closeGroupConnections(hub, group, options) {
1063
- return this.client.sendOperationRequest({ hub, group, options }, closeGroupConnectionsOperationSpec);
1064
- }
1065
- /**
1066
- * Send content inside request body to a group of connections.
1067
- * @param args Includes all the parameters for this operation.
1068
- */
1069
- sendToGroup(...args) {
1070
- let operationSpec;
1071
- let operationArguments;
1072
- let options;
1073
- if (args[2] === "application/json" ||
1074
- args[2] === "application/octet-stream") {
1075
- operationSpec = sendToGroup$binaryOperationSpec;
1076
- operationArguments = {
1077
- hub: args[0],
1078
- group: args[1],
1079
- contentType: args[2],
1080
- message: args[3],
1081
- options: args[4],
1082
- };
1083
- options = args[4];
1084
- }
1085
- else if (args[2] === "text/plain") {
1086
- operationSpec = sendToGroup$textOperationSpec;
1087
- operationArguments = {
1088
- hub: args[0],
1089
- group: args[1],
1090
- contentType: args[2],
1091
- message: args[3],
1092
- options: args[4],
1093
- };
1094
- options = args[4];
1095
- }
1096
- else {
1097
- throw new TypeError(`"contentType" must be a valid value but instead was "${args[2]}".`);
1098
- }
1099
- operationArguments.options = options || {};
1100
- return this.client.sendOperationRequest(operationArguments, operationSpec);
1101
- }
1102
- /**
1103
- * Remove a connection from the target group.
1104
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1105
- * alpha-numeric characters or underscore.
1106
- * @param group Target group name, which length should be greater than 0 and less than 1025.
1107
- * @param connectionId Target connection Id.
1108
- * @param options The options parameters.
1109
- */
1110
- removeConnectionFromGroup(hub, group, connectionId, options) {
1111
- return this.client.sendOperationRequest({ hub, group, connectionId, options }, removeConnectionFromGroupOperationSpec);
1112
- }
1113
- /**
1114
- * Add a connection to the target group.
1115
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1116
- * alpha-numeric characters or underscore.
1117
- * @param group Target group name, which length should be greater than 0 and less than 1025.
1118
- * @param connectionId Target connection Id
1119
- * @param options The options parameters.
1120
- */
1121
- addConnectionToGroup(hub, group, connectionId, options) {
1122
- return this.client.sendOperationRequest({ hub, group, connectionId, options }, addConnectionToGroupOperationSpec);
1123
- }
1124
- /**
1125
- * Revoke permission for the connection.
1126
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1127
- * alpha-numeric characters or underscore.
1128
- * @param permission The permission: current supported actions are joinLeaveGroup and sendToGroup.
1129
- * @param connectionId Target connection Id.
1130
- * @param options The options parameters.
1131
- */
1132
- revokePermission(hub, permission, connectionId, options) {
1133
- return this.client.sendOperationRequest({ hub, permission, connectionId, options }, revokePermissionOperationSpec);
1134
- }
1135
- /**
1136
- * Check if a connection has permission to the specified action.
1137
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1138
- * alpha-numeric characters or underscore.
1139
- * @param permission The permission: current supported actions are joinLeaveGroup and sendToGroup.
1140
- * @param connectionId Target connection Id.
1141
- * @param options The options parameters.
1142
- */
1143
- checkPermission(hub, permission, connectionId, options) {
1144
- return this.client.sendOperationRequest({ hub, permission, connectionId, options }, checkPermissionOperationSpec);
1145
- }
1146
- /**
1147
- * Grant permission to the connection.
1148
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1149
- * alpha-numeric characters or underscore.
1150
- * @param permission The permission: current supported actions are joinLeaveGroup and sendToGroup.
1151
- * @param connectionId Target connection Id.
1152
- * @param options The options parameters.
1153
- */
1154
- grantPermission(hub, permission, connectionId, options) {
1155
- return this.client.sendOperationRequest({ hub, permission, connectionId, options }, grantPermissionOperationSpec);
1156
- }
1157
- /**
1158
- * Check if there are any client connections connected for the given user.
1159
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1160
- * alpha-numeric characters or underscore.
1161
- * @param userId Target user Id.
1162
- * @param options The options parameters.
1163
- */
1164
- userExists(hub, userId, options) {
1165
- return this.client.sendOperationRequest({ hub, userId, options }, userExistsOperationSpec);
1166
- }
1167
- /**
1168
- * Close connections for the specific user.
1169
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1170
- * alpha-numeric characters or underscore.
1171
- * @param userId The user Id.
1172
- * @param options The options parameters.
1173
- */
1174
- closeUserConnections(hub, userId, options) {
1175
- return this.client.sendOperationRequest({ hub, userId, options }, closeUserConnectionsOperationSpec);
1176
- }
1177
- /**
1178
- * Send content inside request body to the specific user.
1179
- * @param args Includes all the parameters for this operation.
1180
- */
1181
- sendToUser(...args) {
1182
- let operationSpec;
1183
- let operationArguments;
1184
- let options;
1185
- if (args[2] === "application/json" ||
1186
- args[2] === "application/octet-stream") {
1187
- operationSpec = sendToUser$binaryOperationSpec;
1188
- operationArguments = {
1189
- hub: args[0],
1190
- userId: args[1],
1191
- contentType: args[2],
1192
- message: args[3],
1193
- options: args[4],
1194
- };
1195
- options = args[4];
1196
- }
1197
- else if (args[2] === "text/plain") {
1198
- operationSpec = sendToUser$textOperationSpec;
1199
- operationArguments = {
1200
- hub: args[0],
1201
- userId: args[1],
1202
- contentType: args[2],
1203
- message: args[3],
1204
- options: args[4],
1205
- };
1206
- options = args[4];
1207
- }
1208
- else {
1209
- throw new TypeError(`"contentType" must be a valid value but instead was "${args[2]}".`);
1210
- }
1211
- operationArguments.options = options || {};
1212
- return this.client.sendOperationRequest(operationArguments, operationSpec);
1213
- }
1214
- /**
1215
- * Remove a user from all groups.
1216
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1217
- * alpha-numeric characters or underscore.
1218
- * @param userId Target user Id.
1219
- * @param options The options parameters.
1220
- */
1221
- removeUserFromAllGroups(hub, userId, options) {
1222
- return this.client.sendOperationRequest({ hub, userId, options }, removeUserFromAllGroupsOperationSpec);
1223
- }
1224
- /**
1225
- * Remove a user from the target group.
1226
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1227
- * alpha-numeric characters or underscore.
1228
- * @param group Target group name, which length should be greater than 0 and less than 1025.
1229
- * @param userId Target user Id.
1230
- * @param options The options parameters.
1231
- */
1232
- removeUserFromGroup(hub, group, userId, options) {
1233
- return this.client.sendOperationRequest({ hub, group, userId, options }, removeUserFromGroupOperationSpec);
1234
- }
1235
- /**
1236
- * Add a user to the target group.
1237
- * @param hub Target hub name, which should start with alphabetic characters and only contain
1238
- * alpha-numeric characters or underscore.
1239
- * @param group Target group name, which length should be greater than 0 and less than 1025.
1240
- * @param userId Target user Id.
1241
- * @param options The options parameters.
1242
- */
1243
- addUserToGroup(hub, group, userId, options) {
1244
- return this.client.sendOperationRequest({ hub, group, userId, options }, addUserToGroupOperationSpec);
1245
- }
1246
- }
1247
- // Operation Specifications
1248
- const serializer = coreClient__namespace.createSerializer(Mappers, /* isXml */ false);
1249
- const addConnectionsToGroupsOperationSpec = {
1250
- path: "/api/hubs/{hub}/:addToGroups",
1251
- httpMethod: "POST",
1252
- responses: {
1253
- 200: {},
1254
- default: {
1255
- bodyMapper: ErrorDetail,
1256
- headersMapper: WebPubSubAddConnectionsToGroupsExceptionHeaders,
1257
- },
1258
- },
1259
- requestBody: groupsToAdd,
1260
- queryParameters: [apiVersion],
1261
- urlParameters: [endpoint, hub],
1262
- headerParameters: [contentType, accept],
1263
- mediaType: "json",
1264
- serializer,
1265
- };
1266
- const closeAllConnectionsOperationSpec = {
1267
- path: "/api/hubs/{hub}/:closeConnections",
1268
- httpMethod: "POST",
1269
- responses: {
1270
- 204: {},
1271
- default: {
1272
- bodyMapper: ErrorDetail,
1273
- headersMapper: WebPubSubCloseAllConnectionsExceptionHeaders,
1274
- },
1275
- },
1276
- queryParameters: [
1277
- apiVersion,
1278
- excluded,
1279
- reason,
1280
- ],
1281
- urlParameters: [endpoint, hub],
1282
- headerParameters: [accept],
1283
- serializer,
1284
- };
1285
- const generateClientTokenOperationSpec = {
1286
- path: "/api/hubs/{hub}/:generateToken",
1287
- httpMethod: "POST",
1288
- responses: {
1289
- 200: {
1290
- bodyMapper: ClientTokenResponse,
1291
- },
1292
- default: {
1293
- bodyMapper: ErrorDetail,
1294
- headersMapper: WebPubSubGenerateClientTokenExceptionHeaders,
1295
- },
1296
- },
1297
- queryParameters: [
1298
- apiVersion,
1299
- userId,
1300
- roles,
1301
- expirationTimeInMinutes,
1302
- groups,
1303
- clientType,
1304
- ],
1305
- urlParameters: [endpoint, hub],
1306
- headerParameters: [accept1],
1307
- serializer,
1308
- };
1309
- const removeConnectionsFromGroupsOperationSpec = {
1310
- path: "/api/hubs/{hub}/:removeFromGroups",
1311
- httpMethod: "POST",
1312
- responses: {
1313
- 200: {},
1314
- default: {
1315
- bodyMapper: ErrorDetail,
1316
- headersMapper: WebPubSubRemoveConnectionsFromGroupsExceptionHeaders,
1317
- },
1318
- },
1319
- requestBody: groupsToRemove,
1320
- queryParameters: [apiVersion],
1321
- urlParameters: [endpoint, hub],
1322
- headerParameters: [contentType, accept],
1323
- mediaType: "json",
1324
- serializer,
1325
- };
1326
- const sendToAll$binaryOperationSpec = {
1327
- path: "/api/hubs/{hub}/:send",
1328
- httpMethod: "POST",
1329
- responses: {
1330
- 202: {},
1331
- default: {
1332
- bodyMapper: ErrorDetail,
1333
- headersMapper: WebPubSubSendToAllExceptionHeaders,
1334
- },
1335
- },
1336
- requestBody: message,
1337
- queryParameters: [
1338
- apiVersion,
1339
- excludedConnections,
1340
- filter,
1341
- messageTtlSeconds,
1342
- ],
1343
- urlParameters: [endpoint, hub],
1344
- headerParameters: [contentType1, accept2],
1345
- mediaType: "binary",
1346
- serializer,
1347
- };
1348
- const sendToAll$textOperationSpec = {
1349
- path: "/api/hubs/{hub}/:send",
1350
- httpMethod: "POST",
1351
- responses: {
1352
- 202: {},
1353
- default: {
1354
- bodyMapper: ErrorDetail,
1355
- headersMapper: WebPubSubSendToAllExceptionHeaders,
1356
- },
1357
- },
1358
- requestBody: message1,
1359
- queryParameters: [
1360
- apiVersion,
1361
- excludedConnections,
1362
- filter,
1363
- messageTtlSeconds,
1364
- ],
1365
- urlParameters: [endpoint, hub],
1366
- headerParameters: [contentType2, accept3],
1367
- mediaType: "text",
1368
- serializer,
1369
- };
1370
- const closeConnectionOperationSpec = {
1371
- path: "/api/hubs/{hub}/connections/{connectionId}",
1372
- httpMethod: "DELETE",
1373
- responses: {
1374
- 204: {},
1375
- default: {
1376
- bodyMapper: ErrorDetail,
1377
- headersMapper: WebPubSubCloseConnectionExceptionHeaders,
1378
- },
1379
- },
1380
- queryParameters: [apiVersion, reason],
1381
- urlParameters: [endpoint, hub, connectionId],
1382
- headerParameters: [accept],
1383
- serializer,
1384
- };
1385
- const connectionExistsOperationSpec = {
1386
- path: "/api/hubs/{hub}/connections/{connectionId}",
1387
- httpMethod: "HEAD",
1388
- responses: {
1389
- 200: {},
1390
- 404: {},
1391
- default: {
1392
- headersMapper: WebPubSubConnectionExistsExceptionHeaders,
1393
- },
1394
- },
1395
- queryParameters: [apiVersion],
1396
- urlParameters: [endpoint, hub, connectionId],
1397
- serializer,
1398
- };
1399
- const sendToConnection$binaryOperationSpec = {
1400
- path: "/api/hubs/{hub}/connections/{connectionId}/:send",
1401
- httpMethod: "POST",
1402
- responses: {
1403
- 202: {},
1404
- default: {
1405
- bodyMapper: ErrorDetail,
1406
- headersMapper: WebPubSubSendToConnectionExceptionHeaders,
1407
- },
1408
- },
1409
- requestBody: message,
1410
- queryParameters: [apiVersion, messageTtlSeconds],
1411
- urlParameters: [endpoint, hub, connectionId],
1412
- headerParameters: [contentType1, accept2],
1413
- mediaType: "binary",
1414
- serializer,
1415
- };
1416
- const sendToConnection$textOperationSpec = {
1417
- path: "/api/hubs/{hub}/connections/{connectionId}/:send",
1418
- httpMethod: "POST",
1419
- responses: {
1420
- 202: {},
1421
- default: {
1422
- bodyMapper: ErrorDetail,
1423
- headersMapper: WebPubSubSendToConnectionExceptionHeaders,
1424
- },
1425
- },
1426
- requestBody: message1,
1427
- queryParameters: [apiVersion, messageTtlSeconds],
1428
- urlParameters: [endpoint, hub, connectionId],
1429
- headerParameters: [contentType2, accept3],
1430
- mediaType: "text",
1431
- serializer,
1432
- };
1433
- const removeConnectionFromAllGroupsOperationSpec = {
1434
- path: "/api/hubs/{hub}/connections/{connectionId}/groups",
1435
- httpMethod: "DELETE",
1436
- responses: {
1437
- 204: {},
1438
- default: {
1439
- bodyMapper: ErrorDetail,
1440
- headersMapper: WebPubSubRemoveConnectionFromAllGroupsExceptionHeaders,
1441
- },
1442
- },
1443
- queryParameters: [apiVersion],
1444
- urlParameters: [endpoint, hub, connectionId],
1445
- headerParameters: [accept],
1446
- serializer,
1447
- };
1448
- const groupExistsOperationSpec = {
1449
- path: "/api/hubs/{hub}/groups/{group}",
1450
- httpMethod: "HEAD",
1451
- responses: {
1452
- 200: {},
1453
- 404: {},
1454
- default: {
1455
- headersMapper: WebPubSubGroupExistsExceptionHeaders,
1456
- },
1457
- },
1458
- queryParameters: [apiVersion],
1459
- urlParameters: [endpoint, hub, group],
1460
- serializer,
1461
- };
1462
- const closeGroupConnectionsOperationSpec = {
1463
- path: "/api/hubs/{hub}/groups/{group}/:closeConnections",
1464
- httpMethod: "POST",
1465
- responses: {
1466
- 204: {},
1467
- default: {
1468
- bodyMapper: ErrorDetail,
1469
- headersMapper: WebPubSubCloseGroupConnectionsExceptionHeaders,
1470
- },
1471
- },
1472
- queryParameters: [
1473
- apiVersion,
1474
- excluded,
1475
- reason,
1476
- ],
1477
- urlParameters: [endpoint, hub, group],
1478
- headerParameters: [accept],
1479
- serializer,
1480
- };
1481
- const sendToGroup$binaryOperationSpec = {
1482
- path: "/api/hubs/{hub}/groups/{group}/:send",
1483
- httpMethod: "POST",
1484
- responses: {
1485
- 202: {},
1486
- default: {
1487
- bodyMapper: ErrorDetail,
1488
- headersMapper: WebPubSubSendToGroupExceptionHeaders,
1489
- },
1490
- },
1491
- requestBody: message,
1492
- queryParameters: [
1493
- apiVersion,
1494
- excludedConnections,
1495
- filter,
1496
- messageTtlSeconds,
1497
- ],
1498
- urlParameters: [endpoint, hub, group],
1499
- headerParameters: [contentType1, accept2],
1500
- mediaType: "binary",
1501
- serializer,
1502
- };
1503
- const sendToGroup$textOperationSpec = {
1504
- path: "/api/hubs/{hub}/groups/{group}/:send",
1505
- httpMethod: "POST",
1506
- responses: {
1507
- 202: {},
1508
- default: {
1509
- bodyMapper: ErrorDetail,
1510
- headersMapper: WebPubSubSendToGroupExceptionHeaders,
1511
- },
1512
- },
1513
- requestBody: message1,
1514
- queryParameters: [
1515
- apiVersion,
1516
- excludedConnections,
1517
- filter,
1518
- messageTtlSeconds,
1519
- ],
1520
- urlParameters: [endpoint, hub, group],
1521
- headerParameters: [contentType2, accept3],
1522
- mediaType: "text",
1523
- serializer,
1524
- };
1525
- const removeConnectionFromGroupOperationSpec = {
1526
- path: "/api/hubs/{hub}/groups/{group}/connections/{connectionId}",
1527
- httpMethod: "DELETE",
1528
- responses: {
1529
- 204: {},
1530
- default: {
1531
- bodyMapper: ErrorDetail,
1532
- headersMapper: WebPubSubRemoveConnectionFromGroupExceptionHeaders,
1533
- },
1534
- },
1535
- queryParameters: [apiVersion],
1536
- urlParameters: [
1537
- endpoint,
1538
- hub,
1539
- connectionId,
1540
- group,
1541
- ],
1542
- headerParameters: [accept],
1543
- serializer,
1544
- };
1545
- const addConnectionToGroupOperationSpec = {
1546
- path: "/api/hubs/{hub}/groups/{group}/connections/{connectionId}",
1547
- httpMethod: "PUT",
1548
- responses: {
1549
- 200: {},
1550
- default: {
1551
- bodyMapper: ErrorDetail,
1552
- headersMapper: WebPubSubAddConnectionToGroupExceptionHeaders,
1553
- },
1554
- },
1555
- queryParameters: [apiVersion],
1556
- urlParameters: [
1557
- endpoint,
1558
- hub,
1559
- connectionId,
1560
- group,
1561
- ],
1562
- headerParameters: [accept],
1563
- serializer,
1564
- };
1565
- const revokePermissionOperationSpec = {
1566
- path: "/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}",
1567
- httpMethod: "DELETE",
1568
- responses: {
1569
- 204: {},
1570
- default: {
1571
- bodyMapper: ErrorDetail,
1572
- headersMapper: WebPubSubRevokePermissionExceptionHeaders,
1573
- },
1574
- },
1575
- queryParameters: [apiVersion, targetName],
1576
- urlParameters: [
1577
- endpoint,
1578
- hub,
1579
- connectionId,
1580
- permission,
1581
- ],
1582
- headerParameters: [accept],
1583
- serializer,
1584
- };
1585
- const checkPermissionOperationSpec = {
1586
- path: "/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}",
1587
- httpMethod: "HEAD",
1588
- responses: {
1589
- 200: {},
1590
- 404: {},
1591
- default: {
1592
- headersMapper: WebPubSubCheckPermissionExceptionHeaders,
1593
- },
1594
- },
1595
- queryParameters: [apiVersion, targetName],
1596
- urlParameters: [
1597
- endpoint,
1598
- hub,
1599
- connectionId,
1600
- permission,
1601
- ],
1602
- serializer,
1603
- };
1604
- const grantPermissionOperationSpec = {
1605
- path: "/api/hubs/{hub}/permissions/{permission}/connections/{connectionId}",
1606
- httpMethod: "PUT",
1607
- responses: {
1608
- 200: {},
1609
- default: {
1610
- bodyMapper: ErrorDetail,
1611
- headersMapper: WebPubSubGrantPermissionExceptionHeaders,
1612
- },
1613
- },
1614
- queryParameters: [apiVersion, targetName],
1615
- urlParameters: [
1616
- endpoint,
1617
- hub,
1618
- connectionId,
1619
- permission,
1620
- ],
1621
- headerParameters: [accept],
1622
- serializer,
1623
- };
1624
- const userExistsOperationSpec = {
1625
- path: "/api/hubs/{hub}/users/{userId}",
1626
- httpMethod: "HEAD",
1627
- responses: {
1628
- 200: {},
1629
- 404: {},
1630
- default: {
1631
- headersMapper: WebPubSubUserExistsExceptionHeaders,
1632
- },
1633
- },
1634
- queryParameters: [apiVersion],
1635
- urlParameters: [endpoint, hub, userId1],
1636
- serializer,
1637
- };
1638
- const closeUserConnectionsOperationSpec = {
1639
- path: "/api/hubs/{hub}/users/{userId}/:closeConnections",
1640
- httpMethod: "POST",
1641
- responses: {
1642
- 204: {},
1643
- default: {
1644
- bodyMapper: ErrorDetail,
1645
- headersMapper: WebPubSubCloseUserConnectionsExceptionHeaders,
1646
- },
1647
- },
1648
- queryParameters: [
1649
- apiVersion,
1650
- excluded,
1651
- reason,
1652
- ],
1653
- urlParameters: [endpoint, hub, userId1],
1654
- headerParameters: [accept],
1655
- serializer,
1656
- };
1657
- const sendToUser$binaryOperationSpec = {
1658
- path: "/api/hubs/{hub}/users/{userId}/:send",
1659
- httpMethod: "POST",
1660
- responses: {
1661
- 202: {},
1662
- default: {
1663
- bodyMapper: ErrorDetail,
1664
- headersMapper: WebPubSubSendToUserExceptionHeaders,
1665
- },
1666
- },
1667
- requestBody: message,
1668
- queryParameters: [
1669
- apiVersion,
1670
- filter,
1671
- messageTtlSeconds,
1672
- ],
1673
- urlParameters: [endpoint, hub, userId1],
1674
- headerParameters: [contentType1, accept2],
1675
- mediaType: "binary",
1676
- serializer,
1677
- };
1678
- const sendToUser$textOperationSpec = {
1679
- path: "/api/hubs/{hub}/users/{userId}/:send",
1680
- httpMethod: "POST",
1681
- responses: {
1682
- 202: {},
1683
- default: {
1684
- bodyMapper: ErrorDetail,
1685
- headersMapper: WebPubSubSendToUserExceptionHeaders,
1686
- },
1687
- },
1688
- requestBody: message1,
1689
- queryParameters: [
1690
- apiVersion,
1691
- filter,
1692
- messageTtlSeconds,
1693
- ],
1694
- urlParameters: [endpoint, hub, userId1],
1695
- headerParameters: [contentType2, accept3],
1696
- mediaType: "text",
1697
- serializer,
1698
- };
1699
- const removeUserFromAllGroupsOperationSpec = {
1700
- path: "/api/hubs/{hub}/users/{userId}/groups",
1701
- httpMethod: "DELETE",
1702
- responses: {
1703
- 204: {},
1704
- default: {
1705
- bodyMapper: ErrorDetail,
1706
- headersMapper: WebPubSubRemoveUserFromAllGroupsExceptionHeaders,
1707
- },
1708
- },
1709
- queryParameters: [apiVersion],
1710
- urlParameters: [endpoint, hub, userId1],
1711
- headerParameters: [accept],
1712
- serializer,
1713
- };
1714
- const removeUserFromGroupOperationSpec = {
1715
- path: "/api/hubs/{hub}/users/{userId}/groups/{group}",
1716
- httpMethod: "DELETE",
1717
- responses: {
1718
- 204: {},
1719
- default: {
1720
- bodyMapper: ErrorDetail,
1721
- headersMapper: WebPubSubRemoveUserFromGroupExceptionHeaders,
1722
- },
1723
- },
1724
- queryParameters: [apiVersion],
1725
- urlParameters: [
1726
- endpoint,
1727
- hub,
1728
- group,
1729
- userId1,
1730
- ],
1731
- headerParameters: [accept],
1732
- serializer,
1733
- };
1734
- const addUserToGroupOperationSpec = {
1735
- path: "/api/hubs/{hub}/users/{userId}/groups/{group}",
1736
- httpMethod: "PUT",
1737
- responses: {
1738
- 200: {},
1739
- default: {
1740
- bodyMapper: ErrorDetail,
1741
- headersMapper: WebPubSubAddUserToGroupExceptionHeaders,
1742
- },
1743
- },
1744
- queryParameters: [apiVersion],
1745
- urlParameters: [
1746
- endpoint,
1747
- hub,
1748
- group,
1749
- userId1,
1750
- ],
1751
- headerParameters: [accept],
1752
- serializer,
1753
- };
1754
-
1755
- /*
1756
- * Copyright (c) Microsoft Corporation.
1757
- * Licensed under the MIT License.
1758
- *
1759
- * Code generated by Microsoft (R) AutoRest Code Generator.
1760
- * Changes may cause incorrect behavior and will be lost if the code is regenerated.
1761
- */
1762
- /** @internal */
1763
- class GeneratedClient extends coreClient__namespace.ServiceClient {
1764
- /**
1765
- * Initializes a new instance of the GeneratedClient class.
1766
- * @param endpoint HTTP or HTTPS endpoint for the Web PubSub service instance.
1767
- * @param options The parameter options
1768
- */
1769
- constructor(endpoint, options) {
1770
- var _a, _b;
1771
- if (endpoint === undefined) {
1772
- throw new Error("'endpoint' cannot be null");
1773
- }
1774
- // Initializing default values for options
1775
- if (!options) {
1776
- options = {};
1777
- }
1778
- const defaults = {
1779
- requestContentType: "application/json; charset=utf-8",
1780
- };
1781
- const packageDetails = `azsdk-js-web-pubsub/1.1.3`;
1782
- const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
1783
- ? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
1784
- : `${packageDetails}`;
1785
- const optionsWithDefaults = Object.assign(Object.assign(Object.assign({}, defaults), options), { userAgentOptions: {
1786
- userAgentPrefix,
1787
- }, endpoint: (_b = (_a = options.endpoint) !== null && _a !== void 0 ? _a : options.baseUri) !== null && _b !== void 0 ? _b : "{endpoint}" });
1788
- super(optionsWithDefaults);
1789
- // Parameter assignments
1790
- this.endpoint = endpoint;
1791
- // Assigning values to Constant parameters
1792
- this.apiVersion = options.apiVersion || "2024-01-01";
1793
- this.healthApi = new HealthApiImpl(this);
1794
- this.webPubSub = new WebPubSubImpl(this);
1795
- this.addCustomApiVersionPolicy(options.apiVersion);
1796
- }
1797
- /** A function that adds a policy that sets the api-version (or equivalent) to reflect the library version. */
1798
- addCustomApiVersionPolicy(apiVersion) {
1799
- if (!apiVersion) {
1800
- return;
1801
- }
1802
- const apiVersionPolicy = {
1803
- name: "CustomApiVersionPolicy",
1804
- async sendRequest(request, next) {
1805
- const param = request.url.split("?");
1806
- if (param.length > 1) {
1807
- const newParams = param[1].split("&").map((item) => {
1808
- if (item.indexOf("api-version") > -1) {
1809
- return "api-version=" + apiVersion;
1810
- }
1811
- else {
1812
- return item;
1813
- }
1814
- });
1815
- request.url = param[0] + "?" + newParams.join("&");
1816
- }
1817
- return next(request);
1818
- },
1819
- };
1820
- this.pipeline.addPolicy(apiVersionPolicy);
1821
- }
1822
- }
1823
-
1824
- // Copyright (c) Microsoft Corporation.
1825
- // Licensed under the MIT License.
1826
- /** @internal */
1827
- const tracingClient = coreTracing.createTracingClient({
1828
- namespace: "Microsoft.WebPubSub",
1829
- packageName: "@azure/web-pubsub",
1830
- });
1831
-
1832
- // Copyright (c) Microsoft Corporation.
1833
- // Licensed under the MIT License.
1834
- function isRequestBody(obj) {
1835
- return (typeof obj === "function" ||
1836
- (typeof obj === "object" &&
1837
- obj != null &&
1838
- (obj.constructor.name === "ArrayBuffer" ||
1839
- obj.constructor.name === "Blob" ||
1840
- ArrayBuffer.isView(obj))));
1841
- }
1842
- function getPayloadForMessage(message, options) {
1843
- if ((options === null || options === void 0 ? void 0 : options.contentType) === "text/plain") {
1844
- if (typeof message !== "string") {
1845
- throw new TypeError("Message must be a string.");
1846
- }
1847
- return { contentType: "text/plain", payload: message };
1848
- }
1849
- else if (isRequestBody(message)) {
1850
- return { contentType: "application/octet-stream", payload: message };
1851
- }
1852
- else {
1853
- return { contentType: "application/json", payload: JSON.stringify(message) };
1854
- }
1855
- }
1856
- function formatNullAndUndefined(input) {
1857
- if (input === null || input === undefined) {
1858
- return "null";
1859
- }
1860
- return input;
1861
- }
1862
- function escapeQuotesIfString(input, previous) {
1863
- let result = input;
1864
- if (typeof input === "string") {
1865
- result = input.replace(/'/g, "''");
1866
- // check if we need to escape this literal
1867
- if (!previous.trim().endsWith("'")) {
1868
- result = `'${result}'`;
1869
- }
1870
- }
1871
- return result;
1872
- }
1873
- /**
1874
- * Escapes an odata filter expression to avoid errors with quoting string literals.
1875
- * Example usage:
1876
- * ```ts
1877
- * const userId = "vic's";
1878
- * const anonymous = null;
1879
- * const length = 3
1880
- * const filter = odata`userId eq ${anonymous} or userId eq ${userId} or length(userId) > ${length}`;
1881
- * ```
1882
- * @param strings - Array of strings for the expression
1883
- * @param values - Array of values for the expression
1884
- */
1885
- function odata(strings, ...values) {
1886
- const results = [];
1887
- for (let i = 0; i < strings.length; i++) {
1888
- results.push(strings[i]);
1889
- if (i < values.length) {
1890
- if (values[i] === null || values[i] === undefined) {
1891
- results.push(formatNullAndUndefined(values[i]));
1892
- }
1893
- else {
1894
- results.push(escapeQuotesIfString(values[i], strings[i]));
1895
- }
1896
- }
1897
- }
1898
- return results.join("");
1899
- }
1900
-
1901
- // Copyright (c) Microsoft Corporation.
1902
- // Licensed under the MIT License.
1903
- /**
1904
- * @hidden
1905
- */
1906
- class WebPubSubGroupImpl {
1907
- /**
1908
- * @internal
1909
- */
1910
- constructor(client, hubName, groupName) {
1911
- /**
1912
- * The Web PubSub API version being used by this client
1913
- */
1914
- this.apiVersion = "2020-10-01";
1915
- this.client = client;
1916
- this.groupName = groupName;
1917
- this.hubName = hubName;
1918
- }
1919
- /**
1920
- * Add a specific connection to this group
1921
- *
1922
- * @param connectionId - The connection id to add to this group
1923
- * @param options - Additional options
1924
- */
1925
- async addConnection(connectionId, options = {}) {
1926
- let response;
1927
- function onResponse(rawResponse, flatResponse) {
1928
- response = rawResponse;
1929
- if (options.onResponse) {
1930
- options.onResponse(rawResponse, flatResponse);
1931
- }
1932
- }
1933
- return tracingClient.withSpan("WebPubSubGroupClient.addConnection", options, async (updatedOptions) => {
1934
- await this.client.webPubSub.addConnectionToGroup(this.hubName, this.groupName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
1935
- if (response.status === 404) {
1936
- throw new coreRestPipeline.RestError(`Connection id '${connectionId}' doesn't exist`, {
1937
- statusCode: response === null || response === void 0 ? void 0 : response.status,
1938
- request: response === null || response === void 0 ? void 0 : response.request,
1939
- response: response,
1940
- });
1941
- }
1942
- });
1943
- }
1944
- /**
1945
- * Remove a specific connection from this group
1946
- *
1947
- * @param connectionId - The connection id to remove from this group
1948
- * @param options - Additional options
1949
- */
1950
- async removeConnection(connectionId, options = {}) {
1951
- return tracingClient.withSpan("WebPubSubGroupClient.removeConnection", options, (updatedOptions) => {
1952
- return this.client.webPubSub.removeConnectionFromGroup(this.hubName, this.groupName, connectionId, updatedOptions);
1953
- });
1954
- }
1955
- /**
1956
- * Close all connections to this group
1957
- *
1958
- * @param options - Additional options
1959
- */
1960
- async closeAllConnections(options = {}) {
1961
- return tracingClient.withSpan("WebPubSubGroupClient.closeAllConnections", options, (updatedOptions) => {
1962
- return this.client.webPubSub.closeGroupConnections(this.hubName, this.groupName, updatedOptions);
1963
- });
1964
- }
1965
- /**
1966
- * Add a user to this group
1967
- *
1968
- * @param username - The user name to add
1969
- * @param options - Additional options
1970
- */
1971
- async addUser(username, options = {}) {
1972
- return tracingClient.withSpan("WebPubSubGroupClient.addUser", options, (updatedOptions) => {
1973
- return this.client.webPubSub.addUserToGroup(this.hubName, this.groupName, username, updatedOptions);
1974
- });
1975
- }
1976
- /**
1977
- * Remove a user from this group
1978
- *
1979
- * @param username - The user name to remove
1980
- * @param options - Additional options
1981
- */
1982
- async removeUser(username, options = {}) {
1983
- return tracingClient.withSpan("WebPubSubGroupClient.removeUser", options, (updatedOptions) => {
1984
- return this.client.webPubSub.removeUserFromGroup(this.hubName, this.groupName, username, updatedOptions);
1985
- });
1986
- }
1987
- async sendToAll(message, options = {}) {
1988
- return tracingClient.withSpan("WebPubSubGroupClient.sendToAll", options, (updatedOptions) => {
1989
- const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
1990
- return this.client.webPubSub.sendToGroup(this.hubName, this.groupName, contentType, payload, updatedOptions);
1991
- });
1992
- }
1993
- }
1994
-
1995
- // Copyright (c) Microsoft Corporation.
1996
- // Licensed under the MIT License.
1997
- /**
1998
- * The programmatic identifier of the webPubSubKeyCredentialPolicy.
1999
- */
2000
- const webPubSubKeyCredentialPolicyName = "webPubSubKeyCredentialPolicy";
2001
- /**
2002
- * Create an HTTP pipeline policy to authenticate a request
2003
- * using an `AzureKeyCredential` for Text Analytics
2004
- * @internal
2005
- */
2006
- function webPubSubKeyCredentialPolicy(credential) {
2007
- return {
2008
- name: webPubSubKeyCredentialPolicyName,
2009
- sendRequest(request, next) {
2010
- const bearerToken = jwt.sign({}, credential.key, {
2011
- audience: request.url,
2012
- expiresIn: "1h",
2013
- algorithm: "HS256",
2014
- });
2015
- request.headers.set("Authorization", `Bearer ${bearerToken}`);
2016
- return next(request);
2017
- },
2018
- };
2019
- }
2020
-
2021
- // Copyright (c) Microsoft Corporation.
2022
- // Licensed under the MIT License.
2023
- /**
2024
- * The `@azure/logger` configuration for this package.
2025
- */
2026
- const logger = logger$1.createClientLogger("web-pubsub");
2027
-
2028
- // Copyright (c) Microsoft Corporation.
2029
- // Licensed under the MIT License.
2030
- function parseConnectionString(conn) {
2031
- const parsed = {};
2032
- conn.split(";").forEach((i) => {
2033
- const assignmentPos = i.indexOf("=");
2034
- if (assignmentPos === -1)
2035
- return;
2036
- const key = i.substring(0, assignmentPos).toLowerCase();
2037
- const value = i.substring(assignmentPos + 1);
2038
- parsed[key] = value;
2039
- });
2040
- let endpointPart = parsed["endpoint"];
2041
- if (!endpointPart)
2042
- throw new TypeError("connection string missing endpoint");
2043
- if (!endpointPart.startsWith("http")) {
2044
- endpointPart = `https://${endpointPart}`;
2045
- }
2046
- const key = parsed["accesskey"];
2047
- if (!key)
2048
- throw new TypeError("connection string missing access key");
2049
- const credential = new coreAuth.AzureKeyCredential(key);
2050
- const port = parsed["port"];
2051
- const url = new URL(endpointPart);
2052
- url.port = port;
2053
- const endpoint = url.toString();
2054
- url.port = "";
2055
- return { credential, endpoint };
2056
- }
2057
-
2058
- // Copyright (c) Microsoft Corporation.
2059
- // Licensed under the MIT License.
2060
- const webPubSubReverseProxyPolicyName = "webPubSubReverseProxyPolicy";
2061
- /**
2062
- * Create an HTTP pipeline policy to use a reverse proxy.
2063
- * This is generally going to be an Azure APIM endpoint.
2064
- * @internal
2065
- */
2066
- function webPubSubReverseProxyPolicy(endpoint) {
2067
- const rpEndpointUrl = new URL(endpoint);
2068
- return {
2069
- name: webPubSubReverseProxyPolicyName,
2070
- sendRequest(request, next) {
2071
- const parsedUrl = new URL(request.url);
2072
- parsedUrl.host = rpEndpointUrl.host;
2073
- request.url = parsedUrl.toString();
2074
- return next(request);
2075
- },
2076
- };
2077
- }
2078
-
2079
- // Copyright (c) Microsoft Corporation.
2080
- // Licensed under the MIT License.
2081
- /**
2082
- * Client for connecting to a Web PubSub hub
2083
- */
2084
- class WebPubSubServiceClient {
2085
- constructor(endpointOrConnectionString, credsOrHubName, hubNameOrOpts, opts) {
2086
- var _a, _b, _c, _d, _e, _f;
2087
- /**
2088
- * The Web PubSub API version being used by this client
2089
- */
2090
- this.apiVersion = "2024-01-01";
2091
- // unpack constructor arguments
2092
- if (typeof credsOrHubName === "object") {
2093
- this.endpoint = endpointOrConnectionString;
2094
- this.hubName = hubNameOrOpts;
2095
- this.clientOptions = opts;
2096
- this.credential = credsOrHubName;
2097
- }
2098
- else {
2099
- const parsedCs = parseConnectionString(endpointOrConnectionString);
2100
- this.endpoint = parsedCs.endpoint;
2101
- this.credential = parsedCs.credential;
2102
- this.hubName = credsOrHubName;
2103
- this.clientOptions = hubNameOrOpts;
2104
- }
2105
- const internalPipelineOptions = Object.assign(Object.assign(Object.assign({}, this.clientOptions), {
2106
- apiVersion: this.apiVersion,
2107
- loggingOptions: {
2108
- additionalAllowedHeaderNames: (_b = (_a = this.clientOptions) === null || _a === void 0 ? void 0 : _a.loggingOptions) === null || _b === void 0 ? void 0 : _b.additionalAllowedHeaderNames,
2109
- additionalAllowedQueryParameters: (_d = (_c = this.clientOptions) === null || _c === void 0 ? void 0 : _c.loggingOptions) === null || _d === void 0 ? void 0 : _d.additionalAllowedQueryParameters,
2110
- logger: logger.info,
2111
- },
2112
- }), (coreAuth.isTokenCredential(this.credential)
2113
- ? {
2114
- credential: this.credential,
2115
- credentialScopes: ["https://webpubsub.azure.com/.default"],
2116
- }
2117
- : {}));
2118
- this.client = new GeneratedClient(this.endpoint, internalPipelineOptions);
2119
- if (!coreAuth.isTokenCredential(this.credential)) {
2120
- this.client.pipeline.addPolicy(webPubSubKeyCredentialPolicy(this.credential));
2121
- }
2122
- if ((_e = this.clientOptions) === null || _e === void 0 ? void 0 : _e.reverseProxyEndpoint) {
2123
- this.client.pipeline.addPolicy(webPubSubReverseProxyPolicy((_f = this.clientOptions) === null || _f === void 0 ? void 0 : _f.reverseProxyEndpoint));
2124
- }
2125
- }
2126
- /**
2127
- * Get a client for a group
2128
- * @param groupName - The name of the group to connect to.
2129
- */
2130
- group(groupName) {
2131
- return new WebPubSubGroupImpl(this.client, this.hubName, groupName);
2132
- }
2133
- async sendToAll(message, options = {}) {
2134
- return tracingClient.withSpan("WebPubSubServiceClient.sendToAll", options, (updatedOptions) => {
2135
- const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
2136
- return this.client.webPubSub.sendToAll(this.hubName, contentType, payload, updatedOptions);
2137
- });
2138
- }
2139
- async sendToUser(username, message, options = {}) {
2140
- return tracingClient.withSpan("WebPubSubServiceClient.sendToUser", options, (updatedOptions) => {
2141
- const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
2142
- return this.client.webPubSub.sendToUser(this.hubName, username, contentType, payload, updatedOptions);
2143
- });
2144
- }
2145
- async sendToConnection(connectionId, message, options = {}) {
2146
- return tracingClient.withSpan("WebPubSubServiceClient.sendToConnection", options, (updatedOptions) => {
2147
- const { contentType, payload } = getPayloadForMessage(message, updatedOptions);
2148
- return this.client.webPubSub.sendToConnection(this.hubName, connectionId, contentType, payload, updatedOptions);
2149
- });
2150
- }
2151
- /**
2152
- * Check if a specific connection is connected to this hub
2153
- *
2154
- * @param connectionId - Connection id to check
2155
- * @param options - Additional options
2156
- */
2157
- async connectionExists(connectionId, options = {}) {
2158
- let response;
2159
- function onResponse(rawResponse, flatResponse) {
2160
- response = rawResponse;
2161
- if (options.onResponse) {
2162
- options.onResponse(rawResponse, flatResponse);
2163
- }
2164
- }
2165
- return tracingClient.withSpan("WebPubSubServiceClient.connectionExists", options, async (updatedOptions) => {
2166
- await this.client.webPubSub.connectionExists(this.hubName, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
2167
- if (response.status === 200) {
2168
- return true;
2169
- }
2170
- else if (response.status === 404) {
2171
- return false;
2172
- }
2173
- else {
2174
- // this is sad - wish this was handled by autorest.
2175
- throw new coreRestPipeline.RestError(response.bodyAsText, {
2176
- statusCode: response === null || response === void 0 ? void 0 : response.status,
2177
- request: response === null || response === void 0 ? void 0 : response.request,
2178
- response: response,
2179
- });
2180
- }
2181
- });
2182
- }
2183
- /**
2184
- * Close a specific connection to this hub
2185
- *
2186
- * @param connectionId - Connection id to close
2187
- * @param options - Additional options
2188
- */
2189
- async closeConnection(connectionId, options = {}) {
2190
- return tracingClient.withSpan("WebPubSubServiceClient.closeConnection", options, (updatedOptions) => {
2191
- return this.client.webPubSub.closeConnection(this.hubName, connectionId, updatedOptions);
2192
- });
2193
- }
2194
- /**
2195
- * Close all connections to this hub
2196
- *
2197
- * @param options - Additional options
2198
- */
2199
- async closeAllConnections(options = {}) {
2200
- return tracingClient.withSpan("WebPubSubServiceClient.closeAllConnections", options, (updatedOptions) => {
2201
- return this.client.webPubSub.closeAllConnections(this.hubName, updatedOptions);
2202
- });
2203
- }
2204
- /**
2205
- * Close all connections with the given user id
2206
- *
2207
- * @param user - User id to close
2208
- * @param options - Additional options
2209
- */
2210
- async closeUserConnections(userId, options = {}) {
2211
- return tracingClient.withSpan("WebPubSubServiceClient.closeUserConnections", options, (updatedOptions) => {
2212
- return this.client.webPubSub.closeUserConnections(this.hubName, userId, updatedOptions);
2213
- });
2214
- }
2215
- /**
2216
- * Remove a specific user from all groups they are joined to
2217
- * @param userId - The user id to remove from all groups
2218
- * @param options - Additional options
2219
- */
2220
- async removeUserFromAllGroups(userId, options = {}) {
2221
- return tracingClient.withSpan("WebPubSubServiceClient.removeUserFromAllGroups", options, (updatedOptions) => {
2222
- return this.client.webPubSub.removeUserFromAllGroups(this.hubName, userId, updatedOptions);
2223
- });
2224
- }
2225
- /**
2226
- * Remove a specific connection from all groups they are joined to
2227
- * @param connectionId - The connection id to remove from all groups
2228
- * @param options - Additional options
2229
- */
2230
- async removeConnectionFromAllGroups(connectionId, options = {}) {
2231
- return tracingClient.withSpan("WebPubSubServiceClient.removeConnectionFromAllGroups", options, (updatedOptions) => {
2232
- return this.client.webPubSub.removeConnectionFromAllGroups(this.hubName, connectionId, updatedOptions);
2233
- });
2234
- }
2235
- /**
2236
- * Add filtered connections to multiple groups
2237
- * @param groups - A list of groups which target connections will be added into
2238
- * @param filter - An OData filter which target connections satisfy
2239
- * @param options - Additional options
2240
- */
2241
- async addConnectionsToGroups(groups, filter, options = {}) {
2242
- return tracingClient.withSpan("WebPubSubServiceClient.addConnectionsToGroups", options, (updatedOptions) => {
2243
- return this.client.webPubSub.addConnectionsToGroups(this.hubName, {
2244
- groups: groups,
2245
- filter: filter,
2246
- }, updatedOptions);
2247
- });
2248
- }
2249
- /**
2250
- * Remove filtered connections from multiple groups
2251
- * @param groups - A list of groups which target connections will be removed from
2252
- * @param filter - An OData filter which target connections satisfy
2253
- * @param options - Additional options
2254
- */
2255
- async removeConnectionsFromGroups(groups, filter, options = {}) {
2256
- return tracingClient.withSpan("WebPubSubServiceClient.removeConnectionsFromGroups", options, (updatedOptions) => {
2257
- return this.client.webPubSub.removeConnectionsFromGroups(this.hubName, {
2258
- groups: groups,
2259
- filter: filter,
2260
- }, updatedOptions);
2261
- });
2262
- }
2263
- /**
2264
- * Check if a particular group exists (i.e. has active connections).
2265
- *
2266
- * @param groupName - The group name to check for
2267
- * @param options - Additional options
2268
- */
2269
- async groupExists(groupName, options = {}) {
2270
- let response;
2271
- function onResponse(rawResponse, flatResponse) {
2272
- response = rawResponse;
2273
- if (options.onResponse) {
2274
- options.onResponse(rawResponse, flatResponse);
2275
- }
2276
- }
2277
- return tracingClient.withSpan("WebPubSubServiceClient.groupExists", options, async (updatedOptions) => {
2278
- await this.client.webPubSub.groupExists(this.hubName, groupName, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
2279
- if (response.status === 200) {
2280
- return true;
2281
- }
2282
- else if (response.status === 404) {
2283
- return false;
2284
- }
2285
- else {
2286
- throw new coreRestPipeline.RestError(response.bodyAsText, {
2287
- statusCode: response === null || response === void 0 ? void 0 : response.status,
2288
- request: response === null || response === void 0 ? void 0 : response.request,
2289
- response: response,
2290
- });
2291
- }
2292
- });
2293
- }
2294
- /**
2295
- * Check if a particular user is connected to this hub.
2296
- *
2297
- * @param username - The user name to check for
2298
- * @param options - Additional options
2299
- */
2300
- async userExists(username, options = {}) {
2301
- let response;
2302
- function onResponse(rawResponse, flatResponse) {
2303
- response = rawResponse;
2304
- if (options.onResponse) {
2305
- options.onResponse(rawResponse, flatResponse);
2306
- }
2307
- }
2308
- return tracingClient.withSpan("WebPubSubServiceClient.userExists", options, async (updatedOptions) => {
2309
- await this.client.webPubSub.userExists(this.hubName, username, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
2310
- if (response.status === 200) {
2311
- return true;
2312
- }
2313
- else if (response.status === 404) {
2314
- return false;
2315
- }
2316
- else {
2317
- // this is sad - wish this was handled by autorest.
2318
- throw new coreRestPipeline.RestError(response.bodyAsText, {
2319
- statusCode: response === null || response === void 0 ? void 0 : response.status,
2320
- request: response === null || response === void 0 ? void 0 : response.request,
2321
- response: response,
2322
- });
2323
- }
2324
- });
2325
- }
2326
- /**
2327
- * Grant permissions to a connection
2328
- *
2329
- * @param connectionId - The connection id to grant permissions to
2330
- * @param Permission - The permission to grant
2331
- * @param options - Additional options
2332
- */
2333
- async grantPermission(connectionId, permission, options = {}) {
2334
- return tracingClient.withSpan("WebPubSubServiceClient.grantPermission", options, (updatedOptions) => {
2335
- return this.client.webPubSub.grantPermission(this.hubName, permission, connectionId, updatedOptions);
2336
- });
2337
- }
2338
- /**
2339
- * Revoke permissions from a connection
2340
- *
2341
- * @param connectionId - The connection id to revoke permissions from
2342
- * @param Permission - The permission to revoke
2343
- * @param options - Additional options
2344
- */
2345
- async revokePermission(connectionId, permission, options = {}) {
2346
- return tracingClient.withSpan("WebPubSubServiceClient.revokePermission", options, (updatedOptions) => {
2347
- return this.client.webPubSub.revokePermission(this.hubName, permission, connectionId, updatedOptions);
2348
- });
2349
- }
2350
- /**
2351
- * Check if the connection has the specified permission
2352
- *
2353
- * @param connectionId - The connection id to check permission
2354
- * @param Permission - The permission to check
2355
- * @param options - Additional options
2356
- */
2357
- async hasPermission(connectionId, permission, options = {}) {
2358
- let response;
2359
- function onResponse(rawResponse, flatResponse) {
2360
- response = rawResponse;
2361
- if (options.onResponse) {
2362
- options.onResponse(rawResponse, flatResponse);
2363
- }
2364
- }
2365
- return tracingClient.withSpan("WebPubSubServiceClient.hasPermission", options, async (updatedOptions) => {
2366
- await this.client.webPubSub.checkPermission(this.hubName, permission, connectionId, Object.assign(Object.assign({}, updatedOptions), { onResponse }));
2367
- if (response.status === 200) {
2368
- return true;
2369
- }
2370
- else if (response.status === 404) {
2371
- return false;
2372
- }
2373
- else {
2374
- // this is sad - wish this was handled by autorest.
2375
- throw new coreRestPipeline.RestError(response.bodyAsText, {
2376
- statusCode: response === null || response === void 0 ? void 0 : response.status,
2377
- request: response === null || response === void 0 ? void 0 : response.request,
2378
- response: response,
2379
- });
2380
- }
2381
- });
2382
- }
2383
- /**
2384
- * Generate a token for a client to connect to the Azure Web PubSub service.
2385
- *
2386
- * @param options - Additional options
2387
- */
2388
- async getClientAccessToken(options = {}) {
2389
- return tracingClient.withSpan("WebPubSubServiceClient.getClientAccessToken", options, async (updatedOptions) => {
2390
- const endpoint = this.endpoint.endsWith("/") ? this.endpoint : this.endpoint + "/";
2391
- const clientEndpoint = endpoint.replace(/(http)(s?:\/\/)/gi, "ws$2");
2392
- const clientProtocol = updatedOptions.clientProtocol;
2393
- let clientPath = `client/hubs/${this.hubName}`;
2394
- switch (clientProtocol) {
2395
- case "mqtt":
2396
- clientPath = `clients/mqtt/hubs/${this.hubName}`;
2397
- break;
2398
- case "socketio":
2399
- clientPath = `clients/socketio/hubs/${this.hubName}`;
2400
- }
2401
- const baseUrl = clientEndpoint + clientPath;
2402
- let token;
2403
- if (coreAuth.isTokenCredential(this.credential)) {
2404
- const response = await this.client.webPubSub.generateClientToken(this.hubName, updatedOptions);
2405
- token = response.token;
2406
- }
2407
- else {
2408
- const key = this.credential.key;
2409
- const audience = endpoint + clientPath;
2410
- const payload = {
2411
- role: updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.roles,
2412
- "webpubsub.group": updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.groups,
2413
- };
2414
- const signOptions = {
2415
- audience: audience,
2416
- expiresIn: (updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.expirationTimeInMinutes) === undefined
2417
- ? "1h"
2418
- : `${updatedOptions.expirationTimeInMinutes}m`,
2419
- algorithm: "HS256",
2420
- };
2421
- if (updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.userId) {
2422
- signOptions.subject = updatedOptions === null || updatedOptions === void 0 ? void 0 : updatedOptions.userId;
2423
- }
2424
- token = jwt.sign(payload, key, signOptions);
2425
- }
2426
- return {
2427
- token,
2428
- baseUrl,
2429
- url: `${baseUrl}?access_token=${token}`,
2430
- };
2431
- });
2432
- }
2433
- }
2434
-
2435
- Object.defineProperty(exports, "AzureKeyCredential", {
2436
- enumerable: true,
2437
- get: function () { return coreAuth.AzureKeyCredential; }
2438
- });
2439
- exports.WebPubSubServiceClient = WebPubSubServiceClient;
2440
- exports.odata = odata;
2441
- //# sourceMappingURL=index.js.map