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

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 (215) hide show
  1. package/README.md +84 -77
  2. package/dist/index.cjs +312 -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 +0 -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.map +1 -1
  73. package/dist-esm/src/serializers/notificationOutcomeSerializer.js +2 -2
  74. package/dist-esm/src/serializers/notificationOutcomeSerializer.js.map +1 -1
  75. package/dist-esm/src/serializers/registrationSerializer.js +16 -16
  76. package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
  77. package/dist-esm/src/utils/constants.js +1 -1
  78. package/dist-esm/src/utils/constants.js.map +1 -1
  79. package/dist-esm/src/utils/notificationUtils.js +0 -6
  80. package/dist-esm/src/utils/notificationUtils.js.map +1 -1
  81. package/package.json +9 -13
  82. package/types/3.1/notification-hubs.d.ts +420 -249
  83. package/types/latest/notification-hubs.d.ts +448 -254
  84. package/types/latest/tsdoc-metadata.json +1 -1
  85. package/types/src/{client → api}/beginSubmitNotificationHubJob.d.ts +0 -0
  86. package/types/src/api/beginSubmitNotificationHubJob.d.ts.map +1 -0
  87. package/types/src/{client → api}/cancelScheduledNotification.d.ts +0 -0
  88. package/types/src/api/cancelScheduledNotification.d.ts.map +1 -0
  89. package/types/src/{client → api}/createOrUpdateInstallation.d.ts +0 -0
  90. package/types/src/api/createOrUpdateInstallation.d.ts.map +1 -0
  91. package/types/src/{client → api}/createOrUpdateRegistration.d.ts +0 -0
  92. package/types/src/api/createOrUpdateRegistration.d.ts.map +1 -0
  93. package/types/src/{client → api}/createRegistration.d.ts +0 -0
  94. package/types/src/api/createRegistration.d.ts.map +1 -0
  95. package/types/src/{client → api}/createRegistrationId.d.ts +0 -0
  96. package/types/src/api/createRegistrationId.d.ts.map +1 -0
  97. package/types/src/{client → api}/deleteInstallation.d.ts +0 -0
  98. package/types/src/api/deleteInstallation.d.ts.map +1 -0
  99. package/types/src/{client → api}/deleteRegistration.d.ts +0 -0
  100. package/types/src/api/deleteRegistration.d.ts.map +1 -0
  101. package/types/src/{client → api}/getFeedbackContainerUrl.d.ts +0 -0
  102. package/types/src/api/getFeedbackContainerUrl.d.ts.map +1 -0
  103. package/types/src/{client → api}/getInstallation.d.ts +0 -0
  104. package/types/src/api/getInstallation.d.ts.map +1 -0
  105. package/types/src/{client → api}/getNotificationHubJob.d.ts +0 -0
  106. package/types/src/api/getNotificationHubJob.d.ts.map +1 -0
  107. package/types/src/{client → api}/getNotificationOutcomeDetails.d.ts +0 -0
  108. package/types/src/api/getNotificationOutcomeDetails.d.ts.map +1 -0
  109. package/types/src/{client → api}/getRegistration.d.ts +0 -0
  110. package/types/src/api/getRegistration.d.ts.map +1 -0
  111. package/types/src/{client → api}/index.d.ts +22 -0
  112. package/types/src/api/index.d.ts.map +1 -0
  113. package/types/src/{client → api}/internal/_client.d.ts +0 -0
  114. package/types/src/api/internal/_client.d.ts.map +1 -0
  115. package/types/src/{client → api}/internal/_createOrUpdateRegistrationDescription.d.ts +0 -0
  116. package/types/src/api/internal/_createOrUpdateRegistrationDescription.d.ts.map +1 -0
  117. package/types/src/api/internal/_listRegistrations.d.ts +6 -0
  118. package/types/src/api/internal/_listRegistrations.d.ts.map +1 -0
  119. package/types/src/{client → api}/listNotificationHubJobs.d.ts +0 -0
  120. package/types/src/api/listNotificationHubJobs.d.ts.map +1 -0
  121. package/types/src/{client → api}/listRegistrations.d.ts +3 -3
  122. package/types/src/api/listRegistrations.d.ts.map +1 -0
  123. package/types/src/api/listRegistrationsByChannel.d.ts +13 -0
  124. package/types/src/api/listRegistrationsByChannel.d.ts.map +1 -0
  125. package/types/src/{client → api}/listRegistrationsByTag.d.ts +0 -0
  126. package/types/src/api/listRegistrationsByTag.d.ts.map +1 -0
  127. package/types/src/{client → api}/scheduleNotification.d.ts +0 -0
  128. package/types/src/api/scheduleNotification.d.ts.map +1 -0
  129. package/types/src/{client → api}/sendNotification.d.ts +0 -0
  130. package/types/src/api/sendNotification.d.ts.map +1 -0
  131. package/types/src/{client → api}/submitNotificationHubJob.d.ts +0 -0
  132. package/types/src/api/submitNotificationHubJob.d.ts.map +1 -0
  133. package/types/src/{client → api}/updateInstallation.d.ts +0 -0
  134. package/types/src/api/updateInstallation.d.ts.map +1 -0
  135. package/types/src/{client → api}/updateRegistration.d.ts +0 -0
  136. package/types/src/api/updateRegistration.d.ts.map +1 -0
  137. package/types/src/index.d.ts +3 -2
  138. package/types/src/index.d.ts.map +1 -1
  139. package/types/src/models/index.d.ts +10 -0
  140. package/types/src/models/index.d.ts.map +1 -0
  141. package/types/src/models/installation.d.ts +12 -11
  142. package/types/src/models/installation.d.ts.map +1 -1
  143. package/types/src/models/notification.d.ts +10 -18
  144. package/types/src/models/notification.d.ts.map +1 -1
  145. package/types/src/models/{notificationBuilder.d.ts → notificationBodyBuilder.d.ts} +62 -64
  146. package/types/src/models/notificationBodyBuilder.d.ts.map +1 -0
  147. package/types/src/models/notificationDetails.d.ts +9 -9
  148. package/types/src/models/notificationDetails.d.ts.map +1 -1
  149. package/types/src/models/options.d.ts +4 -4
  150. package/types/src/models/options.d.ts.map +1 -1
  151. package/types/src/models/registration.d.ts +235 -69
  152. package/types/src/models/registration.d.ts.map +1 -1
  153. package/types/src/models/tagExpressionBuilder.d.ts +7 -0
  154. package/types/src/models/tagExpressionBuilder.d.ts.map +1 -0
  155. package/types/src/notificationHubsClient.d.ts +12 -5
  156. package/types/src/notificationHubsClient.d.ts.map +1 -1
  157. package/types/src/serializers/registrationSerializer.d.ts +14 -14
  158. package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
  159. package/types/src/utils/notificationUtils.d.ts +0 -4
  160. package/types/src/utils/notificationUtils.d.ts.map +1 -1
  161. package/dist-esm/src/client/beginSubmitNotificationHubJob.js.map +0 -1
  162. package/dist-esm/src/client/cancelScheduledNotification.js.map +0 -1
  163. package/dist-esm/src/client/createOrUpdateInstallation.js.map +0 -1
  164. package/dist-esm/src/client/createOrUpdateRegistration.js.map +0 -1
  165. package/dist-esm/src/client/createRegistration.js.map +0 -1
  166. package/dist-esm/src/client/createRegistrationId.js.map +0 -1
  167. package/dist-esm/src/client/deleteInstallation.js.map +0 -1
  168. package/dist-esm/src/client/deleteRegistration.js.map +0 -1
  169. package/dist-esm/src/client/getFeedbackContainerUrl.js.map +0 -1
  170. package/dist-esm/src/client/getInstallation.js.map +0 -1
  171. package/dist-esm/src/client/getNotificationHubJob.js.map +0 -1
  172. package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +0 -1
  173. package/dist-esm/src/client/getRegistration.js.map +0 -1
  174. package/dist-esm/src/client/index.js.map +0 -1
  175. package/dist-esm/src/client/internal/_client.js.map +0 -1
  176. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +0 -1
  177. package/dist-esm/src/client/listNotificationHubJobs.js.map +0 -1
  178. package/dist-esm/src/client/listRegistrations.js.map +0 -1
  179. package/dist-esm/src/client/listRegistrationsByTag.js.map +0 -1
  180. package/dist-esm/src/client/scheduleNotification.js.map +0 -1
  181. package/dist-esm/src/client/sendNotification.js.map +0 -1
  182. package/dist-esm/src/client/submitNotificationHubJob.js.map +0 -1
  183. package/dist-esm/src/client/updateInstallation.js.map +0 -1
  184. package/dist-esm/src/client/updateRegistration.js.map +0 -1
  185. package/dist-esm/src/models/notificationBuilder.js +0 -169
  186. package/dist-esm/src/models/notificationBuilder.js.map +0 -1
  187. package/dist-esm/src/utils/retryPolicy.js +0 -144
  188. package/dist-esm/src/utils/retryPolicy.js.map +0 -1
  189. package/types/src/client/beginSubmitNotificationHubJob.d.ts.map +0 -1
  190. package/types/src/client/cancelScheduledNotification.d.ts.map +0 -1
  191. package/types/src/client/createOrUpdateInstallation.d.ts.map +0 -1
  192. package/types/src/client/createOrUpdateRegistration.d.ts.map +0 -1
  193. package/types/src/client/createRegistration.d.ts.map +0 -1
  194. package/types/src/client/createRegistrationId.d.ts.map +0 -1
  195. package/types/src/client/deleteInstallation.d.ts.map +0 -1
  196. package/types/src/client/deleteRegistration.d.ts.map +0 -1
  197. package/types/src/client/getFeedbackContainerUrl.d.ts.map +0 -1
  198. package/types/src/client/getInstallation.d.ts.map +0 -1
  199. package/types/src/client/getNotificationHubJob.d.ts.map +0 -1
  200. package/types/src/client/getNotificationOutcomeDetails.d.ts.map +0 -1
  201. package/types/src/client/getRegistration.d.ts.map +0 -1
  202. package/types/src/client/index.d.ts.map +0 -1
  203. package/types/src/client/internal/_client.d.ts.map +0 -1
  204. package/types/src/client/internal/_createOrUpdateRegistrationDescription.d.ts.map +0 -1
  205. package/types/src/client/listNotificationHubJobs.d.ts.map +0 -1
  206. package/types/src/client/listRegistrations.d.ts.map +0 -1
  207. package/types/src/client/listRegistrationsByTag.d.ts.map +0 -1
  208. package/types/src/client/scheduleNotification.d.ts.map +0 -1
  209. package/types/src/client/sendNotification.d.ts.map +0 -1
  210. package/types/src/client/submitNotificationHubJob.d.ts.map +0 -1
  211. package/types/src/client/updateInstallation.d.ts.map +0 -1
  212. package/types/src/client/updateRegistration.d.ts.map +0 -1
  213. package/types/src/models/notificationBuilder.d.ts.map +0 -1
  214. package/types/src/utils/retryPolicy.d.ts +0 -72
  215. 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.7";
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);
@@ -859,21 +809,21 @@ const registrationDescriptionParser = {
859
809
  * Creates an ADM registration description from incoming XML property bag.
860
810
  */
861
811
  createAdmRegistrationDescription(rawRegistrationDescription) {
862
- return Object.assign(Object.assign({ admRegistrationId: getString(rawRegistrationDescription["AdmRegistrationId"], "admRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Adm" });
812
+ return Object.assign(Object.assign({ admRegistrationId: getString(rawRegistrationDescription["AdmRegistrationId"], "admRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Adm" });
863
813
  },
864
814
  /**
865
815
  * @internal
866
816
  * Creates an ADM template registration description from incoming XML property bag.
867
817
  */
868
818
  createAdmTemplateRegistrationDescription(rawRegistrationDescription) {
869
- return Object.assign(Object.assign(Object.assign({}, this.createAdmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "AdmTemplate" });
819
+ return Object.assign(Object.assign(Object.assign({}, this.createAdmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "AdmTemplate" });
870
820
  },
871
821
  /**
872
822
  * @internal
873
823
  * Creates an Apple registration description from incoming XML property bag.
874
824
  */
875
825
  createAppleRegistrationDescription(rawRegistrationDescription) {
876
- return Object.assign(Object.assign({ deviceToken: getString(rawRegistrationDescription["DeviceToken"], "deviceToken") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Apple" });
826
+ return Object.assign(Object.assign({ deviceToken: getString(rawRegistrationDescription["DeviceToken"], "deviceToken") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Apple" });
877
827
  },
878
828
  /**
879
829
  * @internal
@@ -881,56 +831,56 @@ const registrationDescriptionParser = {
881
831
  */
882
832
  createAppleTemplateRegistrationDescription(rawRegistrationDescription) {
883
833
  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" });
834
+ 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
835
  },
886
836
  /**
887
837
  * @internal
888
838
  * Creates a Baidu registration description from incoming XML property bag.
889
839
  */
890
840
  createBaiduRegistrationDescription(rawRegistrationDescription) {
891
- return Object.assign(Object.assign({ baiduChannelId: getString(rawRegistrationDescription["BaiduChannelId"], "baiduChannelId"), baiduUserId: getString(rawRegistrationDescription["BaiduUserId"], "baiduUserId") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Baidu" });
841
+ return Object.assign(Object.assign({ baiduChannelId: getString(rawRegistrationDescription["BaiduChannelId"], "baiduChannelId"), baiduUserId: getString(rawRegistrationDescription["BaiduUserId"], "baiduUserId") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Baidu" });
892
842
  },
893
843
  /**
894
844
  * @internal
895
845
  * Creates a Baidu template registration description from incoming XML property bag.
896
846
  */
897
847
  createBaiduTemplateRegistrationDescription(rawRegistrationDescription) {
898
- return Object.assign(Object.assign(Object.assign({}, this.createBaiduRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "BaiduTemplate" });
848
+ return Object.assign(Object.assign(Object.assign({}, this.createBaiduRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "BaiduTemplate" });
899
849
  },
900
850
  /**
901
851
  * @internal
902
852
  * Creates a Browser registration description from incoming XML property bag.
903
853
  */
904
854
  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" });
855
+ 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
856
  },
907
857
  /**
908
858
  * @internal
909
859
  * Creates a Browser template registration description from incoming XML property bag.
910
860
  */
911
861
  createBrowserTemplateRegistrationDescription(rawRegistrationDescription) {
912
- return Object.assign(Object.assign(Object.assign({}, this.createBrowserRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "BrowserTemplate" });
862
+ return Object.assign(Object.assign(Object.assign({}, this.createBrowserRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "BrowserTemplate" });
913
863
  },
914
864
  /**
915
865
  * @internal
916
866
  * Creates an GCM registration description from incoming XML property bag.
917
867
  */
918
868
  createGcmRegistrationDescription(rawRegistrationDescription) {
919
- return Object.assign(Object.assign({ gcmRegistrationId: getString(rawRegistrationDescription["GcmRegistrationId"], "gcmRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Gcm" });
869
+ return Object.assign(Object.assign({ gcmRegistrationId: getString(rawRegistrationDescription["GcmRegistrationId"], "gcmRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Gcm" });
920
870
  },
921
871
  /**
922
872
  * @internal
923
873
  * Creates an FCM template registration description from incoming XML property bag.
924
874
  */
925
875
  createGcmTemplateRegistrationDescription(rawRegistrationDescription) {
926
- return Object.assign(Object.assign(Object.assign({}, this.createGcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "GcmTemplate" });
876
+ return Object.assign(Object.assign(Object.assign({}, this.createGcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "GcmTemplate" });
927
877
  },
928
878
  /**
929
879
  * @internal
930
880
  * Creates a Windows Phone registration description from incoming XML property bag.
931
881
  */
932
882
  createMpnsRegistrationDescription(rawRegistrationDescription) {
933
- return Object.assign(Object.assign({ channelUri: getString(rawRegistrationDescription["ChannelUri"], "channelUri") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Mpns" });
883
+ return Object.assign(Object.assign({ channelUri: getString(rawRegistrationDescription["ChannelUri"], "channelUri") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Mpns" });
934
884
  },
935
885
  /**
936
886
  * @internal
@@ -938,14 +888,14 @@ const registrationDescriptionParser = {
938
888
  */
939
889
  createMpnsTemplateRegistrationDescription(rawRegistrationDescription) {
940
890
  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" });
891
+ 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
892
  },
943
893
  /**
944
894
  * @internal
945
895
  * Creates a Windows registration description from incoming XML property bag.
946
896
  */
947
897
  createWindowsRegistrationDescription(rawRegistrationDescription) {
948
- return Object.assign(Object.assign({ channelUri: getString(rawRegistrationDescription["ChannelUri"], "channelUri") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Windows" });
898
+ return Object.assign(Object.assign({ channelUri: getString(rawRegistrationDescription["ChannelUri"], "channelUri") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Windows" });
949
899
  },
950
900
  /**
951
901
  * @internal
@@ -953,7 +903,7 @@ const registrationDescriptionParser = {
953
903
  */
954
904
  createWindowsTemplateRegistrationDescription(rawRegistrationDescription) {
955
905
  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" });
906
+ 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
907
  },
958
908
  };
959
909
  function getHeadersOrUndefined(value) {
@@ -988,11 +938,11 @@ function createTemplateRegistrationDescription(rawRegistrationDescription) {
988
938
  */
989
939
  const registrationDescriptionSerializer = {
990
940
  serializeRegistrationDescription(description) {
991
- const rootName = `${description.type}RegistrationDescription`;
941
+ const rootName = `${description.kind}RegistrationDescription`;
992
942
  const methodName = `serialize${rootName}`;
993
943
  const method = this[methodName].bind(this);
994
944
  if (!isDefined(method)) {
995
- throw new coreRestPipeline.RestError(`Undefined platform ${description.type}`, { statusCode: 400 });
945
+ throw new coreRestPipeline.RestError(`Undefined platform ${description.kind}`, { statusCode: 400 });
996
946
  }
997
947
  const registration = method(description);
998
948
  const requestObject = serializeToAtomXmlRequest(rootName, registration);
@@ -1187,7 +1137,7 @@ async function createOrUpdateRegistrationDescription(context, registration, oper
1187
1137
  }
1188
1138
 
1189
1139
  // Copyright (c) Microsoft Corporation.
1190
- const OPERATION_NAME$d = "createOrUpdateRegistration";
1140
+ const OPERATION_NAME$c = "createOrUpdateRegistration";
1191
1141
  /**
1192
1142
  * Creates or updates a registration.
1193
1143
  * @param context - The Notification Hubs client.
@@ -1196,32 +1146,8 @@ const OPERATION_NAME$d = "createOrUpdateRegistration";
1196
1146
  * @returns The created or updated registration description.
1197
1147
  */
1198
1148
  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
1149
  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;
1150
+ return createOrUpdateRegistrationDescription(context, registration, "createOrUpdate", updatedOptions);
1225
1151
  });
1226
1152
  }
1227
1153
 
@@ -1247,7 +1173,31 @@ function createRegistration(context, registration, options = {}) {
1247
1173
  }
1248
1174
 
1249
1175
  // Copyright (c) Microsoft Corporation.
1250
- const OPERATION_NAME$a = "deleteInstallation";
1176
+ const OPERATION_NAME$a = "createRegistrationId";
1177
+ /**
1178
+ * Creates a new registration ID.
1179
+ * @param context - The Notification Hubs client.
1180
+ * @param options - The options for creating a new registration ID.
1181
+ * @returns The newly created registration ID.
1182
+ */
1183
+ function createRegistrationId(context, options = {}) {
1184
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$a}`, options, async (updatedOptions) => {
1185
+ const endpoint = context.requestUrl();
1186
+ endpoint.pathname += "/registrationIDs";
1187
+ const headers = await context.createHeaders(OPERATION_NAME$a);
1188
+ headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
1189
+ const request = createRequest(endpoint, "POST", headers, updatedOptions);
1190
+ const response = await sendRequest(context, request, 201);
1191
+ // In the form: https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/<registrationId>
1192
+ const locationHeader = response.headers.get("Location");
1193
+ const locationUrl = new URL(locationHeader);
1194
+ const registrationId = locationUrl.pathname.split("/")[3];
1195
+ return registrationId;
1196
+ });
1197
+ }
1198
+
1199
+ // Copyright (c) Microsoft Corporation.
1200
+ const OPERATION_NAME$9 = "deleteInstallation";
1251
1201
  /**
1252
1202
  * Deletes an installation from a Notification Hub.
1253
1203
  * @param context - The Notification Hubs client.
@@ -1256,10 +1206,10 @@ const OPERATION_NAME$a = "deleteInstallation";
1256
1206
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1257
1207
  */
1258
1208
  function deleteInstallation(context, installationId, options = {}) {
1259
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$a}`, options, async (updatedOptions) => {
1209
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$9}`, options, async (updatedOptions) => {
1260
1210
  const endpoint = context.requestUrl();
1261
1211
  endpoint.pathname += `/installations/${installationId}`;
1262
- const headers = await context.createHeaders(OPERATION_NAME$a);
1212
+ const headers = await context.createHeaders(OPERATION_NAME$9);
1263
1213
  const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
1264
1214
  const response = await sendRequest(context, request, 204);
1265
1215
  return parseNotificationResponse(response);
@@ -1267,7 +1217,7 @@ function deleteInstallation(context, installationId, options = {}) {
1267
1217
  }
1268
1218
 
1269
1219
  // Copyright (c) Microsoft Corporation.
1270
- const OPERATION_NAME$9 = "deleteRegistration";
1220
+ const OPERATION_NAME$8 = "deleteRegistration";
1271
1221
  /**
1272
1222
  * Deletes a registration with the given registration ID.
1273
1223
  * @param context - The Notification Hubs client.
@@ -1276,10 +1226,10 @@ const OPERATION_NAME$9 = "deleteRegistration";
1276
1226
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1277
1227
  */
1278
1228
  function deleteRegistration(context, registrationId, options = {}) {
1279
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$9}`, options, async (updatedOptions) => {
1229
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$8}`, options, async (updatedOptions) => {
1280
1230
  const endpoint = context.requestUrl();
1281
1231
  endpoint.pathname += `/registrations/${registrationId}`;
1282
- const headers = await context.createHeaders(OPERATION_NAME$9);
1232
+ const headers = await context.createHeaders(OPERATION_NAME$8);
1283
1233
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
1284
1234
  headers.set("If-Match", isDefined(options.etag) ? `"${options.etag}"` : "*");
1285
1235
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
@@ -1289,7 +1239,7 @@ function deleteRegistration(context, registrationId, options = {}) {
1289
1239
  }
1290
1240
 
1291
1241
  // Copyright (c) Microsoft Corporation.
1292
- const OPERATION_NAME$8 = "getFeedbackContainerUrl";
1242
+ const OPERATION_NAME$7 = "getFeedbackContainerUrl";
1293
1243
  /**
1294
1244
  * Retrieves an Azure Storage container URL. The container has feedback data for the notification hub.
1295
1245
  * The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.
@@ -1298,10 +1248,10 @@ const OPERATION_NAME$8 = "getFeedbackContainerUrl";
1298
1248
  * @returns The URL of the Azure Storage Container containing the feedback data.
1299
1249
  */
1300
1250
  function getFeedbackContainerUrl(context, options = {}) {
1301
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$8}`, options, async (updatedOptions) => {
1251
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$7}`, options, async (updatedOptions) => {
1302
1252
  const endpoint = context.requestUrl();
1303
1253
  endpoint.pathname += "/feedbackcontainer";
1304
- const headers = await context.createHeaders(OPERATION_NAME$8);
1254
+ const headers = await context.createHeaders(OPERATION_NAME$7);
1305
1255
  headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
1306
1256
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1307
1257
  const response = await sendRequest(context, request, 200);
@@ -1310,7 +1260,7 @@ function getFeedbackContainerUrl(context, options = {}) {
1310
1260
  }
1311
1261
 
1312
1262
  // Copyright (c) Microsoft Corporation.
1313
- const OPERATION_NAME$7 = "getInstallation";
1263
+ const OPERATION_NAME$6 = "getInstallation";
1314
1264
  /**
1315
1265
  * Gets an Azure Notification Hub installation by the installation ID.
1316
1266
  * @param context - The Notification Hubs client.
@@ -1319,10 +1269,10 @@ const OPERATION_NAME$7 = "getInstallation";
1319
1269
  * @returns The installation that matches the installation ID.
1320
1270
  */
1321
1271
  function getInstallation(context, installationId, options = {}) {
1322
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$7}`, options, async (updatedOptions) => {
1272
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$6}`, options, async (updatedOptions) => {
1323
1273
  const endpoint = context.requestUrl();
1324
1274
  endpoint.pathname += `/installations/${installationId}`;
1325
- const headers = await context.createHeaders(OPERATION_NAME$7);
1275
+ const headers = await context.createHeaders(OPERATION_NAME$6);
1326
1276
  headers.set("Content-Type", "application/json");
1327
1277
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1328
1278
  const response = await sendRequest(context, request, 200);
@@ -1387,7 +1337,7 @@ function parseOutcomeCounts(counts) {
1387
1337
  }
1388
1338
 
1389
1339
  // Copyright (c) Microsoft Corporation.
1390
- const OPERATION_NAME$6 = "getNotificationOutcomeDetails";
1340
+ const OPERATION_NAME$5 = "getNotificationOutcomeDetails";
1391
1341
  /**
1392
1342
  * Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed
1393
1343
  * or final results if the Send* has completed. This API can only be called for Standard SKU and above.
@@ -1397,10 +1347,10 @@ const OPERATION_NAME$6 = "getNotificationOutcomeDetails";
1397
1347
  * @returns The results of the send operation.
1398
1348
  */
1399
1349
  function getNotificationOutcomeDetails(context, notificationId, options = {}) {
1400
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$6}`, options, async (updatedOptions) => {
1350
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$5}`, options, async (updatedOptions) => {
1401
1351
  const endpoint = context.requestUrl();
1402
1352
  endpoint.pathname += `/messages/${notificationId}`;
1403
- const headers = await context.createHeaders(OPERATION_NAME$6);
1353
+ const headers = await context.createHeaders(OPERATION_NAME$5);
1404
1354
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1405
1355
  const response = await sendRequest(context, request, 200);
1406
1356
  return parseNotificationDetails(response.bodyAsText);
@@ -1408,7 +1358,7 @@ function getNotificationOutcomeDetails(context, notificationId, options = {}) {
1408
1358
  }
1409
1359
 
1410
1360
  // Copyright (c) Microsoft Corporation.
1411
- const OPERATION_NAME$5 = "getRegistration";
1361
+ const OPERATION_NAME$4 = "getRegistration";
1412
1362
  /**
1413
1363
  * Gets a registration by the given registration ID.
1414
1364
  * @param context - The Notification Hubs client.
@@ -1417,10 +1367,10 @@ const OPERATION_NAME$5 = "getRegistration";
1417
1367
  * @returns A RegistrationDescription that has the given registration ID.
1418
1368
  */
1419
1369
  function getRegistration(context, registrationId, options = {}) {
1420
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$5}`, options, async (updatedOptions) => {
1370
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$4}`, options, async (updatedOptions) => {
1421
1371
  const endpoint = context.requestUrl();
1422
1372
  endpoint.pathname += `/registrations/${registrationId}`;
1423
- const headers = await context.createHeaders(OPERATION_NAME$5);
1373
+ const headers = await context.createHeaders(OPERATION_NAME$4);
1424
1374
  headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
1425
1375
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1426
1376
  const response = await sendRequest(context, request, 200);
@@ -1429,7 +1379,7 @@ function getRegistration(context, registrationId, options = {}) {
1429
1379
  }
1430
1380
 
1431
1381
  // Copyright (c) Microsoft Corporation.
1432
- const OPERATION_NAME$4 = "listNotificationHubJobs";
1382
+ const OPERATION_NAME$3 = "listNotificationHubJobs";
1433
1383
  /**
1434
1384
  * Gets all Notification Hub Jobs for this Notification Hub.
1435
1385
  * @param context - The Notification Hubs client.xs
@@ -1437,10 +1387,10 @@ const OPERATION_NAME$4 = "listNotificationHubJobs";
1437
1387
  * @returns An array of all Notification Hub Jobs for this Notification Hub.
1438
1388
  */
1439
1389
  function listNotificationHubJobs(context, options = {}) {
1440
- return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$4}`, options, async (updatedOptions) => {
1390
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$3}`, options, async (updatedOptions) => {
1441
1391
  const endpoint = context.requestUrl();
1442
1392
  endpoint.pathname += "/jobs";
1443
- const headers = await context.createHeaders(OPERATION_NAME$4);
1393
+ const headers = await context.createHeaders(OPERATION_NAME$3);
1444
1394
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
1445
1395
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1446
1396
  const response = await sendRequest(context, request, 200);
@@ -1449,43 +1399,11 @@ function listNotificationHubJobs(context, options = {}) {
1449
1399
  }
1450
1400
 
1451
1401
  // 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() {
1402
+ function listRegistrationsAll(context, options) {
1403
+ return tslib.__asyncGenerator(this, arguments, function* listRegistrationsAll_1() {
1486
1404
  var e_1, _a;
1487
1405
  try {
1488
- for (var _b = tslib.__asyncValues(listRegistrationsByTagPagingPage(context, tag, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
1406
+ for (var _b = tslib.__asyncValues(listRegistrationPagingPage(context, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
1489
1407
  const page = _c.value;
1490
1408
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
1491
1409
  }
@@ -1499,28 +1417,31 @@ function listRegistrationsByTagAll(context, tag, options) {
1499
1417
  }
1500
1418
  });
1501
1419
  }
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));
1420
+ function listRegistrationPagingPage(context, options) {
1421
+ return tslib.__asyncGenerator(this, arguments, function* listRegistrationPagingPage_1() {
1422
+ let result = yield tslib.__await(_listRegistrations(context, options));
1505
1423
  yield yield tslib.__await(result.registrations || []);
1506
1424
  let continuationToken = result.continuationToken;
1507
1425
  while (continuationToken) {
1508
- result = yield tslib.__await(_listRegistrationsByTag(context, tag, options, continuationToken));
1426
+ result = yield tslib.__await(_listRegistrations(context, options, continuationToken));
1509
1427
  continuationToken = result.continuationToken;
1510
1428
  yield yield tslib.__await(result.registrations || []);
1511
1429
  }
1512
1430
  });
1513
1431
  }
1514
- async function _listRegistrationsByTag(context, tag, options, continuationToken) {
1432
+ async function _listRegistrations(context, options, continuationToken) {
1515
1433
  const endpoint = context.requestUrl();
1516
- endpoint.pathname += `/tags/${tag}/registrations`;
1434
+ endpoint.pathname += "/registrations";
1517
1435
  if (options.top !== undefined) {
1518
1436
  endpoint.searchParams.set("$top", `${options.top}`);
1519
1437
  }
1438
+ if (options.filter !== undefined) {
1439
+ endpoint.searchParams.set("$filter", options.filter);
1440
+ }
1520
1441
  if (continuationToken !== undefined) {
1521
1442
  endpoint.searchParams.set("continuationtoken", continuationToken);
1522
1443
  }
1523
- const headers = await context.createHeaders(OPERATION_NAME$3);
1444
+ const headers = await context.createHeaders("listRegistrations");
1524
1445
  const request = createRequest(endpoint, "GET", headers, options);
1525
1446
  const response = await sendRequest(context, request, 200);
1526
1447
  const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
@@ -1532,15 +1453,14 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
1532
1453
  }
1533
1454
 
1534
1455
  // Copyright (c) Microsoft Corporation.
1535
- const OPERATION_NAME$2 = "listRegistrations";
1536
1456
  /**
1537
1457
  * Gets all registrations for the notification hub with the given query options.
1538
1458
  * @param context - The Notification Hubs client.
1539
- * @param options - The options for querying the registrations such as $top and $filter.
1459
+ * @param options - The options for querying the registrations such as $top.
1540
1460
  * @returns A paged async iterable containing all of the registrations for the notification hub.
1541
1461
  */
1542
1462
  function listRegistrations(context, options = {}) {
1543
- const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext.${OPERATION_NAME$2}`, options);
1463
+ const { span, updatedOptions } = tracingClient.startSpan("NotificationHubsClientContext.listRegistrations", options);
1544
1464
  try {
1545
1465
  const iter = listRegistrationsAll(context, updatedOptions);
1546
1466
  return {
@@ -1551,7 +1471,7 @@ function listRegistrations(context, options = {}) {
1551
1471
  return this;
1552
1472
  },
1553
1473
  byPage: () => {
1554
- return listRegistrationPagingPage(context, options);
1474
+ return listRegistrationPagingPage(context, updatedOptions);
1555
1475
  },
1556
1476
  };
1557
1477
  }
@@ -1563,11 +1483,99 @@ function listRegistrations(context, options = {}) {
1563
1483
  span.end();
1564
1484
  }
1565
1485
  }
1566
- function listRegistrationsAll(context, options) {
1567
- return tslib.__asyncGenerator(this, arguments, function* listRegistrationsAll_1() {
1486
+
1487
+ // Copyright (c) Microsoft Corporation.
1488
+ /**
1489
+ * Gets all registrations for the notification hub with the given device information and options.
1490
+ * @param context - The Notification Hubs client.
1491
+ * @param channel - The Registration channel information to query per PNS type.
1492
+ * @param options - The options for querying the registrations such as $top.
1493
+ * @returns A paged async iterable containing all of the registrations for the notification hub.
1494
+ */
1495
+ function listRegistrationsByChannel(context, channel, options = {}) {
1496
+ const newOptions = Object.assign(Object.assign({}, options), { filter: getFilterByChannel(channel) });
1497
+ const { span, updatedOptions } = tracingClient.startSpan("NotificationHubsClientContext.listRegistrationsByDevice", newOptions);
1498
+ try {
1499
+ const iter = listRegistrationsAll(context, updatedOptions);
1500
+ return {
1501
+ next() {
1502
+ return iter.next();
1503
+ },
1504
+ [Symbol.asyncIterator]() {
1505
+ return this;
1506
+ },
1507
+ byPage: () => {
1508
+ return listRegistrationPagingPage(context, updatedOptions);
1509
+ },
1510
+ };
1511
+ }
1512
+ catch (e) {
1513
+ span.setStatus({ status: "error", error: e });
1514
+ throw e;
1515
+ }
1516
+ finally {
1517
+ span.end();
1518
+ }
1519
+ }
1520
+ function getFilterByChannel(device) {
1521
+ switch (device.kind) {
1522
+ case "adm":
1523
+ return `AdmRegistrationId eq '${device.admRegistrationId}'`;
1524
+ case "apple":
1525
+ return `DeviceToken eq '${device.deviceToken.toLocaleUpperCase()}'`;
1526
+ case "baidu":
1527
+ return `BaiduChannelId eq ${device.baiduChannelId}' and BaiduUserId eq '${device.baiduUserId}'`;
1528
+ case "browser":
1529
+ return `Endpoint eq '${encodeURIComponent(device.endpoint)}' and P256DH eq '${device.p256dh}' and Auth eq '${device.auth}'`;
1530
+ case "gcm":
1531
+ return `GcmRegistrationId eq '${device.gcmRegistrationId}'`;
1532
+ case "windows":
1533
+ return `ChannelUri eq '${encodeURIComponent(device.channelUri)}'`;
1534
+ default:
1535
+ throw new coreRestPipeline.RestError(`Device type is unsupported`, {
1536
+ statusCode: 400,
1537
+ });
1538
+ }
1539
+ }
1540
+
1541
+ // Copyright (c) Microsoft Corporation.
1542
+ const OPERATION_NAME$2 = "listRegistrationsByTag";
1543
+ /**
1544
+ * Lists all registrations with the matching tag.
1545
+ * @param context - The Notification Hubs client.
1546
+ * @param tag - The tag to query for matching registrations.
1547
+ * @param options - The query options such as $top.
1548
+ * @returns A paged async iterable containing the matching registrations for the notification hub.
1549
+ */
1550
+ function listRegistrationsByTag(context, tag, options = {}) {
1551
+ const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext.${OPERATION_NAME$2}`, options);
1552
+ try {
1553
+ const iter = listRegistrationsByTagAll(context, tag, updatedOptions);
1554
+ return {
1555
+ next() {
1556
+ return iter.next();
1557
+ },
1558
+ [Symbol.asyncIterator]() {
1559
+ return this;
1560
+ },
1561
+ byPage: () => {
1562
+ return listRegistrationsByTagPagingPage(context, tag, options);
1563
+ },
1564
+ };
1565
+ }
1566
+ catch (e) {
1567
+ span.setStatus({ status: "error", error: e });
1568
+ throw e;
1569
+ }
1570
+ finally {
1571
+ span.end();
1572
+ }
1573
+ }
1574
+ function listRegistrationsByTagAll(context, tag, options) {
1575
+ return tslib.__asyncGenerator(this, arguments, function* listRegistrationsByTagAll_1() {
1568
1576
  var e_1, _a;
1569
1577
  try {
1570
- for (var _b = tslib.__asyncValues(listRegistrationPagingPage(context, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
1578
+ for (var _b = tslib.__asyncValues(listRegistrationsByTagPagingPage(context, tag, options)), _c; _c = yield tslib.__await(_b.next()), !_c.done;) {
1571
1579
  const page = _c.value;
1572
1580
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
1573
1581
  }
@@ -1581,27 +1589,24 @@ function listRegistrationsAll(context, options) {
1581
1589
  }
1582
1590
  });
1583
1591
  }
1584
- function listRegistrationPagingPage(context, options) {
1585
- return tslib.__asyncGenerator(this, arguments, function* listRegistrationPagingPage_1() {
1586
- let result = yield tslib.__await(_listRegistrations(context, options));
1592
+ function listRegistrationsByTagPagingPage(context, tag, options) {
1593
+ return tslib.__asyncGenerator(this, arguments, function* listRegistrationsByTagPagingPage_1() {
1594
+ let result = yield tslib.__await(_listRegistrationsByTag(context, tag, options));
1587
1595
  yield yield tslib.__await(result.registrations || []);
1588
1596
  let continuationToken = result.continuationToken;
1589
1597
  while (continuationToken) {
1590
- result = yield tslib.__await(_listRegistrations(context, options, continuationToken));
1598
+ result = yield tslib.__await(_listRegistrationsByTag(context, tag, options, continuationToken));
1591
1599
  continuationToken = result.continuationToken;
1592
1600
  yield yield tslib.__await(result.registrations || []);
1593
1601
  }
1594
1602
  });
1595
1603
  }
1596
- async function _listRegistrations(context, options, continuationToken) {
1604
+ async function _listRegistrationsByTag(context, tag, options, continuationToken) {
1597
1605
  const endpoint = context.requestUrl();
1598
- endpoint.pathname += "/registrations";
1606
+ endpoint.pathname += `/tags/${tag}/registrations`;
1599
1607
  if (options.top !== undefined) {
1600
1608
  endpoint.searchParams.set("$top", `${options.top}`);
1601
1609
  }
1602
- if (options.filter !== undefined) {
1603
- endpoint.searchParams.set("$filter", options.filter);
1604
- }
1605
1610
  if (continuationToken !== undefined) {
1606
1611
  endpoint.searchParams.set("continuationtoken", continuationToken);
1607
1612
  }
@@ -1616,31 +1621,6 @@ async function _listRegistrations(context, options, continuationToken) {
1616
1621
  };
1617
1622
  }
1618
1623
 
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
1624
  // Copyright (c) Microsoft Corporation.
1645
1625
  /**
1646
1626
  * Schedules a push notification to devices that match the given tags or tag expression at the specified time.
@@ -1659,8 +1639,8 @@ function scheduleNotification(context, scheduledTime, notification, options = {}
1659
1639
  headers.set("ServiceBusNotification-ScheduleTime", scheduledTime.toISOString());
1660
1640
  headers.set("Content-Type", notification.contentType);
1661
1641
  headers.set("ServiceBusNotification-Format", notification.platform);
1662
- if (options.tags) {
1663
- headers.set("ServiceBusNotification-Tags", normalizeTags(options.tags));
1642
+ if (options.tagExpression) {
1643
+ headers.set("ServiceBusNotification-Tags", options.tagExpression);
1664
1644
  }
1665
1645
  const request = createRequest(endpoint, "POST", headers, updatedOptions);
1666
1646
  request.body = notification.body;
@@ -1687,6 +1667,25 @@ function isDirectSendNotificationOptions(options) {
1687
1667
  return coreUtil.objectHasProperty(options, "deviceHandle");
1688
1668
  }
1689
1669
 
1670
+ // Copyright (c) Microsoft Corporation.
1671
+ // Licensed under the MIT license.
1672
+ /**
1673
+ * @internal
1674
+ */
1675
+ function createMultipartDirectNotification(boundaryName, notification, deviceHandles) {
1676
+ return (`--${boundaryName}\r\n` +
1677
+ `Content-type: ${notification.contentType}\r\n` +
1678
+ "Content-Disposition: inline; name=notification\r\n\r\n" +
1679
+ notification.body +
1680
+ "\r\n" +
1681
+ `--${boundaryName}\r\n` +
1682
+ "Content-type: application/json\r\n" +
1683
+ "Content-Disposition: inline; name=devices\r\n\r\n" +
1684
+ JSON.stringify(deviceHandles) +
1685
+ "\r\n" +
1686
+ `--${boundaryName}--`);
1687
+ }
1688
+
1690
1689
  // Copyright (c) Microsoft Corporation.
1691
1690
  /**
1692
1691
  * Sends push notifications to devices that match the given tags or tag expression.
@@ -1731,8 +1730,8 @@ function sendNotification(context, notification, options = { enableTestSend: fal
1731
1730
  }
1732
1731
  }
1733
1732
  else if (isSendNotificationOptions(options)) {
1734
- if (options.tags) {
1735
- headers.set("ServiceBusNotification-Tags", normalizeTags(options.tags));
1733
+ if (options.tagExpression) {
1734
+ headers.set("ServiceBusNotification-Tags", options.tagExpression);
1736
1735
  }
1737
1736
  }
1738
1737
  headers.set("Content-Type", contentType);
@@ -1785,12 +1784,54 @@ function updateRegistration(context, registration, options = {}) {
1785
1784
  });
1786
1785
  }
1787
1786
 
1787
+ // Copyright (c) Microsoft Corporation.
1788
+ const API_VERSION = "2020-06";
1789
+ /**
1790
+ * Creates a NotificationHubClient from the Access Policy connection string and hub name.
1791
+ * @param connectionString - The Access Policy connection string for the notification hub.
1792
+ * @param hubName - The notification hub name.
1793
+ * @returns A NotificationHubsClientContext initialized from the connection string and hub name.
1794
+ */
1795
+ function createClientContext(connectionString, hubName, options = {}) {
1796
+ return new NotificationHubsServiceClient(connectionString, hubName, options);
1797
+ }
1798
+ class NotificationHubsServiceClient extends coreClient.ServiceClient {
1799
+ constructor(connectionString, hubName, options = {}) {
1800
+ super(Object.assign({ deserializationOptions: {
1801
+ parseXML: coreXml.parseXML,
1802
+ }, serializationOptions: {
1803
+ stringifyXML: coreXml.stringifyXML,
1804
+ }, userAgentOptions: {
1805
+ userAgentPrefix: `azsdk-js-messaging-notificationhubs/${SDK_VERSION}`,
1806
+ } }, options));
1807
+ this.hubName = hubName;
1808
+ const parsedConnection = parseNotificationHubsConnectionString(connectionString);
1809
+ this.baseUrl = parsedConnection.endpoint;
1810
+ this.sasTokenProvider = createTokenProviderFromConnection(parsedConnection.sharedAccessKey, parsedConnection.sharedAccessKeyName);
1811
+ }
1812
+ async createHeaders(operationName, rawHeaders) {
1813
+ const authorization = await this.sasTokenProvider.getToken(this.baseUrl);
1814
+ const headers = coreRestPipeline.createHttpHeaders(rawHeaders);
1815
+ headers.set("Authorization", authorization.token);
1816
+ headers.set("x-ms-version", API_VERSION);
1817
+ headers.set("x-ms-azsdk-telemetry", `class=NotificationHubsServiceClient;method=${operationName}`);
1818
+ return headers;
1819
+ }
1820
+ requestUrl() {
1821
+ // Node doesn't allow change in protocol but browsers do, so doing a string replace
1822
+ const url = new URL(this.baseUrl.replace("sb://", "https://"));
1823
+ url.pathname = this.hubName;
1824
+ url.searchParams.set("api-version", API_VERSION);
1825
+ return url;
1826
+ }
1827
+ }
1828
+
1788
1829
  // Copyright (c) Microsoft Corporation.
1789
1830
  /**
1790
1831
  * This represents a client for Azure Notification Hubs to manage installations and send
1791
1832
  * messages to devices.
1792
1833
  */
1793
- class NotificationHubsServiceClient {
1834
+ class NotificationHubsClient {
1794
1835
  /**
1795
1836
  * Creates a new instance of the NotificationClient with a connection string, hub name and options.
1796
1837
  * @param connectionString - The Notification Hub Access Policy connection string.
@@ -1894,12 +1935,21 @@ class NotificationHubsServiceClient {
1894
1935
  }
1895
1936
  /**
1896
1937
  * 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.
1938
+ * @param options - The options for querying the registrations such as $top.
1898
1939
  * @returns A paged async iterable containing all of the registrations for the notification hub.
1899
1940
  */
1900
1941
  listRegistrations(options = {}) {
1901
1942
  return listRegistrations(this._client, options);
1902
1943
  }
1944
+ /**
1945
+ * Gets all registrations for the notification hub with the given device information and options.
1946
+ * @param channel - The registration channel information to query per PNS type.
1947
+ * @param options - The options for querying the registrations such as $top.
1948
+ * @returns A paged async iterable containing all of the registrations for the notification hub.
1949
+ */
1950
+ listRegistrationsByChannel(channel, options = {}) {
1951
+ return listRegistrationsByChannel(this._client, channel, options);
1952
+ }
1903
1953
  /**
1904
1954
  * Lists all registrations with the matching tag.
1905
1955
  * @param tag - The tag to query for matching registrations.
@@ -2148,168 +2198,49 @@ function createWindowsRawNotification(notification) {
2148
2198
  }
2149
2199
 
2150
2200
  // 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
2201
  /**
2173
2202
  * Creates an APNs native message to send to Notification Hubs.
2174
2203
  * @param nativeMessage - The Apple native message properties to set.
2175
2204
  * @param additionalProperties - Additional properties for Apple messages.
2176
2205
  * @returns An AppleNotification to send to Notification Hubs.
2177
2206
  */
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;
2207
+ function createAppleNotificationBody(nativeMessage) {
2208
+ return JSON.stringify(nativeMessage);
2225
2209
  }
2226
2210
  /**
2227
2211
  * Creates a FcmLegacyNotification from a native Firebase payload.
2228
2212
  * @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
- };
2213
+ * @returns The JSON body to send to Notification Hubs.
2214
+ */
2215
+ function createFirebaseLegacyNotificationBody(nativeMessage) {
2216
+ return JSON.stringify(nativeMessage);
2277
2217
  }
2278
2218
  /**
2279
2219
  * Creates a AdmNotification from a native ADM payload.
2280
2220
  * @param nativeMessage - The native message payload to send to Notification Hubs.
2281
2221
  * @returns The AdmNotification to send to Notification Hubs.
2282
2222
  */
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
- });
2223
+ function createAdmNotificationBody(nativeMessage) {
2224
+ return JSON.stringify(nativeMessage);
2288
2225
  }
2289
2226
  /**
2290
2227
  * Creates a BaiduNotification from a native Baidu payload.
2291
2228
  * @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.
2229
+ * @returns The JSON body to send to Notification Hubs.
2294
2230
  */
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
- });
2231
+ function createBaiduNotificationBody(nativeMessage) {
2232
+ return JSON.stringify(nativeMessage);
2300
2233
  }
2301
2234
  /**
2302
2235
  * Builds a WindowsNotification from a Windows Badge.
2303
2236
  * @param nativeMessage - The Windows Badge Message to build.
2304
- * @returns A WindowsNotification created with the badge information.
2237
+ * @returns The WNS XML created with the badge information.
2305
2238
  */
2306
- function buildWindowsBadgeNativeMessage(nativeMessage) {
2239
+ function createWindowsBadgeNotificationBody(nativeMessage) {
2307
2240
  const badge = {
2308
2241
  $: { value: nativeMessage.value },
2309
2242
  };
2310
- return createWindowsBadgeNotification({
2311
- body: coreXml.stringifyXML(badge, { rootName: "badge" }),
2312
- });
2243
+ return coreXml.stringifyXML(badge, { rootName: "badge" });
2313
2244
  }
2314
2245
 
2315
2246
  // Copyright (c) Microsoft Corporation.
@@ -2320,7 +2251,7 @@ function buildWindowsBadgeNativeMessage(nativeMessage) {
2320
2251
  * @returns A created ADM registration description.
2321
2252
  */
2322
2253
  function createAdmRegistrationDescription(description) {
2323
- return Object.assign(Object.assign({}, description), { type: "Adm" });
2254
+ return Object.assign(Object.assign({}, description), { kind: "Adm" });
2324
2255
  }
2325
2256
  /**
2326
2257
  * Creates an ADM template registration description.
@@ -2328,7 +2259,7 @@ function createAdmRegistrationDescription(description) {
2328
2259
  * @returns A created ADM template registration description.
2329
2260
  */
2330
2261
  function createAdmTemplateRegistrationDescription(description) {
2331
- return Object.assign(Object.assign({}, description), { type: "AdmTemplate" });
2262
+ return Object.assign(Object.assign({}, description), { kind: "AdmTemplate" });
2332
2263
  }
2333
2264
  /**
2334
2265
  * Creates an Apple registration description.
@@ -2336,7 +2267,7 @@ function createAdmTemplateRegistrationDescription(description) {
2336
2267
  * @returns A created Apple registration description.
2337
2268
  */
2338
2269
  function createAppleRegistrationDescription(description) {
2339
- return Object.assign(Object.assign({}, description), { type: "Apple" });
2270
+ return Object.assign(Object.assign({}, description), { kind: "Apple" });
2340
2271
  }
2341
2272
  /**
2342
2273
  * Creates an Apple template registration description.
@@ -2344,7 +2275,7 @@ function createAppleRegistrationDescription(description) {
2344
2275
  * @returns A created Apple template registration description.
2345
2276
  */
2346
2277
  function createAppleTemplateRegistrationDescription(description) {
2347
- return Object.assign(Object.assign({}, description), { type: "AppleTemplate" });
2278
+ return Object.assign(Object.assign({}, description), { kind: "AppleTemplate" });
2348
2279
  }
2349
2280
  /**
2350
2281
  * Creates a Baidu registration description.
@@ -2352,7 +2283,7 @@ function createAppleTemplateRegistrationDescription(description) {
2352
2283
  * @returns A created Baidu registration description.
2353
2284
  */
2354
2285
  function createBaiduRegistrationDescription(description) {
2355
- return Object.assign(Object.assign({}, description), { type: "Baidu" });
2286
+ return Object.assign(Object.assign({}, description), { kind: "Baidu" });
2356
2287
  }
2357
2288
  /**
2358
2289
  * Creates a Baidu template registration description.
@@ -2360,7 +2291,7 @@ function createBaiduRegistrationDescription(description) {
2360
2291
  * @returns A created Baidu template registration description.
2361
2292
  */
2362
2293
  function createBaiduTemplateRegistrationDescription(description) {
2363
- return Object.assign(Object.assign({}, description), { type: "BaiduTemplate" });
2294
+ return Object.assign(Object.assign({}, description), { kind: "BaiduTemplate" });
2364
2295
  }
2365
2296
  /**
2366
2297
  * Creates a Web Push registration description.
@@ -2368,7 +2299,7 @@ function createBaiduTemplateRegistrationDescription(description) {
2368
2299
  * @returns A created Web Push registration description.
2369
2300
  */
2370
2301
  function createBrowserRegistrationDescription(description) {
2371
- return Object.assign(Object.assign({}, description), { type: "Browser" });
2302
+ return Object.assign(Object.assign({}, description), { kind: "Browser" });
2372
2303
  }
2373
2304
  /**
2374
2305
  * Creates a Web Push registration description.
@@ -2376,7 +2307,7 @@ function createBrowserRegistrationDescription(description) {
2376
2307
  * @returns A created Web Push template registration description.
2377
2308
  */
2378
2309
  function createBrowserTemplateRegistrationDescription(description) {
2379
- return Object.assign(Object.assign({}, description), { type: "BrowserTemplate" });
2310
+ return Object.assign(Object.assign({}, description), { kind: "BrowserTemplate" });
2380
2311
  }
2381
2312
  /**
2382
2313
  * Creates a Firebase Legacy registration description.
@@ -2384,7 +2315,7 @@ function createBrowserTemplateRegistrationDescription(description) {
2384
2315
  * @returns A created GCM registration description.
2385
2316
  */
2386
2317
  function createFcmLegacyRegistrationDescription(description) {
2387
- return Object.assign(Object.assign({}, description), { type: "Gcm" });
2318
+ return Object.assign(Object.assign({}, description), { kind: "Gcm" });
2388
2319
  }
2389
2320
  /**
2390
2321
  * Creates a GCM template registration description.
@@ -2392,7 +2323,7 @@ function createFcmLegacyRegistrationDescription(description) {
2392
2323
  * @returns A created GCM template registration description.
2393
2324
  */
2394
2325
  function createFcmLegacyTemplateRegistrationDescription(description) {
2395
- return Object.assign(Object.assign({}, description), { type: "GcmTemplate" });
2326
+ return Object.assign(Object.assign({}, description), { kind: "GcmTemplate" });
2396
2327
  }
2397
2328
  /**
2398
2329
  * Creates a Windows registration description.
@@ -2400,7 +2331,7 @@ function createFcmLegacyTemplateRegistrationDescription(description) {
2400
2331
  * @returns A created Windows registration description.
2401
2332
  */
2402
2333
  function createWindowsRegistrationDescription(description) {
2403
- return Object.assign(Object.assign({}, description), { type: "Windows" });
2334
+ return Object.assign(Object.assign({}, description), { kind: "Windows" });
2404
2335
  }
2405
2336
  /**
2406
2337
  * Creates a Windows template registration description.
@@ -2408,25 +2339,34 @@ function createWindowsRegistrationDescription(description) {
2408
2339
  * @returns A created Windows template registration description.
2409
2340
  */
2410
2341
  function createWindowsTemplateRegistrationDescription(description) {
2411
- return Object.assign(Object.assign({}, description), { type: "WindowsTemplate" });
2342
+ return Object.assign(Object.assign({}, description), { kind: "WindowsTemplate" });
2343
+ }
2344
+
2345
+ // Copyright (c) Microsoft Corporation.
2346
+ // Licensed under the MIT license.
2347
+ /**
2348
+ * Creates a tag expression from a list of tags as a || expression.
2349
+ * @param tags - The tags to create the || expression
2350
+ * @returns The tag expression made from the array of strings into an || expression.
2351
+ */
2352
+ function createTagExpression(tags) {
2353
+ return tags.join("||");
2412
2354
  }
2413
2355
 
2414
- exports.NotificationHubsServiceClient = NotificationHubsServiceClient;
2415
- exports.buildAdmNativeMessage = buildAdmNativeMessage;
2416
- exports.buildAppleNativeMessage = buildAppleNativeMessage;
2417
- exports.buildBaiduNativeMessage = buildBaiduNativeMessage;
2418
- exports.buildFirebaseLegacyNativeMessage = buildFirebaseLegacyNativeMessage;
2419
- exports.buildWindowsBadgeNativeMessage = buildWindowsBadgeNativeMessage;
2356
+ exports.NotificationHubsClient = NotificationHubsClient;
2420
2357
  exports.createAdmInstallation = createAdmInstallation;
2421
2358
  exports.createAdmNotification = createAdmNotification;
2359
+ exports.createAdmNotificationBody = createAdmNotificationBody;
2422
2360
  exports.createAdmRegistrationDescription = createAdmRegistrationDescription;
2423
2361
  exports.createAdmTemplateRegistrationDescription = createAdmTemplateRegistrationDescription;
2424
2362
  exports.createAppleInstallation = createAppleInstallation;
2425
2363
  exports.createAppleNotification = createAppleNotification;
2364
+ exports.createAppleNotificationBody = createAppleNotificationBody;
2426
2365
  exports.createAppleRegistrationDescription = createAppleRegistrationDescription;
2427
2366
  exports.createAppleTemplateRegistrationDescription = createAppleTemplateRegistrationDescription;
2428
2367
  exports.createBaiduInstallation = createBaiduInstallation;
2429
2368
  exports.createBaiduNotification = createBaiduNotification;
2369
+ exports.createBaiduNotificationBody = createBaiduNotificationBody;
2430
2370
  exports.createBaiduRegistrationDescription = createBaiduRegistrationDescription;
2431
2371
  exports.createBaiduTemplateRegistrationDescription = createBaiduTemplateRegistrationDescription;
2432
2372
  exports.createBrowserInstallation = createBrowserInstallation;
@@ -2437,8 +2377,11 @@ exports.createFcmLegacyInstallation = createFcmLegacyInstallation;
2437
2377
  exports.createFcmLegacyNotification = createFcmLegacyNotification;
2438
2378
  exports.createFcmLegacyRegistrationDescription = createFcmLegacyRegistrationDescription;
2439
2379
  exports.createFcmLegacyTemplateRegistrationDescription = createFcmLegacyTemplateRegistrationDescription;
2380
+ exports.createFirebaseLegacyNotificationBody = createFirebaseLegacyNotificationBody;
2381
+ exports.createTagExpression = createTagExpression;
2440
2382
  exports.createTemplateNotification = createTemplateNotification;
2441
2383
  exports.createWindowsBadgeNotification = createWindowsBadgeNotification;
2384
+ exports.createWindowsBadgeNotificationBody = createWindowsBadgeNotificationBody;
2442
2385
  exports.createWindowsInstallation = createWindowsInstallation;
2443
2386
  exports.createWindowsRawNotification = createWindowsRawNotification;
2444
2387
  exports.createWindowsRegistrationDescription = createWindowsRegistrationDescription;