@azure/notification-hubs 1.0.0-beta.6 → 1.0.0-beta.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +86 -78
  2. package/dist/index.cjs +321 -369
  3. package/dist/index.cjs.map +1 -1
  4. package/dist-esm/src/{client → api}/beginSubmitNotificationHubJob.js +0 -0
  5. package/dist-esm/src/api/beginSubmitNotificationHubJob.js.map +1 -0
  6. package/dist-esm/src/{client → api}/cancelScheduledNotification.js +0 -0
  7. package/dist-esm/src/api/cancelScheduledNotification.js.map +1 -0
  8. package/dist-esm/src/{client → api}/createOrUpdateInstallation.js +0 -0
  9. package/dist-esm/src/api/createOrUpdateInstallation.js.map +1 -0
  10. package/dist-esm/src/{client → api}/createOrUpdateRegistration.js +0 -0
  11. package/dist-esm/src/api/createOrUpdateRegistration.js.map +1 -0
  12. package/dist-esm/src/{client → api}/createRegistration.js +0 -0
  13. package/dist-esm/src/api/createRegistration.js.map +1 -0
  14. package/dist-esm/src/{client → api}/createRegistrationId.js +8 -0
  15. package/dist-esm/src/api/createRegistrationId.js.map +1 -0
  16. package/dist-esm/src/{client → api}/deleteInstallation.js +0 -0
  17. package/dist-esm/src/api/deleteInstallation.js.map +1 -0
  18. package/dist-esm/src/{client → api}/deleteRegistration.js +0 -0
  19. package/dist-esm/src/api/deleteRegistration.js.map +1 -0
  20. package/dist-esm/src/{client → api}/getFeedbackContainerUrl.js +0 -0
  21. package/dist-esm/src/api/getFeedbackContainerUrl.js.map +1 -0
  22. package/dist-esm/src/{client → api}/getInstallation.js +0 -0
  23. package/dist-esm/src/api/getInstallation.js.map +1 -0
  24. package/dist-esm/src/{client → api}/getNotificationHubJob.js +0 -0
  25. package/dist-esm/src/api/getNotificationHubJob.js.map +1 -0
  26. package/dist-esm/src/{client → api}/getNotificationOutcomeDetails.js +0 -0
  27. package/dist-esm/src/api/getNotificationOutcomeDetails.js.map +1 -0
  28. package/dist-esm/src/{client → api}/getRegistration.js +0 -0
  29. package/dist-esm/src/api/getRegistration.js.map +1 -0
  30. package/dist-esm/src/{client → api}/index.js +22 -0
  31. package/dist-esm/src/api/index.js.map +1 -0
  32. package/dist-esm/src/{client → api}/internal/_client.js +1 -1
  33. package/dist-esm/src/api/internal/_client.js.map +1 -0
  34. package/dist-esm/src/{client → api}/internal/_createOrUpdateRegistrationDescription.js +0 -0
  35. package/dist-esm/src/api/internal/_createOrUpdateRegistrationDescription.js.map +1 -0
  36. package/dist-esm/src/{client/listRegistrations.js → api/internal/_listRegistrations.js} +6 -38
  37. package/dist-esm/src/api/internal/_listRegistrations.js.map +1 -0
  38. package/dist-esm/src/{client → api}/listNotificationHubJobs.js +0 -0
  39. package/dist-esm/src/api/listNotificationHubJobs.js.map +1 -0
  40. package/dist-esm/src/api/listRegistrations.js +35 -0
  41. package/dist-esm/src/api/listRegistrations.js.map +1 -0
  42. package/dist-esm/src/api/listRegistrationsByChannel.js +58 -0
  43. package/dist-esm/src/api/listRegistrationsByChannel.js.map +1 -0
  44. package/dist-esm/src/{client → api}/listRegistrationsByTag.js +0 -0
  45. package/dist-esm/src/api/listRegistrationsByTag.js.map +1 -0
  46. package/dist-esm/src/{client → api}/scheduleNotification.js +2 -3
  47. package/dist-esm/src/api/scheduleNotification.js.map +1 -0
  48. package/dist-esm/src/{client → api}/sendNotification.js +3 -3
  49. package/dist-esm/src/api/sendNotification.js.map +1 -0
  50. package/dist-esm/src/{client → api}/submitNotificationHubJob.js +0 -0
  51. package/dist-esm/src/api/submitNotificationHubJob.js.map +1 -0
  52. package/dist-esm/src/{client → api}/updateInstallation.js +0 -0
  53. package/dist-esm/src/api/updateInstallation.js.map +1 -0
  54. package/dist-esm/src/{client → api}/updateRegistration.js +0 -0
  55. package/dist-esm/src/api/updateRegistration.js.map +1 -0
  56. package/dist-esm/src/index.js +3 -2
  57. package/dist-esm/src/index.js.map +1 -1
  58. package/dist-esm/src/models/index.js +12 -0
  59. package/dist-esm/src/models/index.js.map +1 -0
  60. package/dist-esm/src/models/installation.js.map +1 -1
  61. package/dist-esm/src/models/notification.js.map +1 -1
  62. package/dist-esm/src/models/notificationBodyBuilder.js +48 -0
  63. package/dist-esm/src/models/notificationBodyBuilder.js.map +1 -0
  64. package/dist-esm/src/models/notificationDetails.js.map +1 -1
  65. package/dist-esm/src/models/options.js.map +1 -1
  66. package/dist-esm/src/models/registration.js +12 -12
  67. package/dist-esm/src/models/registration.js.map +1 -1
  68. package/dist-esm/src/models/tagExpressionBuilder.js +11 -0
  69. package/dist-esm/src/models/tagExpressionBuilder.js.map +1 -0
  70. package/dist-esm/src/notificationHubsClient.js +34 -24
  71. package/dist-esm/src/notificationHubsClient.js.map +1 -1
  72. package/dist-esm/src/serializers/notificationDetailsSerializer.js +1 -0
  73. package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -1
  74. package/dist-esm/src/serializers/notificationOutcomeSerializer.js +2 -2
  75. package/dist-esm/src/serializers/notificationOutcomeSerializer.js.map +1 -1
  76. package/dist-esm/src/serializers/registrationSerializer.js +17 -16
  77. package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
  78. package/dist-esm/src/utils/constants.js +1 -1
  79. package/dist-esm/src/utils/constants.js.map +1 -1
  80. package/dist-esm/src/utils/notificationUtils.js +0 -6
  81. package/dist-esm/src/utils/notificationUtils.js.map +1 -1
  82. package/package.json +23 -19
  83. package/types/3.1/notification-hubs.d.ts +420 -249
  84. package/types/latest/notification-hubs.d.ts +448 -254
  85. package/types/latest/tsdoc-metadata.json +1 -1
  86. package/types/src/{client → api}/beginSubmitNotificationHubJob.d.ts +0 -0
  87. package/types/src/api/beginSubmitNotificationHubJob.d.ts.map +1 -0
  88. package/types/src/{client → api}/cancelScheduledNotification.d.ts +0 -0
  89. package/types/src/api/cancelScheduledNotification.d.ts.map +1 -0
  90. package/types/src/{client → api}/createOrUpdateInstallation.d.ts +0 -0
  91. package/types/src/api/createOrUpdateInstallation.d.ts.map +1 -0
  92. package/types/src/{client → api}/createOrUpdateRegistration.d.ts +0 -0
  93. package/types/src/api/createOrUpdateRegistration.d.ts.map +1 -0
  94. package/types/src/{client → api}/createRegistration.d.ts +0 -0
  95. package/types/src/api/createRegistration.d.ts.map +1 -0
  96. package/types/src/{client → api}/createRegistrationId.d.ts +0 -0
  97. package/types/src/api/createRegistrationId.d.ts.map +1 -0
  98. package/types/src/{client → api}/deleteInstallation.d.ts +0 -0
  99. package/types/src/api/deleteInstallation.d.ts.map +1 -0
  100. package/types/src/{client → api}/deleteRegistration.d.ts +0 -0
  101. package/types/src/api/deleteRegistration.d.ts.map +1 -0
  102. package/types/src/{client → api}/getFeedbackContainerUrl.d.ts +0 -0
  103. package/types/src/api/getFeedbackContainerUrl.d.ts.map +1 -0
  104. package/types/src/{client → api}/getInstallation.d.ts +0 -0
  105. package/types/src/api/getInstallation.d.ts.map +1 -0
  106. package/types/src/{client → api}/getNotificationHubJob.d.ts +0 -0
  107. package/types/src/api/getNotificationHubJob.d.ts.map +1 -0
  108. package/types/src/{client → api}/getNotificationOutcomeDetails.d.ts +0 -0
  109. package/types/src/api/getNotificationOutcomeDetails.d.ts.map +1 -0
  110. package/types/src/{client → api}/getRegistration.d.ts +0 -0
  111. package/types/src/api/getRegistration.d.ts.map +1 -0
  112. package/types/src/{client → api}/index.d.ts +22 -0
  113. package/types/src/api/index.d.ts.map +1 -0
  114. package/types/src/{client → api}/internal/_client.d.ts +0 -0
  115. package/types/src/api/internal/_client.d.ts.map +1 -0
  116. package/types/src/{client → api}/internal/_createOrUpdateRegistrationDescription.d.ts +0 -0
  117. package/types/src/api/internal/_createOrUpdateRegistrationDescription.d.ts.map +1 -0
  118. package/types/src/api/internal/_listRegistrations.d.ts +6 -0
  119. package/types/src/api/internal/_listRegistrations.d.ts.map +1 -0
  120. package/types/src/{client → api}/listNotificationHubJobs.d.ts +0 -0
  121. package/types/src/api/listNotificationHubJobs.d.ts.map +1 -0
  122. package/types/src/{client → api}/listRegistrations.d.ts +3 -3
  123. package/types/src/api/listRegistrations.d.ts.map +1 -0
  124. package/types/src/api/listRegistrationsByChannel.d.ts +13 -0
  125. package/types/src/api/listRegistrationsByChannel.d.ts.map +1 -0
  126. package/types/src/{client → api}/listRegistrationsByTag.d.ts +0 -0
  127. package/types/src/api/listRegistrationsByTag.d.ts.map +1 -0
  128. package/types/src/{client → api}/scheduleNotification.d.ts +0 -0
  129. package/types/src/api/scheduleNotification.d.ts.map +1 -0
  130. package/types/src/{client → api}/sendNotification.d.ts +0 -0
  131. package/types/src/api/sendNotification.d.ts.map +1 -0
  132. package/types/src/{client → api}/submitNotificationHubJob.d.ts +0 -0
  133. package/types/src/api/submitNotificationHubJob.d.ts.map +1 -0
  134. package/types/src/{client → api}/updateInstallation.d.ts +0 -0
  135. package/types/src/api/updateInstallation.d.ts.map +1 -0
  136. package/types/src/{client → api}/updateRegistration.d.ts +0 -0
  137. package/types/src/api/updateRegistration.d.ts.map +1 -0
  138. package/types/src/index.d.ts +3 -2
  139. package/types/src/index.d.ts.map +1 -1
  140. package/types/src/models/index.d.ts +10 -0
  141. package/types/src/models/index.d.ts.map +1 -0
  142. package/types/src/models/installation.d.ts +12 -11
  143. package/types/src/models/installation.d.ts.map +1 -1
  144. package/types/src/models/notification.d.ts +10 -18
  145. package/types/src/models/notification.d.ts.map +1 -1
  146. package/types/src/models/{notificationBuilder.d.ts → notificationBodyBuilder.d.ts} +62 -64
  147. package/types/src/models/notificationBodyBuilder.d.ts.map +1 -0
  148. package/types/src/models/notificationDetails.d.ts +9 -9
  149. package/types/src/models/notificationDetails.d.ts.map +1 -1
  150. package/types/src/models/options.d.ts +4 -4
  151. package/types/src/models/options.d.ts.map +1 -1
  152. package/types/src/models/registration.d.ts +235 -69
  153. package/types/src/models/registration.d.ts.map +1 -1
  154. package/types/src/models/tagExpressionBuilder.d.ts +7 -0
  155. package/types/src/models/tagExpressionBuilder.d.ts.map +1 -0
  156. package/types/src/notificationHubsClient.d.ts +12 -5
  157. package/types/src/notificationHubsClient.d.ts.map +1 -1
  158. package/types/src/serializers/notificationDetailsSerializer.d.ts.map +1 -1
  159. package/types/src/serializers/registrationSerializer.d.ts +14 -14
  160. package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
  161. package/types/src/utils/notificationUtils.d.ts +0 -4
  162. package/types/src/utils/notificationUtils.d.ts.map +1 -1
  163. package/dist-esm/src/client/beginSubmitNotificationHubJob.js.map +0 -1
  164. package/dist-esm/src/client/cancelScheduledNotification.js.map +0 -1
  165. package/dist-esm/src/client/createOrUpdateInstallation.js.map +0 -1
  166. package/dist-esm/src/client/createOrUpdateRegistration.js.map +0 -1
  167. package/dist-esm/src/client/createRegistration.js.map +0 -1
  168. package/dist-esm/src/client/createRegistrationId.js.map +0 -1
  169. package/dist-esm/src/client/deleteInstallation.js.map +0 -1
  170. package/dist-esm/src/client/deleteRegistration.js.map +0 -1
  171. package/dist-esm/src/client/getFeedbackContainerUrl.js.map +0 -1
  172. package/dist-esm/src/client/getInstallation.js.map +0 -1
  173. package/dist-esm/src/client/getNotificationHubJob.js.map +0 -1
  174. package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +0 -1
  175. package/dist-esm/src/client/getRegistration.js.map +0 -1
  176. package/dist-esm/src/client/index.js.map +0 -1
  177. package/dist-esm/src/client/internal/_client.js.map +0 -1
  178. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +0 -1
  179. package/dist-esm/src/client/listNotificationHubJobs.js.map +0 -1
  180. package/dist-esm/src/client/listRegistrations.js.map +0 -1
  181. package/dist-esm/src/client/listRegistrationsByTag.js.map +0 -1
  182. package/dist-esm/src/client/scheduleNotification.js.map +0 -1
  183. package/dist-esm/src/client/sendNotification.js.map +0 -1
  184. package/dist-esm/src/client/submitNotificationHubJob.js.map +0 -1
  185. package/dist-esm/src/client/updateInstallation.js.map +0 -1
  186. package/dist-esm/src/client/updateRegistration.js.map +0 -1
  187. package/dist-esm/src/models/notificationBuilder.js +0 -169
  188. package/dist-esm/src/models/notificationBuilder.js.map +0 -1
  189. package/dist-esm/src/utils/retryPolicy.js +0 -144
  190. package/dist-esm/src/utils/retryPolicy.js.map +0 -1
  191. package/types/src/client/beginSubmitNotificationHubJob.d.ts.map +0 -1
  192. package/types/src/client/cancelScheduledNotification.d.ts.map +0 -1
  193. package/types/src/client/createOrUpdateInstallation.d.ts.map +0 -1
  194. package/types/src/client/createOrUpdateRegistration.d.ts.map +0 -1
  195. package/types/src/client/createRegistration.d.ts.map +0 -1
  196. package/types/src/client/createRegistrationId.d.ts.map +0 -1
  197. package/types/src/client/deleteInstallation.d.ts.map +0 -1
  198. package/types/src/client/deleteRegistration.d.ts.map +0 -1
  199. package/types/src/client/getFeedbackContainerUrl.d.ts.map +0 -1
  200. package/types/src/client/getInstallation.d.ts.map +0 -1
  201. package/types/src/client/getNotificationHubJob.d.ts.map +0 -1
  202. package/types/src/client/getNotificationOutcomeDetails.d.ts.map +0 -1
  203. package/types/src/client/getRegistration.d.ts.map +0 -1
  204. package/types/src/client/index.d.ts.map +0 -1
  205. package/types/src/client/internal/_client.d.ts.map +0 -1
  206. package/types/src/client/internal/_createOrUpdateRegistrationDescription.d.ts.map +0 -1
  207. package/types/src/client/listNotificationHubJobs.d.ts.map +0 -1
  208. package/types/src/client/listRegistrations.d.ts.map +0 -1
  209. package/types/src/client/listRegistrationsByTag.d.ts.map +0 -1
  210. package/types/src/client/scheduleNotification.d.ts.map +0 -1
  211. package/types/src/client/sendNotification.d.ts.map +0 -1
  212. package/types/src/client/submitNotificationHubJob.d.ts.map +0 -1
  213. package/types/src/client/updateInstallation.d.ts.map +0 -1
  214. package/types/src/client/updateRegistration.d.ts.map +0 -1
  215. package/types/src/models/notificationBuilder.d.ts.map +0 -1
  216. package/types/src/utils/retryPolicy.d.ts +0 -72
  217. package/types/src/utils/retryPolicy.d.ts.map +0 -1
package/dist/index.cjs CHANGED
@@ -14,7 +14,7 @@ var uuid = require('uuid');
14
14
 
15
15
  // Copyright (c) Microsoft Corporation.
16
16
  // Licensed under the MIT license.
17
- const SDK_VERSION = "1.0.0-beta.6";
17
+ const SDK_VERSION = "1.0.0-beta.8";
18
18
  const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
19
19
  const XML_CONTENT_TYPE = "application/xml";
20
20
  const STREAM_CONTENT_TYPE = "application/octet-stream";
@@ -157,48 +157,6 @@ function parseNotificationHubsConnectionString(connectionString) {
157
157
  return output;
158
158
  }
159
159
 
160
- // Copyright (c) Microsoft Corporation.
161
- const API_VERSION = "2020-06";
162
- /**
163
- * Creates a NotificationHubClient from the Access Policy connection string and hub name.
164
- * @param connectionString - The Access Policy connection string for the notification hub.
165
- * @param hubName - The notification hub name.
166
- * @returns A NotificationHubsClientContext initialized from the connection string and hub name.
167
- */
168
- function createClientContext(connectionString, hubName, options = {}) {
169
- return new NotificationHubsServiceClient$1(connectionString, hubName, options);
170
- }
171
- class NotificationHubsServiceClient$1 extends coreClient.ServiceClient {
172
- constructor(connectionString, hubName, options = {}) {
173
- super(Object.assign({ deserializationOptions: {
174
- parseXML: coreXml.parseXML,
175
- }, serializationOptions: {
176
- stringifyXML: coreXml.stringifyXML,
177
- }, userAgentOptions: {
178
- userAgentPrefix: `azsdk-js-messaging-notificationhubs/${SDK_VERSION}`,
179
- } }, options));
180
- this.hubName = hubName;
181
- const parsedConnection = parseNotificationHubsConnectionString(connectionString);
182
- this.baseUrl = parsedConnection.endpoint;
183
- this.sasTokenProvider = createTokenProviderFromConnection(parsedConnection.sharedAccessKey, parsedConnection.sharedAccessKeyName);
184
- }
185
- async createHeaders(operationName, rawHeaders) {
186
- const authorization = await this.sasTokenProvider.getToken(this.baseUrl);
187
- const headers = coreRestPipeline.createHttpHeaders(rawHeaders);
188
- headers.set("Authorization", authorization.token);
189
- headers.set("x-ms-version", API_VERSION);
190
- headers.set("x-ms-azsdk-telemetry", `class=NotificationHubsServiceClient;method=${operationName}`);
191
- return headers;
192
- }
193
- requestUrl() {
194
- // Node doesn't allow change in protocol but browsers do, so doing a string replace
195
- const url = new URL(this.baseUrl.replace("sb://", "https://"));
196
- url.pathname = this.hubName;
197
- url.searchParams.set("api-version", API_VERSION);
198
- return url;
199
- }
200
- }
201
-
202
160
  // Copyright (c) Microsoft Corporation.
203
161
  // Licensed under the MIT license.
204
162
  /**
@@ -209,14 +167,6 @@ class NotificationHubsServiceClient$1 extends coreClient.ServiceClient {
209
167
  function isDefined(thing) {
210
168
  return typeof thing !== "undefined" && thing !== null;
211
169
  }
212
- /**
213
- * Helper TypeGuard that checks if something is a string or not.
214
- * @param thing - Anything
215
- * @internal
216
- */
217
- function isString(thing) {
218
- return typeof thing === "string" || thing instanceof String;
219
- }
220
170
  /**
221
171
  * @internal
222
172
  * Helper utility to retrieve `string` value from given string,
@@ -311,8 +261,8 @@ async function parseNotificationOutcome(bodyText) {
311
261
  const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
312
262
  const outcome = xml.NotificationOutcome;
313
263
  return {
314
- success: getInteger(outcome.Success, "Success"),
315
- failure: getInteger(outcome.Failure, "Failure"),
264
+ successCount: getInteger(outcome.Success, "Success"),
265
+ failureCount: getInteger(outcome.Failure, "Failure"),
316
266
  results: parseRegistrationResults(outcome.Results.RegistrationResult),
317
267
  state: "DetailedStateAvailable",
318
268
  };
@@ -472,7 +422,7 @@ async function parseNotificationSendResponse(response) {
472
422
  }
473
423
  }
474
424
  function createDefaultResponse(response, notificationId) {
475
- return Object.assign(Object.assign({}, response), { notificationId, success: 0, failure: 0, results: [], state: "Enqueued" });
425
+ return Object.assign(Object.assign({}, response), { notificationId, successCount: 0, failureCount: 0, results: [], state: "Enqueued" });
476
426
  }
477
427
  /**
478
428
  * Sends a request through the client context.
@@ -600,7 +550,7 @@ const tracingClient = coreTracing.createTracingClient({
600
550
  });
601
551
 
602
552
  // Copyright (c) Microsoft Corporation.
603
- const OPERATION_NAME$h = "getNotificationHubJob";
553
+ const OPERATION_NAME$g = "getNotificationHubJob";
604
554
  /**
605
555
  * Gets a Notification Hub Job by the ID.
606
556
  * @param context - The Notification Hubs client.
@@ -609,10 +559,10 @@ const OPERATION_NAME$h = "getNotificationHubJob";
609
559
  * @returns The Notification Hub Job with the matching ID.
610
560
  */
611
561
  function getNotificationHubJob(context, jobId, options = {}) {
612
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$h}`, options, async (updatedOptions) => {
562
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$g}`, options, async (updatedOptions) => {
613
563
  const endpoint = context.requestUrl();
614
564
  endpoint.pathname += `/jobs/${jobId}`;
615
- const headers = await context.createHeaders(OPERATION_NAME$h);
565
+ const headers = await context.createHeaders(OPERATION_NAME$g);
616
566
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
617
567
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
618
568
  const response = await sendRequest(context, request, 200);
@@ -621,7 +571,7 @@ function getNotificationHubJob(context, jobId, options = {}) {
621
571
  }
622
572
 
623
573
  // Copyright (c) Microsoft Corporation.
624
- const OPERATION_NAME$g = "submitNotificationHubJob";
574
+ const OPERATION_NAME$f = "submitNotificationHubJob";
625
575
  /**
626
576
  * Submits a Notification Hub Job.
627
577
  * Note: this is available to Standard SKU namespace and above.
@@ -631,10 +581,10 @@ const OPERATION_NAME$g = "submitNotificationHubJob";
631
581
  * @returns The notification hub job details including job ID and status.
632
582
  */
633
583
  function submitNotificationHubJob(context, job, options = {}) {
634
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$g}`, options, async (updatedOptions) => {
584
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$f}`, options, async (updatedOptions) => {
635
585
  const endpoint = context.requestUrl();
636
586
  endpoint.pathname += "/jobs";
637
- const headers = await context.createHeaders(OPERATION_NAME$g);
587
+ const headers = await context.createHeaders(OPERATION_NAME$f);
638
588
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
639
589
  const request = createRequest(endpoint, "POST", headers, updatedOptions);
640
590
  request.body = serializeNotificationHubJobEntry(job);
@@ -771,7 +721,7 @@ function sleep(ms, signal) {
771
721
  }
772
722
 
773
723
  // Copyright (c) Microsoft Corporation.
774
- const OPERATION_NAME$f = "cancelScheduledNotification";
724
+ const OPERATION_NAME$e = "cancelScheduledNotification";
775
725
  /**
776
726
  * Cancels the scheduled notification with the given notification ID.
777
727
  * NOTE: This is only available in Standard SKU Azure Notification Hubs.
@@ -781,10 +731,10 @@ const OPERATION_NAME$f = "cancelScheduledNotification";
781
731
  * @returns A notification hub response with correlation ID and tracking ID.
782
732
  */
783
733
  function cancelScheduledNotification(context, notificationId, options = {}) {
784
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$f}`, options, async (updatedOptions) => {
734
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$e}`, options, async (updatedOptions) => {
785
735
  const endpoint = context.requestUrl();
786
736
  endpoint.pathname += `/schedulednotifications/${notificationId}`;
787
- const headers = await context.createHeaders(OPERATION_NAME$f);
737
+ const headers = await context.createHeaders(OPERATION_NAME$e);
788
738
  const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
789
739
  const response = await sendRequest(context, request, 200);
790
740
  return parseNotificationSendResponse(response);
@@ -792,7 +742,7 @@ function cancelScheduledNotification(context, notificationId, options = {}) {
792
742
  }
793
743
 
794
744
  // Copyright (c) Microsoft Corporation.
795
- const OPERATION_NAME$e = "createOrUpdateInstallation";
745
+ const OPERATION_NAME$d = "createOrUpdateInstallation";
796
746
  /**
797
747
  * Creates or overwrites an installation to a Notification Hub.
798
748
  * @param context - The Notification Hubs client.
@@ -801,10 +751,10 @@ const OPERATION_NAME$e = "createOrUpdateInstallation";
801
751
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
802
752
  */
803
753
  function createOrUpdateInstallation(context, installation, options = {}) {
804
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$e}`, options, async (updatedOptions) => {
754
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$d}`, options, async (updatedOptions) => {
805
755
  const endpoint = context.requestUrl();
806
756
  endpoint.pathname += `/installations/${installation.installationId}`;
807
- const headers = await context.createHeaders(OPERATION_NAME$e);
757
+ const headers = await context.createHeaders(OPERATION_NAME$d);
808
758
  headers.set("Content-Type", "application/json");
809
759
  const request = createRequest(endpoint, "PUT", headers, updatedOptions);
810
760
  request.body = JSON.stringify(installation);
@@ -821,6 +771,7 @@ const registrationDescriptionParser = {
821
771
  */
822
772
  async parseRegistrationEntry(bodyText) {
823
773
  const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
774
+ delete xml.entry.content["$"];
824
775
  const keyName = Object.keys(xml.entry.content)[0];
825
776
  const content = xml.entry.content[keyName];
826
777
  const methodName = `create${keyName}`;
@@ -859,21 +810,21 @@ const registrationDescriptionParser = {
859
810
  * Creates an ADM registration description from incoming XML property bag.
860
811
  */
861
812
  createAdmRegistrationDescription(rawRegistrationDescription) {
862
- return Object.assign(Object.assign({ admRegistrationId: getString(rawRegistrationDescription["AdmRegistrationId"], "admRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Adm" });
813
+ return Object.assign(Object.assign({ admRegistrationId: getString(rawRegistrationDescription["AdmRegistrationId"], "admRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Adm" });
863
814
  },
864
815
  /**
865
816
  * @internal
866
817
  * Creates an ADM template registration description from incoming XML property bag.
867
818
  */
868
819
  createAdmTemplateRegistrationDescription(rawRegistrationDescription) {
869
- return Object.assign(Object.assign(Object.assign({}, this.createAdmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "AdmTemplate" });
820
+ return Object.assign(Object.assign(Object.assign({}, this.createAdmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "AdmTemplate" });
870
821
  },
871
822
  /**
872
823
  * @internal
873
824
  * Creates an Apple registration description from incoming XML property bag.
874
825
  */
875
826
  createAppleRegistrationDescription(rawRegistrationDescription) {
876
- return Object.assign(Object.assign({ deviceToken: getString(rawRegistrationDescription["DeviceToken"], "deviceToken") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Apple" });
827
+ return Object.assign(Object.assign({ deviceToken: getString(rawRegistrationDescription["DeviceToken"], "deviceToken") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Apple" });
877
828
  },
878
829
  /**
879
830
  * @internal
@@ -881,56 +832,56 @@ const registrationDescriptionParser = {
881
832
  */
882
833
  createAppleTemplateRegistrationDescription(rawRegistrationDescription) {
883
834
  var _a;
884
- return Object.assign(Object.assign(Object.assign({ priority: getStringOrUndefined(rawRegistrationDescription["Priority"]), apnsHeaders: getHeadersOrUndefined((_a = rawRegistrationDescription["ApnsHeaders"]) === null || _a === void 0 ? void 0 : _a["ApnsHeader"]) }, this.createAppleRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "AppleTemplate" });
835
+ return Object.assign(Object.assign(Object.assign({ priority: getStringOrUndefined(rawRegistrationDescription["Priority"]), apnsHeaders: getHeadersOrUndefined((_a = rawRegistrationDescription["ApnsHeaders"]) === null || _a === void 0 ? void 0 : _a["ApnsHeader"]) }, this.createAppleRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "AppleTemplate" });
885
836
  },
886
837
  /**
887
838
  * @internal
888
839
  * Creates a Baidu registration description from incoming XML property bag.
889
840
  */
890
841
  createBaiduRegistrationDescription(rawRegistrationDescription) {
891
- return Object.assign(Object.assign({ baiduChannelId: getString(rawRegistrationDescription["BaiduChannelId"], "baiduChannelId"), baiduUserId: getString(rawRegistrationDescription["BaiduUserId"], "baiduUserId") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Baidu" });
842
+ return Object.assign(Object.assign({ baiduChannelId: getString(rawRegistrationDescription["BaiduChannelId"], "baiduChannelId"), baiduUserId: getString(rawRegistrationDescription["BaiduUserId"], "baiduUserId") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Baidu" });
892
843
  },
893
844
  /**
894
845
  * @internal
895
846
  * Creates a Baidu template registration description from incoming XML property bag.
896
847
  */
897
848
  createBaiduTemplateRegistrationDescription(rawRegistrationDescription) {
898
- return Object.assign(Object.assign(Object.assign({}, this.createBaiduRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "BaiduTemplate" });
849
+ return Object.assign(Object.assign(Object.assign({}, this.createBaiduRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "BaiduTemplate" });
899
850
  },
900
851
  /**
901
852
  * @internal
902
853
  * Creates a Browser registration description from incoming XML property bag.
903
854
  */
904
855
  createBrowserRegistrationDescription(rawRegistrationDescription) {
905
- return Object.assign(Object.assign({ endpoint: getString(rawRegistrationDescription["Endpoint"], "endpoint"), p256dh: getString(rawRegistrationDescription["P256DH"], "p256dh"), auth: getString(rawRegistrationDescription["Auth"], "auth") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Browser" });
856
+ return Object.assign(Object.assign({ endpoint: getString(rawRegistrationDescription["Endpoint"], "endpoint"), p256dh: getString(rawRegistrationDescription["P256DH"], "p256dh"), auth: getString(rawRegistrationDescription["Auth"], "auth") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Browser" });
906
857
  },
907
858
  /**
908
859
  * @internal
909
860
  * Creates a Browser template registration description from incoming XML property bag.
910
861
  */
911
862
  createBrowserTemplateRegistrationDescription(rawRegistrationDescription) {
912
- return Object.assign(Object.assign(Object.assign({}, this.createBrowserRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "BrowserTemplate" });
863
+ return Object.assign(Object.assign(Object.assign({}, this.createBrowserRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "BrowserTemplate" });
913
864
  },
914
865
  /**
915
866
  * @internal
916
867
  * Creates an GCM registration description from incoming XML property bag.
917
868
  */
918
869
  createGcmRegistrationDescription(rawRegistrationDescription) {
919
- return Object.assign(Object.assign({ gcmRegistrationId: getString(rawRegistrationDescription["GcmRegistrationId"], "gcmRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Gcm" });
870
+ return Object.assign(Object.assign({ gcmRegistrationId: getString(rawRegistrationDescription["GcmRegistrationId"], "gcmRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Gcm" });
920
871
  },
921
872
  /**
922
873
  * @internal
923
874
  * Creates an FCM template registration description from incoming XML property bag.
924
875
  */
925
876
  createGcmTemplateRegistrationDescription(rawRegistrationDescription) {
926
- return Object.assign(Object.assign(Object.assign({}, this.createGcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "GcmTemplate" });
877
+ return Object.assign(Object.assign(Object.assign({}, this.createGcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "GcmTemplate" });
927
878
  },
928
879
  /**
929
880
  * @internal
930
881
  * Creates a Windows Phone registration description from incoming XML property bag.
931
882
  */
932
883
  createMpnsRegistrationDescription(rawRegistrationDescription) {
933
- return Object.assign(Object.assign({ channelUri: getString(rawRegistrationDescription["ChannelUri"], "channelUri") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Mpns" });
884
+ return Object.assign(Object.assign({ channelUri: getString(rawRegistrationDescription["ChannelUri"], "channelUri") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Mpns" });
934
885
  },
935
886
  /**
936
887
  * @internal
@@ -938,14 +889,14 @@ const registrationDescriptionParser = {
938
889
  */
939
890
  createMpnsTemplateRegistrationDescription(rawRegistrationDescription) {
940
891
  var _a;
941
- return Object.assign(Object.assign(Object.assign({ mpnsHeaders: getHeadersOrUndefined((_a = rawRegistrationDescription["MpnsHeaders"]) === null || _a === void 0 ? void 0 : _a["MpnsHeader"]) }, this.createWindowsRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "MpnsTemplate" });
892
+ return Object.assign(Object.assign(Object.assign({ mpnsHeaders: getHeadersOrUndefined((_a = rawRegistrationDescription["MpnsHeaders"]) === null || _a === void 0 ? void 0 : _a["MpnsHeader"]) }, this.createWindowsRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "MpnsTemplate" });
942
893
  },
943
894
  /**
944
895
  * @internal
945
896
  * Creates a Windows registration description from incoming XML property bag.
946
897
  */
947
898
  createWindowsRegistrationDescription(rawRegistrationDescription) {
948
- return Object.assign(Object.assign({ channelUri: getString(rawRegistrationDescription["ChannelUri"], "channelUri") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Windows" });
899
+ return Object.assign(Object.assign({ channelUri: getString(rawRegistrationDescription["ChannelUri"], "channelUri") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Windows" });
949
900
  },
950
901
  /**
951
902
  * @internal
@@ -953,7 +904,7 @@ const registrationDescriptionParser = {
953
904
  */
954
905
  createWindowsTemplateRegistrationDescription(rawRegistrationDescription) {
955
906
  var _a;
956
- return Object.assign(Object.assign(Object.assign({ wnsHeaders: getHeadersOrUndefined((_a = rawRegistrationDescription["WnsHeaders"]) === null || _a === void 0 ? void 0 : _a["WnsHeader"]) }, this.createWindowsRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "WindowsTemplate" });
907
+ return Object.assign(Object.assign(Object.assign({ wnsHeaders: getHeadersOrUndefined((_a = rawRegistrationDescription["WnsHeaders"]) === null || _a === void 0 ? void 0 : _a["WnsHeader"]) }, this.createWindowsRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "WindowsTemplate" });
957
908
  },
958
909
  };
959
910
  function getHeadersOrUndefined(value) {
@@ -988,11 +939,11 @@ function createTemplateRegistrationDescription(rawRegistrationDescription) {
988
939
  */
989
940
  const registrationDescriptionSerializer = {
990
941
  serializeRegistrationDescription(description) {
991
- const rootName = `${description.type}RegistrationDescription`;
942
+ const rootName = `${description.kind}RegistrationDescription`;
992
943
  const methodName = `serialize${rootName}`;
993
944
  const method = this[methodName].bind(this);
994
945
  if (!isDefined(method)) {
995
- throw new coreRestPipeline.RestError(`Undefined platform ${description.type}`, { statusCode: 400 });
946
+ throw new coreRestPipeline.RestError(`Undefined platform ${description.kind}`, { statusCode: 400 });
996
947
  }
997
948
  const registration = method(description);
998
949
  const requestObject = serializeToAtomXmlRequest(rootName, registration);
@@ -1187,7 +1138,7 @@ async function createOrUpdateRegistrationDescription(context, registration, oper
1187
1138
  }
1188
1139
 
1189
1140
  // Copyright (c) Microsoft Corporation.
1190
- const OPERATION_NAME$d = "createOrUpdateRegistration";
1141
+ const OPERATION_NAME$c = "createOrUpdateRegistration";
1191
1142
  /**
1192
1143
  * Creates or updates a registration.
1193
1144
  * @param context - The Notification Hubs client.
@@ -1196,32 +1147,8 @@ const OPERATION_NAME$d = "createOrUpdateRegistration";
1196
1147
  * @returns The created or updated registration description.
1197
1148
  */
1198
1149
  function createOrUpdateRegistration(context, registration, options = {}) {
1199
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$d}`, options, async (updatedOptions) => {
1200
- return createOrUpdateRegistrationDescription(context, registration, "createOrUpdate", updatedOptions);
1201
- });
1202
- }
1203
-
1204
- // Copyright (c) Microsoft Corporation.
1205
- const OPERATION_NAME$c = "createRegistrationId";
1206
- /**
1207
- * Creates a new registration ID.
1208
- * @param context - The Notification Hubs client.
1209
- * @param options - The options for creating a new registration ID.
1210
- * @returns The newly created registration ID.
1211
- */
1212
- function createRegistrationId(context, options = {}) {
1213
1150
  return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$c}`, options, async (updatedOptions) => {
1214
- const endpoint = context.requestUrl();
1215
- endpoint.pathname += "/registrationIDs";
1216
- const headers = await context.createHeaders(OPERATION_NAME$c);
1217
- headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
1218
- const request = createRequest(endpoint, "POST", headers, updatedOptions);
1219
- const response = await sendRequest(context, request, 201);
1220
- // In the form: https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/<registrationId>
1221
- const locationHeader = response.headers.get("Location");
1222
- const locationUrl = new URL(locationHeader);
1223
- const registrationId = locationUrl.pathname.split("/")[3];
1224
- return registrationId;
1151
+ return createOrUpdateRegistrationDescription(context, registration, "createOrUpdate", updatedOptions);
1225
1152
  });
1226
1153
  }
1227
1154
 
@@ -1247,7 +1174,38 @@ function createRegistration(context, registration, options = {}) {
1247
1174
  }
1248
1175
 
1249
1176
  // Copyright (c) Microsoft Corporation.
1250
- const OPERATION_NAME$a = "deleteInstallation";
1177
+ const OPERATION_NAME$a = "createRegistrationId";
1178
+ /**
1179
+ * Creates a new registration ID.
1180
+ * @param context - The Notification Hubs client.
1181
+ * @param options - The options for creating a new registration ID.
1182
+ * @returns The newly created registration ID.
1183
+ */
1184
+ function createRegistrationId(context, options = {}) {
1185
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$a}`, options, async (updatedOptions) => {
1186
+ const endpoint = context.requestUrl();
1187
+ endpoint.pathname += "/registrationIDs";
1188
+ const headers = await context.createHeaders(OPERATION_NAME$a);
1189
+ headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
1190
+ const request = createRequest(endpoint, "POST", headers, updatedOptions);
1191
+ const response = await sendRequest(context, request, 201);
1192
+ // In the form: https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/<registrationId>
1193
+ const locationHeader = response.headers.get("Location");
1194
+ if (!locationHeader || !locationHeader.startsWith("https://")) {
1195
+ throw new coreRestPipeline.RestError(`Location header ${locationHeader} is an invalid URL`, {
1196
+ statusCode: 500,
1197
+ request,
1198
+ response,
1199
+ });
1200
+ }
1201
+ const locationUrl = new URL(locationHeader);
1202
+ const registrationId = locationUrl.pathname.split("/")[3];
1203
+ return registrationId;
1204
+ });
1205
+ }
1206
+
1207
+ // Copyright (c) Microsoft Corporation.
1208
+ const OPERATION_NAME$9 = "deleteInstallation";
1251
1209
  /**
1252
1210
  * Deletes an installation from a Notification Hub.
1253
1211
  * @param context - The Notification Hubs client.
@@ -1256,10 +1214,10 @@ const OPERATION_NAME$a = "deleteInstallation";
1256
1214
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1257
1215
  */
1258
1216
  function deleteInstallation(context, installationId, options = {}) {
1259
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$a}`, options, async (updatedOptions) => {
1217
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$9}`, options, async (updatedOptions) => {
1260
1218
  const endpoint = context.requestUrl();
1261
1219
  endpoint.pathname += `/installations/${installationId}`;
1262
- const headers = await context.createHeaders(OPERATION_NAME$a);
1220
+ const headers = await context.createHeaders(OPERATION_NAME$9);
1263
1221
  const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
1264
1222
  const response = await sendRequest(context, request, 204);
1265
1223
  return parseNotificationResponse(response);
@@ -1267,7 +1225,7 @@ function deleteInstallation(context, installationId, options = {}) {
1267
1225
  }
1268
1226
 
1269
1227
  // Copyright (c) Microsoft Corporation.
1270
- const OPERATION_NAME$9 = "deleteRegistration";
1228
+ const OPERATION_NAME$8 = "deleteRegistration";
1271
1229
  /**
1272
1230
  * Deletes a registration with the given registration ID.
1273
1231
  * @param context - The Notification Hubs client.
@@ -1276,10 +1234,10 @@ const OPERATION_NAME$9 = "deleteRegistration";
1276
1234
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1277
1235
  */
1278
1236
  function deleteRegistration(context, registrationId, options = {}) {
1279
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$9}`, options, async (updatedOptions) => {
1237
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$8}`, options, async (updatedOptions) => {
1280
1238
  const endpoint = context.requestUrl();
1281
1239
  endpoint.pathname += `/registrations/${registrationId}`;
1282
- const headers = await context.createHeaders(OPERATION_NAME$9);
1240
+ const headers = await context.createHeaders(OPERATION_NAME$8);
1283
1241
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
1284
1242
  headers.set("If-Match", isDefined(options.etag) ? `"${options.etag}"` : "*");
1285
1243
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
@@ -1289,7 +1247,7 @@ function deleteRegistration(context, registrationId, options = {}) {
1289
1247
  }
1290
1248
 
1291
1249
  // Copyright (c) Microsoft Corporation.
1292
- const OPERATION_NAME$8 = "getFeedbackContainerUrl";
1250
+ const OPERATION_NAME$7 = "getFeedbackContainerUrl";
1293
1251
  /**
1294
1252
  * Retrieves an Azure Storage container URL. The container has feedback data for the notification hub.
1295
1253
  * The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.
@@ -1298,10 +1256,10 @@ const OPERATION_NAME$8 = "getFeedbackContainerUrl";
1298
1256
  * @returns The URL of the Azure Storage Container containing the feedback data.
1299
1257
  */
1300
1258
  function getFeedbackContainerUrl(context, options = {}) {
1301
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$8}`, options, async (updatedOptions) => {
1259
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$7}`, options, async (updatedOptions) => {
1302
1260
  const endpoint = context.requestUrl();
1303
1261
  endpoint.pathname += "/feedbackcontainer";
1304
- const headers = await context.createHeaders(OPERATION_NAME$8);
1262
+ const headers = await context.createHeaders(OPERATION_NAME$7);
1305
1263
  headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
1306
1264
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1307
1265
  const response = await sendRequest(context, request, 200);
@@ -1310,7 +1268,7 @@ function getFeedbackContainerUrl(context, options = {}) {
1310
1268
  }
1311
1269
 
1312
1270
  // Copyright (c) Microsoft Corporation.
1313
- const OPERATION_NAME$7 = "getInstallation";
1271
+ const OPERATION_NAME$6 = "getInstallation";
1314
1272
  /**
1315
1273
  * Gets an Azure Notification Hub installation by the installation ID.
1316
1274
  * @param context - The Notification Hubs client.
@@ -1319,10 +1277,10 @@ const OPERATION_NAME$7 = "getInstallation";
1319
1277
  * @returns The installation that matches the installation ID.
1320
1278
  */
1321
1279
  function getInstallation(context, installationId, options = {}) {
1322
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$7}`, options, async (updatedOptions) => {
1280
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$6}`, options, async (updatedOptions) => {
1323
1281
  const endpoint = context.requestUrl();
1324
1282
  endpoint.pathname += `/installations/${installationId}`;
1325
- const headers = await context.createHeaders(OPERATION_NAME$7);
1283
+ const headers = await context.createHeaders(OPERATION_NAME$6);
1326
1284
  headers.set("Content-Type", "application/json");
1327
1285
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1328
1286
  const response = await sendRequest(context, request, 200);
@@ -1370,6 +1328,7 @@ async function parseNotificationDetails(bodyText) {
1370
1328
  endTime: getDateOrUndefined(notificationDetails["EndTime"]),
1371
1329
  pnsErrorDetailsUrl: getStringOrUndefined(notificationDetails["PnsErrorDetailsUri"]),
1372
1330
  targetPlatforms: getStringOrUndefined(notificationDetails["TargetPlatforms"]),
1331
+ notificationBody: getStringOrUndefined(notificationDetails["NotificationBody"]),
1373
1332
  apnsOutcomeCounts,
1374
1333
  admOutcomeCounts,
1375
1334
  baiduOutcomeCounts,
@@ -1387,7 +1346,7 @@ function parseOutcomeCounts(counts) {
1387
1346
  }
1388
1347
 
1389
1348
  // Copyright (c) Microsoft Corporation.
1390
- const OPERATION_NAME$6 = "getNotificationOutcomeDetails";
1349
+ const OPERATION_NAME$5 = "getNotificationOutcomeDetails";
1391
1350
  /**
1392
1351
  * Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed
1393
1352
  * or final results if the Send* has completed. This API can only be called for Standard SKU and above.
@@ -1397,10 +1356,10 @@ const OPERATION_NAME$6 = "getNotificationOutcomeDetails";
1397
1356
  * @returns The results of the send operation.
1398
1357
  */
1399
1358
  function getNotificationOutcomeDetails(context, notificationId, options = {}) {
1400
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$6}`, options, async (updatedOptions) => {
1359
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$5}`, options, async (updatedOptions) => {
1401
1360
  const endpoint = context.requestUrl();
1402
1361
  endpoint.pathname += `/messages/${notificationId}`;
1403
- const headers = await context.createHeaders(OPERATION_NAME$6);
1362
+ const headers = await context.createHeaders(OPERATION_NAME$5);
1404
1363
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1405
1364
  const response = await sendRequest(context, request, 200);
1406
1365
  return parseNotificationDetails(response.bodyAsText);
@@ -1408,7 +1367,7 @@ function getNotificationOutcomeDetails(context, notificationId, options = {}) {
1408
1367
  }
1409
1368
 
1410
1369
  // Copyright (c) Microsoft Corporation.
1411
- const OPERATION_NAME$5 = "getRegistration";
1370
+ const OPERATION_NAME$4 = "getRegistration";
1412
1371
  /**
1413
1372
  * Gets a registration by the given registration ID.
1414
1373
  * @param context - The Notification Hubs client.
@@ -1417,10 +1376,10 @@ const OPERATION_NAME$5 = "getRegistration";
1417
1376
  * @returns A RegistrationDescription that has the given registration ID.
1418
1377
  */
1419
1378
  function getRegistration(context, registrationId, options = {}) {
1420
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$5}`, options, async (updatedOptions) => {
1379
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$4}`, options, async (updatedOptions) => {
1421
1380
  const endpoint = context.requestUrl();
1422
1381
  endpoint.pathname += `/registrations/${registrationId}`;
1423
- const headers = await context.createHeaders(OPERATION_NAME$5);
1382
+ const headers = await context.createHeaders(OPERATION_NAME$4);
1424
1383
  headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
1425
1384
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1426
1385
  const response = await sendRequest(context, request, 200);
@@ -1429,7 +1388,7 @@ function getRegistration(context, registrationId, options = {}) {
1429
1388
  }
1430
1389
 
1431
1390
  // Copyright (c) Microsoft Corporation.
1432
- const OPERATION_NAME$4 = "listNotificationHubJobs";
1391
+ const OPERATION_NAME$3 = "listNotificationHubJobs";
1433
1392
  /**
1434
1393
  * Gets all Notification Hub Jobs for this Notification Hub.
1435
1394
  * @param context - The Notification Hubs client.xs
@@ -1437,10 +1396,10 @@ const OPERATION_NAME$4 = "listNotificationHubJobs";
1437
1396
  * @returns An array of all Notification Hub Jobs for this Notification Hub.
1438
1397
  */
1439
1398
  function listNotificationHubJobs(context, options = {}) {
1440
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$4}`, options, async (updatedOptions) => {
1399
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$3}`, options, async (updatedOptions) => {
1441
1400
  const endpoint = context.requestUrl();
1442
1401
  endpoint.pathname += "/jobs";
1443
- const headers = await context.createHeaders(OPERATION_NAME$4);
1402
+ const headers = await context.createHeaders(OPERATION_NAME$3);
1444
1403
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
1445
1404
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1446
1405
  const response = await sendRequest(context, request, 200);
@@ -1449,43 +1408,11 @@ function listNotificationHubJobs(context, options = {}) {
1449
1408
  }
1450
1409
 
1451
1410
  // Copyright (c) Microsoft Corporation.
1452
- const OPERATION_NAME$3 = "listRegistrationsByTag";
1453
- /**
1454
- * Lists all registrations with the matching tag.
1455
- * @param context - The Notification Hubs client.
1456
- * @param tag - The tag to query for matching registrations.
1457
- * @param options - The query options such as $top.
1458
- * @returns A paged async iterable containing the matching registrations for the notification hub.
1459
- */
1460
- function listRegistrationsByTag(context, tag, options = {}) {
1461
- const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext.${OPERATION_NAME$3}`, options);
1462
- try {
1463
- const iter = listRegistrationsByTagAll(context, tag, updatedOptions);
1464
- return {
1465
- next() {
1466
- return iter.next();
1467
- },
1468
- [Symbol.asyncIterator]() {
1469
- return this;
1470
- },
1471
- byPage: () => {
1472
- return listRegistrationsByTagPagingPage(context, tag, options);
1473
- },
1474
- };
1475
- }
1476
- catch (e) {
1477
- span.setStatus({ status: "error", error: e });
1478
- throw e;
1479
- }
1480
- finally {
1481
- span.end();
1482
- }
1483
- }
1484
- function listRegistrationsByTagAll(context, tag, options) {
1485
- return tslib.__asyncGenerator(this, arguments, function* listRegistrationsByTagAll_1() {
1411
+ function listRegistrationsAll(context, options) {
1412
+ return tslib.__asyncGenerator(this, arguments, function* listRegistrationsAll_1() {
1486
1413
  var e_1, _a;
1487
1414
  try {
1488
- for (var _b = tslib.__asyncValues(listRegistrationsByTagPagingPage(context, tag, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
1415
+ for (var _b = tslib.__asyncValues(listRegistrationPagingPage(context, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
1489
1416
  const page = _c.value;
1490
1417
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
1491
1418
  }
@@ -1499,28 +1426,31 @@ function listRegistrationsByTagAll(context, tag, options) {
1499
1426
  }
1500
1427
  });
1501
1428
  }
1502
- function listRegistrationsByTagPagingPage(context, tag, options) {
1503
- return tslib.__asyncGenerator(this, arguments, function* listRegistrationsByTagPagingPage_1() {
1504
- let result = yield tslib.__await(_listRegistrationsByTag(context, tag, options));
1429
+ function listRegistrationPagingPage(context, options) {
1430
+ return tslib.__asyncGenerator(this, arguments, function* listRegistrationPagingPage_1() {
1431
+ let result = yield tslib.__await(_listRegistrations(context, options));
1505
1432
  yield yield tslib.__await(result.registrations || []);
1506
1433
  let continuationToken = result.continuationToken;
1507
1434
  while (continuationToken) {
1508
- result = yield tslib.__await(_listRegistrationsByTag(context, tag, options, continuationToken));
1435
+ result = yield tslib.__await(_listRegistrations(context, options, continuationToken));
1509
1436
  continuationToken = result.continuationToken;
1510
1437
  yield yield tslib.__await(result.registrations || []);
1511
1438
  }
1512
1439
  });
1513
1440
  }
1514
- async function _listRegistrationsByTag(context, tag, options, continuationToken) {
1441
+ async function _listRegistrations(context, options, continuationToken) {
1515
1442
  const endpoint = context.requestUrl();
1516
- endpoint.pathname += `/tags/${tag}/registrations`;
1443
+ endpoint.pathname += "/registrations";
1517
1444
  if (options.top !== undefined) {
1518
1445
  endpoint.searchParams.set("$top", `${options.top}`);
1519
1446
  }
1447
+ if (options.filter !== undefined) {
1448
+ endpoint.searchParams.set("$filter", options.filter);
1449
+ }
1520
1450
  if (continuationToken !== undefined) {
1521
1451
  endpoint.searchParams.set("continuationtoken", continuationToken);
1522
1452
  }
1523
- const headers = await context.createHeaders(OPERATION_NAME$3);
1453
+ const headers = await context.createHeaders("listRegistrations");
1524
1454
  const request = createRequest(endpoint, "GET", headers, options);
1525
1455
  const response = await sendRequest(context, request, 200);
1526
1456
  const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
@@ -1532,15 +1462,14 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
1532
1462
  }
1533
1463
 
1534
1464
  // Copyright (c) Microsoft Corporation.
1535
- const OPERATION_NAME$2 = "listRegistrations";
1536
1465
  /**
1537
1466
  * Gets all registrations for the notification hub with the given query options.
1538
1467
  * @param context - The Notification Hubs client.
1539
- * @param options - The options for querying the registrations such as $top and $filter.
1468
+ * @param options - The options for querying the registrations such as $top.
1540
1469
  * @returns A paged async iterable containing all of the registrations for the notification hub.
1541
1470
  */
1542
1471
  function listRegistrations(context, options = {}) {
1543
- const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext.${OPERATION_NAME$2}`, options);
1472
+ const { span, updatedOptions } = tracingClient.startSpan("NotificationHubsClientContext.listRegistrations", options);
1544
1473
  try {
1545
1474
  const iter = listRegistrationsAll(context, updatedOptions);
1546
1475
  return {
@@ -1551,7 +1480,7 @@ function listRegistrations(context, options = {}) {
1551
1480
  return this;
1552
1481
  },
1553
1482
  byPage: () => {
1554
- return listRegistrationPagingPage(context, options);
1483
+ return listRegistrationPagingPage(context, updatedOptions);
1555
1484
  },
1556
1485
  };
1557
1486
  }
@@ -1563,11 +1492,99 @@ function listRegistrations(context, options = {}) {
1563
1492
  span.end();
1564
1493
  }
1565
1494
  }
1566
- function listRegistrationsAll(context, options) {
1567
- return tslib.__asyncGenerator(this, arguments, function* listRegistrationsAll_1() {
1495
+
1496
+ // Copyright (c) Microsoft Corporation.
1497
+ /**
1498
+ * Gets all registrations for the notification hub with the given device information and options.
1499
+ * @param context - The Notification Hubs client.
1500
+ * @param channel - The Registration channel information to query per PNS type.
1501
+ * @param options - The options for querying the registrations such as $top.
1502
+ * @returns A paged async iterable containing all of the registrations for the notification hub.
1503
+ */
1504
+ function listRegistrationsByChannel(context, channel, options = {}) {
1505
+ const newOptions = Object.assign(Object.assign({}, options), { filter: getFilterByChannel(channel) });
1506
+ const { span, updatedOptions } = tracingClient.startSpan("NotificationHubsClientContext.listRegistrationsByDevice", newOptions);
1507
+ try {
1508
+ const iter = listRegistrationsAll(context, updatedOptions);
1509
+ return {
1510
+ next() {
1511
+ return iter.next();
1512
+ },
1513
+ [Symbol.asyncIterator]() {
1514
+ return this;
1515
+ },
1516
+ byPage: () => {
1517
+ return listRegistrationPagingPage(context, updatedOptions);
1518
+ },
1519
+ };
1520
+ }
1521
+ catch (e) {
1522
+ span.setStatus({ status: "error", error: e });
1523
+ throw e;
1524
+ }
1525
+ finally {
1526
+ span.end();
1527
+ }
1528
+ }
1529
+ function getFilterByChannel(device) {
1530
+ switch (device.kind) {
1531
+ case "adm":
1532
+ return `AdmRegistrationId eq '${device.admRegistrationId}'`;
1533
+ case "apple":
1534
+ return `DeviceToken eq '${device.deviceToken.toLocaleUpperCase()}'`;
1535
+ case "baidu":
1536
+ return `BaiduChannelId eq ${device.baiduChannelId}' and BaiduUserId eq '${device.baiduUserId}'`;
1537
+ case "browser":
1538
+ return `Endpoint eq '${encodeURIComponent(device.endpoint)}' and P256DH eq '${device.p256dh}' and Auth eq '${device.auth}'`;
1539
+ case "gcm":
1540
+ return `GcmRegistrationId eq '${device.gcmRegistrationId}'`;
1541
+ case "windows":
1542
+ return `ChannelUri eq '${encodeURIComponent(device.channelUri)}'`;
1543
+ default:
1544
+ throw new coreRestPipeline.RestError(`Device type is unsupported`, {
1545
+ statusCode: 400,
1546
+ });
1547
+ }
1548
+ }
1549
+
1550
+ // Copyright (c) Microsoft Corporation.
1551
+ const OPERATION_NAME$2 = "listRegistrationsByTag";
1552
+ /**
1553
+ * Lists all registrations with the matching tag.
1554
+ * @param context - The Notification Hubs client.
1555
+ * @param tag - The tag to query for matching registrations.
1556
+ * @param options - The query options such as $top.
1557
+ * @returns A paged async iterable containing the matching registrations for the notification hub.
1558
+ */
1559
+ function listRegistrationsByTag(context, tag, options = {}) {
1560
+ const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext.${OPERATION_NAME$2}`, options);
1561
+ try {
1562
+ const iter = listRegistrationsByTagAll(context, tag, updatedOptions);
1563
+ return {
1564
+ next() {
1565
+ return iter.next();
1566
+ },
1567
+ [Symbol.asyncIterator]() {
1568
+ return this;
1569
+ },
1570
+ byPage: () => {
1571
+ return listRegistrationsByTagPagingPage(context, tag, options);
1572
+ },
1573
+ };
1574
+ }
1575
+ catch (e) {
1576
+ span.setStatus({ status: "error", error: e });
1577
+ throw e;
1578
+ }
1579
+ finally {
1580
+ span.end();
1581
+ }
1582
+ }
1583
+ function listRegistrationsByTagAll(context, tag, options) {
1584
+ return tslib.__asyncGenerator(this, arguments, function* listRegistrationsByTagAll_1() {
1568
1585
  var e_1, _a;
1569
1586
  try {
1570
- for (var _b = tslib.__asyncValues(listRegistrationPagingPage(context, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
1587
+ for (var _b = tslib.__asyncValues(listRegistrationsByTagPagingPage(context, tag, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
1571
1588
  const page = _c.value;
1572
1589
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
1573
1590
  }
@@ -1581,27 +1598,24 @@ function listRegistrationsAll(context, options) {
1581
1598
  }
1582
1599
  });
1583
1600
  }
1584
- function listRegistrationPagingPage(context, options) {
1585
- return tslib.__asyncGenerator(this, arguments, function* listRegistrationPagingPage_1() {
1586
- let result = yield tslib.__await(_listRegistrations(context, options));
1601
+ function listRegistrationsByTagPagingPage(context, tag, options) {
1602
+ return tslib.__asyncGenerator(this, arguments, function* listRegistrationsByTagPagingPage_1() {
1603
+ let result = yield tslib.__await(_listRegistrationsByTag(context, tag, options));
1587
1604
  yield yield tslib.__await(result.registrations || []);
1588
1605
  let continuationToken = result.continuationToken;
1589
1606
  while (continuationToken) {
1590
- result = yield tslib.__await(_listRegistrations(context, options, continuationToken));
1607
+ result = yield tslib.__await(_listRegistrationsByTag(context, tag, options, continuationToken));
1591
1608
  continuationToken = result.continuationToken;
1592
1609
  yield yield tslib.__await(result.registrations || []);
1593
1610
  }
1594
1611
  });
1595
1612
  }
1596
- async function _listRegistrations(context, options, continuationToken) {
1613
+ async function _listRegistrationsByTag(context, tag, options, continuationToken) {
1597
1614
  const endpoint = context.requestUrl();
1598
- endpoint.pathname += "/registrations";
1615
+ endpoint.pathname += `/tags/${tag}/registrations`;
1599
1616
  if (options.top !== undefined) {
1600
1617
  endpoint.searchParams.set("$top", `${options.top}`);
1601
1618
  }
1602
- if (options.filter !== undefined) {
1603
- endpoint.searchParams.set("$filter", options.filter);
1604
- }
1605
1619
  if (continuationToken !== undefined) {
1606
1620
  endpoint.searchParams.set("continuationtoken", continuationToken);
1607
1621
  }
@@ -1616,31 +1630,6 @@ async function _listRegistrations(context, options, continuationToken) {
1616
1630
  };
1617
1631
  }
1618
1632
 
1619
- // Copyright (c) Microsoft Corporation.
1620
- // Licensed under the MIT license.
1621
- /**
1622
- * @internal
1623
- */
1624
- function createMultipartDirectNotification(boundaryName, notification, deviceHandles) {
1625
- return (`--${boundaryName}\r\n` +
1626
- `Content-type: ${notification.contentType}\r\n` +
1627
- "Content-Disposition: inline; name=notification\r\n\r\n" +
1628
- notification.body +
1629
- "\r\n" +
1630
- `--${boundaryName}\r\n` +
1631
- "Content-type: application/json\r\n" +
1632
- "Content-Disposition: inline; name=devices\r\n\r\n" +
1633
- JSON.stringify(deviceHandles) +
1634
- "\r\n" +
1635
- `--${boundaryName}--`);
1636
- }
1637
- /**
1638
- * @internal
1639
- */
1640
- function normalizeTags(tags) {
1641
- return Array.isArray(tags) ? tags.join("||") : tags;
1642
- }
1643
-
1644
1633
  // Copyright (c) Microsoft Corporation.
1645
1634
  /**
1646
1635
  * Schedules a push notification to devices that match the given tags or tag expression at the specified time.
@@ -1659,8 +1648,8 @@ function scheduleNotification(context, scheduledTime, notification, options = {}
1659
1648
  headers.set("ServiceBusNotification-ScheduleTime", scheduledTime.toISOString());
1660
1649
  headers.set("Content-Type", notification.contentType);
1661
1650
  headers.set("ServiceBusNotification-Format", notification.platform);
1662
- if (options.tags) {
1663
- headers.set("ServiceBusNotification-Tags", normalizeTags(options.tags));
1651
+ if (options.tagExpression) {
1652
+ headers.set("ServiceBusNotification-Tags", options.tagExpression);
1664
1653
  }
1665
1654
  const request = createRequest(endpoint, "POST", headers, updatedOptions);
1666
1655
  request.body = notification.body;
@@ -1687,6 +1676,25 @@ function isDirectSendNotificationOptions(options) {
1687
1676
  return coreUtil.objectHasProperty(options, "deviceHandle");
1688
1677
  }
1689
1678
 
1679
+ // Copyright (c) Microsoft Corporation.
1680
+ // Licensed under the MIT license.
1681
+ /**
1682
+ * @internal
1683
+ */
1684
+ function createMultipartDirectNotification(boundaryName, notification, deviceHandles) {
1685
+ return (`--${boundaryName}\r\n` +
1686
+ `Content-type: ${notification.contentType}\r\n` +
1687
+ "Content-Disposition: inline; name=notification\r\n\r\n" +
1688
+ notification.body +
1689
+ "\r\n" +
1690
+ `--${boundaryName}\r\n` +
1691
+ "Content-type: application/json\r\n" +
1692
+ "Content-Disposition: inline; name=devices\r\n\r\n" +
1693
+ JSON.stringify(deviceHandles) +
1694
+ "\r\n" +
1695
+ `--${boundaryName}--`);
1696
+ }
1697
+
1690
1698
  // Copyright (c) Microsoft Corporation.
1691
1699
  /**
1692
1700
  * Sends push notifications to devices that match the given tags or tag expression.
@@ -1731,8 +1739,8 @@ function sendNotification(context, notification, options = { enableTestSend: fal
1731
1739
  }
1732
1740
  }
1733
1741
  else if (isSendNotificationOptions(options)) {
1734
- if (options.tags) {
1735
- headers.set("ServiceBusNotification-Tags", normalizeTags(options.tags));
1742
+ if (options.tagExpression) {
1743
+ headers.set("ServiceBusNotification-Tags", options.tagExpression);
1736
1744
  }
1737
1745
  }
1738
1746
  headers.set("Content-Type", contentType);
@@ -1785,12 +1793,54 @@ function updateRegistration(context, registration, options = {}) {
1785
1793
  });
1786
1794
  }
1787
1795
 
1796
+ // Copyright (c) Microsoft Corporation.
1797
+ const API_VERSION = "2020-06";
1798
+ /**
1799
+ * Creates a NotificationHubClient from the Access Policy connection string and hub name.
1800
+ * @param connectionString - The Access Policy connection string for the notification hub.
1801
+ * @param hubName - The notification hub name.
1802
+ * @returns A NotificationHubsClientContext initialized from the connection string and hub name.
1803
+ */
1804
+ function createClientContext(connectionString, hubName, options = {}) {
1805
+ return new NotificationHubsServiceClient(connectionString, hubName, options);
1806
+ }
1807
+ class NotificationHubsServiceClient extends coreClient.ServiceClient {
1808
+ constructor(connectionString, hubName, options = {}) {
1809
+ super(Object.assign({ deserializationOptions: {
1810
+ parseXML: coreXml.parseXML,
1811
+ }, serializationOptions: {
1812
+ stringifyXML: coreXml.stringifyXML,
1813
+ }, userAgentOptions: {
1814
+ userAgentPrefix: `azsdk-js-messaging-notificationhubs/${SDK_VERSION}`,
1815
+ } }, options));
1816
+ this.hubName = hubName;
1817
+ const parsedConnection = parseNotificationHubsConnectionString(connectionString);
1818
+ this.baseUrl = parsedConnection.endpoint;
1819
+ this.sasTokenProvider = createTokenProviderFromConnection(parsedConnection.sharedAccessKey, parsedConnection.sharedAccessKeyName);
1820
+ }
1821
+ async createHeaders(operationName, rawHeaders) {
1822
+ const authorization = await this.sasTokenProvider.getToken(this.baseUrl);
1823
+ const headers = coreRestPipeline.createHttpHeaders(rawHeaders);
1824
+ headers.set("Authorization", authorization.token);
1825
+ headers.set("x-ms-version", API_VERSION);
1826
+ headers.set("x-ms-azsdk-telemetry", `class=NotificationHubsServiceClient;method=${operationName}`);
1827
+ return headers;
1828
+ }
1829
+ requestUrl() {
1830
+ // Node doesn't allow change in protocol but browsers do, so doing a string replace
1831
+ const url = new URL(this.baseUrl.replace("sb://", "https://"));
1832
+ url.pathname = this.hubName;
1833
+ url.searchParams.set("api-version", API_VERSION);
1834
+ return url;
1835
+ }
1836
+ }
1837
+
1788
1838
  // Copyright (c) Microsoft Corporation.
1789
1839
  /**
1790
1840
  * This represents a client for Azure Notification Hubs to manage installations and send
1791
1841
  * messages to devices.
1792
1842
  */
1793
- class NotificationHubsServiceClient {
1843
+ class NotificationHubsClient {
1794
1844
  /**
1795
1845
  * Creates a new instance of the NotificationClient with a connection string, hub name and options.
1796
1846
  * @param connectionString - The Notification Hub Access Policy connection string.
@@ -1894,12 +1944,21 @@ class NotificationHubsServiceClient {
1894
1944
  }
1895
1945
  /**
1896
1946
  * Gets all registrations for the notification hub with the given query options.
1897
- * @param options - The options for querying the registrations such as $top and $filter.
1947
+ * @param options - The options for querying the registrations such as $top.
1898
1948
  * @returns A paged async iterable containing all of the registrations for the notification hub.
1899
1949
  */
1900
1950
  listRegistrations(options = {}) {
1901
1951
  return listRegistrations(this._client, options);
1902
1952
  }
1953
+ /**
1954
+ * Gets all registrations for the notification hub with the given device information and options.
1955
+ * @param channel - The registration channel information to query per PNS type.
1956
+ * @param options - The options for querying the registrations such as $top.
1957
+ * @returns A paged async iterable containing all of the registrations for the notification hub.
1958
+ */
1959
+ listRegistrationsByChannel(channel, options = {}) {
1960
+ return listRegistrationsByChannel(this._client, channel, options);
1961
+ }
1903
1962
  /**
1904
1963
  * Lists all registrations with the matching tag.
1905
1964
  * @param tag - The tag to query for matching registrations.
@@ -2148,168 +2207,49 @@ function createWindowsRawNotification(notification) {
2148
2207
  }
2149
2208
 
2150
2209
  // Copyright (c) Microsoft Corporation.
2151
- function createAppleNativeAlert(nativeAlert) {
2152
- if (!isDefined(nativeAlert)) {
2153
- return undefined;
2154
- }
2155
- if (isString(nativeAlert)) {
2156
- return nativeAlert;
2157
- }
2158
- const alert = {
2159
- title: nativeAlert.title,
2160
- subtitle: nativeAlert.subtitle,
2161
- body: nativeAlert.body,
2162
- "launch-image": nativeAlert.launchImage,
2163
- "title-loc-key": nativeAlert.titleLocKey,
2164
- "title-loc-args": nativeAlert.titleLocArgs,
2165
- "subtitle-loc-key": nativeAlert.subtitleLocKey,
2166
- "subtitle-loc-args": nativeAlert.subtitleLocArgs,
2167
- "loc-key": nativeAlert.locKey,
2168
- "loc-args": nativeAlert.locArgs,
2169
- };
2170
- return alert;
2171
- }
2172
2210
  /**
2173
2211
  * Creates an APNs native message to send to Notification Hubs.
2174
2212
  * @param nativeMessage - The Apple native message properties to set.
2175
2213
  * @param additionalProperties - Additional properties for Apple messages.
2176
2214
  * @returns An AppleNotification to send to Notification Hubs.
2177
2215
  */
2178
- function buildAppleNativeMessage(nativeMessage, additionalProperties) {
2179
- const headers = {};
2180
- const message = Object.assign({ aps: {
2181
- alert: createAppleNativeAlert(nativeMessage.alert),
2182
- sound: nativeMessage.sound,
2183
- badge: nativeMessage.badge,
2184
- "thread-id": nativeMessage.threadId,
2185
- category: nativeMessage.category,
2186
- "content-available": nativeMessage.contentAvailable,
2187
- "mutable-content": nativeMessage.mutableContent,
2188
- "target-content-id": nativeMessage.targetContentId,
2189
- "interruption-level": nativeMessage.interruptionLevel,
2190
- "relevance-score": nativeMessage.relevanceScore,
2191
- "filter-criteria": nativeMessage.filterCriteria,
2192
- } }, additionalProperties);
2193
- const apnsPriority = (nativeMessage === null || nativeMessage === void 0 ? void 0 : nativeMessage.contentAvailable) === 1 ? "5" : "10";
2194
- headers["apns-priority"] = apnsPriority;
2195
- return createAppleNotification({
2196
- body: JSON.stringify(message),
2197
- headers: headers,
2198
- });
2199
- }
2200
- function buildFcmLegacyNativePayload(nativeNotification) {
2201
- if (!isDefined(nativeNotification)) {
2202
- return undefined;
2203
- }
2204
- const androidMessage = nativeNotification;
2205
- const appleMessage = nativeNotification;
2206
- const notification = {
2207
- title: nativeNotification.title,
2208
- body: nativeNotification.body,
2209
- click_action: nativeNotification.clickAction,
2210
- // Apple/Android fields
2211
- sound: appleMessage.sound,
2212
- badge: appleMessage.badge,
2213
- subtitle: appleMessage.subtitle,
2214
- body_loc_key: appleMessage.bodyLocKey,
2215
- body_loc_args: appleMessage.bodyLocArgs,
2216
- title_loc_key: appleMessage.bodyLocKey,
2217
- title_loc_args: appleMessage.bodyLocArgs,
2218
- // Android/Web fields
2219
- android_channel_id: androidMessage.androidChannelId,
2220
- icon: androidMessage.icon,
2221
- tag: androidMessage.tag,
2222
- color: androidMessage.color,
2223
- };
2224
- return notification;
2216
+ function createAppleNotificationBody(nativeMessage) {
2217
+ return JSON.stringify(nativeMessage);
2225
2218
  }
2226
2219
  /**
2227
2220
  * Creates a FcmLegacyNotification from a native Firebase payload.
2228
2221
  * @param nativeMessage - The native message payload to send to Notification Hubs.
2229
- * @returns The FcmLegacyNotification to send to Notification Hubs.
2230
- */
2231
- function buildFirebaseLegacyNativeMessage(nativeMessage) {
2232
- const jsonMessage = {
2233
- to: nativeMessage.to,
2234
- registration_ids: nativeMessage.registrationIds,
2235
- condition: nativeMessage.condition,
2236
- collapse_key: nativeMessage.collapseKey,
2237
- priority: nativeMessage.priority,
2238
- content_available: nativeMessage.contentAvailable,
2239
- mutable_content: nativeMessage.mutableContent,
2240
- time_to_live: nativeMessage.timeToLive,
2241
- restricted_package_name: nativeMessage.restrictedPackageName,
2242
- dry_run: nativeMessage.dryRun,
2243
- data: nativeMessage.data,
2244
- notification: buildFcmLegacyNativePayload(nativeMessage.notification),
2245
- };
2246
- return createFcmLegacyNotification({
2247
- body: JSON.stringify(jsonMessage),
2248
- });
2249
- }
2250
- function buildAdmNativeNotification(nativeNotification) {
2251
- if (!isDefined(nativeNotification)) {
2252
- return undefined;
2253
- }
2254
- return {
2255
- title: nativeNotification.title,
2256
- body: nativeNotification.body,
2257
- icon: nativeNotification.icon,
2258
- color: nativeNotification.color,
2259
- sound: nativeNotification.sound,
2260
- tag: nativeNotification.tag,
2261
- click_action: nativeNotification.clickAction,
2262
- body_loc_key: nativeNotification.bodyLocKey,
2263
- body_loc_args: nativeNotification.bodyLocArgs,
2264
- title_loc_key: nativeNotification.titleLocKey,
2265
- title_loc_args: nativeNotification.titleLocArgs,
2266
- channel_id: nativeNotification.channelId,
2267
- ticker: nativeNotification.ticker,
2268
- sticky: nativeNotification.sticky,
2269
- event_time: nativeNotification.eventTime,
2270
- local_only: nativeNotification.localOnly,
2271
- notification_priority: nativeNotification.notificationPriority,
2272
- default_sound: nativeNotification.defaultSound,
2273
- visibility: nativeNotification.visibility,
2274
- notification_count: nativeNotification.notificationCount,
2275
- image: nativeNotification.image,
2276
- };
2222
+ * @returns The JSON body to send to Notification Hubs.
2223
+ */
2224
+ function createFirebaseLegacyNotificationBody(nativeMessage) {
2225
+ return JSON.stringify(nativeMessage);
2277
2226
  }
2278
2227
  /**
2279
2228
  * Creates a AdmNotification from a native ADM payload.
2280
2229
  * @param nativeMessage - The native message payload to send to Notification Hubs.
2281
2230
  * @returns The AdmNotification to send to Notification Hubs.
2282
2231
  */
2283
- function buildAdmNativeMessage(nativeMessage) {
2284
- const jsonObj = Object.assign({ notification: buildAdmNativeNotification(nativeMessage.notification), data: nativeMessage.data || {} }, nativeMessage);
2285
- return createAdmNotification({
2286
- body: JSON.stringify(jsonObj),
2287
- });
2232
+ function createAdmNotificationBody(nativeMessage) {
2233
+ return JSON.stringify(nativeMessage);
2288
2234
  }
2289
2235
  /**
2290
2236
  * Creates a BaiduNotification from a native Baidu payload.
2291
2237
  * @param nativeMessage - The native message payload to send to Notification Hubs.
2292
- * @param additionalProperties - Additional properties for Apple Baidu messages.
2293
- * @returns The BaiduNotification to send to Notification Hubs.
2238
+ * @returns The JSON body to send to Notification Hubs.
2294
2239
  */
2295
- function buildBaiduNativeMessage(nativeMessage, additionalProperties) {
2296
- const jsonObj = Object.assign({ title: nativeMessage.title, description: nativeMessage.description, notification_builder_id: nativeMessage.notificationBuilderId, notification_basic_style: nativeMessage.notificationBasicStyle, open_type: nativeMessage.openType, net_support: nativeMessage.netSupport, user_confirm: nativeMessage.userConfirm, url: nativeMessage.url, pkg_content: nativeMessage.pkgContent, pkg_version: nativeMessage.pkgVersion, custom_content: nativeMessage.customContent, aps: nativeMessage.aps }, additionalProperties);
2297
- return createBaiduNotification({
2298
- body: JSON.stringify(jsonObj),
2299
- });
2240
+ function createBaiduNotificationBody(nativeMessage) {
2241
+ return JSON.stringify(nativeMessage);
2300
2242
  }
2301
2243
  /**
2302
2244
  * Builds a WindowsNotification from a Windows Badge.
2303
2245
  * @param nativeMessage - The Windows Badge Message to build.
2304
- * @returns A WindowsNotification created with the badge information.
2246
+ * @returns The WNS XML created with the badge information.
2305
2247
  */
2306
- function buildWindowsBadgeNativeMessage(nativeMessage) {
2248
+ function createWindowsBadgeNotificationBody(nativeMessage) {
2307
2249
  const badge = {
2308
2250
  $: { value: nativeMessage.value },
2309
2251
  };
2310
- return createWindowsBadgeNotification({
2311
- body: coreXml.stringifyXML(badge, { rootName: "badge" }),
2312
- });
2252
+ return coreXml.stringifyXML(badge, { rootName: "badge" });
2313
2253
  }
2314
2254
 
2315
2255
  // Copyright (c) Microsoft Corporation.
@@ -2320,7 +2260,7 @@ function buildWindowsBadgeNativeMessage(nativeMessage) {
2320
2260
  * @returns A created ADM registration description.
2321
2261
  */
2322
2262
  function createAdmRegistrationDescription(description) {
2323
- return Object.assign(Object.assign({}, description), { type: "Adm" });
2263
+ return Object.assign(Object.assign({}, description), { kind: "Adm" });
2324
2264
  }
2325
2265
  /**
2326
2266
  * Creates an ADM template registration description.
@@ -2328,7 +2268,7 @@ function createAdmRegistrationDescription(description) {
2328
2268
  * @returns A created ADM template registration description.
2329
2269
  */
2330
2270
  function createAdmTemplateRegistrationDescription(description) {
2331
- return Object.assign(Object.assign({}, description), { type: "AdmTemplate" });
2271
+ return Object.assign(Object.assign({}, description), { kind: "AdmTemplate" });
2332
2272
  }
2333
2273
  /**
2334
2274
  * Creates an Apple registration description.
@@ -2336,7 +2276,7 @@ function createAdmTemplateRegistrationDescription(description) {
2336
2276
  * @returns A created Apple registration description.
2337
2277
  */
2338
2278
  function createAppleRegistrationDescription(description) {
2339
- return Object.assign(Object.assign({}, description), { type: "Apple" });
2279
+ return Object.assign(Object.assign({}, description), { kind: "Apple" });
2340
2280
  }
2341
2281
  /**
2342
2282
  * Creates an Apple template registration description.
@@ -2344,7 +2284,7 @@ function createAppleRegistrationDescription(description) {
2344
2284
  * @returns A created Apple template registration description.
2345
2285
  */
2346
2286
  function createAppleTemplateRegistrationDescription(description) {
2347
- return Object.assign(Object.assign({}, description), { type: "AppleTemplate" });
2287
+ return Object.assign(Object.assign({}, description), { kind: "AppleTemplate" });
2348
2288
  }
2349
2289
  /**
2350
2290
  * Creates a Baidu registration description.
@@ -2352,7 +2292,7 @@ function createAppleTemplateRegistrationDescription(description) {
2352
2292
  * @returns A created Baidu registration description.
2353
2293
  */
2354
2294
  function createBaiduRegistrationDescription(description) {
2355
- return Object.assign(Object.assign({}, description), { type: "Baidu" });
2295
+ return Object.assign(Object.assign({}, description), { kind: "Baidu" });
2356
2296
  }
2357
2297
  /**
2358
2298
  * Creates a Baidu template registration description.
@@ -2360,7 +2300,7 @@ function createBaiduRegistrationDescription(description) {
2360
2300
  * @returns A created Baidu template registration description.
2361
2301
  */
2362
2302
  function createBaiduTemplateRegistrationDescription(description) {
2363
- return Object.assign(Object.assign({}, description), { type: "BaiduTemplate" });
2303
+ return Object.assign(Object.assign({}, description), { kind: "BaiduTemplate" });
2364
2304
  }
2365
2305
  /**
2366
2306
  * Creates a Web Push registration description.
@@ -2368,7 +2308,7 @@ function createBaiduTemplateRegistrationDescription(description) {
2368
2308
  * @returns A created Web Push registration description.
2369
2309
  */
2370
2310
  function createBrowserRegistrationDescription(description) {
2371
- return Object.assign(Object.assign({}, description), { type: "Browser" });
2311
+ return Object.assign(Object.assign({}, description), { kind: "Browser" });
2372
2312
  }
2373
2313
  /**
2374
2314
  * Creates a Web Push registration description.
@@ -2376,7 +2316,7 @@ function createBrowserRegistrationDescription(description) {
2376
2316
  * @returns A created Web Push template registration description.
2377
2317
  */
2378
2318
  function createBrowserTemplateRegistrationDescription(description) {
2379
- return Object.assign(Object.assign({}, description), { type: "BrowserTemplate" });
2319
+ return Object.assign(Object.assign({}, description), { kind: "BrowserTemplate" });
2380
2320
  }
2381
2321
  /**
2382
2322
  * Creates a Firebase Legacy registration description.
@@ -2384,7 +2324,7 @@ function createBrowserTemplateRegistrationDescription(description) {
2384
2324
  * @returns A created GCM registration description.
2385
2325
  */
2386
2326
  function createFcmLegacyRegistrationDescription(description) {
2387
- return Object.assign(Object.assign({}, description), { type: "Gcm" });
2327
+ return Object.assign(Object.assign({}, description), { kind: "Gcm" });
2388
2328
  }
2389
2329
  /**
2390
2330
  * Creates a GCM template registration description.
@@ -2392,7 +2332,7 @@ function createFcmLegacyRegistrationDescription(description) {
2392
2332
  * @returns A created GCM template registration description.
2393
2333
  */
2394
2334
  function createFcmLegacyTemplateRegistrationDescription(description) {
2395
- return Object.assign(Object.assign({}, description), { type: "GcmTemplate" });
2335
+ return Object.assign(Object.assign({}, description), { kind: "GcmTemplate" });
2396
2336
  }
2397
2337
  /**
2398
2338
  * Creates a Windows registration description.
@@ -2400,7 +2340,7 @@ function createFcmLegacyTemplateRegistrationDescription(description) {
2400
2340
  * @returns A created Windows registration description.
2401
2341
  */
2402
2342
  function createWindowsRegistrationDescription(description) {
2403
- return Object.assign(Object.assign({}, description), { type: "Windows" });
2343
+ return Object.assign(Object.assign({}, description), { kind: "Windows" });
2404
2344
  }
2405
2345
  /**
2406
2346
  * Creates a Windows template registration description.
@@ -2408,25 +2348,34 @@ function createWindowsRegistrationDescription(description) {
2408
2348
  * @returns A created Windows template registration description.
2409
2349
  */
2410
2350
  function createWindowsTemplateRegistrationDescription(description) {
2411
- return Object.assign(Object.assign({}, description), { type: "WindowsTemplate" });
2351
+ return Object.assign(Object.assign({}, description), { kind: "WindowsTemplate" });
2352
+ }
2353
+
2354
+ // Copyright (c) Microsoft Corporation.
2355
+ // Licensed under the MIT license.
2356
+ /**
2357
+ * Creates a tag expression from a list of tags as a || expression.
2358
+ * @param tags - The tags to create the || expression
2359
+ * @returns The tag expression made from the array of strings into an || expression.
2360
+ */
2361
+ function createTagExpression(tags) {
2362
+ return tags.join("||");
2412
2363
  }
2413
2364
 
2414
- exports.NotificationHubsServiceClient = NotificationHubsServiceClient;
2415
- exports.buildAdmNativeMessage = buildAdmNativeMessage;
2416
- exports.buildAppleNativeMessage = buildAppleNativeMessage;
2417
- exports.buildBaiduNativeMessage = buildBaiduNativeMessage;
2418
- exports.buildFirebaseLegacyNativeMessage = buildFirebaseLegacyNativeMessage;
2419
- exports.buildWindowsBadgeNativeMessage = buildWindowsBadgeNativeMessage;
2365
+ exports.NotificationHubsClient = NotificationHubsClient;
2420
2366
  exports.createAdmInstallation = createAdmInstallation;
2421
2367
  exports.createAdmNotification = createAdmNotification;
2368
+ exports.createAdmNotificationBody = createAdmNotificationBody;
2422
2369
  exports.createAdmRegistrationDescription = createAdmRegistrationDescription;
2423
2370
  exports.createAdmTemplateRegistrationDescription = createAdmTemplateRegistrationDescription;
2424
2371
  exports.createAppleInstallation = createAppleInstallation;
2425
2372
  exports.createAppleNotification = createAppleNotification;
2373
+ exports.createAppleNotificationBody = createAppleNotificationBody;
2426
2374
  exports.createAppleRegistrationDescription = createAppleRegistrationDescription;
2427
2375
  exports.createAppleTemplateRegistrationDescription = createAppleTemplateRegistrationDescription;
2428
2376
  exports.createBaiduInstallation = createBaiduInstallation;
2429
2377
  exports.createBaiduNotification = createBaiduNotification;
2378
+ exports.createBaiduNotificationBody = createBaiduNotificationBody;
2430
2379
  exports.createBaiduRegistrationDescription = createBaiduRegistrationDescription;
2431
2380
  exports.createBaiduTemplateRegistrationDescription = createBaiduTemplateRegistrationDescription;
2432
2381
  exports.createBrowserInstallation = createBrowserInstallation;
@@ -2437,8 +2386,11 @@ exports.createFcmLegacyInstallation = createFcmLegacyInstallation;
2437
2386
  exports.createFcmLegacyNotification = createFcmLegacyNotification;
2438
2387
  exports.createFcmLegacyRegistrationDescription = createFcmLegacyRegistrationDescription;
2439
2388
  exports.createFcmLegacyTemplateRegistrationDescription = createFcmLegacyTemplateRegistrationDescription;
2389
+ exports.createFirebaseLegacyNotificationBody = createFirebaseLegacyNotificationBody;
2390
+ exports.createTagExpression = createTagExpression;
2440
2391
  exports.createTemplateNotification = createTemplateNotification;
2441
2392
  exports.createWindowsBadgeNotification = createWindowsBadgeNotification;
2393
+ exports.createWindowsBadgeNotificationBody = createWindowsBadgeNotificationBody;
2442
2394
  exports.createWindowsInstallation = createWindowsInstallation;
2443
2395
  exports.createWindowsRawNotification = createWindowsRawNotification;
2444
2396
  exports.createWindowsRegistrationDescription = createWindowsRegistrationDescription;