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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +86 -78
  2. package/dist/index.cjs +321 -369
  3. package/dist/index.cjs.map +1 -1
  4. package/dist-esm/src/{client → api}/beginSubmitNotificationHubJob.js +0 -0
  5. package/dist-esm/src/api/beginSubmitNotificationHubJob.js.map +1 -0
  6. package/dist-esm/src/{client → api}/cancelScheduledNotification.js +0 -0
  7. package/dist-esm/src/api/cancelScheduledNotification.js.map +1 -0
  8. package/dist-esm/src/{client → api}/createOrUpdateInstallation.js +0 -0
  9. package/dist-esm/src/api/createOrUpdateInstallation.js.map +1 -0
  10. package/dist-esm/src/{client → api}/createOrUpdateRegistration.js +0 -0
  11. package/dist-esm/src/api/createOrUpdateRegistration.js.map +1 -0
  12. package/dist-esm/src/{client → api}/createRegistration.js +0 -0
  13. package/dist-esm/src/api/createRegistration.js.map +1 -0
  14. package/dist-esm/src/{client → api}/createRegistrationId.js +8 -0
  15. package/dist-esm/src/api/createRegistrationId.js.map +1 -0
  16. package/dist-esm/src/{client → api}/deleteInstallation.js +0 -0
  17. package/dist-esm/src/api/deleteInstallation.js.map +1 -0
  18. package/dist-esm/src/{client → api}/deleteRegistration.js +0 -0
  19. package/dist-esm/src/api/deleteRegistration.js.map +1 -0
  20. package/dist-esm/src/{client → api}/getFeedbackContainerUrl.js +0 -0
  21. package/dist-esm/src/api/getFeedbackContainerUrl.js.map +1 -0
  22. package/dist-esm/src/{client → api}/getInstallation.js +0 -0
  23. package/dist-esm/src/api/getInstallation.js.map +1 -0
  24. package/dist-esm/src/{client → api}/getNotificationHubJob.js +0 -0
  25. package/dist-esm/src/api/getNotificationHubJob.js.map +1 -0
  26. package/dist-esm/src/{client → api}/getNotificationOutcomeDetails.js +0 -0
  27. package/dist-esm/src/api/getNotificationOutcomeDetails.js.map +1 -0
  28. package/dist-esm/src/{client → api}/getRegistration.js +0 -0
  29. package/dist-esm/src/api/getRegistration.js.map +1 -0
  30. package/dist-esm/src/{client → api}/index.js +22 -0
  31. package/dist-esm/src/api/index.js.map +1 -0
  32. package/dist-esm/src/{client → api}/internal/_client.js +1 -1
  33. package/dist-esm/src/api/internal/_client.js.map +1 -0
  34. package/dist-esm/src/{client → api}/internal/_createOrUpdateRegistrationDescription.js +0 -0
  35. package/dist-esm/src/api/internal/_createOrUpdateRegistrationDescription.js.map +1 -0
  36. package/dist-esm/src/{client/listRegistrations.js → api/internal/_listRegistrations.js} +6 -38
  37. package/dist-esm/src/api/internal/_listRegistrations.js.map +1 -0
  38. package/dist-esm/src/{client → api}/listNotificationHubJobs.js +0 -0
  39. package/dist-esm/src/api/listNotificationHubJobs.js.map +1 -0
  40. package/dist-esm/src/api/listRegistrations.js +35 -0
  41. package/dist-esm/src/api/listRegistrations.js.map +1 -0
  42. package/dist-esm/src/api/listRegistrationsByChannel.js +58 -0
  43. package/dist-esm/src/api/listRegistrationsByChannel.js.map +1 -0
  44. package/dist-esm/src/{client → api}/listRegistrationsByTag.js +0 -0
  45. package/dist-esm/src/api/listRegistrationsByTag.js.map +1 -0
  46. package/dist-esm/src/{client → api}/scheduleNotification.js +2 -3
  47. package/dist-esm/src/api/scheduleNotification.js.map +1 -0
  48. package/dist-esm/src/{client → api}/sendNotification.js +3 -3
  49. package/dist-esm/src/api/sendNotification.js.map +1 -0
  50. package/dist-esm/src/{client → api}/submitNotificationHubJob.js +0 -0
  51. package/dist-esm/src/api/submitNotificationHubJob.js.map +1 -0
  52. package/dist-esm/src/{client → api}/updateInstallation.js +0 -0
  53. package/dist-esm/src/api/updateInstallation.js.map +1 -0
  54. package/dist-esm/src/{client → api}/updateRegistration.js +0 -0
  55. package/dist-esm/src/api/updateRegistration.js.map +1 -0
  56. package/dist-esm/src/index.js +3 -2
  57. package/dist-esm/src/index.js.map +1 -1
  58. package/dist-esm/src/models/index.js +12 -0
  59. package/dist-esm/src/models/index.js.map +1 -0
  60. package/dist-esm/src/models/installation.js.map +1 -1
  61. package/dist-esm/src/models/notification.js.map +1 -1
  62. package/dist-esm/src/models/notificationBodyBuilder.js +48 -0
  63. package/dist-esm/src/models/notificationBodyBuilder.js.map +1 -0
  64. package/dist-esm/src/models/notificationDetails.js.map +1 -1
  65. package/dist-esm/src/models/options.js.map +1 -1
  66. package/dist-esm/src/models/registration.js +12 -12
  67. package/dist-esm/src/models/registration.js.map +1 -1
  68. package/dist-esm/src/models/tagExpressionBuilder.js +11 -0
  69. package/dist-esm/src/models/tagExpressionBuilder.js.map +1 -0
  70. package/dist-esm/src/notificationHubsClient.js +34 -24
  71. package/dist-esm/src/notificationHubsClient.js.map +1 -1
  72. package/dist-esm/src/serializers/notificationDetailsSerializer.js +1 -0
  73. package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -1
  74. package/dist-esm/src/serializers/notificationOutcomeSerializer.js +2 -2
  75. package/dist-esm/src/serializers/notificationOutcomeSerializer.js.map +1 -1
  76. package/dist-esm/src/serializers/registrationSerializer.js +17 -16
  77. package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
  78. package/dist-esm/src/utils/constants.js +1 -1
  79. package/dist-esm/src/utils/constants.js.map +1 -1
  80. package/dist-esm/src/utils/notificationUtils.js +0 -6
  81. package/dist-esm/src/utils/notificationUtils.js.map +1 -1
  82. package/package.json +23 -19
  83. package/types/3.1/notification-hubs.d.ts +420 -249
  84. package/types/latest/notification-hubs.d.ts +448 -254
  85. package/types/latest/tsdoc-metadata.json +1 -1
  86. package/types/src/{client → api}/beginSubmitNotificationHubJob.d.ts +0 -0
  87. package/types/src/api/beginSubmitNotificationHubJob.d.ts.map +1 -0
  88. package/types/src/{client → api}/cancelScheduledNotification.d.ts +0 -0
  89. package/types/src/api/cancelScheduledNotification.d.ts.map +1 -0
  90. package/types/src/{client → api}/createOrUpdateInstallation.d.ts +0 -0
  91. package/types/src/api/createOrUpdateInstallation.d.ts.map +1 -0
  92. package/types/src/{client → api}/createOrUpdateRegistration.d.ts +0 -0
  93. package/types/src/api/createOrUpdateRegistration.d.ts.map +1 -0
  94. package/types/src/{client → api}/createRegistration.d.ts +0 -0
  95. package/types/src/api/createRegistration.d.ts.map +1 -0
  96. package/types/src/{client → api}/createRegistrationId.d.ts +0 -0
  97. package/types/src/api/createRegistrationId.d.ts.map +1 -0
  98. package/types/src/{client → api}/deleteInstallation.d.ts +0 -0
  99. package/types/src/api/deleteInstallation.d.ts.map +1 -0
  100. package/types/src/{client → api}/deleteRegistration.d.ts +0 -0
  101. package/types/src/api/deleteRegistration.d.ts.map +1 -0
  102. package/types/src/{client → api}/getFeedbackContainerUrl.d.ts +0 -0
  103. package/types/src/api/getFeedbackContainerUrl.d.ts.map +1 -0
  104. package/types/src/{client → api}/getInstallation.d.ts +0 -0
  105. package/types/src/api/getInstallation.d.ts.map +1 -0
  106. package/types/src/{client → api}/getNotificationHubJob.d.ts +0 -0
  107. package/types/src/api/getNotificationHubJob.d.ts.map +1 -0
  108. package/types/src/{client → api}/getNotificationOutcomeDetails.d.ts +0 -0
  109. package/types/src/api/getNotificationOutcomeDetails.d.ts.map +1 -0
  110. package/types/src/{client → api}/getRegistration.d.ts +0 -0
  111. package/types/src/api/getRegistration.d.ts.map +1 -0
  112. package/types/src/{client → api}/index.d.ts +22 -0
  113. package/types/src/api/index.d.ts.map +1 -0
  114. package/types/src/{client → api}/internal/_client.d.ts +0 -0
  115. package/types/src/api/internal/_client.d.ts.map +1 -0
  116. package/types/src/{client → api}/internal/_createOrUpdateRegistrationDescription.d.ts +0 -0
  117. package/types/src/api/internal/_createOrUpdateRegistrationDescription.d.ts.map +1 -0
  118. package/types/src/api/internal/_listRegistrations.d.ts +6 -0
  119. package/types/src/api/internal/_listRegistrations.d.ts.map +1 -0
  120. package/types/src/{client → api}/listNotificationHubJobs.d.ts +0 -0
  121. package/types/src/api/listNotificationHubJobs.d.ts.map +1 -0
  122. package/types/src/{client → api}/listRegistrations.d.ts +3 -3
  123. package/types/src/api/listRegistrations.d.ts.map +1 -0
  124. package/types/src/api/listRegistrationsByChannel.d.ts +13 -0
  125. package/types/src/api/listRegistrationsByChannel.d.ts.map +1 -0
  126. package/types/src/{client → api}/listRegistrationsByTag.d.ts +0 -0
  127. package/types/src/api/listRegistrationsByTag.d.ts.map +1 -0
  128. package/types/src/{client → api}/scheduleNotification.d.ts +0 -0
  129. package/types/src/api/scheduleNotification.d.ts.map +1 -0
  130. package/types/src/{client → api}/sendNotification.d.ts +0 -0
  131. package/types/src/api/sendNotification.d.ts.map +1 -0
  132. package/types/src/{client → api}/submitNotificationHubJob.d.ts +0 -0
  133. package/types/src/api/submitNotificationHubJob.d.ts.map +1 -0
  134. package/types/src/{client → api}/updateInstallation.d.ts +0 -0
  135. package/types/src/api/updateInstallation.d.ts.map +1 -0
  136. package/types/src/{client → api}/updateRegistration.d.ts +0 -0
  137. package/types/src/api/updateRegistration.d.ts.map +1 -0
  138. package/types/src/index.d.ts +3 -2
  139. package/types/src/index.d.ts.map +1 -1
  140. package/types/src/models/index.d.ts +10 -0
  141. package/types/src/models/index.d.ts.map +1 -0
  142. package/types/src/models/installation.d.ts +12 -11
  143. package/types/src/models/installation.d.ts.map +1 -1
  144. package/types/src/models/notification.d.ts +10 -18
  145. package/types/src/models/notification.d.ts.map +1 -1
  146. package/types/src/models/{notificationBuilder.d.ts → notificationBodyBuilder.d.ts} +62 -64
  147. package/types/src/models/notificationBodyBuilder.d.ts.map +1 -0
  148. package/types/src/models/notificationDetails.d.ts +9 -9
  149. package/types/src/models/notificationDetails.d.ts.map +1 -1
  150. package/types/src/models/options.d.ts +4 -4
  151. package/types/src/models/options.d.ts.map +1 -1
  152. package/types/src/models/registration.d.ts +235 -69
  153. package/types/src/models/registration.d.ts.map +1 -1
  154. package/types/src/models/tagExpressionBuilder.d.ts +7 -0
  155. package/types/src/models/tagExpressionBuilder.d.ts.map +1 -0
  156. package/types/src/notificationHubsClient.d.ts +12 -5
  157. package/types/src/notificationHubsClient.d.ts.map +1 -1
  158. package/types/src/serializers/notificationDetailsSerializer.d.ts.map +1 -1
  159. package/types/src/serializers/registrationSerializer.d.ts +14 -14
  160. package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
  161. package/types/src/utils/notificationUtils.d.ts +0 -4
  162. package/types/src/utils/notificationUtils.d.ts.map +1 -1
  163. package/dist-esm/src/client/beginSubmitNotificationHubJob.js.map +0 -1
  164. package/dist-esm/src/client/cancelScheduledNotification.js.map +0 -1
  165. package/dist-esm/src/client/createOrUpdateInstallation.js.map +0 -1
  166. package/dist-esm/src/client/createOrUpdateRegistration.js.map +0 -1
  167. package/dist-esm/src/client/createRegistration.js.map +0 -1
  168. package/dist-esm/src/client/createRegistrationId.js.map +0 -1
  169. package/dist-esm/src/client/deleteInstallation.js.map +0 -1
  170. package/dist-esm/src/client/deleteRegistration.js.map +0 -1
  171. package/dist-esm/src/client/getFeedbackContainerUrl.js.map +0 -1
  172. package/dist-esm/src/client/getInstallation.js.map +0 -1
  173. package/dist-esm/src/client/getNotificationHubJob.js.map +0 -1
  174. package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +0 -1
  175. package/dist-esm/src/client/getRegistration.js.map +0 -1
  176. package/dist-esm/src/client/index.js.map +0 -1
  177. package/dist-esm/src/client/internal/_client.js.map +0 -1
  178. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +0 -1
  179. package/dist-esm/src/client/listNotificationHubJobs.js.map +0 -1
  180. package/dist-esm/src/client/listRegistrations.js.map +0 -1
  181. package/dist-esm/src/client/listRegistrationsByTag.js.map +0 -1
  182. package/dist-esm/src/client/scheduleNotification.js.map +0 -1
  183. package/dist-esm/src/client/sendNotification.js.map +0 -1
  184. package/dist-esm/src/client/submitNotificationHubJob.js.map +0 -1
  185. package/dist-esm/src/client/updateInstallation.js.map +0 -1
  186. package/dist-esm/src/client/updateRegistration.js.map +0 -1
  187. package/dist-esm/src/models/notificationBuilder.js +0 -169
  188. package/dist-esm/src/models/notificationBuilder.js.map +0 -1
  189. package/dist-esm/src/utils/retryPolicy.js +0 -144
  190. package/dist-esm/src/utils/retryPolicy.js.map +0 -1
  191. package/types/src/client/beginSubmitNotificationHubJob.d.ts.map +0 -1
  192. package/types/src/client/cancelScheduledNotification.d.ts.map +0 -1
  193. package/types/src/client/createOrUpdateInstallation.d.ts.map +0 -1
  194. package/types/src/client/createOrUpdateRegistration.d.ts.map +0 -1
  195. package/types/src/client/createRegistration.d.ts.map +0 -1
  196. package/types/src/client/createRegistrationId.d.ts.map +0 -1
  197. package/types/src/client/deleteInstallation.d.ts.map +0 -1
  198. package/types/src/client/deleteRegistration.d.ts.map +0 -1
  199. package/types/src/client/getFeedbackContainerUrl.d.ts.map +0 -1
  200. package/types/src/client/getInstallation.d.ts.map +0 -1
  201. package/types/src/client/getNotificationHubJob.d.ts.map +0 -1
  202. package/types/src/client/getNotificationOutcomeDetails.d.ts.map +0 -1
  203. package/types/src/client/getRegistration.d.ts.map +0 -1
  204. package/types/src/client/index.d.ts.map +0 -1
  205. package/types/src/client/internal/_client.d.ts.map +0 -1
  206. package/types/src/client/internal/_createOrUpdateRegistrationDescription.d.ts.map +0 -1
  207. package/types/src/client/listNotificationHubJobs.d.ts.map +0 -1
  208. package/types/src/client/listRegistrations.d.ts.map +0 -1
  209. package/types/src/client/listRegistrationsByTag.d.ts.map +0 -1
  210. package/types/src/client/scheduleNotification.d.ts.map +0 -1
  211. package/types/src/client/sendNotification.d.ts.map +0 -1
  212. package/types/src/client/submitNotificationHubJob.d.ts.map +0 -1
  213. package/types/src/client/updateInstallation.d.ts.map +0 -1
  214. package/types/src/client/updateRegistration.d.ts.map +0 -1
  215. package/types/src/models/notificationBuilder.d.ts.map +0 -1
  216. package/types/src/utils/retryPolicy.d.ts +0 -72
  217. package/types/src/utils/retryPolicy.d.ts.map +0 -1
package/README.md CHANGED
@@ -53,11 +53,11 @@ This SDK for JavaScript offers two ways of interacting with Azure Notification H
53
53
 
54
54
  ```typescript
55
55
  import {
56
- NotificationHubsServiceClient
56
+ NotificationHubsClient,
57
57
  createAppleInstallation
58
58
  } from "@azure/notification-hubs";
59
59
 
60
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
60
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
61
61
 
62
62
  const installation = createAppleInstallation({
63
63
  installationId: "<installation-id>",
@@ -70,24 +70,18 @@ const result = await client.createOrUpdateInstallation(installation);
70
70
 
71
71
  The modular approach allows the developer to pick and choose which functions to import as each method is exposed individually. This approach uses subpath-exports with ES-Modules to expose the methods via direct imports. With the individual exports, this creates a better tree-shaking experience and smaller bundle sizes that the developer can take advantage of.
72
72
 
73
- Note that creating a client is exposed through the `"@azure/notification-hubs/client"` subpath and all client methods are exposed through the `"@azure/notification-hubs/client"` subpath. Each function exported takes the `client` as the first parameter and the rest of the parameters remain unchanged.
73
+ Note that creating a client is exposed through the `"@azure/notification-hubs/api"` subpath and all client methods are exposed through the `"@azure/notification-hubs/api"` subpath. Each function exported takes the `client` as the first parameter and the rest of the parameters remain unchanged.
74
74
 
75
75
  The following subpaths are exposed:
76
76
 
77
- - `@azure/notification-hubs/client` - The main entry point for the client via `createClientContext`
78
- - `@azure/notification-hubs/client/*` - The client methods such as `getInstallation` or `sendNotification`
79
- - `@azure/notification-hubs/models/installation` - The installation models and factory methods.
80
- - `@azure/notification-hubs/models/notification` - The notification models and factory methods.
81
- - `@azure/notification-hubs/models/notificationBuilder` - The notification builder models and factory methods.
82
- - `@azure/notification-hubs/models/options` - The method options such as `SendOperationOptions`.
83
- - `@azure/notification-hubs/models/registration` - The registration models and factory methods.
77
+ - `@azure/notification-hubs/api` - The main entry point for the client via `createClientContext` and client methods such as `getInstallation` or `sendNotification`
78
+ - `@azure/notification-hubs/models` - The Notification Hubs models and factory methods.
84
79
 
85
80
  The above code snippet then becomes the following:
86
81
 
87
82
  ```typescript
88
- import { createClientContext } from "@azure/notification-hubs/client";
89
- import { createAppleInstallation } from "@azure/notification-hubs/models/installation";
90
- import { createOrUpdateInstallation } from "@azure/notification-hubs/client/createOrUpdateInstallation";
83
+ import { createClientContext, createOrUpdateInstallation } from "@azure/notification-hubs/api";
84
+ import { createAppleInstallation } from "@azure/notification-hubs/models";
91
85
 
92
86
  const context = createClientContext("<connection string>", "<hub name>");
93
87
 
@@ -102,22 +96,22 @@ const result = await createOrUpdateInstallation(context, installation);
102
96
 
103
97
  ### Authenticate the client
104
98
 
105
- Interaction with an Azure Notification Hub starts with the `NotificationHubServiceClient` which supports [Shared Access Signature connection strings](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-security). This includes the following permission levels: **Listen**, **Manage**, **Send**.
99
+ Interaction with an Azure Notification Hub starts with the `NotificationHubsClient` which supports [Shared Access Signature connection strings](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-push-notification-security). This includes the following permission levels: **Listen**, **Manage**, **Send**.
106
100
 
107
101
  Listen allows for a client to register itself via the Registration and Installations API. Send allows for the client to send notifications to devices using the send APIs. Finally, Manage allows the user to do Registration and Installation management, such as queries.
108
102
 
109
- A new `NotificationHubServiceClient` client can be created using the constructor with the connection string and Notification Hub name.
103
+ A new `NotificationHubsClient` client can be created using the constructor with the connection string and Notification Hub name.
110
104
 
111
105
  ```typescript
112
- import { NotificationHubServiceClient } from "@azure/notification-hubs";
106
+ import { NotificationHubsClient } from "@azure/notification-hubs";
113
107
 
114
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
108
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
115
109
  ```
116
110
 
117
- Using the modular approach, the `createClientContext` can be imported via the `"@azure/notification-hubs/client"` subpath.
111
+ Using the modular approach, the `createClientContext` can be imported via the `"@azure/notification-hubs/api"` subpath.
118
112
 
119
113
  ```typescript
120
- import { createClientContext } from "@azure/notification-hubs/client";
114
+ import { createClientContext } from "@azure/notification-hubs/api";
121
115
 
122
116
  const context = createClientContext("<connection string>", "<hub name>");
123
117
  ```
@@ -145,10 +139,10 @@ Installations are a newer and native JSON approach to device management that con
145
139
  Installations can be created through the `createOrUpdateInstallation` method such as the following:
146
140
 
147
141
  ```typescript
148
- import { NotificationHubServiceClient, createAppleInstallation } from "@azure/notification-hubs";
142
+ import { NotificationHubsClient, createAppleInstallation } from "@azure/notification-hubs";
149
143
  import { v4 as uuid } from "uuid";
150
144
 
151
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
145
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
152
146
 
153
147
  // Create an installation for APNs
154
148
  let installation = createAppleInstallation({
@@ -163,9 +157,8 @@ installation = await client.createOrUpdateInstallation(installation);
163
157
  Using the modular approach, the code would be as follows:
164
158
 
165
159
  ```typescript
166
- import { createClientContext } from "@azure/notification-hubs/client";
167
- import { createAppleInstallation } from "@azure/notification-hubs/models/installation";
168
- import { createOrUpdateInstallation } from "@azure/notification-hubs/client/createOrUpdateInstallation";
160
+ import { createClientContext, createOrUpdateInstallation } from "@azure/notification-hubs/api";
161
+ import { createAppleInstallation } from "@azure/notification-hubs/models";
169
162
  import { v4 as uuid } from "uuid";
170
163
 
171
164
  const context = createClientContext("<connection string>", "<hub name>");
@@ -183,9 +176,9 @@ installation = await createOrUpdateInstallation(context, installation);
183
176
  An update to an installation can be made through the JSON Patch schema such as adding a tag and a user ID using the `updateInstallation` method.
184
177
 
185
178
  ```typescript
186
- import { NotificationHubServiceClient, JsonPatch } from "@azure/notification-hubs";
179
+ import { NotificationHubsClient, JsonPatch } from "@azure/notification-hubs";
187
180
 
188
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
181
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
189
182
 
190
183
  const installationId = "<unique installation ID>";
191
184
 
@@ -200,9 +193,8 @@ const installation = await client.updateInstallation(installationId, updates);
200
193
  Using the modular approach, the code would be as follows:
201
194
 
202
195
  ```typescript
203
- import { createClientContext } from "@azure/notification-hubs/client";
204
- import { JsonPatch, createAppleInstallation } from "@azure/notification-hubs/models/installation";
205
- import { updateInstallation } from "@azure/notification-hubs/client/updateInstallation";
196
+ import { createClientContext, updateInstallation } from "@azure/notification-hubs/api";
197
+ import { JsonPatch } from "@azure/notification-hubs/models";
206
198
 
207
199
  const context = createClientContext("<connection string>", "<hub name>");
208
200
 
@@ -219,9 +211,9 @@ const installation = await updateInstallation(context, installationId, updates);
219
211
  To retrieve an existing installation, use the `getInstallation` method with your existing unique installation ID.
220
212
 
221
213
  ```typescript
222
- import { NotificationHubServiceClient } from "@azure/notification-hubs";
214
+ import { NotificationHubsClient } from "@azure/notification-hubs";
223
215
 
224
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
216
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
225
217
 
226
218
  const installationId = "<unique installation ID>";
227
219
 
@@ -231,8 +223,7 @@ const installation = client.getInstallation(installationId);
231
223
  Using the modular approach, the code would be as follows:
232
224
 
233
225
  ```typescript
234
- import { createClientContext } from "@azure/notification-hubs/client";
235
- import { getInstallation } from "@azure/notification-hubs/client/getInstallation";
226
+ import { createClientContext, getInstallation } from "@azure/notification-hubs/api";
236
227
 
237
228
  const context = createClientContext("<connection string>", "<hub name>");
238
229
 
@@ -249,11 +240,11 @@ An installation may be created in one of two ways, first by getting a registrati
249
240
 
250
241
  ```typescript
251
242
  import {
252
- NotificationHubServiceClient,
243
+ NotificationHubsClient,
253
244
  createAppleRegistrationDescription,
254
245
  } from "@azure/notification-hubs";
255
246
 
256
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
247
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
257
248
 
258
249
  let registration = createAppleRegistrationDescription({
259
250
  deviceToken: "00fc13adff785122b4ad28809a3420982341241421348097878e577c991de8f0",
@@ -268,9 +259,8 @@ console.log(`New Registration ID: ${registration.registrationId}`);
268
259
  Using the modular approach, the code would be as follows:
269
260
 
270
261
  ```typescript
271
- import { createClientContext } from "@azure/notification-hubs/client";
272
- import { createAppleRegistrationDescription } from "@azure/notification-hubs/models/registration";
273
- import { createRegistration } from "@azure/notification-hubs/client/createRegistration";
262
+ import { createClientContext, createRegistration } from "@azure/notification-hubs/api";
263
+ import { createAppleRegistrationDescription } from "@azure/notification-hubs/models";
274
264
 
275
265
  const context = createClientContext("<connection string>", "<hub name>");
276
266
 
@@ -287,9 +277,9 @@ console.log(`New Registration ID: ${registration.registrationId}`);
287
277
  Updates can be done via the `updateRegistration` method but unlike installations, does not support incremental updates. Querying for an existing registration can be done with the `getRegistration` method.
288
278
 
289
279
  ```typescript
290
- import { NotificationHubServiceClient } from "@azure/notification-hubs";
280
+ import { NotificationHubsClient } from "@azure/notification-hubs";
291
281
 
292
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
282
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
293
283
 
294
284
  const registrationId = "<unique Registration ID>";
295
285
 
@@ -303,9 +293,11 @@ registration = await client.updateRegistration(registration);
303
293
  Using the modular approach, the code would be as follows:
304
294
 
305
295
  ```typescript
306
- import { createClientContext } from "@azure/notification-hubs/client";
307
- import { getRegistration } from "@azure/notification-hubs/client/getRegistration";
308
- import { updateRegistration } from "@azure/notification-hubs/client/updateRegistration";
296
+ import {
297
+ createClientContext,
298
+ getRegistration,
299
+ updateRegistration
300
+ } from "@azure/notification-hubs/api";
309
301
 
310
302
  const context = createClientContext("<connection string>", "<hub name>");
311
303
 
@@ -318,12 +310,12 @@ registration.tags.push("likes_sports");
318
310
  registration = await updateRegistration(context, registration);
319
311
  ```
320
312
 
321
- Registrations, unlike installations, can be queried to get all registrations, matching registrations to a condition, or by tags. Registrations can be queried using the `listRegistrations` and `listRegistrationsByTag` method. Both methods support limiting via the `top` option and support asynchronous paging.
313
+ Registrations, unlike installations, can be queried to get all registrations, matching registrations to a condition, or by tags. Registrations can be queried using the `listRegistrations`, `listRegistrationsByChannel` and `listRegistrationsByTag` method. All methods support limiting via the `top` option and support asynchronous paging.
322
314
 
323
315
  ```typescript
324
- import { NotificationHubServiceClient } from "@azure/notification-hubs/client";
316
+ import { NotificationHubsClient } from "@azure/notification-hubs/api";
325
317
 
326
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
318
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
327
319
 
328
320
  const registrations = await client.listRegistrationsByTag("likes_hockey");
329
321
 
@@ -339,8 +331,7 @@ for await (const pages of registrations.byPage()) {
339
331
  Using the modular approach, the code would be as follows:
340
332
 
341
333
  ```typescript
342
- import { createClientContext } from "@azure/notification-hubs/client";
343
- import { listRegistrationsByTag } from "@azure/notification-hubs/client/listRegistrationsByTag";
334
+ import { createClientContext, listRegistrationsByTag } from "@azure/notification-hubs/api";
344
335
 
345
336
  const context = createClientContext("<connection string>", "<hub name>");
346
337
 
@@ -361,16 +352,16 @@ Notification Hubs supports sending notifications to devices either directly usin
361
352
 
362
353
  For debugging purposes, the `enableTestSend` options can be set to `true` which gets immediate feedback from the PNS on the `sendNotification` method, however, is not supported in production scenarios. This is not supported on the scheduled send methods.
363
354
 
364
- Raw JSON or XML strings can be sent to the send or scheduled send methods, or the notification builders can be used which helps construct messages per PNS such as APNs, Firebase, Baidu, ADM and WNS. These builders will build the native message format and fill in associated HTTP headers so there is no guessing about which fields are available for each PNS.
355
+ Raw JSON or XML strings can be sent to the send or scheduled send methods, or the notification builders can be used which helps construct messages per PNS such as APNs, Firebase, Baidu, ADM and WNS. These builders will build the native message format so there is no guessing about which fields are available for each PNS.
365
356
 
366
357
  ```typescript
367
358
  // Using the class-based approach
368
- import { buildAppleNativeMessage } from "@azure/notification-hubs";
359
+ import { createAppleNotificationBody } from "@azure/notification-hubs";
369
360
 
370
361
  // Using the modular approach
371
- import { buildAppleNativeMessage } from "@azure/notification-hubs/models/notificationBuilder";
362
+ import { createAppleNotification, createAppleNotificationBody } from "@azure/notification-hubs/models";
372
363
 
373
- const apnsMessage = buildAppleNativeMessage({
364
+ const apnsBody = createAppleNotificationBody({
374
365
  alert: {
375
366
  title: "Notification Title",
376
367
  subtitle: "Notification Subtitle",
@@ -381,8 +372,11 @@ const apnsMessage = buildAppleNativeMessage({
381
372
  });
382
373
 
383
374
  // Send the message using the modular approach
375
+ const notification = createAppleNotification({
376
+ body: apnsBody
377
+ })
384
378
 
385
- const result = await sendNotification(context, apnsMessage);
379
+ const result = await sendNotification(context, notification);
386
380
  ```
387
381
 
388
382
  #### Broadcast Send
@@ -391,9 +385,9 @@ Notification Hubs can be used to send notifications to all registered devices pe
391
385
 
392
386
  ```typescript
393
387
  import {
394
- NotificationHubServiceClient,
388
+ NotificationHubsClient,
395
389
  createAppleNotification,
396
- } from "@azure/notification-hubs/client";
390
+ } from "@azure/notification-hubs/api";
397
391
 
398
392
  const context = createClientContext(connectionString, hubName);
399
393
 
@@ -421,9 +415,8 @@ if (result.notificationId) {
421
415
  Using the modular approach, the code would be as follows:
422
416
 
423
417
  ```typescript
424
- import { createClientContext } from "@azure/notification-hubs/client";
425
- import { createAppleNotification } from "@azure/notification-hubs/models/notification";
426
- import { sendNotification } from "@azure/notification-hubs/client/sendNotification";
418
+ import { createClientContext, sendNotification } from "@azure/notification-hubs/api";
419
+ import { createAppleNotification } from "@azure/notification-hubs/models";
427
420
 
428
421
  const context = createClientContext(connectionString, hubName);
429
422
 
@@ -454,11 +447,11 @@ To send directly a device, the user can send using the platform provided unique
454
447
 
455
448
  ```typescript
456
449
  import {
457
- NotificationHubServiceClient,
450
+ NotificationHubsClient,
458
451
  createAppleNotification,
459
452
  } from "@azure/notification-hubs";
460
453
 
461
- const client = new NotificationHubServiceClient(connectionString, hubName);
454
+ const client = new NotificationHubsClient(connectionString, hubName);
462
455
 
463
456
  const deviceHandle = "00fc13adff785122b4ad28809a3420982341241421348097878e577c991de8f0";
464
457
  const messageBody = `{ "aps" : { "alert" : "Hello" } }`;
@@ -485,9 +478,8 @@ if (result.notificationId) {
485
478
  Using the modular approach, the code would be as follows:
486
479
 
487
480
  ```typescript
488
- import { createClientContext } from "@azure/notification-hubs/client";
489
- import { createAppleNotification } from "@azure/notification-hubs/models/notification";
490
- import { sendNotification } from "@azure/notification-hubs/client/sendDirectNotification";
481
+ import { createClientContext, sendDirectNotification } from "@azure/notification-hubs/api";
482
+ import { createAppleNotification } from "@azure/notification-hubs/models";
491
483
 
492
484
  const context = createClientContext(connectionString, hubName);
493
485
 
@@ -517,13 +509,31 @@ if (result.notificationId) {
517
509
 
518
510
  In addition to targeting a single device, a user can target multiple devices using tags. These tags can be supplied as a list of tags, which then creates a tag expression to match registered devices, or via a tag expression which can then use Boolean logic to target the right audience. For more information about tags and tags expressions, see [Routing and Tag Expressions](https://docs.microsoft.com/azure/notification-hubs/notification-hubs-tags-segment-push-message).
519
511
 
512
+ If you wish to create a tag expression from an array of tags, there is a Tag Expression Builder available with the `createTagExpression` method which is exposed at the top level import or `@azure/notification-hubs/models/tagExpressionBuilder` modular import which creates an "or tag expression" from the tags.
513
+
514
+ ```typescript
515
+ // Top level import
516
+ import { createTagExpression } from "@azure/notification-hubs";
517
+
518
+ // Modular import
519
+ import { createTagExpression } from "@azure/notification-hubs/models";
520
+
521
+ const tags = ["likes_football", "likes_hockey"];
522
+ const tagExpression = createTagExpression(tags);
523
+
524
+ console.log(tagExpression);
525
+ // likes_football||likes_hockey
526
+ ```
527
+
528
+ Tag expression messages can be sent using the following code:
529
+
520
530
  ```typescript
521
531
  import {
522
- NotificationHubServiceClient,
532
+ NotificationHubsClient,
523
533
  createAppleNotification,
524
534
  } from "@azure/notification-hubs";
525
535
 
526
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
536
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
527
537
 
528
538
  const tagExpression = "likes_hockey && likes_football";
529
539
  const messageBody = `{ "aps" : { "alert" : "Hello" } }`;
@@ -536,7 +546,7 @@ const notification = createAppleNotification({
536
546
  },
537
547
  });
538
548
 
539
- const result = await client.sendNotification(notification, { tags: tagExpression });
549
+ const result = await client.sendNotification(notification, { tagExpression });
540
550
 
541
551
  console.log(`Tracking ID: ${result.trackingId}`);
542
552
  console.log(`Correlation ID: ${result.correlationId}`);
@@ -550,9 +560,8 @@ if (result.notificationId) {
550
560
  Using the modular approach, the code would be as follows:
551
561
 
552
562
  ```typescript
553
- import { createClientContext } from "@azure/notification-hubs/client";
554
- import { createAppleNotification } from "@azure/notification-hubs/models/notification";
555
- import { sendNotification } from "@azure/notification-hubs/client/sendNotification";
563
+ import { createClientContext, sendNotification } from "@azure/notification-hubs/api";
564
+ import { createAppleNotification } from "@azure/notification-hubs/models";
556
565
 
557
566
  const context = createClientContext("<connection string>", "<hub name>");
558
567
 
@@ -567,7 +576,7 @@ const notification = createAppleNotification({
567
576
  },
568
577
  });
569
578
 
570
- const result = await sendNotification(context, notification, { tags: tagExpression });
579
+ const result = await sendNotification(context, notification, { tagExpression });
571
580
 
572
581
  console.log(`Tracking ID: ${result.trackingId}`);
573
582
  console.log(`Correlation ID: ${result.correlationId}`);
@@ -584,11 +593,11 @@ Push notifications can be scheduled up to seven days in advance with Standard SK
584
593
 
585
594
  ```typescript
586
595
  import {
587
- NotificationHubServiceClient,
596
+ NotificationHubsClient,
588
597
  createAppleNotification,
589
598
  } from "@azure/notification-hubs";
590
599
 
591
- const client = new NotificationHubServiceClient("<connection string>", "<hub name>");
600
+ const client = new NotificationHubsClient("<connection string>", "<hub name>");
592
601
 
593
602
  const tagExpression = "likes_hockey && likes_football";
594
603
  const messageBody = `{ "aps" : { "alert" : "Hello" } }`;
@@ -604,7 +613,7 @@ const message = createAppleNotification({
604
613
  },
605
614
  });
606
615
 
607
- const result = await client.scheduleNotification(scheduledTime, message, { tags: tagExpression });
616
+ const result = await client.scheduleNotification(scheduledTime, message, { tagExpression });
608
617
 
609
618
  console.log(`Tracking ID: ${result.trackingId}`);
610
619
  console.log(`Correlation ID: ${result.correlationId}`);
@@ -616,9 +625,8 @@ console.log(`Notification ID: ${result.notificationId}`);
616
625
  Using the modular approach, the code would be as follows:
617
626
 
618
627
  ```typescript
619
- import { createClientContext } from "@azure/notification-hubs/client";
620
- import { createAppleNotification } from "@azure/notification-hubs/models/notification";
621
- import { scheduleNotification } from "@azure/notification-hubs/client/scheduleNotification";
628
+ import { createClientContext, scheduleNotification } from "@azure/notification-hubs/api";
629
+ import { createAppleNotification } from "@azure/notification-hubs/models";
622
630
 
623
631
  const context = createClientContext("<connection string>", "<hub name>");
624
632
 
@@ -636,7 +644,7 @@ const message = createAppleNotification({
636
644
  },
637
645
  });
638
646
 
639
- const result = await scheduleNotification(context, scheduledTime, message, { tags: tagExpression });
647
+ const result = await scheduleNotification(context, scheduledTime, message, { tagExpression });
640
648
 
641
649
  console.log(`Tracking ID: ${result.trackingId}`);
642
650
  console.log(`Correlation ID: ${result.correlationId}`);
@@ -655,7 +663,7 @@ Azure Notification Hubs has a complete guide to troubleshooting problems with dr
655
663
 
656
664
  ```typescript
657
665
  // Using the client
658
- const result = await client.sendNotification(message, { tags, enableTestSend: true });
666
+ const result = await client.sendNotification(notification, { tags, enableTestSend: true });
659
667
 
660
668
  // Using the modular approach
661
669
  const result = await sendNotification(context, notification, { tags, enableTestSend: true });