@azure/notification-hubs 1.0.0-beta.5 → 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 (245) hide show
  1. package/README.md +104 -113
  2. package/dist/index.cjs +625 -602
  3. package/dist/index.cjs.map +1 -1
  4. package/dist-esm/src/api/beginSubmitNotificationHubJob.js +131 -0
  5. package/dist-esm/src/api/beginSubmitNotificationHubJob.js.map +1 -0
  6. package/dist-esm/src/{client → api}/cancelScheduledNotification.js +1 -1
  7. package/dist-esm/src/api/cancelScheduledNotification.js.map +1 -0
  8. package/dist-esm/src/{client → api}/createOrUpdateInstallation.js +1 -1
  9. package/dist-esm/src/api/createOrUpdateInstallation.js.map +1 -0
  10. package/dist-esm/src/{client → api}/createOrUpdateRegistration.js +1 -1
  11. package/dist-esm/src/api/createOrUpdateRegistration.js.map +1 -0
  12. package/dist-esm/src/{client → api}/createRegistration.js +1 -1
  13. package/dist-esm/src/api/createRegistration.js.map +1 -0
  14. package/dist-esm/src/{client → api}/createRegistrationId.js +1 -1
  15. package/dist-esm/src/api/createRegistrationId.js.map +1 -0
  16. package/dist-esm/src/{client → api}/deleteInstallation.js +1 -1
  17. package/dist-esm/src/api/deleteInstallation.js.map +1 -0
  18. package/dist-esm/src/{client → api}/deleteRegistration.js +1 -1
  19. package/dist-esm/src/api/deleteRegistration.js.map +1 -0
  20. package/dist-esm/src/{client → api}/getFeedbackContainerUrl.js +1 -1
  21. package/dist-esm/src/api/getFeedbackContainerUrl.js.map +1 -0
  22. package/dist-esm/src/{client → api}/getInstallation.js +1 -1
  23. package/dist-esm/src/api/getInstallation.js.map +1 -0
  24. package/dist-esm/src/{client → api}/getNotificationHubJob.js +1 -1
  25. package/dist-esm/src/api/getNotificationHubJob.js.map +1 -0
  26. package/dist-esm/src/{client → api}/getNotificationOutcomeDetails.js +1 -1
  27. package/dist-esm/src/api/getNotificationOutcomeDetails.js.map +1 -0
  28. package/dist-esm/src/{client → api}/getRegistration.js +1 -1
  29. package/dist-esm/src/api/getRegistration.js.map +1 -0
  30. package/dist-esm/src/{client → api}/index.js +24 -2
  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 +1 -1
  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 +1 -1
  45. package/dist-esm/src/api/listRegistrationsByTag.js.map +1 -0
  46. package/dist-esm/src/api/scheduleNotification.js +31 -0
  47. package/dist-esm/src/api/scheduleNotification.js.map +1 -0
  48. package/dist-esm/src/api/sendNotification.js +63 -0
  49. package/dist-esm/src/api/sendNotification.js.map +1 -0
  50. package/dist-esm/src/{client → api}/submitNotificationHubJob.js +1 -1
  51. package/dist-esm/src/api/submitNotificationHubJob.js.map +1 -0
  52. package/dist-esm/src/{client → api}/updateInstallation.js +1 -1
  53. package/dist-esm/src/api/updateInstallation.js.map +1 -0
  54. package/dist-esm/src/{client → api}/updateRegistration.js +1 -1
  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/notificationHubJob.js.map +1 -1
  66. package/dist-esm/src/models/options.js.map +1 -1
  67. package/dist-esm/src/models/registration.js +12 -12
  68. package/dist-esm/src/models/registration.js.map +1 -1
  69. package/dist-esm/src/models/tagExpressionBuilder.js +11 -0
  70. package/dist-esm/src/models/tagExpressionBuilder.js.map +1 -0
  71. package/dist-esm/src/notificationHubsClient.js +49 -68
  72. package/dist-esm/src/notificationHubsClient.js.map +1 -1
  73. package/dist-esm/src/serializers/notificationDetailsSerializer.js +2 -1
  74. package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -1
  75. package/dist-esm/src/serializers/notificationHubJobSerializer.js +3 -1
  76. package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -1
  77. package/dist-esm/src/serializers/notificationOutcomeSerializer.js +2 -2
  78. package/dist-esm/src/serializers/notificationOutcomeSerializer.js.map +1 -1
  79. package/dist-esm/src/serializers/registrationSerializer.js +16 -16
  80. package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
  81. package/dist-esm/src/utils/constants.js +1 -1
  82. package/dist-esm/src/utils/constants.js.map +1 -1
  83. package/dist-esm/src/utils/notificationUtils.js +19 -0
  84. package/dist-esm/src/utils/notificationUtils.js.map +1 -0
  85. package/dist-esm/src/utils/optionUtils.js +20 -0
  86. package/dist-esm/src/utils/optionUtils.js.map +1 -0
  87. package/package.json +14 -17
  88. package/types/3.1/notification-hubs.d.ts +468 -281
  89. package/types/latest/notification-hubs.d.ts +500 -286
  90. package/types/latest/tsdoc-metadata.json +1 -1
  91. package/types/src/api/beginSubmitNotificationHubJob.d.ts +12 -0
  92. package/types/src/api/beginSubmitNotificationHubJob.d.ts.map +1 -0
  93. package/types/src/{client → api}/cancelScheduledNotification.d.ts +0 -0
  94. package/types/src/api/cancelScheduledNotification.d.ts.map +1 -0
  95. package/types/src/{client → api}/createOrUpdateInstallation.d.ts +0 -0
  96. package/types/src/api/createOrUpdateInstallation.d.ts.map +1 -0
  97. package/types/src/{client → api}/createOrUpdateRegistration.d.ts +0 -0
  98. package/types/src/api/createOrUpdateRegistration.d.ts.map +1 -0
  99. package/types/src/{client → api}/createRegistration.d.ts +0 -0
  100. package/types/src/api/createRegistration.d.ts.map +1 -0
  101. package/types/src/{client → api}/createRegistrationId.d.ts +0 -0
  102. package/types/src/api/createRegistrationId.d.ts.map +1 -0
  103. package/types/src/{client → api}/deleteInstallation.d.ts +0 -0
  104. package/types/src/api/deleteInstallation.d.ts.map +1 -0
  105. package/types/src/{client → api}/deleteRegistration.d.ts +0 -0
  106. package/types/src/api/deleteRegistration.d.ts.map +1 -0
  107. package/types/src/{client → api}/getFeedbackContainerUrl.d.ts +0 -0
  108. package/types/src/api/getFeedbackContainerUrl.d.ts.map +1 -0
  109. package/types/src/{client → api}/getInstallation.d.ts +0 -0
  110. package/types/src/api/getInstallation.d.ts.map +1 -0
  111. package/types/src/{client → api}/getNotificationHubJob.d.ts +0 -0
  112. package/types/src/api/getNotificationHubJob.d.ts.map +1 -0
  113. package/types/src/{client → api}/getNotificationOutcomeDetails.d.ts +0 -0
  114. package/types/src/api/getNotificationOutcomeDetails.d.ts.map +1 -0
  115. package/types/src/{client → api}/getRegistration.d.ts +0 -0
  116. package/types/src/api/getRegistration.d.ts.map +1 -0
  117. package/types/src/{client → api}/index.d.ts +23 -1
  118. package/types/src/api/index.d.ts.map +1 -0
  119. package/types/src/{client → api}/internal/_client.d.ts +0 -0
  120. package/types/src/api/internal/_client.d.ts.map +1 -0
  121. package/types/src/{client → api}/internal/_createOrUpdateRegistrationDescription.d.ts +0 -0
  122. package/types/src/api/internal/_createOrUpdateRegistrationDescription.d.ts.map +1 -0
  123. package/types/src/api/internal/_listRegistrations.d.ts +6 -0
  124. package/types/src/api/internal/_listRegistrations.d.ts.map +1 -0
  125. package/types/src/{client → api}/listNotificationHubJobs.d.ts +0 -0
  126. package/types/src/api/listNotificationHubJobs.d.ts.map +1 -0
  127. package/types/src/{client → api}/listRegistrations.d.ts +3 -3
  128. package/types/src/api/listRegistrations.d.ts.map +1 -0
  129. package/types/src/api/listRegistrationsByChannel.d.ts +13 -0
  130. package/types/src/api/listRegistrationsByChannel.d.ts.map +1 -0
  131. package/types/src/{client → api}/listRegistrationsByTag.d.ts +0 -0
  132. package/types/src/api/listRegistrationsByTag.d.ts.map +1 -0
  133. package/types/src/{client → api}/scheduleNotification.d.ts +3 -5
  134. package/types/src/api/scheduleNotification.d.ts.map +1 -0
  135. package/types/src/{client → api}/sendNotification.d.ts +3 -5
  136. package/types/src/api/sendNotification.d.ts.map +1 -0
  137. package/types/src/{client → api}/submitNotificationHubJob.d.ts +0 -0
  138. package/types/src/api/submitNotificationHubJob.d.ts.map +1 -0
  139. package/types/src/{client → api}/updateInstallation.d.ts +0 -0
  140. package/types/src/api/updateInstallation.d.ts.map +1 -0
  141. package/types/src/{client → api}/updateRegistration.d.ts +0 -0
  142. package/types/src/api/updateRegistration.d.ts.map +1 -0
  143. package/types/src/index.d.ts +3 -2
  144. package/types/src/index.d.ts.map +1 -1
  145. package/types/src/models/index.d.ts +10 -0
  146. package/types/src/models/index.d.ts.map +1 -0
  147. package/types/src/models/installation.d.ts +12 -11
  148. package/types/src/models/installation.d.ts.map +1 -1
  149. package/types/src/models/notification.d.ts +10 -18
  150. package/types/src/models/notification.d.ts.map +1 -1
  151. package/types/src/models/{notificationBuilder.d.ts → notificationBodyBuilder.d.ts} +62 -64
  152. package/types/src/models/notificationBodyBuilder.d.ts.map +1 -0
  153. package/types/src/models/notificationDetails.d.ts +9 -9
  154. package/types/src/models/notificationDetails.d.ts.map +1 -1
  155. package/types/src/models/notificationHubJob.d.ts +5 -0
  156. package/types/src/models/notificationHubJob.d.ts.map +1 -1
  157. package/types/src/models/options.d.ts +36 -2
  158. package/types/src/models/options.d.ts.map +1 -1
  159. package/types/src/models/registration.d.ts +235 -69
  160. package/types/src/models/registration.d.ts.map +1 -1
  161. package/types/src/models/tagExpressionBuilder.d.ts +7 -0
  162. package/types/src/models/tagExpressionBuilder.d.ts.map +1 -0
  163. package/types/src/notificationHubsClient.d.ts +25 -41
  164. package/types/src/notificationHubsClient.d.ts.map +1 -1
  165. package/types/src/serializers/registrationSerializer.d.ts +14 -14
  166. package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
  167. package/types/src/utils/notificationUtils.d.ts +6 -0
  168. package/types/src/utils/notificationUtils.d.ts.map +1 -0
  169. package/types/src/utils/optionUtils.d.ts +14 -0
  170. package/types/src/utils/optionUtils.d.ts.map +1 -0
  171. package/dist-esm/src/client/cancelScheduledNotification.js.map +0 -1
  172. package/dist-esm/src/client/createOrUpdateInstallation.js.map +0 -1
  173. package/dist-esm/src/client/createOrUpdateRegistration.js.map +0 -1
  174. package/dist-esm/src/client/createRegistration.js.map +0 -1
  175. package/dist-esm/src/client/createRegistrationId.js.map +0 -1
  176. package/dist-esm/src/client/deleteInstallation.js.map +0 -1
  177. package/dist-esm/src/client/deleteRegistration.js.map +0 -1
  178. package/dist-esm/src/client/getFeedbackContainerUrl.js.map +0 -1
  179. package/dist-esm/src/client/getInstallation.js.map +0 -1
  180. package/dist-esm/src/client/getNotificationHubJob.js.map +0 -1
  181. package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +0 -1
  182. package/dist-esm/src/client/getRegistration.js.map +0 -1
  183. package/dist-esm/src/client/index.js.map +0 -1
  184. package/dist-esm/src/client/internal/_client.js.map +0 -1
  185. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +0 -1
  186. package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +0 -38
  187. package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +0 -1
  188. package/dist-esm/src/client/internal/_sendNotificationPayload.js +0 -51
  189. package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +0 -1
  190. package/dist-esm/src/client/listNotificationHubJobs.js.map +0 -1
  191. package/dist-esm/src/client/listRegistrations.js.map +0 -1
  192. package/dist-esm/src/client/listRegistrationsByTag.js.map +0 -1
  193. package/dist-esm/src/client/scheduleBroadcastNotification.js +0 -17
  194. package/dist-esm/src/client/scheduleBroadcastNotification.js.map +0 -1
  195. package/dist-esm/src/client/scheduleNotification.js +0 -18
  196. package/dist-esm/src/client/scheduleNotification.js.map +0 -1
  197. package/dist-esm/src/client/sendBroadcastNotification.js +0 -15
  198. package/dist-esm/src/client/sendBroadcastNotification.js.map +0 -1
  199. package/dist-esm/src/client/sendDirectNotification.js +0 -15
  200. package/dist-esm/src/client/sendDirectNotification.js.map +0 -1
  201. package/dist-esm/src/client/sendNotification.js +0 -16
  202. package/dist-esm/src/client/sendNotification.js.map +0 -1
  203. package/dist-esm/src/client/submitNotificationHubJob.js.map +0 -1
  204. package/dist-esm/src/client/updateInstallation.js.map +0 -1
  205. package/dist-esm/src/client/updateRegistration.js.map +0 -1
  206. package/dist-esm/src/models/notificationBuilder.js +0 -169
  207. package/dist-esm/src/models/notificationBuilder.js.map +0 -1
  208. package/dist-esm/src/utils/retryPolicy.js +0 -144
  209. package/dist-esm/src/utils/retryPolicy.js.map +0 -1
  210. package/types/src/client/cancelScheduledNotification.d.ts.map +0 -1
  211. package/types/src/client/createOrUpdateInstallation.d.ts.map +0 -1
  212. package/types/src/client/createOrUpdateRegistration.d.ts.map +0 -1
  213. package/types/src/client/createRegistration.d.ts.map +0 -1
  214. package/types/src/client/createRegistrationId.d.ts.map +0 -1
  215. package/types/src/client/deleteInstallation.d.ts.map +0 -1
  216. package/types/src/client/deleteRegistration.d.ts.map +0 -1
  217. package/types/src/client/getFeedbackContainerUrl.d.ts.map +0 -1
  218. package/types/src/client/getInstallation.d.ts.map +0 -1
  219. package/types/src/client/getNotificationHubJob.d.ts.map +0 -1
  220. package/types/src/client/getNotificationOutcomeDetails.d.ts.map +0 -1
  221. package/types/src/client/getRegistration.d.ts.map +0 -1
  222. package/types/src/client/index.d.ts.map +0 -1
  223. package/types/src/client/internal/_client.d.ts.map +0 -1
  224. package/types/src/client/internal/_createOrUpdateRegistrationDescription.d.ts.map +0 -1
  225. package/types/src/client/internal/_scheduleNotificationPayload.d.ts +0 -9
  226. package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +0 -1
  227. package/types/src/client/internal/_sendNotificationPayload.d.ts +0 -10
  228. package/types/src/client/internal/_sendNotificationPayload.d.ts.map +0 -1
  229. package/types/src/client/listNotificationHubJobs.d.ts.map +0 -1
  230. package/types/src/client/listRegistrations.d.ts.map +0 -1
  231. package/types/src/client/listRegistrationsByTag.d.ts.map +0 -1
  232. package/types/src/client/scheduleBroadcastNotification.d.ts +0 -16
  233. package/types/src/client/scheduleBroadcastNotification.d.ts.map +0 -1
  234. package/types/src/client/scheduleNotification.d.ts.map +0 -1
  235. package/types/src/client/sendBroadcastNotification.d.ts +0 -14
  236. package/types/src/client/sendBroadcastNotification.d.ts.map +0 -1
  237. package/types/src/client/sendDirectNotification.d.ts +0 -15
  238. package/types/src/client/sendDirectNotification.d.ts.map +0 -1
  239. package/types/src/client/sendNotification.d.ts.map +0 -1
  240. package/types/src/client/submitNotificationHubJob.d.ts.map +0 -1
  241. package/types/src/client/updateInstallation.d.ts.map +0 -1
  242. package/types/src/client/updateRegistration.d.ts.map +0 -1
  243. package/types/src/models/notificationBuilder.d.ts.map +0 -1
  244. package/types/src/utils/retryPolicy.d.ts +0 -72
  245. package/types/src/utils/retryPolicy.d.ts.map +0 -1
package/dist/index.cjs CHANGED
@@ -6,12 +6,15 @@ var coreRestPipeline = require('@azure/core-rest-pipeline');
6
6
  var crypto = require('crypto');
7
7
  var coreXml = require('@azure/core-xml');
8
8
  var coreClient = require('@azure/core-client');
9
+ var abortController = require('@azure/abort-controller');
9
10
  var coreTracing = require('@azure/core-tracing');
10
11
  var tslib = require('tslib');
12
+ var coreUtil = require('@azure/core-util');
13
+ var uuid = require('uuid');
11
14
 
12
15
  // Copyright (c) Microsoft Corporation.
13
16
  // Licensed under the MIT license.
14
- const SDK_VERSION = "1.0.0-beta.5";
17
+ const SDK_VERSION = "1.0.0-beta.7";
15
18
  const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
16
19
  const XML_CONTENT_TYPE = "application/xml";
17
20
  const STREAM_CONTENT_TYPE = "application/octet-stream";
@@ -154,48 +157,6 @@ function parseNotificationHubsConnectionString(connectionString) {
154
157
  return output;
155
158
  }
156
159
 
157
- // Copyright (c) Microsoft Corporation.
158
- const API_VERSION = "2020-06";
159
- /**
160
- * Creates a NotificationHubClient from the Access Policy connection string and hub name.
161
- * @param connectionString - The Access Policy connection string for the notification hub.
162
- * @param hubName - The notification hub name.
163
- * @returns A NotificationHubsClientContext initialized from the connection string and hub name.
164
- */
165
- function createClientContext(connectionString, hubName, options = {}) {
166
- return new NotificationHubsServiceClient$1(connectionString, hubName, options);
167
- }
168
- class NotificationHubsServiceClient$1 extends coreClient.ServiceClient {
169
- constructor(connectionString, hubName, options = {}) {
170
- super(Object.assign({ deserializationOptions: {
171
- parseXML: coreXml.parseXML,
172
- }, serializationOptions: {
173
- stringifyXML: coreXml.stringifyXML,
174
- }, userAgentOptions: {
175
- userAgentPrefix: `azsdk-js-messaging-notificationhubs/${SDK_VERSION}`,
176
- } }, options));
177
- this.hubName = hubName;
178
- const parsedConnection = parseNotificationHubsConnectionString(connectionString);
179
- this.baseUrl = parsedConnection.endpoint;
180
- this.sasTokenProvider = createTokenProviderFromConnection(parsedConnection.sharedAccessKey, parsedConnection.sharedAccessKeyName);
181
- }
182
- async createHeaders(operationName) {
183
- const authorization = await this.sasTokenProvider.getToken(this.baseUrl);
184
- const headers = coreRestPipeline.createHttpHeaders();
185
- headers.set("Authorization", authorization.token);
186
- headers.set("x-ms-version", API_VERSION);
187
- headers.set("x-ms-azsdk-telemetry", `class=NotificationHubsServiceClient;method=${operationName}`);
188
- return headers;
189
- }
190
- requestUrl() {
191
- // Node doesn't allow change in protocol but browsers do, so doing a string replace
192
- const url = new URL(this.baseUrl.replace("sb://", "https://"));
193
- url.pathname = this.hubName;
194
- url.searchParams.set("api-version", API_VERSION);
195
- return url;
196
- }
197
- }
198
-
199
160
  // Copyright (c) Microsoft Corporation.
200
161
  // Licensed under the MIT license.
201
162
  /**
@@ -206,14 +167,6 @@ class NotificationHubsServiceClient$1 extends coreClient.ServiceClient {
206
167
  function isDefined(thing) {
207
168
  return typeof thing !== "undefined" && thing !== null;
208
169
  }
209
- /**
210
- * Helper TypeGuard that checks if something is a string or not.
211
- * @param thing - Anything
212
- * @internal
213
- */
214
- function isString(thing) {
215
- return typeof thing === "string" || thing instanceof String;
216
- }
217
170
  /**
218
171
  * @internal
219
172
  * Helper utility to retrieve `string` value from given string,
@@ -308,8 +261,8 @@ async function parseNotificationOutcome(bodyText) {
308
261
  const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
309
262
  const outcome = xml.NotificationOutcome;
310
263
  return {
311
- success: getInteger(outcome.Success, "Success"),
312
- failure: getInteger(outcome.Failure, "Failure"),
264
+ successCount: getInteger(outcome.Success, "Success"),
265
+ failureCount: getInteger(outcome.Failure, "Failure"),
313
266
  results: parseRegistrationResults(outcome.Results.RegistrationResult),
314
267
  state: "DetailedStateAvailable",
315
268
  };
@@ -469,7 +422,7 @@ async function parseNotificationSendResponse(response) {
469
422
  }
470
423
  }
471
424
  function createDefaultResponse(response, notificationId) {
472
- 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" });
473
426
  }
474
427
  /**
475
428
  * Sends a request through the client context.
@@ -509,6 +462,82 @@ async function sendRequest(context, request, successStatusCode) {
509
462
  return response;
510
463
  }
511
464
 
465
+ // Copyright (c) Microsoft Corporation.
466
+ /**
467
+ * @internal
468
+ * Serializes a NotificationHubJob into an Atom XML entry.
469
+ * @param entry - The NotificationHubJob to turn into an Atom XML entry.
470
+ * @returns An Atom XML entry containing the notification hub job.
471
+ */
472
+ function serializeNotificationHubJobEntry(entry) {
473
+ const job = {
474
+ Type: entry.type,
475
+ OutputContainerUri: { __cdata: entry.outputContainerUrl },
476
+ ImportFileUri: isDefined(entry.importFileUrl) ? { __cdata: entry.importFileUrl } : undefined,
477
+ };
478
+ const requestObject = serializeToAtomXmlRequest("NotificationHubJob", job);
479
+ return coreXml.stringifyXML(requestObject, { rootName: "entry", cdataPropName: "__cdata" });
480
+ }
481
+ /**
482
+ * Parses an Atom XML of an notification hub job entry.
483
+ * @param bodyText - The incoming Atom XML entry to parse into a notification hub job.
484
+ * @returns A parsed NotificationHubJob.
485
+ */
486
+ async function parseNotificationHubJobEntry(bodyText) {
487
+ const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
488
+ const content = xml.entry.content.NotificationHubJob;
489
+ return createNotificationHubJob(content);
490
+ }
491
+ /**
492
+ * Parses an Atom XML feed of notification hub jobs.
493
+ * @param bodyText - The incoming Atom XML feed to parse into notification hub jobs.
494
+ * @returns A list of notification hub jobs.
495
+ */
496
+ async function parseNotificationHubJobFeed(bodyText) {
497
+ const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
498
+ const results = [];
499
+ if (!isDefined(xml.feed.entry)) {
500
+ return results;
501
+ }
502
+ const entries = Array.isArray(xml.feed.entry) ? xml.feed.entry : [xml.feed.entry];
503
+ for (const item of entries) {
504
+ results.push(createNotificationHubJob(item.content.NotificationHubJob));
505
+ }
506
+ return results;
507
+ }
508
+ function createInputOutputProperties(content) {
509
+ const props = {};
510
+ const keyValues = content["d3p1:KeyValueOfstringstring"];
511
+ const keyValueArray = Array.isArray(keyValues) ? keyValues : [keyValues];
512
+ for (const item of keyValueArray) {
513
+ props[item["d3p1:Key"]] = item["d3p1:Value"];
514
+ }
515
+ return props;
516
+ }
517
+ function createNotificationHubJob(content) {
518
+ let outputProperties;
519
+ if (isDefined(content["OutputProperties"])) {
520
+ outputProperties = createInputOutputProperties(content["OutputProperties"]);
521
+ }
522
+ let inputProperties;
523
+ if (isDefined(content["InputProperties"])) {
524
+ inputProperties = createInputOutputProperties(content["InputProperties"]);
525
+ }
526
+ return {
527
+ jobId: getStringOrUndefined(content["JobId"]),
528
+ type: getString(content["Type"], "type"),
529
+ status: getStringOrUndefined(content["Status"]),
530
+ progress: getFloatOrUndefined(content["Progress"]),
531
+ outputContainerUrl: getString(content["OutputContainerUri"], "outputContainerUrl"),
532
+ importFileUrl: getStringOrUndefined(content["ImportFileUri"]),
533
+ failure: getStringOrUndefined(content["Failure"]),
534
+ createdAt: getDateOrUndefined(content["CreatedAt"]),
535
+ updatedAt: getDateOrUndefined(content["UpdatedAt"]),
536
+ inputProperties,
537
+ outputProperties,
538
+ };
539
+ }
540
+
512
541
  // Copyright (c) Microsoft Corporation.
513
542
  /**
514
543
  * A tracing client to handle spans.
@@ -521,7 +550,178 @@ const tracingClient = coreTracing.createTracingClient({
521
550
  });
522
551
 
523
552
  // Copyright (c) Microsoft Corporation.
524
- const OPERATION_NAME$i = "cancelScheduledNotification";
553
+ const OPERATION_NAME$g = "getNotificationHubJob";
554
+ /**
555
+ * Gets a Notification Hub Job by the ID.
556
+ * @param context - The Notification Hubs client.
557
+ * @param jobId - The Notification Hub Job ID.
558
+ * @param options - The operation options.
559
+ * @returns The Notification Hub Job with the matching ID.
560
+ */
561
+ function getNotificationHubJob(context, jobId, options = {}) {
562
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$g}`, options, async (updatedOptions) => {
563
+ const endpoint = context.requestUrl();
564
+ endpoint.pathname += `/jobs/${jobId}`;
565
+ const headers = await context.createHeaders(OPERATION_NAME$g);
566
+ headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
567
+ const request = createRequest(endpoint, "GET", headers, updatedOptions);
568
+ const response = await sendRequest(context, request, 200);
569
+ return parseNotificationHubJobEntry(response.bodyAsText);
570
+ });
571
+ }
572
+
573
+ // Copyright (c) Microsoft Corporation.
574
+ const OPERATION_NAME$f = "submitNotificationHubJob";
575
+ /**
576
+ * Submits a Notification Hub Job.
577
+ * Note: this is available to Standard SKU namespace and above.
578
+ * @param context - The Notification Hubs client.
579
+ * @param job - The notification hub job to submit.
580
+ * @param options - The operation options.
581
+ * @returns The notification hub job details including job ID and status.
582
+ */
583
+ function submitNotificationHubJob(context, job, options = {}) {
584
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$f}`, options, async (updatedOptions) => {
585
+ const endpoint = context.requestUrl();
586
+ endpoint.pathname += "/jobs";
587
+ const headers = await context.createHeaders(OPERATION_NAME$f);
588
+ headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
589
+ const request = createRequest(endpoint, "POST", headers, updatedOptions);
590
+ request.body = serializeNotificationHubJobEntry(job);
591
+ const response = await sendRequest(context, request, 201);
592
+ return parseNotificationHubJobEntry(response.bodyAsText);
593
+ });
594
+ }
595
+
596
+ // Copyright (c) Microsoft Corporation.
597
+ /**
598
+ * Submits a Notification Hub job and creates a poller to poll for results.
599
+ * @param context - The Notification Hubs client.
600
+ * @param notificationHubJob - The Notification Hub import/export job to start.
601
+ * @param options - The operation options.
602
+ * @returns A poller which can be called to poll until completion of the job.
603
+ */
604
+ async function beginSubmitNotificationHubJob(context, notificationHubJob, polledOperationOptions = {}) {
605
+ var _a;
606
+ let submittedJob = await submitNotificationHubJob(context, notificationHubJob, polledOperationOptions);
607
+ const state = {
608
+ status: "notStarted",
609
+ };
610
+ const progressCallbacks = new Map();
611
+ const processProgressCallbacks = async () => progressCallbacks.forEach((h) => h(state));
612
+ let resultPromise;
613
+ let cancelJob;
614
+ const abortController$1 = new abortController.AbortController();
615
+ const currentPollIntervalInMs = (_a = polledOperationOptions.updateIntervalInMs) !== null && _a !== void 0 ? _a : 2000;
616
+ const poller = {
617
+ async poll(options) {
618
+ submittedJob = await getNotificationHubJob(context, submittedJob.jobId, options);
619
+ if (submittedJob.status === "Running" || submittedJob.status === "Started") {
620
+ state.status = "running";
621
+ }
622
+ if (submittedJob.status === "Completed") {
623
+ state.status = "succeeded";
624
+ state.result = submittedJob;
625
+ }
626
+ if (submittedJob.status === "Failed") {
627
+ state.status = "failed";
628
+ state.error = new Error(submittedJob.failure);
629
+ }
630
+ await processProgressCallbacks();
631
+ if (state.status === "canceled") {
632
+ throw new Error("Operation was canceled");
633
+ }
634
+ if (state.status === "failed") {
635
+ throw state.error;
636
+ }
637
+ },
638
+ pollUntilDone(pollOptions) {
639
+ return (resultPromise !== null && resultPromise !== void 0 ? resultPromise : (resultPromise = (async () => {
640
+ const { abortSignal: inputAbortSignal } = pollOptions || {};
641
+ const { signal: abortSignal } = inputAbortSignal
642
+ ? new abortController.AbortController([inputAbortSignal, abortController$1.signal])
643
+ : abortController$1;
644
+ if (!poller.isDone()) {
645
+ await poller.poll({ abortSignal });
646
+ while (!poller.isDone()) {
647
+ const delay = sleep(currentPollIntervalInMs, abortSignal);
648
+ cancelJob = () => abortController$1.abort();
649
+ await delay;
650
+ await poller.poll({ abortSignal });
651
+ }
652
+ }
653
+ switch (state.status) {
654
+ case "succeeded": {
655
+ return poller.getResult();
656
+ }
657
+ case "canceled": {
658
+ throw new Error("Operation was canceled");
659
+ }
660
+ case "failed": {
661
+ throw state.error;
662
+ }
663
+ case "notStarted":
664
+ case "running": {
665
+ // Unreachable
666
+ throw new Error(`polling completed without succeeding or failing`);
667
+ }
668
+ }
669
+ })().finally(() => {
670
+ resultPromise = undefined;
671
+ })));
672
+ },
673
+ onProgress(callback) {
674
+ const s = Symbol();
675
+ progressCallbacks.set(s, callback);
676
+ return () => progressCallbacks.delete(s);
677
+ },
678
+ isDone() {
679
+ return ["succeeded", "failed", "canceled"].includes(state.status);
680
+ },
681
+ stopPolling() {
682
+ abortController$1.abort();
683
+ cancelJob === null || cancelJob === void 0 ? void 0 : cancelJob();
684
+ },
685
+ isStopped() {
686
+ return resultPromise === undefined;
687
+ },
688
+ getOperationState() {
689
+ return state;
690
+ },
691
+ getResult() {
692
+ return state.result;
693
+ },
694
+ toString() {
695
+ return JSON.stringify({ state });
696
+ },
697
+ };
698
+ return poller;
699
+ }
700
+ const REJECTED_ERR = new Error("The operation has been aborted");
701
+ function sleep(ms, signal) {
702
+ return new Promise((resolve, reject) => {
703
+ if (signal.aborted) {
704
+ reject(REJECTED_ERR);
705
+ return;
706
+ }
707
+ const id = setTimeout(() => {
708
+ signal.removeEventListener("abort", onAbort);
709
+ if (signal.aborted) {
710
+ reject(REJECTED_ERR);
711
+ return;
712
+ }
713
+ resolve();
714
+ }, ms);
715
+ signal.addEventListener("abort", onAbort, { once: true });
716
+ function onAbort() {
717
+ clearTimeout(id);
718
+ reject(REJECTED_ERR);
719
+ }
720
+ });
721
+ }
722
+
723
+ // Copyright (c) Microsoft Corporation.
724
+ const OPERATION_NAME$e = "cancelScheduledNotification";
525
725
  /**
526
726
  * Cancels the scheduled notification with the given notification ID.
527
727
  * NOTE: This is only available in Standard SKU Azure Notification Hubs.
@@ -531,10 +731,10 @@ const OPERATION_NAME$i = "cancelScheduledNotification";
531
731
  * @returns A notification hub response with correlation ID and tracking ID.
532
732
  */
533
733
  function cancelScheduledNotification(context, notificationId, options = {}) {
534
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$i}`, options, async (updatedOptions) => {
734
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$e}`, options, async (updatedOptions) => {
535
735
  const endpoint = context.requestUrl();
536
736
  endpoint.pathname += `/schedulednotifications/${notificationId}`;
537
- const headers = await context.createHeaders(OPERATION_NAME$i);
737
+ const headers = await context.createHeaders(OPERATION_NAME$e);
538
738
  const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
539
739
  const response = await sendRequest(context, request, 200);
540
740
  return parseNotificationSendResponse(response);
@@ -542,7 +742,7 @@ function cancelScheduledNotification(context, notificationId, options = {}) {
542
742
  }
543
743
 
544
744
  // Copyright (c) Microsoft Corporation.
545
- const OPERATION_NAME$h = "createOrUpdateInstallation";
745
+ const OPERATION_NAME$d = "createOrUpdateInstallation";
546
746
  /**
547
747
  * Creates or overwrites an installation to a Notification Hub.
548
748
  * @param context - The Notification Hubs client.
@@ -551,10 +751,10 @@ const OPERATION_NAME$h = "createOrUpdateInstallation";
551
751
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
552
752
  */
553
753
  function createOrUpdateInstallation(context, installation, options = {}) {
554
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$h}`, options, async (updatedOptions) => {
754
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$d}`, options, async (updatedOptions) => {
555
755
  const endpoint = context.requestUrl();
556
756
  endpoint.pathname += `/installations/${installation.installationId}`;
557
- const headers = await context.createHeaders(OPERATION_NAME$h);
757
+ const headers = await context.createHeaders(OPERATION_NAME$d);
558
758
  headers.set("Content-Type", "application/json");
559
759
  const request = createRequest(endpoint, "PUT", headers, updatedOptions);
560
760
  request.body = JSON.stringify(installation);
@@ -609,21 +809,21 @@ const registrationDescriptionParser = {
609
809
  * Creates an ADM registration description from incoming XML property bag.
610
810
  */
611
811
  createAdmRegistrationDescription(rawRegistrationDescription) {
612
- 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" });
613
813
  },
614
814
  /**
615
815
  * @internal
616
816
  * Creates an ADM template registration description from incoming XML property bag.
617
817
  */
618
818
  createAdmTemplateRegistrationDescription(rawRegistrationDescription) {
619
- 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" });
620
820
  },
621
821
  /**
622
822
  * @internal
623
823
  * Creates an Apple registration description from incoming XML property bag.
624
824
  */
625
825
  createAppleRegistrationDescription(rawRegistrationDescription) {
626
- 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" });
627
827
  },
628
828
  /**
629
829
  * @internal
@@ -631,56 +831,56 @@ const registrationDescriptionParser = {
631
831
  */
632
832
  createAppleTemplateRegistrationDescription(rawRegistrationDescription) {
633
833
  var _a;
634
- 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" });
635
835
  },
636
836
  /**
637
837
  * @internal
638
838
  * Creates a Baidu registration description from incoming XML property bag.
639
839
  */
640
840
  createBaiduRegistrationDescription(rawRegistrationDescription) {
641
- 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" });
642
842
  },
643
843
  /**
644
844
  * @internal
645
845
  * Creates a Baidu template registration description from incoming XML property bag.
646
846
  */
647
847
  createBaiduTemplateRegistrationDescription(rawRegistrationDescription) {
648
- 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" });
649
849
  },
650
850
  /**
651
851
  * @internal
652
852
  * Creates a Browser registration description from incoming XML property bag.
653
853
  */
654
854
  createBrowserRegistrationDescription(rawRegistrationDescription) {
655
- 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" });
656
856
  },
657
857
  /**
658
858
  * @internal
659
859
  * Creates a Browser template registration description from incoming XML property bag.
660
860
  */
661
861
  createBrowserTemplateRegistrationDescription(rawRegistrationDescription) {
662
- 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" });
663
863
  },
664
864
  /**
665
865
  * @internal
666
866
  * Creates an GCM registration description from incoming XML property bag.
667
867
  */
668
868
  createGcmRegistrationDescription(rawRegistrationDescription) {
669
- 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" });
670
870
  },
671
871
  /**
672
872
  * @internal
673
873
  * Creates an FCM template registration description from incoming XML property bag.
674
874
  */
675
875
  createGcmTemplateRegistrationDescription(rawRegistrationDescription) {
676
- 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" });
677
877
  },
678
878
  /**
679
879
  * @internal
680
880
  * Creates a Windows Phone registration description from incoming XML property bag.
681
881
  */
682
882
  createMpnsRegistrationDescription(rawRegistrationDescription) {
683
- 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" });
684
884
  },
685
885
  /**
686
886
  * @internal
@@ -688,14 +888,14 @@ const registrationDescriptionParser = {
688
888
  */
689
889
  createMpnsTemplateRegistrationDescription(rawRegistrationDescription) {
690
890
  var _a;
691
- 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" });
692
892
  },
693
893
  /**
694
894
  * @internal
695
895
  * Creates a Windows registration description from incoming XML property bag.
696
896
  */
697
897
  createWindowsRegistrationDescription(rawRegistrationDescription) {
698
- 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" });
699
899
  },
700
900
  /**
701
901
  * @internal
@@ -703,7 +903,7 @@ const registrationDescriptionParser = {
703
903
  */
704
904
  createWindowsTemplateRegistrationDescription(rawRegistrationDescription) {
705
905
  var _a;
706
- 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" });
707
907
  },
708
908
  };
709
909
  function getHeadersOrUndefined(value) {
@@ -738,11 +938,11 @@ function createTemplateRegistrationDescription(rawRegistrationDescription) {
738
938
  */
739
939
  const registrationDescriptionSerializer = {
740
940
  serializeRegistrationDescription(description) {
741
- const rootName = `${description.type}RegistrationDescription`;
941
+ const rootName = `${description.kind}RegistrationDescription`;
742
942
  const methodName = `serialize${rootName}`;
743
943
  const method = this[methodName].bind(this);
744
944
  if (!isDefined(method)) {
745
- throw new coreRestPipeline.RestError(`Undefined platform ${description.type}`, { statusCode: 400 });
945
+ throw new coreRestPipeline.RestError(`Undefined platform ${description.kind}`, { statusCode: 400 });
746
946
  }
747
947
  const registration = method(description);
748
948
  const requestObject = serializeToAtomXmlRequest(rootName, registration);
@@ -937,7 +1137,7 @@ async function createOrUpdateRegistrationDescription(context, registration, oper
937
1137
  }
938
1138
 
939
1139
  // Copyright (c) Microsoft Corporation.
940
- const OPERATION_NAME$g = "createOrUpdateRegistration";
1140
+ const OPERATION_NAME$c = "createOrUpdateRegistration";
941
1141
  /**
942
1142
  * Creates or updates a registration.
943
1143
  * @param context - The Notification Hubs client.
@@ -946,13 +1146,34 @@ const OPERATION_NAME$g = "createOrUpdateRegistration";
946
1146
  * @returns The created or updated registration description.
947
1147
  */
948
1148
  function createOrUpdateRegistration(context, registration, options = {}) {
949
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$g}`, options, async (updatedOptions) => {
1149
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$c}`, options, async (updatedOptions) => {
950
1150
  return createOrUpdateRegistrationDescription(context, registration, "createOrUpdate", updatedOptions);
951
1151
  });
952
1152
  }
953
1153
 
954
1154
  // Copyright (c) Microsoft Corporation.
955
- const OPERATION_NAME$f = "createRegistrationId";
1155
+ const OPERATION_NAME$b = "createRegistration";
1156
+ /**
1157
+ * Creates a new registration. This method generates a registration ID,
1158
+ * which you can subsequently use to retrieve, update, and delete this registration.
1159
+ * @param context - The Notification Hubs client.
1160
+ * @param registration - The registration to create.
1161
+ * @param options - Options for creating a new registration.
1162
+ * @returns The newly created registration description.
1163
+ */
1164
+ function createRegistration(context, registration, options = {}) {
1165
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$b}`, options, async (updatedOptions) => {
1166
+ if (registration.registrationId) {
1167
+ throw new coreRestPipeline.RestError("registrationId must not be set during a create operation", {
1168
+ statusCode: 400,
1169
+ });
1170
+ }
1171
+ return createOrUpdateRegistrationDescription(context, registration, "create", updatedOptions);
1172
+ });
1173
+ }
1174
+
1175
+ // Copyright (c) Microsoft Corporation.
1176
+ const OPERATION_NAME$a = "createRegistrationId";
956
1177
  /**
957
1178
  * Creates a new registration ID.
958
1179
  * @param context - The Notification Hubs client.
@@ -960,10 +1181,10 @@ const OPERATION_NAME$f = "createRegistrationId";
960
1181
  * @returns The newly created registration ID.
961
1182
  */
962
1183
  function createRegistrationId(context, options = {}) {
963
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$f}`, options, async (updatedOptions) => {
1184
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$a}`, options, async (updatedOptions) => {
964
1185
  const endpoint = context.requestUrl();
965
1186
  endpoint.pathname += "/registrationIDs";
966
- const headers = await context.createHeaders(OPERATION_NAME$f);
1187
+ const headers = await context.createHeaders(OPERATION_NAME$a);
967
1188
  headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
968
1189
  const request = createRequest(endpoint, "POST", headers, updatedOptions);
969
1190
  const response = await sendRequest(context, request, 201);
@@ -976,28 +1197,7 @@ function createRegistrationId(context, options = {}) {
976
1197
  }
977
1198
 
978
1199
  // Copyright (c) Microsoft Corporation.
979
- const OPERATION_NAME$e = "createRegistration";
980
- /**
981
- * Creates a new registration. This method generates a registration ID,
982
- * which you can subsequently use to retrieve, update, and delete this registration.
983
- * @param context - The Notification Hubs client.
984
- * @param registration - The registration to create.
985
- * @param options - Options for creating a new registration.
986
- * @returns The newly created registration description.
987
- */
988
- function createRegistration(context, registration, options = {}) {
989
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$e}`, options, async (updatedOptions) => {
990
- if (registration.registrationId) {
991
- throw new coreRestPipeline.RestError("registrationId must not be set during a create operation", {
992
- statusCode: 400,
993
- });
994
- }
995
- return createOrUpdateRegistrationDescription(context, registration, "create", updatedOptions);
996
- });
997
- }
998
-
999
- // Copyright (c) Microsoft Corporation.
1000
- const OPERATION_NAME$d = "deleteInstallation";
1200
+ const OPERATION_NAME$9 = "deleteInstallation";
1001
1201
  /**
1002
1202
  * Deletes an installation from a Notification Hub.
1003
1203
  * @param context - The Notification Hubs client.
@@ -1006,10 +1206,10 @@ const OPERATION_NAME$d = "deleteInstallation";
1006
1206
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1007
1207
  */
1008
1208
  function deleteInstallation(context, installationId, options = {}) {
1009
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$d}`, options, async (updatedOptions) => {
1209
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$9}`, options, async (updatedOptions) => {
1010
1210
  const endpoint = context.requestUrl();
1011
1211
  endpoint.pathname += `/installations/${installationId}`;
1012
- const headers = await context.createHeaders(OPERATION_NAME$d);
1212
+ const headers = await context.createHeaders(OPERATION_NAME$9);
1013
1213
  const request = createRequest(endpoint, "DELETE", headers, updatedOptions);
1014
1214
  const response = await sendRequest(context, request, 204);
1015
1215
  return parseNotificationResponse(response);
@@ -1017,7 +1217,7 @@ function deleteInstallation(context, installationId, options = {}) {
1017
1217
  }
1018
1218
 
1019
1219
  // Copyright (c) Microsoft Corporation.
1020
- const OPERATION_NAME$c = "deleteRegistration";
1220
+ const OPERATION_NAME$8 = "deleteRegistration";
1021
1221
  /**
1022
1222
  * Deletes a registration with the given registration ID.
1023
1223
  * @param context - The Notification Hubs client.
@@ -1026,10 +1226,10 @@ const OPERATION_NAME$c = "deleteRegistration";
1026
1226
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1027
1227
  */
1028
1228
  function deleteRegistration(context, registrationId, options = {}) {
1029
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$c}`, options, async (updatedOptions) => {
1229
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$8}`, options, async (updatedOptions) => {
1030
1230
  const endpoint = context.requestUrl();
1031
1231
  endpoint.pathname += `/registrations/${registrationId}`;
1032
- const headers = await context.createHeaders(OPERATION_NAME$c);
1232
+ const headers = await context.createHeaders(OPERATION_NAME$8);
1033
1233
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
1034
1234
  headers.set("If-Match", isDefined(options.etag) ? `"${options.etag}"` : "*");
1035
1235
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
@@ -1039,7 +1239,7 @@ function deleteRegistration(context, registrationId, options = {}) {
1039
1239
  }
1040
1240
 
1041
1241
  // Copyright (c) Microsoft Corporation.
1042
- const OPERATION_NAME$b = "getFeedbackContainerUrl";
1242
+ const OPERATION_NAME$7 = "getFeedbackContainerUrl";
1043
1243
  /**
1044
1244
  * Retrieves an Azure Storage container URL. The container has feedback data for the notification hub.
1045
1245
  * The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.
@@ -1048,10 +1248,10 @@ const OPERATION_NAME$b = "getFeedbackContainerUrl";
1048
1248
  * @returns The URL of the Azure Storage Container containing the feedback data.
1049
1249
  */
1050
1250
  function getFeedbackContainerUrl(context, options = {}) {
1051
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$b}`, options, async (updatedOptions) => {
1251
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$7}`, options, async (updatedOptions) => {
1052
1252
  const endpoint = context.requestUrl();
1053
1253
  endpoint.pathname += "/feedbackcontainer";
1054
- const headers = await context.createHeaders(OPERATION_NAME$b);
1254
+ const headers = await context.createHeaders(OPERATION_NAME$7);
1055
1255
  headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
1056
1256
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1057
1257
  const response = await sendRequest(context, request, 200);
@@ -1060,7 +1260,7 @@ function getFeedbackContainerUrl(context, options = {}) {
1060
1260
  }
1061
1261
 
1062
1262
  // Copyright (c) Microsoft Corporation.
1063
- const OPERATION_NAME$a = "getInstallation";
1263
+ const OPERATION_NAME$6 = "getInstallation";
1064
1264
  /**
1065
1265
  * Gets an Azure Notification Hub installation by the installation ID.
1066
1266
  * @param context - The Notification Hubs client.
@@ -1069,10 +1269,10 @@ const OPERATION_NAME$a = "getInstallation";
1069
1269
  * @returns The installation that matches the installation ID.
1070
1270
  */
1071
1271
  function getInstallation(context, installationId, options = {}) {
1072
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$a}`, options, async (updatedOptions) => {
1272
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$6}`, options, async (updatedOptions) => {
1073
1273
  const endpoint = context.requestUrl();
1074
1274
  endpoint.pathname += `/installations/${installationId}`;
1075
- const headers = await context.createHeaders(OPERATION_NAME$a);
1275
+ const headers = await context.createHeaders(OPERATION_NAME$6);
1076
1276
  headers.set("Content-Type", "application/json");
1077
1277
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1078
1278
  const response = await sendRequest(context, request, 200);
@@ -1083,102 +1283,7 @@ function getInstallation(context, installationId, options = {}) {
1083
1283
  // Copyright (c) Microsoft Corporation.
1084
1284
  /**
1085
1285
  * @internal
1086
- * Serializes a NotificationHubJob into an Atom XML entry.
1087
- * @param entry - The NotificationHubJob to turn into an Atom XML entry.
1088
- * @returns An Atom XML entry containing the notification hub job.
1089
- */
1090
- function serializeNotificationHubJobEntry(entry) {
1091
- const job = {
1092
- Type: entry.type,
1093
- OutputContainerUri: { __cdata: entry.outputContainerUrl },
1094
- ImportFileUri: isDefined(entry.importFileUrl) ? { __cdata: entry.importFileUrl } : undefined,
1095
- };
1096
- const requestObject = serializeToAtomXmlRequest("NotificationHubJob", job);
1097
- return coreXml.stringifyXML(requestObject, { rootName: "entry", cdataPropName: "__cdata" });
1098
- }
1099
- /**
1100
- * Parses an Atom XML of an notification hub job entry.
1101
- * @param bodyText - The incoming Atom XML entry to parse into a notification hub job.
1102
- * @returns A parsed NotificationHubJob.
1103
- */
1104
- async function parseNotificationHubJobEntry(bodyText) {
1105
- const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
1106
- const content = xml.entry.content.NotificationHubJob;
1107
- return createNotificationHubJob(content);
1108
- }
1109
- /**
1110
- * Parses an Atom XML feed of notification hub jobs.
1111
- * @param bodyText - The incoming Atom XML feed to parse into notification hub jobs.
1112
- * @returns A list of notification hub jobs.
1113
- */
1114
- async function parseNotificationHubJobFeed(bodyText) {
1115
- const xml = await coreXml.parseXML(bodyText, { includeRoot: true });
1116
- const results = [];
1117
- if (!isDefined(xml.feed.entry)) {
1118
- return results;
1119
- }
1120
- const entries = Array.isArray(xml.feed.entry) ? xml.feed.entry : [xml.feed.entry];
1121
- for (const item of entries) {
1122
- results.push(createNotificationHubJob(item.content.NotificationHubJob));
1123
- }
1124
- return results;
1125
- }
1126
- function createInputOutputProperties(content) {
1127
- const props = {};
1128
- for (const item of content["d3p1:KeyValueOfstringstring"]) {
1129
- props[item["d3p1:Key"]] = item["d3p1:Value"];
1130
- }
1131
- return props;
1132
- }
1133
- function createNotificationHubJob(content) {
1134
- let outputProperties;
1135
- if (isDefined(content["OutputProperties"])) {
1136
- outputProperties = createInputOutputProperties(content["OutputProperties"]);
1137
- }
1138
- let inputProperties;
1139
- if (isDefined(content["InputProperties"])) {
1140
- inputProperties = createInputOutputProperties(content["InputProperties"]);
1141
- }
1142
- return {
1143
- jobId: getStringOrUndefined(content["JobId"]),
1144
- type: getString(content["Type"], "type"),
1145
- status: getStringOrUndefined(content["Status"]),
1146
- progress: getFloatOrUndefined(content["Progress"]),
1147
- outputContainerUrl: getString(content["OutputContainerUri"], "outputContainerUrl"),
1148
- importFileUrl: getStringOrUndefined(content["ImportFileUri"]),
1149
- failure: getStringOrUndefined(content["Failure"]),
1150
- createdAt: getDateOrUndefined(content["CreatedAt"]),
1151
- updatedAt: getDateOrUndefined(content["UpdatedAt"]),
1152
- inputProperties,
1153
- outputProperties,
1154
- };
1155
- }
1156
-
1157
- // Copyright (c) Microsoft Corporation.
1158
- const OPERATION_NAME$9 = "getNotificationHubJob";
1159
- /**
1160
- * Gets a Notification Hub Job by the ID.
1161
- * @param context - The Notification Hubs client.
1162
- * @param jobId - The Notification Hub Job ID.
1163
- * @param options - The operation options.
1164
- * @returns The Notification Hub Job with the matching ID.
1165
- */
1166
- function getNotificationHubJob(context, jobId, options = {}) {
1167
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$9}`, options, async (updatedOptions) => {
1168
- const endpoint = context.requestUrl();
1169
- endpoint.pathname += `/jobs/${jobId}`;
1170
- const headers = await context.createHeaders(OPERATION_NAME$9);
1171
- headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
1172
- const request = createRequest(endpoint, "GET", headers, updatedOptions);
1173
- const response = await sendRequest(context, request, 200);
1174
- return parseNotificationHubJobEntry(response.bodyAsText);
1175
- });
1176
- }
1177
-
1178
- // Copyright (c) Microsoft Corporation.
1179
- /**
1180
- * @internal
1181
- * Parses a NotificationDetails from incoming XML.
1286
+ * Parses a NotificationDetails from incoming XML.
1182
1287
  */
1183
1288
  async function parseNotificationDetails(bodyText) {
1184
1289
  const xml = await coreXml.parseXML(bodyText, {
@@ -1223,15 +1328,16 @@ async function parseNotificationDetails(bodyText) {
1223
1328
  };
1224
1329
  }
1225
1330
  function parseOutcomeCounts(counts) {
1331
+ const items = Array.isArray(counts) ? counts : [counts];
1226
1332
  const results = [];
1227
- for (const item of counts) {
1333
+ for (const item of items) {
1228
1334
  results.push({ state: item["Name"], count: getInteger(item["Count"], "Count") });
1229
1335
  }
1230
1336
  return results;
1231
1337
  }
1232
1338
 
1233
1339
  // Copyright (c) Microsoft Corporation.
1234
- const OPERATION_NAME$8 = "getNotificationOutcomeDetails";
1340
+ const OPERATION_NAME$5 = "getNotificationOutcomeDetails";
1235
1341
  /**
1236
1342
  * Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed
1237
1343
  * or final results if the Send* has completed. This API can only be called for Standard SKU and above.
@@ -1241,10 +1347,10 @@ const OPERATION_NAME$8 = "getNotificationOutcomeDetails";
1241
1347
  * @returns The results of the send operation.
1242
1348
  */
1243
1349
  function getNotificationOutcomeDetails(context, notificationId, options = {}) {
1244
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$8}`, options, async (updatedOptions) => {
1350
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$5}`, options, async (updatedOptions) => {
1245
1351
  const endpoint = context.requestUrl();
1246
1352
  endpoint.pathname += `/messages/${notificationId}`;
1247
- const headers = await context.createHeaders(OPERATION_NAME$8);
1353
+ const headers = await context.createHeaders(OPERATION_NAME$5);
1248
1354
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1249
1355
  const response = await sendRequest(context, request, 200);
1250
1356
  return parseNotificationDetails(response.bodyAsText);
@@ -1252,7 +1358,7 @@ function getNotificationOutcomeDetails(context, notificationId, options = {}) {
1252
1358
  }
1253
1359
 
1254
1360
  // Copyright (c) Microsoft Corporation.
1255
- const OPERATION_NAME$7 = "getRegistration";
1361
+ const OPERATION_NAME$4 = "getRegistration";
1256
1362
  /**
1257
1363
  * Gets a registration by the given registration ID.
1258
1364
  * @param context - The Notification Hubs client.
@@ -1261,10 +1367,10 @@ const OPERATION_NAME$7 = "getRegistration";
1261
1367
  * @returns A RegistrationDescription that has the given registration ID.
1262
1368
  */
1263
1369
  function getRegistration(context, registrationId, options = {}) {
1264
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$7}`, options, async (updatedOptions) => {
1370
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$4}`, options, async (updatedOptions) => {
1265
1371
  const endpoint = context.requestUrl();
1266
1372
  endpoint.pathname += `/registrations/${registrationId}`;
1267
- const headers = await context.createHeaders(OPERATION_NAME$7);
1373
+ const headers = await context.createHeaders(OPERATION_NAME$4);
1268
1374
  headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
1269
1375
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1270
1376
  const response = await sendRequest(context, request, 200);
@@ -1273,7 +1379,7 @@ function getRegistration(context, registrationId, options = {}) {
1273
1379
  }
1274
1380
 
1275
1381
  // Copyright (c) Microsoft Corporation.
1276
- const OPERATION_NAME$6 = "listNotificationHubJobs";
1382
+ const OPERATION_NAME$3 = "listNotificationHubJobs";
1277
1383
  /**
1278
1384
  * Gets all Notification Hub Jobs for this Notification Hub.
1279
1385
  * @param context - The Notification Hubs client.xs
@@ -1281,10 +1387,10 @@ const OPERATION_NAME$6 = "listNotificationHubJobs";
1281
1387
  * @returns An array of all Notification Hub Jobs for this Notification Hub.
1282
1388
  */
1283
1389
  function listNotificationHubJobs(context, options = {}) {
1284
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$6}`, options, async (updatedOptions) => {
1390
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$3}`, options, async (updatedOptions) => {
1285
1391
  const endpoint = context.requestUrl();
1286
1392
  endpoint.pathname += "/jobs";
1287
- const headers = await context.createHeaders(OPERATION_NAME$6);
1393
+ const headers = await context.createHeaders(OPERATION_NAME$3);
1288
1394
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
1289
1395
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
1290
1396
  const response = await sendRequest(context, request, 200);
@@ -1293,43 +1399,11 @@ function listNotificationHubJobs(context, options = {}) {
1293
1399
  }
1294
1400
 
1295
1401
  // Copyright (c) Microsoft Corporation.
1296
- const OPERATION_NAME$5 = "listRegistrationsByTag";
1297
- /**
1298
- * Lists all registrations with the matching tag.
1299
- * @param context - The Notification Hubs client.
1300
- * @param tag - The tag to query for matching registrations.
1301
- * @param options - The query options such as $top.
1302
- * @returns A paged async iterable containing the matching registrations for the notification hub.
1303
- */
1304
- function listRegistrationsByTag(context, tag, options = {}) {
1305
- const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext-${OPERATION_NAME$5}`, options);
1306
- try {
1307
- const iter = listRegistrationsByTagAll(context, tag, updatedOptions);
1308
- return {
1309
- next() {
1310
- return iter.next();
1311
- },
1312
- [Symbol.asyncIterator]() {
1313
- return this;
1314
- },
1315
- byPage: () => {
1316
- return listRegistrationsByTagPagingPage(context, tag, options);
1317
- },
1318
- };
1319
- }
1320
- catch (e) {
1321
- span.setStatus({ status: "error", error: e });
1322
- throw e;
1323
- }
1324
- finally {
1325
- span.end();
1326
- }
1327
- }
1328
- function listRegistrationsByTagAll(context, tag, options) {
1329
- return tslib.__asyncGenerator(this, arguments, function* listRegistrationsByTagAll_1() {
1402
+ function listRegistrationsAll(context, options) {
1403
+ return tslib.__asyncGenerator(this, arguments, function* listRegistrationsAll_1() {
1330
1404
  var e_1, _a;
1331
1405
  try {
1332
- 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;) {
1333
1407
  const page = _c.value;
1334
1408
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
1335
1409
  }
@@ -1343,28 +1417,31 @@ function listRegistrationsByTagAll(context, tag, options) {
1343
1417
  }
1344
1418
  });
1345
1419
  }
1346
- function listRegistrationsByTagPagingPage(context, tag, options) {
1347
- return tslib.__asyncGenerator(this, arguments, function* listRegistrationsByTagPagingPage_1() {
1348
- 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));
1349
1423
  yield yield tslib.__await(result.registrations || []);
1350
1424
  let continuationToken = result.continuationToken;
1351
1425
  while (continuationToken) {
1352
- result = yield tslib.__await(_listRegistrationsByTag(context, tag, options, continuationToken));
1426
+ result = yield tslib.__await(_listRegistrations(context, options, continuationToken));
1353
1427
  continuationToken = result.continuationToken;
1354
1428
  yield yield tslib.__await(result.registrations || []);
1355
1429
  }
1356
1430
  });
1357
1431
  }
1358
- async function _listRegistrationsByTag(context, tag, options, continuationToken) {
1432
+ async function _listRegistrations(context, options, continuationToken) {
1359
1433
  const endpoint = context.requestUrl();
1360
- endpoint.pathname += `/tags/${tag}/registrations`;
1434
+ endpoint.pathname += "/registrations";
1361
1435
  if (options.top !== undefined) {
1362
1436
  endpoint.searchParams.set("$top", `${options.top}`);
1363
1437
  }
1438
+ if (options.filter !== undefined) {
1439
+ endpoint.searchParams.set("$filter", options.filter);
1440
+ }
1364
1441
  if (continuationToken !== undefined) {
1365
1442
  endpoint.searchParams.set("continuationtoken", continuationToken);
1366
1443
  }
1367
- const headers = await context.createHeaders(OPERATION_NAME$5);
1444
+ const headers = await context.createHeaders("listRegistrations");
1368
1445
  const request = createRequest(endpoint, "GET", headers, options);
1369
1446
  const response = await sendRequest(context, request, 200);
1370
1447
  const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
@@ -1376,15 +1453,14 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
1376
1453
  }
1377
1454
 
1378
1455
  // Copyright (c) Microsoft Corporation.
1379
- const OPERATION_NAME$4 = "listRegistrations";
1380
1456
  /**
1381
1457
  * Gets all registrations for the notification hub with the given query options.
1382
1458
  * @param context - The Notification Hubs client.
1383
- * @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.
1384
1460
  * @returns A paged async iterable containing all of the registrations for the notification hub.
1385
1461
  */
1386
1462
  function listRegistrations(context, options = {}) {
1387
- const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext-${OPERATION_NAME$4}`, options);
1463
+ const { span, updatedOptions } = tracingClient.startSpan("NotificationHubsClientContext.listRegistrations", options);
1388
1464
  try {
1389
1465
  const iter = listRegistrationsAll(context, updatedOptions);
1390
1466
  return {
@@ -1395,7 +1471,7 @@ function listRegistrations(context, options = {}) {
1395
1471
  return this;
1396
1472
  },
1397
1473
  byPage: () => {
1398
- return listRegistrationPagingPage(context, options);
1474
+ return listRegistrationPagingPage(context, updatedOptions);
1399
1475
  },
1400
1476
  };
1401
1477
  }
@@ -1407,11 +1483,99 @@ function listRegistrations(context, options = {}) {
1407
1483
  span.end();
1408
1484
  }
1409
1485
  }
1410
- function listRegistrationsAll(context, options) {
1411
- 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() {
1412
1576
  var e_1, _a;
1413
1577
  try {
1414
- 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;) {
1415
1579
  const page = _c.value;
1416
1580
  yield tslib.__await(yield* tslib.__asyncDelegator(tslib.__asyncValues(page)));
1417
1581
  }
@@ -1425,31 +1589,28 @@ function listRegistrationsAll(context, options) {
1425
1589
  }
1426
1590
  });
1427
1591
  }
1428
- function listRegistrationPagingPage(context, options) {
1429
- return tslib.__asyncGenerator(this, arguments, function* listRegistrationPagingPage_1() {
1430
- 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));
1431
1595
  yield yield tslib.__await(result.registrations || []);
1432
1596
  let continuationToken = result.continuationToken;
1433
1597
  while (continuationToken) {
1434
- result = yield tslib.__await(_listRegistrations(context, options, continuationToken));
1598
+ result = yield tslib.__await(_listRegistrationsByTag(context, tag, options, continuationToken));
1435
1599
  continuationToken = result.continuationToken;
1436
1600
  yield yield tslib.__await(result.registrations || []);
1437
1601
  }
1438
1602
  });
1439
1603
  }
1440
- async function _listRegistrations(context, options, continuationToken) {
1604
+ async function _listRegistrationsByTag(context, tag, options, continuationToken) {
1441
1605
  const endpoint = context.requestUrl();
1442
- endpoint.pathname += "/registrations";
1606
+ endpoint.pathname += `/tags/${tag}/registrations`;
1443
1607
  if (options.top !== undefined) {
1444
1608
  endpoint.searchParams.set("$top", `${options.top}`);
1445
1609
  }
1446
- if (options.filter !== undefined) {
1447
- endpoint.searchParams.set("$filter", options.filter);
1448
- }
1449
1610
  if (continuationToken !== undefined) {
1450
1611
  endpoint.searchParams.set("continuationtoken", continuationToken);
1451
1612
  }
1452
- const headers = await context.createHeaders(OPERATION_NAME$4);
1613
+ const headers = await context.createHeaders(OPERATION_NAME$2);
1453
1614
  const request = createRequest(endpoint, "GET", headers, options);
1454
1615
  const response = await sendRequest(context, request, 200);
1455
1616
  const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
@@ -1461,32 +1622,25 @@ async function _listRegistrations(context, options, continuationToken) {
1461
1622
  }
1462
1623
 
1463
1624
  // Copyright (c) Microsoft Corporation.
1464
- const OPERATION_NAME$3 = "scheduleNotificationPayload";
1465
1625
  /**
1466
- * @internal
1626
+ * Schedules a push notification to devices that match the given tags or tag expression at the specified time.
1627
+ * NOTE: This is only available in Standard SKU Azure Notification Hubs.
1628
+ * @param context - The Notification Hubs client.
1629
+ * @param scheduledTime - The Date to send the push notification.
1630
+ * @param notification - The notification to send to the matching devices.
1631
+ * @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.
1632
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1467
1633
  */
1468
- function scheduleNotificationPayload(context, scheduledTime, tags, notification, options = {}) {
1469
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$3}`, options, async (updatedOptions) => {
1634
+ function scheduleNotification(context, scheduledTime, notification, options = {}) {
1635
+ return tracingClient.withSpan(`NotificationHubsClientContext.scheduleNotification`, options, async (updatedOptions) => {
1470
1636
  const endpoint = context.requestUrl();
1471
1637
  endpoint.pathname += "/schedulednotifications/";
1472
- const headers = await context.createHeaders(OPERATION_NAME$3);
1473
- if (notification.headers) {
1474
- for (const headerName of Object.keys(notification.headers)) {
1475
- headers.set(headerName, notification.headers[headerName]);
1476
- }
1477
- }
1638
+ const headers = await context.createHeaders("scheduleNotification", notification.headers);
1478
1639
  headers.set("ServiceBusNotification-ScheduleTime", scheduledTime.toISOString());
1479
1640
  headers.set("Content-Type", notification.contentType);
1480
1641
  headers.set("ServiceBusNotification-Format", notification.platform);
1481
- if (tags) {
1482
- let tagExpression = null;
1483
- if (Array.isArray(tags)) {
1484
- tagExpression = tags.join("||");
1485
- }
1486
- else {
1487
- tagExpression = tags;
1488
- }
1489
- headers.set("ServiceBusNotification-Tags", tagExpression);
1642
+ if (options.tagExpression) {
1643
+ headers.set("ServiceBusNotification-Tags", options.tagExpression);
1490
1644
  }
1491
1645
  const request = createRequest(endpoint, "POST", headers, updatedOptions);
1492
1646
  request.body = notification.body;
@@ -1497,146 +1651,98 @@ function scheduleNotificationPayload(context, scheduledTime, tags, notification,
1497
1651
 
1498
1652
  // Copyright (c) Microsoft Corporation.
1499
1653
  /**
1500
- * Schedules a push notification to all devices registered on the Notification Hub.
1501
- * NOTE: This is only available in Standard SKU Azure Notification Hubs.
1502
- * @param context - The Notification Hubs client.
1503
- * @param scheduledTime - The Date to send the push notification.
1504
- * @param notification - The notification to send to the matching devices.
1505
- * @param options - Configuration options for the direct send operation which can contain custom headers
1506
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1507
- * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1654
+ * Determines whether the options are of type SendNotificationOptions.
1655
+ * @param options - The options to test if SendNotificationOptions.
1656
+ * @returns true if SendNotificationOptions otherwise false.
1657
+ */
1658
+ function isSendNotificationOptions(options) {
1659
+ return coreUtil.objectHasProperty(options, "tags") || coreUtil.objectHasProperty(options, "enableTestSend");
1660
+ }
1661
+ /**
1662
+ * Determines whether the options are of type DirectSendNotificationOptions.
1663
+ * @param options - The options to test if DirectSendNotificationOptions.
1664
+ * @returns true if DirectSendNotificationOptions otherwise false.
1508
1665
  */
1509
- function scheduleBroadcastNotification(context, scheduledTime, notification, options = {}) {
1510
- return scheduleNotificationPayload(context, scheduledTime, undefined, notification, options);
1666
+ function isDirectSendNotificationOptions(options) {
1667
+ return coreUtil.objectHasProperty(options, "deviceHandle");
1511
1668
  }
1512
1669
 
1513
1670
  // Copyright (c) Microsoft Corporation.
1671
+ // Licensed under the MIT license.
1514
1672
  /**
1515
- * Schedules a push notification to devices that match the given tags or tag expression at the specified time.
1516
- * NOTE: This is only available in Standard SKU Azure Notification Hubs.
1517
- * @param context - The Notification Hubs client.
1518
- * @param scheduledTime - The Date to send the push notification.
1519
- * @param tags - The tags used to target the device for push notifications in either an array or tag expression.
1520
- * @param notification - The notification to send to the matching devices.
1521
- * @param options - Configuration options for the direct send operation which can contain custom headers
1522
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1523
- * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1673
+ * @internal
1524
1674
  */
1525
- function scheduleNotification(context, scheduledTime, tags, notification, options = {}) {
1526
- return scheduleNotificationPayload(context, scheduledTime, tags, notification, options);
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}--`);
1527
1687
  }
1528
1688
 
1529
1689
  // Copyright (c) Microsoft Corporation.
1530
1690
  /**
1531
- * @internal
1691
+ * Sends push notifications to devices that match the given tags or tag expression.
1692
+ * @param context - The Notification Hubs client.
1693
+ * @param notification - The notification to send to the matching devices.
1694
+ * @param options - Options for the notification including tags, device handles and whether to enable test send.
1695
+ * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1532
1696
  */
1533
- function sendNotificationPayload(context, notification, method, pushHandle, tags, options = {}) {
1534
- return tracingClient.withSpan(`NotificationHubsClientContext-${method}`, options, async (updatedOptions) => {
1697
+ function sendNotification(context, notification, options = { enableTestSend: false }) {
1698
+ return tracingClient.withSpan(`NotificationHubsClientContext.sendNotification`, options, async (updatedOptions) => {
1535
1699
  const endpoint = context.requestUrl();
1536
1700
  endpoint.pathname += "/messages/";
1537
- if (options.enableTestSend) {
1701
+ // Check if batch direct send
1702
+ if (isDirectSendNotificationOptions(options) && Array.isArray(options.deviceHandle)) {
1703
+ endpoint.pathname += "$batch";
1704
+ }
1705
+ // Check for test send
1706
+ if (isSendNotificationOptions(options) && options.enableTestSend) {
1538
1707
  endpoint.searchParams.append("test", "true");
1539
1708
  }
1540
- const headers = await context.createHeaders(method);
1541
- if (notification.headers) {
1542
- for (const headerName of Object.keys(notification.headers)) {
1543
- headers.set(headerName, notification.headers[headerName]);
1544
- }
1709
+ const headers = await context.createHeaders("sendNotification", notification.headers);
1710
+ headers.set("ServiceBusNotification-Format", notification.platform);
1711
+ let body = notification.body;
1712
+ let contentType = notification.contentType;
1713
+ // Check for direct batch send
1714
+ if (isDirectSendNotificationOptions(options) && Array.isArray(options.deviceHandle)) {
1715
+ endpoint.searchParams.append("direct", "true");
1716
+ const boundary = `nh-boundary-${uuid.v4()}`;
1717
+ contentType = `multipart/mixed; boundary = "${boundary}"`;
1718
+ body = createMultipartDirectNotification(boundary, notification, options.deviceHandle);
1545
1719
  }
1546
- if (pushHandle) {
1720
+ else if (isDirectSendNotificationOptions(options)) {
1547
1721
  endpoint.searchParams.append("direct", "true");
1548
1722
  if (notification.platform === "browser") {
1549
- const browserHandle = pushHandle;
1723
+ const browserHandle = options.deviceHandle;
1550
1724
  headers.set("ServiceBusNotification-DeviceHandle", browserHandle.endpoint);
1551
1725
  headers.set("Auth", browserHandle.auth);
1552
1726
  headers.set("P256DH", browserHandle.p256dh);
1553
1727
  }
1554
1728
  else {
1555
- headers.set("ServiceBusNotification-DeviceHandle", pushHandle);
1729
+ headers.set("ServiceBusNotification-DeviceHandle", options.deviceHandle);
1556
1730
  }
1557
1731
  }
1558
- headers.set("Content-Type", notification.contentType);
1559
- headers.set("ServiceBusNotification-Format", notification.platform);
1560
- if (tags) {
1561
- let tagExpression = null;
1562
- if (Array.isArray(tags)) {
1563
- tagExpression = tags.join("||");
1564
- }
1565
- else {
1566
- tagExpression = tags;
1732
+ else if (isSendNotificationOptions(options)) {
1733
+ if (options.tagExpression) {
1734
+ headers.set("ServiceBusNotification-Tags", options.tagExpression);
1567
1735
  }
1568
- headers.set("ServiceBusNotification-Tags", tagExpression);
1569
1736
  }
1737
+ headers.set("Content-Type", contentType);
1738
+ headers.set("ServiceBusNotification-Format", notification.platform);
1570
1739
  const request = createRequest(endpoint, "POST", headers, updatedOptions);
1571
- request.body = notification.body;
1740
+ request.body = body;
1572
1741
  const response = await sendRequest(context, request, 201);
1573
1742
  return parseNotificationSendResponse(response);
1574
1743
  });
1575
1744
  }
1576
1745
 
1577
- // Copyright (c) Microsoft Corporation.
1578
- /**
1579
- * Sends push notifications to all devices on the Notification Hub.
1580
- * @param context - The Notification Hubs client.
1581
- * @param notification - The notification to send to all devices.
1582
- * @param options - Configuration options for the direct send operation which can contain custom headers
1583
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1584
- * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1585
- */
1586
- function sendBroadcastNotification(context, notification, options = {}) {
1587
- return sendNotificationPayload(context, notification, "sendNotification", undefined, undefined, options);
1588
- }
1589
-
1590
- // Copyright (c) Microsoft Corporation.
1591
- /**
1592
- * Sends a direct push notification to a device with the given push handle.
1593
- * @param context - The Notification Hubs client.
1594
- * @param pushHandle - The push handle which is the unique identifier for the device.
1595
- * @param notification - The notification to send to the device.
1596
- * @param options - The options for sending a direct notification.
1597
- * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1598
- */
1599
- function sendDirectNotification(context, pushHandle, notification, options = {}) {
1600
- return sendNotificationPayload(context, notification, "sendDirectNotification", pushHandle, undefined, options);
1601
- }
1602
-
1603
- // Copyright (c) Microsoft Corporation.
1604
- /**
1605
- * Sends push notifications to devices that match the given tags or tag expression.
1606
- * @param context - The Notification Hubs client.
1607
- * @param tags - The tags used to target the device for push notifications in either an array or tag expression.
1608
- * @param notification - The notification to send to the matching devices.
1609
- * @param options - Configuration options for the direct send operation which can contain custom headers
1610
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1611
- * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1612
- */
1613
- function sendNotification(context, tags, notification, options = {}) {
1614
- return sendNotificationPayload(context, notification, "sendNotification", undefined, tags, options);
1615
- }
1616
-
1617
- // Copyright (c) Microsoft Corporation.
1618
- const OPERATION_NAME$2 = "submitNotificationHubJob";
1619
- /**
1620
- * Submits a Notification Hub Job.
1621
- * Note: this is available to Standard SKU namespace and above.
1622
- * @param context - The Notification Hubs client.
1623
- * @param job - The notification hub job to submit.
1624
- * @param options - The operation options.
1625
- * @returns The notification hub job details including job ID and status.
1626
- */
1627
- function submitNotificationHubJob(context, job, options = {}) {
1628
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$2}`, options, async (updatedOptions) => {
1629
- const endpoint = context.requestUrl();
1630
- endpoint.pathname += "/jobs";
1631
- const headers = await context.createHeaders(OPERATION_NAME$2);
1632
- headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
1633
- const request = createRequest(endpoint, "POST", headers, updatedOptions);
1634
- request.body = serializeNotificationHubJobEntry(job);
1635
- const response = await sendRequest(context, request, 201);
1636
- return parseNotificationHubJobEntry(response.bodyAsText);
1637
- });
1638
- }
1639
-
1640
1746
  // Copyright (c) Microsoft Corporation.
1641
1747
  const OPERATION_NAME$1 = "updateInstallation";
1642
1748
  /**
@@ -1648,7 +1754,7 @@ const OPERATION_NAME$1 = "updateInstallation";
1648
1754
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1649
1755
  */
1650
1756
  function updateInstallation(context, installationId, installationPatches, options = {}) {
1651
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME$1}`, options, async (updatedOptions) => {
1757
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME$1}`, options, async (updatedOptions) => {
1652
1758
  const endpoint = context.requestUrl();
1653
1759
  endpoint.pathname += `/installations/${installationId}`;
1654
1760
  const headers = await context.createHeaders(OPERATION_NAME$1);
@@ -1670,7 +1776,7 @@ const OPERATION_NAME = "updateRegistration";
1670
1776
  * @returns The updated registration description.
1671
1777
  */
1672
1778
  function updateRegistration(context, registration, options = {}) {
1673
- return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options, async (updatedOptions) => {
1779
+ return tracingClient.withSpan(`NotificationHubsClientContext.${OPERATION_NAME}`, options, async (updatedOptions) => {
1674
1780
  if (!registration.etag) {
1675
1781
  throw new coreRestPipeline.RestError("ETag is required for registration update", { statusCode: 400 });
1676
1782
  }
@@ -1678,12 +1784,54 @@ function updateRegistration(context, registration, options = {}) {
1678
1784
  });
1679
1785
  }
1680
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
+
1681
1829
  // Copyright (c) Microsoft Corporation.
1682
1830
  /**
1683
1831
  * This represents a client for Azure Notification Hubs to manage installations and send
1684
1832
  * messages to devices.
1685
1833
  */
1686
- class NotificationHubsServiceClient {
1834
+ class NotificationHubsClient {
1687
1835
  /**
1688
1836
  * Creates a new instance of the NotificationClient with a connection string, hub name and options.
1689
1837
  * @param connectionString - The Notification Hub Access Policy connection string.
@@ -1787,12 +1935,21 @@ class NotificationHubsServiceClient {
1787
1935
  }
1788
1936
  /**
1789
1937
  * Gets all registrations for the notification hub with the given query options.
1790
- * @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.
1791
1939
  * @returns A paged async iterable containing all of the registrations for the notification hub.
1792
1940
  */
1793
1941
  listRegistrations(options = {}) {
1794
1942
  return listRegistrations(this._client, options);
1795
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
+ }
1796
1953
  /**
1797
1954
  * Lists all registrations with the matching tag.
1798
1955
  * @param tag - The tag to query for matching registrations.
@@ -1802,61 +1959,25 @@ class NotificationHubsServiceClient {
1802
1959
  listRegistrationsByTag(tag, options = {}) {
1803
1960
  return listRegistrationsByTag(this._client, tag, options);
1804
1961
  }
1805
- /**
1806
- * Sends a direct push notification to a device with the given push handle.
1807
- * @param pushHandle - The push handle which is the unique identifier for the device.
1808
- * @param notification - The notification to send to the device.
1809
- * @param options - The options for sending a direct notification.
1810
- * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1811
- */
1812
- sendDirectNotification(pushHandle, notification, options = {}) {
1813
- return sendDirectNotification(this._client, pushHandle, notification, options);
1814
- }
1815
1962
  /**
1816
1963
  * Sends push notifications to devices that match the given tags or tag expression.
1817
- * @param tags - The tags used to target the device for push notifications in either an array or tag expression.
1818
1964
  * @param notification - The notification to send to the matching devices.
1819
- * @param options - Configuration options for the direct send operation which can contain custom headers
1820
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1821
- * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1822
- */
1823
- sendNotification(tags, notification, options = {}) {
1824
- return sendNotification(this._client, tags, notification, options);
1825
- }
1826
- /**
1827
- * Sends push notifications to all devices on the Notification Hub.
1828
- * @param notification - The notification to send to all devices.
1829
- * @param options - Configuration options for the direct send operation which can contain custom headers
1830
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1965
+ * @param options - Options for the notification including tags, device handles and whether to enable test send.
1831
1966
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1832
1967
  */
1833
- sendBroadcastNotification(notification, options = {}) {
1834
- return sendBroadcastNotification(this._client, notification, options);
1968
+ sendNotification(notification, options = { enableTestSend: false }) {
1969
+ return sendNotification(this._client, notification, options);
1835
1970
  }
1836
1971
  /**
1837
1972
  * Schedules a push notification to devices that match the given tags or tag expression at the specified time.
1838
1973
  * NOTE: This is only available in Standard SKU Azure Notification Hubs.
1839
1974
  * @param scheduledTime - The Date to send the push notification.
1840
- * @param tags - The tags used to target the device for push notifications in either an array or tag expression.
1841
1975
  * @param notification - The notification to send to the matching devices.
1842
- * @param options - Configuration options for the direct send operation which can contain custom headers
1843
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1976
+ * @param options - Options which include tags used to target the device for push notifications in either an array or tag expression.
1844
1977
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1845
1978
  */
1846
- scheduleNotification(scheduledTime, tags, notification, options = {}) {
1847
- return scheduleNotification(this._client, scheduledTime, tags, notification, options);
1848
- }
1849
- /**
1850
- * Schedules a push notification to all devices registered on the Notification Hub.
1851
- * NOTE: This is only available in Standard SKU Azure Notification Hubs.
1852
- * @param scheduledTime - The Date to send the push notification.
1853
- * @param notification - The notification to send to the matching devices.
1854
- * @param options - Configuration options for the direct send operation which can contain custom headers
1855
- * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
1856
- * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
1857
- */
1858
- scheduleBroadcastNotification(scheduledTime, notification, options = {}) {
1859
- return scheduleBroadcastNotification(this._client, scheduledTime, notification, options);
1979
+ scheduleNotification(scheduledTime, notification, options = {}) {
1980
+ return scheduleNotification(this._client, scheduledTime, notification, options);
1860
1981
  }
1861
1982
  /**
1862
1983
  * Cancels the scheduled notification with the given notification ID.
@@ -1895,6 +2016,15 @@ class NotificationHubsServiceClient {
1895
2016
  getNotificationHubJob(jobId, options = {}) {
1896
2017
  return getNotificationHubJob(this._client, jobId, options);
1897
2018
  }
2019
+ /**
2020
+ * Submits a Notification Hub job and creates a poller to poll for results.
2021
+ * @param notificationHubJob - The Notification Hub import/export job to start.
2022
+ * @param options - The operation options.
2023
+ * @returns A poller which can be called to poll until completion of the job.
2024
+ */
2025
+ beginSubmitNotificationHubJob(notificationHubJob, options = {}) {
2026
+ return beginSubmitNotificationHubJob(this._client, notificationHubJob, options);
2027
+ }
1898
2028
  /**
1899
2029
  * Submits a Notification Hub Job. Note this is available to Standard SKU namespace and above.
1900
2030
  * @param job - The notification hub job to submit.
@@ -2068,168 +2198,49 @@ function createWindowsRawNotification(notification) {
2068
2198
  }
2069
2199
 
2070
2200
  // Copyright (c) Microsoft Corporation.
2071
- function createAppleNativeAlert(nativeAlert) {
2072
- if (!isDefined(nativeAlert)) {
2073
- return undefined;
2074
- }
2075
- if (isString(nativeAlert)) {
2076
- return nativeAlert;
2077
- }
2078
- const alert = {
2079
- title: nativeAlert.title,
2080
- subtitle: nativeAlert.subtitle,
2081
- body: nativeAlert.body,
2082
- "launch-image": nativeAlert.launchImage,
2083
- "title-loc-key": nativeAlert.titleLocKey,
2084
- "title-loc-args": nativeAlert.titleLocArgs,
2085
- "subtitle-loc-key": nativeAlert.subtitleLocKey,
2086
- "subtitle-loc-args": nativeAlert.subtitleLocArgs,
2087
- "loc-key": nativeAlert.locKey,
2088
- "loc-args": nativeAlert.locArgs,
2089
- };
2090
- return alert;
2091
- }
2092
2201
  /**
2093
2202
  * Creates an APNs native message to send to Notification Hubs.
2094
2203
  * @param nativeMessage - The Apple native message properties to set.
2095
2204
  * @param additionalProperties - Additional properties for Apple messages.
2096
2205
  * @returns An AppleNotification to send to Notification Hubs.
2097
2206
  */
2098
- function buildAppleNativeMessage(nativeMessage, additionalProperties) {
2099
- const headers = {};
2100
- const message = Object.assign({ aps: {
2101
- alert: createAppleNativeAlert(nativeMessage.alert),
2102
- sound: nativeMessage.sound,
2103
- badge: nativeMessage.badge,
2104
- "thread-id": nativeMessage.threadId,
2105
- category: nativeMessage.category,
2106
- "content-available": nativeMessage.contentAvailable,
2107
- "mutable-content": nativeMessage.mutableContent,
2108
- "target-content-id": nativeMessage.targetContentId,
2109
- "interruption-level": nativeMessage.interruptionLevel,
2110
- "relevance-score": nativeMessage.relevanceScore,
2111
- "filter-criteria": nativeMessage.filterCriteria,
2112
- } }, additionalProperties);
2113
- const apnsPriority = (nativeMessage === null || nativeMessage === void 0 ? void 0 : nativeMessage.contentAvailable) === 1 ? "5" : "10";
2114
- headers["apns-priority"] = apnsPriority;
2115
- return createAppleNotification({
2116
- body: JSON.stringify(message),
2117
- headers: headers,
2118
- });
2119
- }
2120
- function buildFcmLegacyNativePayload(nativeNotification) {
2121
- if (!isDefined(nativeNotification)) {
2122
- return undefined;
2123
- }
2124
- const androidMessage = nativeNotification;
2125
- const appleMessage = nativeNotification;
2126
- const notification = {
2127
- title: nativeNotification.title,
2128
- body: nativeNotification.body,
2129
- click_action: nativeNotification.clickAction,
2130
- // Apple/Android fields
2131
- sound: appleMessage.sound,
2132
- badge: appleMessage.badge,
2133
- subtitle: appleMessage.subtitle,
2134
- body_loc_key: appleMessage.bodyLocKey,
2135
- body_loc_args: appleMessage.bodyLocArgs,
2136
- title_loc_key: appleMessage.bodyLocKey,
2137
- title_loc_args: appleMessage.bodyLocArgs,
2138
- // Android/Web fields
2139
- android_channel_id: androidMessage.androidChannelId,
2140
- icon: androidMessage.icon,
2141
- tag: androidMessage.tag,
2142
- color: androidMessage.color,
2143
- };
2144
- return notification;
2207
+ function createAppleNotificationBody(nativeMessage) {
2208
+ return JSON.stringify(nativeMessage);
2145
2209
  }
2146
2210
  /**
2147
2211
  * Creates a FcmLegacyNotification from a native Firebase payload.
2148
2212
  * @param nativeMessage - The native message payload to send to Notification Hubs.
2149
- * @returns The FcmLegacyNotification to send to Notification Hubs.
2150
- */
2151
- function buildFirebaseLegacyNativeMessage(nativeMessage) {
2152
- const jsonMessage = {
2153
- to: nativeMessage.to,
2154
- registration_ids: nativeMessage.registrationIds,
2155
- condition: nativeMessage.condition,
2156
- collapse_key: nativeMessage.collapseKey,
2157
- priority: nativeMessage.priority,
2158
- content_available: nativeMessage.contentAvailable,
2159
- mutable_content: nativeMessage.mutableContent,
2160
- time_to_live: nativeMessage.timeToLive,
2161
- restricted_package_name: nativeMessage.restrictedPackageName,
2162
- dry_run: nativeMessage.dryRun,
2163
- data: nativeMessage.data,
2164
- notification: buildFcmLegacyNativePayload(nativeMessage.notification),
2165
- };
2166
- return createFcmLegacyNotification({
2167
- body: JSON.stringify(jsonMessage),
2168
- });
2169
- }
2170
- function buildAdmNativeNotification(nativeNotification) {
2171
- if (!isDefined(nativeNotification)) {
2172
- return undefined;
2173
- }
2174
- return {
2175
- title: nativeNotification.title,
2176
- body: nativeNotification.body,
2177
- icon: nativeNotification.icon,
2178
- color: nativeNotification.color,
2179
- sound: nativeNotification.sound,
2180
- tag: nativeNotification.tag,
2181
- click_action: nativeNotification.clickAction,
2182
- body_loc_key: nativeNotification.bodyLocKey,
2183
- body_loc_args: nativeNotification.bodyLocArgs,
2184
- title_loc_key: nativeNotification.titleLocKey,
2185
- title_loc_args: nativeNotification.titleLocArgs,
2186
- channel_id: nativeNotification.channelId,
2187
- ticker: nativeNotification.ticker,
2188
- sticky: nativeNotification.sticky,
2189
- event_time: nativeNotification.eventTime,
2190
- local_only: nativeNotification.localOnly,
2191
- notification_priority: nativeNotification.notificationPriority,
2192
- default_sound: nativeNotification.defaultSound,
2193
- visibility: nativeNotification.visibility,
2194
- notification_count: nativeNotification.notificationCount,
2195
- image: nativeNotification.image,
2196
- };
2213
+ * @returns The JSON body to send to Notification Hubs.
2214
+ */
2215
+ function createFirebaseLegacyNotificationBody(nativeMessage) {
2216
+ return JSON.stringify(nativeMessage);
2197
2217
  }
2198
2218
  /**
2199
2219
  * Creates a AdmNotification from a native ADM payload.
2200
2220
  * @param nativeMessage - The native message payload to send to Notification Hubs.
2201
2221
  * @returns The AdmNotification to send to Notification Hubs.
2202
2222
  */
2203
- function buildAdmNativeMessage(nativeMessage) {
2204
- const jsonObj = Object.assign({ notification: buildAdmNativeNotification(nativeMessage.notification), data: nativeMessage.data || {} }, nativeMessage);
2205
- return createAdmNotification({
2206
- body: JSON.stringify(jsonObj),
2207
- });
2223
+ function createAdmNotificationBody(nativeMessage) {
2224
+ return JSON.stringify(nativeMessage);
2208
2225
  }
2209
2226
  /**
2210
2227
  * Creates a BaiduNotification from a native Baidu payload.
2211
2228
  * @param nativeMessage - The native message payload to send to Notification Hubs.
2212
- * @param additionalProperties - Additional properties for Apple Baidu messages.
2213
- * @returns The BaiduNotification to send to Notification Hubs.
2229
+ * @returns The JSON body to send to Notification Hubs.
2214
2230
  */
2215
- function buildBaiduNativeMessage(nativeMessage, additionalProperties) {
2216
- 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);
2217
- return createBaiduNotification({
2218
- body: JSON.stringify(jsonObj),
2219
- });
2231
+ function createBaiduNotificationBody(nativeMessage) {
2232
+ return JSON.stringify(nativeMessage);
2220
2233
  }
2221
2234
  /**
2222
2235
  * Builds a WindowsNotification from a Windows Badge.
2223
2236
  * @param nativeMessage - The Windows Badge Message to build.
2224
- * @returns A WindowsNotification created with the badge information.
2237
+ * @returns The WNS XML created with the badge information.
2225
2238
  */
2226
- function buildWindowsBadgeNativeMessage(nativeMessage) {
2239
+ function createWindowsBadgeNotificationBody(nativeMessage) {
2227
2240
  const badge = {
2228
2241
  $: { value: nativeMessage.value },
2229
2242
  };
2230
- return createWindowsBadgeNotification({
2231
- body: coreXml.stringifyXML(badge, { rootName: "badge" }),
2232
- });
2243
+ return coreXml.stringifyXML(badge, { rootName: "badge" });
2233
2244
  }
2234
2245
 
2235
2246
  // Copyright (c) Microsoft Corporation.
@@ -2240,7 +2251,7 @@ function buildWindowsBadgeNativeMessage(nativeMessage) {
2240
2251
  * @returns A created ADM registration description.
2241
2252
  */
2242
2253
  function createAdmRegistrationDescription(description) {
2243
- return Object.assign(Object.assign({}, description), { type: "Adm" });
2254
+ return Object.assign(Object.assign({}, description), { kind: "Adm" });
2244
2255
  }
2245
2256
  /**
2246
2257
  * Creates an ADM template registration description.
@@ -2248,7 +2259,7 @@ function createAdmRegistrationDescription(description) {
2248
2259
  * @returns A created ADM template registration description.
2249
2260
  */
2250
2261
  function createAdmTemplateRegistrationDescription(description) {
2251
- return Object.assign(Object.assign({}, description), { type: "AdmTemplate" });
2262
+ return Object.assign(Object.assign({}, description), { kind: "AdmTemplate" });
2252
2263
  }
2253
2264
  /**
2254
2265
  * Creates an Apple registration description.
@@ -2256,7 +2267,7 @@ function createAdmTemplateRegistrationDescription(description) {
2256
2267
  * @returns A created Apple registration description.
2257
2268
  */
2258
2269
  function createAppleRegistrationDescription(description) {
2259
- return Object.assign(Object.assign({}, description), { type: "Apple" });
2270
+ return Object.assign(Object.assign({}, description), { kind: "Apple" });
2260
2271
  }
2261
2272
  /**
2262
2273
  * Creates an Apple template registration description.
@@ -2264,7 +2275,7 @@ function createAppleRegistrationDescription(description) {
2264
2275
  * @returns A created Apple template registration description.
2265
2276
  */
2266
2277
  function createAppleTemplateRegistrationDescription(description) {
2267
- return Object.assign(Object.assign({}, description), { type: "AppleTemplate" });
2278
+ return Object.assign(Object.assign({}, description), { kind: "AppleTemplate" });
2268
2279
  }
2269
2280
  /**
2270
2281
  * Creates a Baidu registration description.
@@ -2272,7 +2283,7 @@ function createAppleTemplateRegistrationDescription(description) {
2272
2283
  * @returns A created Baidu registration description.
2273
2284
  */
2274
2285
  function createBaiduRegistrationDescription(description) {
2275
- return Object.assign(Object.assign({}, description), { type: "Baidu" });
2286
+ return Object.assign(Object.assign({}, description), { kind: "Baidu" });
2276
2287
  }
2277
2288
  /**
2278
2289
  * Creates a Baidu template registration description.
@@ -2280,7 +2291,7 @@ function createBaiduRegistrationDescription(description) {
2280
2291
  * @returns A created Baidu template registration description.
2281
2292
  */
2282
2293
  function createBaiduTemplateRegistrationDescription(description) {
2283
- return Object.assign(Object.assign({}, description), { type: "BaiduTemplate" });
2294
+ return Object.assign(Object.assign({}, description), { kind: "BaiduTemplate" });
2284
2295
  }
2285
2296
  /**
2286
2297
  * Creates a Web Push registration description.
@@ -2288,7 +2299,7 @@ function createBaiduTemplateRegistrationDescription(description) {
2288
2299
  * @returns A created Web Push registration description.
2289
2300
  */
2290
2301
  function createBrowserRegistrationDescription(description) {
2291
- return Object.assign(Object.assign({}, description), { type: "Browser" });
2302
+ return Object.assign(Object.assign({}, description), { kind: "Browser" });
2292
2303
  }
2293
2304
  /**
2294
2305
  * Creates a Web Push registration description.
@@ -2296,7 +2307,7 @@ function createBrowserRegistrationDescription(description) {
2296
2307
  * @returns A created Web Push template registration description.
2297
2308
  */
2298
2309
  function createBrowserTemplateRegistrationDescription(description) {
2299
- return Object.assign(Object.assign({}, description), { type: "BrowserTemplate" });
2310
+ return Object.assign(Object.assign({}, description), { kind: "BrowserTemplate" });
2300
2311
  }
2301
2312
  /**
2302
2313
  * Creates a Firebase Legacy registration description.
@@ -2304,7 +2315,7 @@ function createBrowserTemplateRegistrationDescription(description) {
2304
2315
  * @returns A created GCM registration description.
2305
2316
  */
2306
2317
  function createFcmLegacyRegistrationDescription(description) {
2307
- return Object.assign(Object.assign({}, description), { type: "Gcm" });
2318
+ return Object.assign(Object.assign({}, description), { kind: "Gcm" });
2308
2319
  }
2309
2320
  /**
2310
2321
  * Creates a GCM template registration description.
@@ -2312,7 +2323,7 @@ function createFcmLegacyRegistrationDescription(description) {
2312
2323
  * @returns A created GCM template registration description.
2313
2324
  */
2314
2325
  function createFcmLegacyTemplateRegistrationDescription(description) {
2315
- return Object.assign(Object.assign({}, description), { type: "GcmTemplate" });
2326
+ return Object.assign(Object.assign({}, description), { kind: "GcmTemplate" });
2316
2327
  }
2317
2328
  /**
2318
2329
  * Creates a Windows registration description.
@@ -2320,7 +2331,7 @@ function createFcmLegacyTemplateRegistrationDescription(description) {
2320
2331
  * @returns A created Windows registration description.
2321
2332
  */
2322
2333
  function createWindowsRegistrationDescription(description) {
2323
- return Object.assign(Object.assign({}, description), { type: "Windows" });
2334
+ return Object.assign(Object.assign({}, description), { kind: "Windows" });
2324
2335
  }
2325
2336
  /**
2326
2337
  * Creates a Windows template registration description.
@@ -2328,25 +2339,34 @@ function createWindowsRegistrationDescription(description) {
2328
2339
  * @returns A created Windows template registration description.
2329
2340
  */
2330
2341
  function createWindowsTemplateRegistrationDescription(description) {
2331
- 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("||");
2332
2354
  }
2333
2355
 
2334
- exports.NotificationHubsServiceClient = NotificationHubsServiceClient;
2335
- exports.buildAdmNativeMessage = buildAdmNativeMessage;
2336
- exports.buildAppleNativeMessage = buildAppleNativeMessage;
2337
- exports.buildBaiduNativeMessage = buildBaiduNativeMessage;
2338
- exports.buildFirebaseLegacyNativeMessage = buildFirebaseLegacyNativeMessage;
2339
- exports.buildWindowsBadgeNativeMessage = buildWindowsBadgeNativeMessage;
2356
+ exports.NotificationHubsClient = NotificationHubsClient;
2340
2357
  exports.createAdmInstallation = createAdmInstallation;
2341
2358
  exports.createAdmNotification = createAdmNotification;
2359
+ exports.createAdmNotificationBody = createAdmNotificationBody;
2342
2360
  exports.createAdmRegistrationDescription = createAdmRegistrationDescription;
2343
2361
  exports.createAdmTemplateRegistrationDescription = createAdmTemplateRegistrationDescription;
2344
2362
  exports.createAppleInstallation = createAppleInstallation;
2345
2363
  exports.createAppleNotification = createAppleNotification;
2364
+ exports.createAppleNotificationBody = createAppleNotificationBody;
2346
2365
  exports.createAppleRegistrationDescription = createAppleRegistrationDescription;
2347
2366
  exports.createAppleTemplateRegistrationDescription = createAppleTemplateRegistrationDescription;
2348
2367
  exports.createBaiduInstallation = createBaiduInstallation;
2349
2368
  exports.createBaiduNotification = createBaiduNotification;
2369
+ exports.createBaiduNotificationBody = createBaiduNotificationBody;
2350
2370
  exports.createBaiduRegistrationDescription = createBaiduRegistrationDescription;
2351
2371
  exports.createBaiduTemplateRegistrationDescription = createBaiduTemplateRegistrationDescription;
2352
2372
  exports.createBrowserInstallation = createBrowserInstallation;
@@ -2357,8 +2377,11 @@ exports.createFcmLegacyInstallation = createFcmLegacyInstallation;
2357
2377
  exports.createFcmLegacyNotification = createFcmLegacyNotification;
2358
2378
  exports.createFcmLegacyRegistrationDescription = createFcmLegacyRegistrationDescription;
2359
2379
  exports.createFcmLegacyTemplateRegistrationDescription = createFcmLegacyTemplateRegistrationDescription;
2380
+ exports.createFirebaseLegacyNotificationBody = createFirebaseLegacyNotificationBody;
2381
+ exports.createTagExpression = createTagExpression;
2360
2382
  exports.createTemplateNotification = createTemplateNotification;
2361
2383
  exports.createWindowsBadgeNotification = createWindowsBadgeNotification;
2384
+ exports.createWindowsBadgeNotificationBody = createWindowsBadgeNotificationBody;
2362
2385
  exports.createWindowsInstallation = createWindowsInstallation;
2363
2386
  exports.createWindowsRawNotification = createWindowsRawNotification;
2364
2387
  exports.createWindowsRegistrationDescription = createWindowsRegistrationDescription;