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

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 (32) hide show
  1. package/README.md +1 -1
  2. package/dist/index.cjs +71 -3
  3. package/dist/index.cjs.map +1 -1
  4. package/dist-esm/src/models/installation.js +8 -0
  5. package/dist-esm/src/models/installation.js.map +1 -1
  6. package/dist-esm/src/models/notification.js +9 -1
  7. package/dist-esm/src/models/notification.js.map +1 -1
  8. package/dist-esm/src/models/notificationDetails.js.map +1 -1
  9. package/dist-esm/src/models/registration.js +16 -0
  10. package/dist-esm/src/models/registration.js.map +1 -1
  11. package/dist-esm/src/serializers/notificationDetailsSerializer.js +5 -1
  12. package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -1
  13. package/dist-esm/src/serializers/registrationSerializer.js +28 -0
  14. package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
  15. package/dist-esm/src/utils/constants.js +1 -1
  16. package/dist-esm/src/utils/constants.js.map +1 -1
  17. package/package.json +14 -9
  18. package/types/3.1/notification-hubs.d.ts +97 -6
  19. package/types/latest/notification-hubs.d.ts +108 -6
  20. package/types/latest/tsdoc-metadata.json +1 -1
  21. package/types/src/models/installation.d.ts +16 -1
  22. package/types/src/models/installation.d.ts.map +1 -1
  23. package/types/src/models/notification.d.ts +17 -2
  24. package/types/src/models/notification.d.ts.map +1 -1
  25. package/types/src/models/notificationDetails.d.ts +4 -0
  26. package/types/src/models/notificationDetails.d.ts.map +1 -1
  27. package/types/src/models/registration.d.ts +60 -3
  28. package/types/src/models/registration.d.ts.map +1 -1
  29. package/types/src/serializers/notificationDetailsSerializer.d.ts.map +1 -1
  30. package/types/src/serializers/registrationSerializer.d.ts +21 -1
  31. package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
  32. package/types/src/utils/constants.d.ts.map +1 -1
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Azure Notification Hubs SDK for JavaScript
2
2
 
3
- Azure Notification Hubs provide a scaled-out push engine that enables you to send notifications to any platform (Apple, Amazon Kindle, Android, Baidu, Web, Windows, etc.) from any back-end (cloud or on-premises). Notification Hubs works well for both enterprise and consumer scenarios. Here are a few example scenarios:
3
+ Azure Notification Hubs provide a scaled-out push engine that enables you to send notifications to any platform (Apple, Amazon Kindle, Android, Baidu, Xiaomi, Web, Windows, etc.) from any back-end (cloud or on-premises). Notification Hubs works well for both enterprise and consumer scenarios. Here are a few example scenarios:
4
4
 
5
5
  - Send breaking news notifications to millions with low latency.
6
6
  - Send location-based coupons to interested user segments.
package/dist/index.cjs CHANGED
@@ -14,7 +14,7 @@ var uuid = require('uuid');
14
14
 
15
15
  // Copyright (c) Microsoft Corporation.
16
16
  // Licensed under the MIT license.
17
- const SDK_VERSION = "1.0.0-beta.8";
17
+ const SDK_VERSION = "1.0.0";
18
18
  const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
19
19
  const XML_CONTENT_TYPE = "application/xml";
20
20
  const STREAM_CONTENT_TYPE = "application/octet-stream";
@@ -891,6 +891,20 @@ const registrationDescriptionParser = {
891
891
  var _a;
892
892
  return Object.assign(Object.assign(Object.assign({ mpnsHeaders: getHeadersOrUndefined((_a = rawRegistrationDescription["MpnsHeaders"]) === null || _a === void 0 ? void 0 : _a["MpnsHeader"]) }, this.createWindowsRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "MpnsTemplate" });
893
893
  },
894
+ /**
895
+ * @internal
896
+ * Creates a Xiaomi registration description from incoming XML property bag.
897
+ */
898
+ createXiaomiRegistrationDescription(rawRegistrationDescription) {
899
+ return Object.assign(Object.assign({ xiaomiRegistrationId: getString(rawRegistrationDescription["XiaomiRegistrationId"], "xiaomiRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Xiaomi" });
900
+ },
901
+ /**
902
+ * @internal
903
+ * Creates a Xiaomi template registration description from incoming XML property bag.
904
+ */
905
+ createXiaomiTemplateRegistrationDescription(rawRegistrationDescription) {
906
+ return Object.assign(Object.assign(Object.assign({}, this.createXiaomiRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "XiaomiTemplate" });
907
+ },
894
908
  /**
895
909
  * @internal
896
910
  * Creates a Windows registration description from incoming XML property bag.
@@ -1061,6 +1075,20 @@ const registrationDescriptionSerializer = {
1061
1075
  }
1062
1076
  return Object.assign(Object.assign(Object.assign({}, this.serializeMpnsRegistrationDescription(description)), serializeTemplateRegistrationDescription(description)), { MpnsHeaders: mpnsHeaders });
1063
1077
  },
1078
+ /**
1079
+ * @internal
1080
+ * Serializes an existing Xiaomi registration description to an object for serialization.
1081
+ */
1082
+ serializeXiaomiRegistrationDescription(description) {
1083
+ return Object.assign(Object.assign({}, serializeRegistrationDescription(description)), { XiaomiRegistrationId: getString(description.xiaomiRegistrationId, "xiaomiRegistrationId") });
1084
+ },
1085
+ /**
1086
+ * @internal
1087
+ * Serializes an existing Xiaomi template registration description to an object for serialization.
1088
+ */
1089
+ serializeXiaomiTemplateRegistrationDescription(description) {
1090
+ return Object.assign(Object.assign({}, this.serializeXiaomiRegistrationDescription(description)), serializeTemplateRegistrationDescription(description));
1091
+ },
1064
1092
  /**
1065
1093
  * @internal
1066
1094
  * Serializes an existing Windows registration description to an object for serialization.
@@ -1296,7 +1324,6 @@ function getInstallation(context, installationId, options = {}) {
1296
1324
  async function parseNotificationDetails(bodyText) {
1297
1325
  const xml = await coreXml.parseXML(bodyText, {
1298
1326
  includeRoot: true,
1299
- stopNodes: ["NotificationDetails.NotificationBody"],
1300
1327
  });
1301
1328
  const notificationDetails = xml["NotificationDetails"];
1302
1329
  let apnsOutcomeCounts;
@@ -1315,6 +1342,10 @@ async function parseNotificationDetails(bodyText) {
1315
1342
  if (isDefined(notificationDetails["GcmOutcomeCounts"])) {
1316
1343
  fcmOutcomeCounts = parseOutcomeCounts(notificationDetails["GcmOutcomeCounts"]["Outcome"]);
1317
1344
  }
1345
+ let xiaomiOutcomeCounts;
1346
+ if (isDefined(notificationDetails["XiaomiOutcomeCounts"])) {
1347
+ xiaomiOutcomeCounts = parseOutcomeCounts(notificationDetails["XiaomiOutcomeCounts"]["Outcome"]);
1348
+ }
1318
1349
  let wnsOutcomeCounts;
1319
1350
  if (isDefined(notificationDetails["WnsOutcomeCounts"])) {
1320
1351
  wnsOutcomeCounts = parseOutcomeCounts(notificationDetails["WnsOutcomeCounts"]["Outcome"]);
@@ -1333,6 +1364,7 @@ async function parseNotificationDetails(bodyText) {
1333
1364
  admOutcomeCounts,
1334
1365
  baiduOutcomeCounts,
1335
1366
  fcmOutcomeCounts,
1367
+ xiaomiOutcomeCounts,
1336
1368
  wnsOutcomeCounts,
1337
1369
  };
1338
1370
  }
@@ -2087,6 +2119,14 @@ function createBaiduInstallation(installation) {
2087
2119
  function createFcmLegacyInstallation(installation) {
2088
2120
  return Object.assign(Object.assign({}, installation), { platform: "gcm" });
2089
2121
  }
2122
+ /**
2123
+ * Creates a Xiaomi based installation.
2124
+ * @param installation - A partial installation used to create the Xiaomi installation.
2125
+ * @returns The newly created Xiaomi installation.
2126
+ */
2127
+ function createXiaomiInstallation(installation) {
2128
+ return Object.assign(Object.assign({}, installation), { platform: "xiaomi" });
2129
+ }
2090
2130
  /**
2091
2131
  * Creates a Windows Notification Services (WNS) based installation.
2092
2132
  * @param installation - A partial installation used to create the WNS installation.
@@ -2140,11 +2180,19 @@ function createBrowserNotification(notification) {
2140
2180
  /**
2141
2181
  * Creates a notification to send to Firebase.
2142
2182
  * @param notification - A partial message used to create a message for Firebase.
2143
- * @returns A newly created Firebase.
2183
+ * @returns A newly created Firebase notification.
2144
2184
  */
2145
2185
  function createFcmLegacyNotification(notification) {
2146
2186
  return Object.assign(Object.assign({}, notification), { platform: "gcm", contentType: JSON_CONTENT_TYPE });
2147
2187
  }
2188
+ /**
2189
+ * Creates a notification to send to Xiaomi.
2190
+ * @param notification - A partial message used to create a message for Xiaomi.
2191
+ * @returns A newly created Xiaomi notification.
2192
+ */
2193
+ function createXiaomiNotification(notification) {
2194
+ return Object.assign(Object.assign({}, notification), { platform: "xiaomi", contentType: JSON_CONTENT_TYPE });
2195
+ }
2148
2196
  /**
2149
2197
  * Creates a notification to send to Firebase.
2150
2198
  * @param notification - A partial message used to create a message for Firebase.
@@ -2350,6 +2398,22 @@ function createWindowsRegistrationDescription(description) {
2350
2398
  function createWindowsTemplateRegistrationDescription(description) {
2351
2399
  return Object.assign(Object.assign({}, description), { kind: "WindowsTemplate" });
2352
2400
  }
2401
+ /**
2402
+ * Creates a Xiaomi registration description.
2403
+ * @param description - A partial Xiaomi registration description.
2404
+ * @returns A created Xiaomi registration description.
2405
+ */
2406
+ function createXiaomiRegistrationDescription(description) {
2407
+ return Object.assign(Object.assign({}, description), { kind: "Xiaomi" });
2408
+ }
2409
+ /**
2410
+ * Creates a Xiaomi template registration description.
2411
+ * @param description - A partial Xiaomi template registration description.
2412
+ * @returns A created Xiaomi template registration description.
2413
+ */
2414
+ function createXiaomiTemplateRegistrationDescription(description) {
2415
+ return Object.assign(Object.assign({}, description), { kind: "XiaomiTemplate" });
2416
+ }
2353
2417
 
2354
2418
  // Copyright (c) Microsoft Corporation.
2355
2419
  // Licensed under the MIT license.
@@ -2397,4 +2461,8 @@ exports.createWindowsRegistrationDescription = createWindowsRegistrationDescript
2397
2461
  exports.createWindowsTemplateRegistrationDescription = createWindowsTemplateRegistrationDescription;
2398
2462
  exports.createWindowsTileNotification = createWindowsTileNotification;
2399
2463
  exports.createWindowsToastNotification = createWindowsToastNotification;
2464
+ exports.createXiaomiInstallation = createXiaomiInstallation;
2465
+ exports.createXiaomiNotification = createXiaomiNotification;
2466
+ exports.createXiaomiRegistrationDescription = createXiaomiRegistrationDescription;
2467
+ exports.createXiaomiTemplateRegistrationDescription = createXiaomiTemplateRegistrationDescription;
2400
2468
  //# sourceMappingURL=index.js.map