@azure/notification-hubs 1.0.0-alpha.20230214.2 → 1.0.0-alpha.20230315.3
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.
- package/README.md +1 -1
- package/dist/index.cjs +71 -2
- package/dist/index.cjs.map +1 -1
- package/dist-esm/src/models/installation.js +8 -0
- package/dist-esm/src/models/installation.js.map +1 -1
- package/dist-esm/src/models/notification.js +9 -1
- package/dist-esm/src/models/notification.js.map +1 -1
- package/dist-esm/src/models/notificationDetails.js.map +1 -1
- package/dist-esm/src/models/registration.js +16 -0
- package/dist-esm/src/models/registration.js.map +1 -1
- package/dist-esm/src/serializers/notificationDetailsSerializer.js +5 -0
- package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -1
- package/dist-esm/src/serializers/registrationSerializer.js +28 -0
- package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
- package/dist-esm/src/utils/constants.js +1 -1
- package/dist-esm/src/utils/constants.js.map +1 -1
- package/package.json +2 -3
- package/types/3.1/notification-hubs.d.ts +97 -6
- package/types/latest/notification-hubs.d.ts +108 -6
- package/types/latest/tsdoc-metadata.json +1 -1
- package/types/src/models/installation.d.ts +16 -1
- package/types/src/models/installation.d.ts.map +1 -1
- package/types/src/models/notification.d.ts +17 -2
- package/types/src/models/notification.d.ts.map +1 -1
- package/types/src/models/notificationDetails.d.ts +4 -0
- package/types/src/models/notificationDetails.d.ts.map +1 -1
- package/types/src/models/registration.d.ts +60 -3
- package/types/src/models/registration.d.ts.map +1 -1
- package/types/src/serializers/notificationDetailsSerializer.d.ts.map +1 -1
- package/types/src/serializers/registrationSerializer.d.ts +21 -1
- package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
- 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
|
|
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.
|
|
@@ -1314,6 +1342,10 @@ async function parseNotificationDetails(bodyText) {
|
|
|
1314
1342
|
if (isDefined(notificationDetails["GcmOutcomeCounts"])) {
|
|
1315
1343
|
fcmOutcomeCounts = parseOutcomeCounts(notificationDetails["GcmOutcomeCounts"]["Outcome"]);
|
|
1316
1344
|
}
|
|
1345
|
+
let xiaomiOutcomeCounts;
|
|
1346
|
+
if (isDefined(notificationDetails["XiaomiOutcomeCounts"])) {
|
|
1347
|
+
xiaomiOutcomeCounts = parseOutcomeCounts(notificationDetails["XiaomiOutcomeCounts"]["Outcome"]);
|
|
1348
|
+
}
|
|
1317
1349
|
let wnsOutcomeCounts;
|
|
1318
1350
|
if (isDefined(notificationDetails["WnsOutcomeCounts"])) {
|
|
1319
1351
|
wnsOutcomeCounts = parseOutcomeCounts(notificationDetails["WnsOutcomeCounts"]["Outcome"]);
|
|
@@ -1332,6 +1364,7 @@ async function parseNotificationDetails(bodyText) {
|
|
|
1332
1364
|
admOutcomeCounts,
|
|
1333
1365
|
baiduOutcomeCounts,
|
|
1334
1366
|
fcmOutcomeCounts,
|
|
1367
|
+
xiaomiOutcomeCounts,
|
|
1335
1368
|
wnsOutcomeCounts,
|
|
1336
1369
|
};
|
|
1337
1370
|
}
|
|
@@ -2086,6 +2119,14 @@ function createBaiduInstallation(installation) {
|
|
|
2086
2119
|
function createFcmLegacyInstallation(installation) {
|
|
2087
2120
|
return Object.assign(Object.assign({}, installation), { platform: "gcm" });
|
|
2088
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
|
+
}
|
|
2089
2130
|
/**
|
|
2090
2131
|
* Creates a Windows Notification Services (WNS) based installation.
|
|
2091
2132
|
* @param installation - A partial installation used to create the WNS installation.
|
|
@@ -2139,11 +2180,19 @@ function createBrowserNotification(notification) {
|
|
|
2139
2180
|
/**
|
|
2140
2181
|
* Creates a notification to send to Firebase.
|
|
2141
2182
|
* @param notification - A partial message used to create a message for Firebase.
|
|
2142
|
-
* @returns A newly created Firebase.
|
|
2183
|
+
* @returns A newly created Firebase notification.
|
|
2143
2184
|
*/
|
|
2144
2185
|
function createFcmLegacyNotification(notification) {
|
|
2145
2186
|
return Object.assign(Object.assign({}, notification), { platform: "gcm", contentType: JSON_CONTENT_TYPE });
|
|
2146
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
|
+
}
|
|
2147
2196
|
/**
|
|
2148
2197
|
* Creates a notification to send to Firebase.
|
|
2149
2198
|
* @param notification - A partial message used to create a message for Firebase.
|
|
@@ -2349,6 +2398,22 @@ function createWindowsRegistrationDescription(description) {
|
|
|
2349
2398
|
function createWindowsTemplateRegistrationDescription(description) {
|
|
2350
2399
|
return Object.assign(Object.assign({}, description), { kind: "WindowsTemplate" });
|
|
2351
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
|
+
}
|
|
2352
2417
|
|
|
2353
2418
|
// Copyright (c) Microsoft Corporation.
|
|
2354
2419
|
// Licensed under the MIT license.
|
|
@@ -2396,4 +2461,8 @@ exports.createWindowsRegistrationDescription = createWindowsRegistrationDescript
|
|
|
2396
2461
|
exports.createWindowsTemplateRegistrationDescription = createWindowsTemplateRegistrationDescription;
|
|
2397
2462
|
exports.createWindowsTileNotification = createWindowsTileNotification;
|
|
2398
2463
|
exports.createWindowsToastNotification = createWindowsToastNotification;
|
|
2464
|
+
exports.createXiaomiInstallation = createXiaomiInstallation;
|
|
2465
|
+
exports.createXiaomiNotification = createXiaomiNotification;
|
|
2466
|
+
exports.createXiaomiRegistrationDescription = createXiaomiRegistrationDescription;
|
|
2467
|
+
exports.createXiaomiTemplateRegistrationDescription = createXiaomiTemplateRegistrationDescription;
|
|
2399
2468
|
//# sourceMappingURL=index.js.map
|