@azure/notification-hubs 1.0.0-alpha.20220804.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.
- package/LICENSE +21 -0
- package/README.md +749 -0
- package/dist/index.js +2235 -0
- package/dist/index.js.map +1 -0
- package/dist-esm/src/client/cancelScheduledNotification.js +23 -0
- package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -0
- package/dist-esm/src/client/createOrUpdateInstallation.js +24 -0
- package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -0
- package/dist-esm/src/client/createOrUpdateRegistration.js +17 -0
- package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -0
- package/dist-esm/src/client/createRegistration.js +24 -0
- package/dist-esm/src/client/createRegistration.js.map +1 -0
- package/dist-esm/src/client/createRegistrationId.js +26 -0
- package/dist-esm/src/client/createRegistrationId.js.map +1 -0
- package/dist-esm/src/client/deleteInstallation.js +22 -0
- package/dist-esm/src/client/deleteInstallation.js.map +1 -0
- package/dist-esm/src/client/deleteRegistration.js +25 -0
- package/dist-esm/src/client/deleteRegistration.js.map +1 -0
- package/dist-esm/src/client/getFeedbackContainerUrl.js +23 -0
- package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -0
- package/dist-esm/src/client/getInstallation.js +23 -0
- package/dist-esm/src/client/getInstallation.js.map +1 -0
- package/dist-esm/src/client/getNotificationHubJob.js +24 -0
- package/dist-esm/src/client/getNotificationHubJob.js.map +1 -0
- package/dist-esm/src/client/getNotificationOutcomeDetails.js +24 -0
- package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -0
- package/dist-esm/src/client/getRegistration.js +24 -0
- package/dist-esm/src/client/getRegistration.js.map +1 -0
- package/dist-esm/src/client/index.js +44 -0
- package/dist-esm/src/client/index.js.map +1 -0
- package/dist-esm/src/client/internal/_client.js +75 -0
- package/dist-esm/src/client/internal/_client.js.map +1 -0
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js +31 -0
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +1 -0
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +37 -0
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +1 -0
- package/dist-esm/src/client/internal/_sendNotificationPayload.js +51 -0
- package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +1 -0
- package/dist-esm/src/client/listNotificationHubJobs.js +23 -0
- package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -0
- package/dist-esm/src/client/listRegistrations.js +89 -0
- package/dist-esm/src/client/listRegistrations.js.map +1 -0
- package/dist-esm/src/client/listRegistrationsByTag.js +87 -0
- package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -0
- package/dist-esm/src/client/scheduleBroadcastNotification.js +17 -0
- package/dist-esm/src/client/scheduleBroadcastNotification.js.map +1 -0
- package/dist-esm/src/client/scheduleNotification.js +18 -0
- package/dist-esm/src/client/scheduleNotification.js.map +1 -0
- package/dist-esm/src/client/sendBroadcastNotification.js +15 -0
- package/dist-esm/src/client/sendBroadcastNotification.js.map +1 -0
- package/dist-esm/src/client/sendDirectNotification.js +16 -0
- package/dist-esm/src/client/sendDirectNotification.js.map +1 -0
- package/dist-esm/src/client/sendNotification.js +16 -0
- package/dist-esm/src/client/sendNotification.js.map +1 -0
- package/dist-esm/src/client/submitNotificationHubJob.js +26 -0
- package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -0
- package/dist-esm/src/client/updateInstallation.js +25 -0
- package/dist-esm/src/client/updateInstallation.js.map +1 -0
- package/dist-esm/src/client/updateRegistration.js +21 -0
- package/dist-esm/src/client/updateRegistration.js.map +1 -0
- package/dist-esm/src/index.js +12 -0
- package/dist-esm/src/index.js.map +1 -0
- package/dist-esm/src/models/installation.js +51 -0
- package/dist-esm/src/models/installation.js.map +1 -0
- package/dist-esm/src/models/notification.js +104 -0
- package/dist-esm/src/models/notification.js.map +1 -0
- package/dist-esm/src/models/notificationBuilder.js +169 -0
- package/dist-esm/src/models/notificationBuilder.js.map +1 -0
- package/dist-esm/src/models/notificationDetails.js +4 -0
- package/dist-esm/src/models/notificationDetails.js.map +1 -0
- package/dist-esm/src/models/notificationHubJob.js +4 -0
- package/dist-esm/src/models/notificationHubJob.js.map +1 -0
- package/dist-esm/src/models/options.js +4 -0
- package/dist-esm/src/models/options.js.map +1 -0
- package/dist-esm/src/models/registration.js +135 -0
- package/dist-esm/src/models/registration.js.map +1 -0
- package/dist-esm/src/models/response.js +4 -0
- package/dist-esm/src/models/response.js.map +1 -0
- package/dist-esm/src/notificationHubsClient.js +251 -0
- package/dist-esm/src/notificationHubsClient.js.map +1 -0
- package/dist-esm/src/serializers/notificationDetailsSerializer.js +58 -0
- package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -0
- package/dist-esm/src/serializers/notificationHubJobSerializer.js +74 -0
- package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -0
- package/dist-esm/src/serializers/registrationSerializer.js +375 -0
- package/dist-esm/src/serializers/registrationSerializer.js.map +1 -0
- package/dist-esm/src/utils/connectionStringUtils.js +37 -0
- package/dist-esm/src/utils/connectionStringUtils.js.map +1 -0
- package/dist-esm/src/utils/constants.js +11 -0
- package/dist-esm/src/utils/constants.js.map +1 -0
- package/dist-esm/src/utils/retryPolicy.js +144 -0
- package/dist-esm/src/utils/retryPolicy.js.map +1 -0
- package/dist-esm/src/utils/tracing.js +13 -0
- package/dist-esm/src/utils/tracing.js.map +1 -0
- package/dist-esm/src/utils/utils.js +130 -0
- package/dist-esm/src/utils/utils.js.map +1 -0
- package/dist-esm/src/utils/xmlUtils.js +101 -0
- package/dist-esm/src/utils/xmlUtils.js.map +1 -0
- package/package.json +144 -0
- package/types/3.1/notification-hubs.d.ts +1728 -0
- package/types/latest/notification-hubs.d.ts +1840 -0
- package/types/latest/tsdoc-metadata.json +11 -0
- package/types/src/client/cancelScheduledNotification.d.ts +13 -0
- package/types/src/client/cancelScheduledNotification.d.ts.map +1 -0
- package/types/src/client/createOrUpdateInstallation.d.ts +13 -0
- package/types/src/client/createOrUpdateInstallation.d.ts.map +1 -0
- package/types/src/client/createOrUpdateRegistration.d.ts +12 -0
- package/types/src/client/createOrUpdateRegistration.d.ts.map +1 -0
- package/types/src/client/createRegistration.d.ts +13 -0
- package/types/src/client/createRegistration.d.ts.map +1 -0
- package/types/src/client/createRegistrationId.d.ts +10 -0
- package/types/src/client/createRegistrationId.d.ts.map +1 -0
- package/types/src/client/deleteInstallation.d.ts +12 -0
- package/types/src/client/deleteInstallation.d.ts.map +1 -0
- package/types/src/client/deleteRegistration.d.ts +12 -0
- package/types/src/client/deleteRegistration.d.ts.map +1 -0
- package/types/src/client/getFeedbackContainerUrl.d.ts +11 -0
- package/types/src/client/getFeedbackContainerUrl.d.ts.map +1 -0
- package/types/src/client/getInstallation.d.ts +12 -0
- package/types/src/client/getInstallation.d.ts.map +1 -0
- package/types/src/client/getNotificationHubJob.d.ts +12 -0
- package/types/src/client/getNotificationHubJob.d.ts.map +1 -0
- package/types/src/client/getNotificationOutcomeDetails.d.ts +13 -0
- package/types/src/client/getNotificationOutcomeDetails.d.ts.map +1 -0
- package/types/src/client/getRegistration.d.ts +12 -0
- package/types/src/client/getRegistration.d.ts.map +1 -0
- package/types/src/client/index.d.ts +41 -0
- package/types/src/client/index.d.ts.map +1 -0
- package/types/src/client/internal/_client.d.ts +26 -0
- package/types/src/client/internal/_client.d.ts.map +1 -0
- package/types/src/client/internal/_createOrUpdateRegistrationDescription.d.ts +8 -0
- package/types/src/client/internal/_createOrUpdateRegistrationDescription.d.ts.map +1 -0
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts +9 -0
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +1 -0
- package/types/src/client/internal/_sendNotificationPayload.d.ts +10 -0
- package/types/src/client/internal/_sendNotificationPayload.d.ts.map +1 -0
- package/types/src/client/listNotificationHubJobs.d.ts +11 -0
- package/types/src/client/listNotificationHubJobs.d.ts.map +1 -0
- package/types/src/client/listRegistrations.d.ts +12 -0
- package/types/src/client/listRegistrations.d.ts.map +1 -0
- package/types/src/client/listRegistrationsByTag.d.ts +13 -0
- package/types/src/client/listRegistrationsByTag.d.ts.map +1 -0
- package/types/src/client/scheduleBroadcastNotification.d.ts +16 -0
- package/types/src/client/scheduleBroadcastNotification.d.ts.map +1 -0
- package/types/src/client/scheduleNotification.d.ts +17 -0
- package/types/src/client/scheduleNotification.d.ts.map +1 -0
- package/types/src/client/sendBroadcastNotification.d.ts +14 -0
- package/types/src/client/sendBroadcastNotification.d.ts.map +1 -0
- package/types/src/client/sendDirectNotification.d.ts +16 -0
- package/types/src/client/sendDirectNotification.d.ts.map +1 -0
- package/types/src/client/sendNotification.d.ts +15 -0
- package/types/src/client/sendNotification.d.ts.map +1 -0
- package/types/src/client/submitNotificationHubJob.d.ts +13 -0
- package/types/src/client/submitNotificationHubJob.d.ts.map +1 -0
- package/types/src/client/updateInstallation.d.ts +14 -0
- package/types/src/client/updateInstallation.d.ts.map +1 -0
- package/types/src/client/updateRegistration.d.ts +12 -0
- package/types/src/client/updateRegistration.d.ts.map +1 -0
- package/types/src/index.d.ts +10 -0
- package/types/src/index.d.ts.map +1 -0
- package/types/src/models/installation.d.ts +200 -0
- package/types/src/models/installation.d.ts.map +1 -0
- package/types/src/models/notification.d.ts +166 -0
- package/types/src/models/notification.d.ts.map +1 -0
- package/types/src/models/notificationBuilder.d.ts +546 -0
- package/types/src/models/notificationBuilder.d.ts.map +1 -0
- package/types/src/models/notificationDetails.d.ts +87 -0
- package/types/src/models/notificationDetails.d.ts.map +1 -0
- package/types/src/models/notificationHubJob.d.ts +104 -0
- package/types/src/models/notificationHubJob.d.ts.map +1 -0
- package/types/src/models/options.d.ts +43 -0
- package/types/src/models/options.d.ts.map +1 -0
- package/types/src/models/registration.d.ts +368 -0
- package/types/src/models/registration.d.ts.map +1 -0
- package/types/src/models/response.d.ts +41 -0
- package/types/src/models/response.d.ts.map +1 -0
- package/types/src/notificationHubsClient.d.ts +190 -0
- package/types/src/notificationHubsClient.d.ts.map +1 -0
- package/types/src/serializers/notificationDetailsSerializer.d.ts +7 -0
- package/types/src/serializers/notificationDetailsSerializer.d.ts.map +1 -0
- package/types/src/serializers/notificationHubJobSerializer.d.ts +21 -0
- package/types/src/serializers/notificationHubJobSerializer.d.ts.map +1 -0
- package/types/src/serializers/registrationSerializer.d.ts +193 -0
- package/types/src/serializers/registrationSerializer.d.ts.map +1 -0
- package/types/src/utils/connectionStringUtils.d.ts +37 -0
- package/types/src/utils/connectionStringUtils.d.ts.map +1 -0
- package/types/src/utils/constants.d.ts +9 -0
- package/types/src/utils/constants.d.ts.map +1 -0
- package/types/src/utils/retryPolicy.d.ts +72 -0
- package/types/src/utils/retryPolicy.d.ts.map +1 -0
- package/types/src/utils/tracing.d.ts +6 -0
- package/types/src/utils/tracing.d.ts.map +1 -0
- package/types/src/utils/utils.d.ts +65 -0
- package/types/src/utils/utils.d.ts.map +1 -0
- package/types/src/utils/xmlUtils.d.ts +46 -0
- package/types/src/utils/xmlUtils.d.ts.map +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
/**
|
|
4
|
+
* Creates an Apple based installation.
|
|
5
|
+
* @param installation - A partial installation used to create the Apple installation.
|
|
6
|
+
* @returns The newly created Apple installation.
|
|
7
|
+
*/
|
|
8
|
+
export function createAppleInstallation(installation) {
|
|
9
|
+
return Object.assign(Object.assign({}, installation), { platform: "apns" });
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates an Amazon Device Messaging (ADM) based installation.
|
|
13
|
+
* @param installation - A partial installation used to create the ADM installation.
|
|
14
|
+
* @returns The newly created ADM installation.
|
|
15
|
+
*/
|
|
16
|
+
export function createAdmInstallation(installation) {
|
|
17
|
+
return Object.assign(Object.assign({}, installation), { platform: "adm" });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates a Baidu based installation.
|
|
21
|
+
* @param installation - A partial installation used to create the Baidu installation.
|
|
22
|
+
* @returns The newly created Baidu installation.
|
|
23
|
+
*/
|
|
24
|
+
export function createBaiduInstallation(installation) {
|
|
25
|
+
return Object.assign(Object.assign({}, installation), { platform: "baidu" });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates a Firebase legacy HTTP based installation.
|
|
29
|
+
* @param installation - A partial installation used to create the Firebase Legacy HTTP installation.
|
|
30
|
+
* @returns The newly created Baidu installation.
|
|
31
|
+
*/
|
|
32
|
+
export function createFirebaseLegacyInstallation(installation) {
|
|
33
|
+
return Object.assign(Object.assign({}, installation), { platform: "gcm" });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a Windows Notification Services (WNS) based installation.
|
|
37
|
+
* @param installation - A partial installation used to create the WNS installation.
|
|
38
|
+
* @returns The newly created WNS installation.
|
|
39
|
+
*/
|
|
40
|
+
export function createWindowsInstallation(installation) {
|
|
41
|
+
return Object.assign(Object.assign({}, installation), { platform: "wns" });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a Web Push based installation.
|
|
45
|
+
* @param installation - A partial installation used to create the Web Push installation.
|
|
46
|
+
* @returns The newly created Web Push installation.
|
|
47
|
+
*/
|
|
48
|
+
export function createBrowserInstallation(installation) {
|
|
49
|
+
return Object.assign(Object.assign({}, installation), { platform: "browser" });
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL=installation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"installation.js","sourceRoot":"","sources":["../../../src/models/installation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AA8DlC;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAiD;IAEjD,uCACK,YAAY,KACf,QAAQ,EAAE,MAAM,IAChB;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,YAA+C;IAE/C,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,IACf;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CACrC,YAAiD;IAEjD,uCACK,YAAY,KACf,QAAQ,EAAE,OAAO,IACjB;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,YAA0D;IAE1D,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,IACf;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,YAAmD;IAEnD,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,IACf;AACJ,CAAC;AAqCD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,YAAmD;IAEnD,uCACK,YAAY,KACf,QAAQ,EAAE,SAAS,IACnB;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Represents an installation for a device for Notification Hubs.\n */\nexport interface InstallationCommon {\n /**\n * The ID for the installation.\n */\n installationId: string;\n\n /**\n * The User ID for the installation used for targeting.\n */\n userId?: string;\n\n /**\n * The installation expiration time.\n */\n readonly expirationTime?: string;\n\n /**\n * The last update date of the installation.\n */\n readonly lastUpdate?: string;\n\n /**\n * The platform for the installation.\n */\n platform: \"apns\" | \"adm\" | \"baidu\" | \"browser\" | \"gcm\" | \"wns\";\n\n /**\n * The tags used for targeting this installation.\n */\n tags?: string[];\n\n /**\n * The templates for the installation.\n */\n templates?: Record<string, InstallationTemplate>;\n}\n\n/**\n * Represents an installation with a string based device token.\n */\nexport interface DeviceTokenInstallation extends InstallationCommon {\n /**\n * The push channel for a device.\n */\n pushChannel: string;\n}\n\n/**\n * Represents an Apple APNs based installation.\n */\nexport interface AppleInstallation extends DeviceTokenInstallation {\n /**\n * The platform for the installation.\n */\n platform: \"apns\";\n}\n\n/**\n * Creates an Apple based installation.\n * @param installation - A partial installation used to create the Apple installation.\n * @returns The newly created Apple installation.\n */\nexport function createAppleInstallation(\n installation: Omit<AppleInstallation, \"platform\">\n): AppleInstallation {\n return {\n ...installation,\n platform: \"apns\",\n };\n}\n\n/**\n * Represents an Amazon Device Messaging (ADM) based installation.\n */\nexport interface AdmInstallation extends DeviceTokenInstallation {\n /**\n * The platform for the installation.\n */\n platform: \"adm\";\n}\n\n/**\n * Creates an Amazon Device Messaging (ADM) based installation.\n * @param installation - A partial installation used to create the ADM installation.\n * @returns The newly created ADM installation.\n */\nexport function createAdmInstallation(\n installation: Omit<AdmInstallation, \"platform\">\n): AdmInstallation {\n return {\n ...installation,\n platform: \"adm\",\n };\n}\n\n/**\n * Represents a Baidu based installation.\n */\nexport interface BaiduInstallation extends DeviceTokenInstallation {\n /**\n * The platform for the installation.\n */\n platform: \"baidu\";\n}\n\n/**\n * Creates a Baidu based installation.\n * @param installation - A partial installation used to create the Baidu installation.\n * @returns The newly created Baidu installation.\n */\nexport function createBaiduInstallation(\n installation: Omit<BaiduInstallation, \"platform\">\n): BaiduInstallation {\n return {\n ...installation,\n platform: \"baidu\",\n };\n}\n\n/**\n * Represents a Firebase Legacy HTTP installation.\n */\nexport interface FirebaseLegacyInstallation extends DeviceTokenInstallation {\n /**\n * The platform for the installation.\n */\n platform: \"gcm\";\n}\n\n/**\n * Creates a Firebase legacy HTTP based installation.\n * @param installation - A partial installation used to create the Firebase Legacy HTTP installation.\n * @returns The newly created Baidu installation.\n */\nexport function createFirebaseLegacyInstallation(\n installation: Omit<FirebaseLegacyInstallation, \"platform\">\n): FirebaseLegacyInstallation {\n return {\n ...installation,\n platform: \"gcm\",\n };\n}\n\n/**\n * Represents a Windows Notification Services (WNS) based installation.\n */\nexport interface WindowsInstallation extends DeviceTokenInstallation {\n /**\n * The platform for the installation.\n */\n platform: \"wns\";\n}\n\n/**\n * Creates a Windows Notification Services (WNS) based installation.\n * @param installation - A partial installation used to create the WNS installation.\n * @returns The newly created WNS installation.\n */\nexport function createWindowsInstallation(\n installation: Omit<WindowsInstallation, \"platform\">\n): WindowsInstallation {\n return {\n ...installation,\n platform: \"wns\",\n };\n}\n\n/**\n * Represents the push channel for a Browser Push installation.\n */\nexport interface BrowserPushChannel {\n /**\n * The P256DH for the browser push installation.\n */\n p256dh: string;\n\n /**\n * The auth secret for the browser push installation.\n */\n auth: string;\n\n /**\n * The endpoint URL for the browser push installation.\n */\n endpoint: string;\n}\n\n/**\n * Represents a Browser/Web Push based installation.\n */\nexport interface BrowserInstallation extends InstallationCommon {\n /**\n * The push channel for the Web Push API.\n */\n pushChannel: BrowserPushChannel;\n\n /**\n * The platform for the installation.\n */\n platform: \"browser\";\n}\n\n/**\n * Creates a Web Push based installation.\n * @param installation - A partial installation used to create the Web Push installation.\n * @returns The newly created Web Push installation.\n */\nexport function createBrowserInstallation(\n installation: Omit<BrowserInstallation, \"platform\">\n): BrowserInstallation {\n return {\n ...installation,\n platform: \"browser\",\n };\n}\n\n/**\n * Represents the types of installations available in Notification Hubs.\n */\nexport type Installation =\n | AppleInstallation\n | AdmInstallation\n | BaiduInstallation\n | BrowserInstallation\n | FirebaseLegacyInstallation\n | WindowsInstallation;\n\n/**\n * Represents an installation template.\n */\nexport interface InstallationTemplate {\n /**\n * The body for the installation template.\n */\n body: string;\n\n /**\n * Headers to include for the template send.\n */\n headers: Record<string, string>;\n\n /**\n * The tags to include for the template.\n */\n tags?: string[];\n}\n\n/**\n * Represents the JSON Patch types of add, remove and replace.\n */\nexport type JsonPatchOperation = \"add\" | \"remove\" | \"replace\";\n\n/**\n * Represents a patch operation.\n */\nexport interface JsonPatch {\n /**\n * The patch operation.\n */\n op: JsonPatchOperation;\n\n /**\n * The path for the patch operation.\n */\n path: string;\n\n /**\n * The value to add or replace for the operation.\n */\n value?: string;\n}\n\n/**\n * Represents the types of push channels available for Notification Hubs.\n */\nexport type PushHandle = BrowserPushChannel | string;\n"]}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import * as Constants from "../utils/constants.js";
|
|
4
|
+
/**
|
|
5
|
+
* Creates a notification to send to an Apple device.
|
|
6
|
+
* @param notification - A partial message used to create a message for Apple.
|
|
7
|
+
* @returns A newly created Apple.
|
|
8
|
+
*/
|
|
9
|
+
export function createAppleNotification(notification) {
|
|
10
|
+
return Object.assign(Object.assign({}, notification), { platform: "apple", contentType: Constants.JSON_CONTENT_TYPE });
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Creates a notification to send to an Amazon Device Messaging device.
|
|
14
|
+
* @param notification - A partial message used to create a message for Amazon Device Messaging.
|
|
15
|
+
* @returns A newly created Amazon Device Messaging.
|
|
16
|
+
*/
|
|
17
|
+
export function createAdmNotification(notification) {
|
|
18
|
+
return Object.assign(Object.assign({}, notification), { platform: "adm", contentType: Constants.JSON_CONTENT_TYPE });
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Creates a notification to send to a Baidu registered device.
|
|
22
|
+
* @param notification - A partial message used to create a message for Baidu.
|
|
23
|
+
* @returns A newly created Baidu.
|
|
24
|
+
*/
|
|
25
|
+
export function createBaiduNotification(notification) {
|
|
26
|
+
return Object.assign(Object.assign({}, notification), { platform: "baidu", contentType: Constants.JSON_CONTENT_TYPE });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Creates a notification to send to a browser.
|
|
30
|
+
* @param notification - A partial message used to create a message for a browser.
|
|
31
|
+
* @returns A newly created Web Push browser.
|
|
32
|
+
*/
|
|
33
|
+
export function createBrowserNotification(notification) {
|
|
34
|
+
return Object.assign(Object.assign({}, notification), { platform: "browser", contentType: Constants.JSON_CONTENT_TYPE });
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a notification to send to Firebase.
|
|
38
|
+
* @param notification - A partial message used to create a message for Firebase.
|
|
39
|
+
* @returns A newly created Firebase.
|
|
40
|
+
*/
|
|
41
|
+
export function createFirebaseLegacyNotification(notification) {
|
|
42
|
+
return Object.assign(Object.assign({}, notification), { platform: "gcm", contentType: Constants.JSON_CONTENT_TYPE });
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Creates a notification to send to Firebase.
|
|
46
|
+
* @param notification - A partial message used to create a message for Firebase.
|
|
47
|
+
* @returns A newly created Firebase.
|
|
48
|
+
*/
|
|
49
|
+
export function createTemplateNotification(notification) {
|
|
50
|
+
return Object.assign(Object.assign({}, notification), { platform: "template", contentType: Constants.JSON_CONTENT_TYPE });
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Creates a badge message to send to WNS.
|
|
54
|
+
* @param notification - A partial message used to create a badge message for WNS.
|
|
55
|
+
* @returns A newly created WNS badge.
|
|
56
|
+
*/
|
|
57
|
+
export function createWindowsBadgeNotification(notification) {
|
|
58
|
+
const result = Object.assign(Object.assign({}, notification), { platform: "wns", contentType: Constants.XML_CONTENT_TYPE });
|
|
59
|
+
if (!result.headers) {
|
|
60
|
+
result.headers = {};
|
|
61
|
+
}
|
|
62
|
+
result.headers[Constants.WNS_TYPE_NAME] = Constants.WNS_BADGE;
|
|
63
|
+
return result;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Creates a tile message to send to WNS.
|
|
67
|
+
* @param notification - A partial message used to create a tile message for WNS.
|
|
68
|
+
* @returns A newly created WNS tile.
|
|
69
|
+
*/
|
|
70
|
+
export function createWindowsTileNotification(notification) {
|
|
71
|
+
const result = Object.assign(Object.assign({}, notification), { platform: "wns", contentType: Constants.XML_CONTENT_TYPE });
|
|
72
|
+
if (!result.headers) {
|
|
73
|
+
result.headers = {};
|
|
74
|
+
}
|
|
75
|
+
result.headers[Constants.WNS_TYPE_NAME] = Constants.WNS_TITLE;
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates a toast message to send to WNS.
|
|
80
|
+
* @param notification - A partial message used to create a toast message for WNS.
|
|
81
|
+
* @returns A newly created WNS toast.
|
|
82
|
+
*/
|
|
83
|
+
export function createWindowsToastNotification(notification) {
|
|
84
|
+
const result = Object.assign(Object.assign({}, notification), { platform: "wns", contentType: Constants.XML_CONTENT_TYPE });
|
|
85
|
+
if (!result.headers) {
|
|
86
|
+
result.headers = {};
|
|
87
|
+
}
|
|
88
|
+
result.headers[Constants.WNS_TYPE_NAME] = Constants.WNS_TOAST;
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Creates a notification to send to WNS in wns/raw format..
|
|
93
|
+
* @param notification - A partial message used to create a message for WNS in XML format.
|
|
94
|
+
* @returns A newly created WNS message using XML.
|
|
95
|
+
*/
|
|
96
|
+
export function createWindowsRawNotification(notification) {
|
|
97
|
+
const result = Object.assign(Object.assign({}, notification), { platform: "wns", contentType: Constants.STREAM_CONTENT_TYPE });
|
|
98
|
+
if (!result.headers) {
|
|
99
|
+
result.headers = {};
|
|
100
|
+
}
|
|
101
|
+
result.headers[Constants.WNS_TYPE_NAME] = Constants.WNS_RAW;
|
|
102
|
+
return result;
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=notification.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../src/models/notification.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as Constants from \"../utils/constants.js\";\n\n/**\n * Represents a notification hub.\n */\nexport interface NotificationCommon {\n /**\n * The body for the push notification.\n */\n body: string;\n\n /**\n * The headers to include for the push notification.\n */\n headers?: Record<string, string>;\n\n /**\n * The platform for the push notification.\n */\n platform: string;\n\n /**\n * The content type for the push notification.\n */\n contentType: string;\n}\n\n/**\n * Represents a JSON notification hub.\n */\nexport interface JsonNotification extends NotificationCommon {\n /**\n * The content type for the push notification.\n */\n contentType: \"application/json;charset=utf-8\";\n}\n\n/**\n * Represents an Apple APNs push notification.\n */\nexport interface AppleNotification extends JsonNotification {\n /**\n * The platform for the push notification.\n */\n platform: \"apple\";\n}\n\n/**\n * Creates a notification to send to an Apple device.\n * @param notification - A partial message used to create a message for Apple.\n * @returns A newly created Apple.\n */\nexport function createAppleNotification(\n notification: Omit<AppleNotification, \"platform\" | \"contentType\">\n): AppleNotification {\n return {\n ...notification,\n platform: \"apple\",\n contentType: Constants.JSON_CONTENT_TYPE,\n };\n}\n\n/**\n * Represents an Amazon Device Messaging (ADM) push notification.\n */\nexport interface AdmNotification extends JsonNotification {\n /**\n * The platform for the push notification.\n */\n platform: \"adm\";\n}\n\n/**\n * Creates a notification to send to an Amazon Device Messaging device.\n * @param notification - A partial message used to create a message for Amazon Device Messaging.\n * @returns A newly created Amazon Device Messaging.\n */\nexport function createAdmNotification(\n notification: Omit<AdmNotification, \"platform\" | \"contentType\">\n): AdmNotification {\n return {\n ...notification,\n platform: \"adm\",\n contentType: Constants.JSON_CONTENT_TYPE,\n };\n}\n\n/**\n * Represents a Baidu push notification.\n */\nexport interface BaiduNotification extends JsonNotification {\n /**\n * The platform for the push notification.\n */\n platform: \"baidu\";\n}\n\n/**\n * Creates a notification to send to a Baidu registered device.\n * @param notification - A partial message used to create a message for Baidu.\n * @returns A newly created Baidu.\n */\nexport function createBaiduNotification(\n notification: Omit<BaiduNotification, \"platform\" | \"contentType\">\n): BaiduNotification {\n return {\n ...notification,\n platform: \"baidu\",\n contentType: Constants.JSON_CONTENT_TYPE,\n };\n}\n\n/**\n * Represents a Browser push notification.\n */\nexport interface BrowserNotification extends JsonNotification {\n /**\n * The platform for the push notification.\n */\n platform: \"browser\";\n}\n\n/**\n * Creates a notification to send to a browser.\n * @param notification - A partial message used to create a message for a browser.\n * @returns A newly created Web Push browser.\n */\nexport function createBrowserNotification(\n notification: Omit<BrowserNotification, \"platform\" | \"contentType\">\n): BrowserNotification {\n return {\n ...notification,\n platform: \"browser\",\n contentType: Constants.JSON_CONTENT_TYPE,\n };\n}\n\n/**\n * Represents a Firebase legacy HTTP push notification.\n */\nexport interface FirebaseLegacyNotification extends JsonNotification {\n /**\n * The platform for the push notification.\n */\n platform: \"gcm\";\n}\n\n/**\n * Creates a notification to send to Firebase.\n * @param notification - A partial message used to create a message for Firebase.\n * @returns A newly created Firebase.\n */\nexport function createFirebaseLegacyNotification(\n notification: Omit<FirebaseLegacyNotification, \"platform\" | \"contentType\">\n): FirebaseLegacyNotification {\n return {\n ...notification,\n platform: \"gcm\",\n contentType: Constants.JSON_CONTENT_TYPE,\n };\n}\n\n/**\n * Represents a template based push notification.\n */\nexport interface TemplateNotification extends JsonNotification {\n /**\n * The platform for the push notification.\n */\n platform: \"template\";\n}\n\n/**\n * Creates a notification to send to Firebase.\n * @param notification - A partial message used to create a message for Firebase.\n * @returns A newly created Firebase.\n */\nexport function createTemplateNotification(\n notification: Omit<TemplateNotification, \"platform\" | \"contentType\">\n): TemplateNotification {\n return {\n ...notification,\n platform: \"template\",\n contentType: Constants.JSON_CONTENT_TYPE,\n };\n}\n\n/**\n * Represents the possible WNS content-types.\n */\nexport type WindowsContentType = \"application/xml\" | \"application/octet-stream\";\n\n/**\n * Represents a Windows Notification Services (WNS) push notification.\n */\nexport interface WindowsNotification extends NotificationCommon {\n /**\n * The platform for the push notification.\n */\n platform: \"wns\";\n\n /**\n * The content type for the push notification.\n */\n contentType: WindowsContentType;\n}\n\n/**\n * Creates a badge message to send to WNS.\n * @param notification - A partial message used to create a badge message for WNS.\n * @returns A newly created WNS badge.\n */\nexport function createWindowsBadgeNotification(\n notification: Omit<WindowsNotification, \"platform\" | \"contentType\">\n): WindowsNotification {\n const result: WindowsNotification = {\n ...notification,\n platform: \"wns\",\n contentType: Constants.XML_CONTENT_TYPE,\n };\n\n if (!result.headers) {\n result.headers = {};\n }\n\n result.headers[Constants.WNS_TYPE_NAME] = Constants.WNS_BADGE;\n\n return result;\n}\n\n/**\n * Creates a tile message to send to WNS.\n * @param notification - A partial message used to create a tile message for WNS.\n * @returns A newly created WNS tile.\n */\nexport function createWindowsTileNotification(\n notification: Omit<WindowsNotification, \"platform\" | \"contentType\">\n): WindowsNotification {\n const result: WindowsNotification = {\n ...notification,\n platform: \"wns\",\n contentType: Constants.XML_CONTENT_TYPE,\n };\n\n if (!result.headers) {\n result.headers = {};\n }\n\n result.headers[Constants.WNS_TYPE_NAME] = Constants.WNS_TITLE;\n\n return result;\n}\n\n/**\n * Creates a toast message to send to WNS.\n * @param notification - A partial message used to create a toast message for WNS.\n * @returns A newly created WNS toast.\n */\nexport function createWindowsToastNotification(\n notification: Omit<WindowsNotification, \"platform\" | \"contentType\">\n): WindowsNotification {\n const result: WindowsNotification = {\n ...notification,\n platform: \"wns\",\n contentType: Constants.XML_CONTENT_TYPE,\n };\n\n if (!result.headers) {\n result.headers = {};\n }\n\n result.headers[Constants.WNS_TYPE_NAME] = Constants.WNS_TOAST;\n\n return result;\n}\n\n/**\n * Creates a notification to send to WNS in wns/raw format..\n * @param notification - A partial message used to create a message for WNS in XML format.\n * @returns A newly created WNS message using XML.\n */\nexport function createWindowsRawNotification(\n notification: Omit<WindowsNotification, \"platform\" | \"contentType\">\n): WindowsNotification {\n const result: WindowsNotification = {\n ...notification,\n platform: \"wns\",\n contentType: Constants.STREAM_CONTENT_TYPE,\n };\n\n if (!result.headers) {\n result.headers = {};\n }\n\n result.headers[Constants.WNS_TYPE_NAME] = Constants.WNS_RAW;\n\n return result;\n}\n\n/**\n * Represents the possible push notification messages types.\n */\nexport type Notification =\n | AppleNotification\n | AdmNotification\n | BaiduNotification\n | BrowserNotification\n | FirebaseLegacyNotification\n | WindowsNotification\n | TemplateNotification;\n"]}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
import { createAdmNotification, createAppleNotification, createBaiduNotification, createFirebaseLegacyNotification, createWindowsBadgeNotification, } from "./notification.js";
|
|
4
|
+
import { isDefined, isString } from "../utils/utils.js";
|
|
5
|
+
import { stringifyXML } from "@azure/core-xml";
|
|
6
|
+
function createAppleNativeAlert(nativeAlert) {
|
|
7
|
+
if (!isDefined(nativeAlert)) {
|
|
8
|
+
return undefined;
|
|
9
|
+
}
|
|
10
|
+
if (isString(nativeAlert)) {
|
|
11
|
+
return nativeAlert;
|
|
12
|
+
}
|
|
13
|
+
const alert = {
|
|
14
|
+
title: nativeAlert.title,
|
|
15
|
+
subtitle: nativeAlert.subtitle,
|
|
16
|
+
body: nativeAlert.body,
|
|
17
|
+
"launch-image": nativeAlert.launchImage,
|
|
18
|
+
"title-loc-key": nativeAlert.titleLocKey,
|
|
19
|
+
"title-loc-args": nativeAlert.titleLocArgs,
|
|
20
|
+
"subtitle-loc-key": nativeAlert.subtitleLocKey,
|
|
21
|
+
"subtitle-loc-args": nativeAlert.subtitleLocArgs,
|
|
22
|
+
"loc-key": nativeAlert.locKey,
|
|
23
|
+
"loc-args": nativeAlert.locArgs,
|
|
24
|
+
};
|
|
25
|
+
return alert;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates an APNs native message to send to Notification Hubs.
|
|
29
|
+
* @param nativeMessage - The Apple native message properties to set.
|
|
30
|
+
* @param additionalProperties - Additional properties for Apple messages.
|
|
31
|
+
* @returns An AppleNotification to send to Notification Hubs.
|
|
32
|
+
*/
|
|
33
|
+
export function buildAppleNativeMessage(nativeMessage, additionalProperties) {
|
|
34
|
+
const headers = {};
|
|
35
|
+
const message = Object.assign({ aps: {
|
|
36
|
+
alert: createAppleNativeAlert(nativeMessage.alert),
|
|
37
|
+
sound: nativeMessage.sound,
|
|
38
|
+
badge: nativeMessage.badge,
|
|
39
|
+
"thread-id": nativeMessage.threadId,
|
|
40
|
+
category: nativeMessage.category,
|
|
41
|
+
"content-available": nativeMessage.contentAvailable,
|
|
42
|
+
"mutable-content": nativeMessage.mutableContent,
|
|
43
|
+
"target-content-id": nativeMessage.targetContentId,
|
|
44
|
+
"interruption-level": nativeMessage.interruptionLevel,
|
|
45
|
+
"relevance-score": nativeMessage.relevanceScore,
|
|
46
|
+
"filter-criteria": nativeMessage.filterCriteria,
|
|
47
|
+
} }, additionalProperties);
|
|
48
|
+
const apnsPriority = (nativeMessage === null || nativeMessage === void 0 ? void 0 : nativeMessage.contentAvailable) === 1 ? "5" : "10";
|
|
49
|
+
headers["apns-priority"] = apnsPriority;
|
|
50
|
+
return createAppleNotification({
|
|
51
|
+
body: JSON.stringify(message),
|
|
52
|
+
headers: headers,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
function buildFirebaseLegacyNativePayload(nativeNotification) {
|
|
56
|
+
if (!isDefined(nativeNotification)) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
const androidMessage = nativeNotification;
|
|
60
|
+
const appleMessage = nativeNotification;
|
|
61
|
+
const notification = {
|
|
62
|
+
title: nativeNotification.title,
|
|
63
|
+
body: nativeNotification.body,
|
|
64
|
+
click_action: nativeNotification.clickAction,
|
|
65
|
+
// Apple/Android fields
|
|
66
|
+
sound: appleMessage.sound,
|
|
67
|
+
badge: appleMessage.badge,
|
|
68
|
+
subtitle: appleMessage.subtitle,
|
|
69
|
+
body_loc_key: appleMessage.bodyLocKey,
|
|
70
|
+
body_loc_args: appleMessage.bodyLocArgs,
|
|
71
|
+
title_loc_key: appleMessage.bodyLocKey,
|
|
72
|
+
title_loc_args: appleMessage.bodyLocArgs,
|
|
73
|
+
// Android/Web fields
|
|
74
|
+
android_channel_id: androidMessage.androidChannelId,
|
|
75
|
+
icon: androidMessage.icon,
|
|
76
|
+
tag: androidMessage.tag,
|
|
77
|
+
color: androidMessage.color,
|
|
78
|
+
};
|
|
79
|
+
return notification;
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Creates a FirebaseLegacyNotification from a native Firebase payload.
|
|
83
|
+
* @param nativeMessage - The native message payload to send to Notification Hubs.
|
|
84
|
+
* @returns The FirebaseLegacyNotification to send to Notification Hubs.
|
|
85
|
+
*/
|
|
86
|
+
export function buildFirebaseLegacyNativeMessage(nativeMessage) {
|
|
87
|
+
const jsonMessage = {
|
|
88
|
+
to: nativeMessage.to,
|
|
89
|
+
registration_ids: nativeMessage.registrationIds,
|
|
90
|
+
condition: nativeMessage.condition,
|
|
91
|
+
collapse_key: nativeMessage.collapseKey,
|
|
92
|
+
priority: nativeMessage.priority,
|
|
93
|
+
content_available: nativeMessage.contentAvailable,
|
|
94
|
+
mutable_content: nativeMessage.mutableContent,
|
|
95
|
+
time_to_live: nativeMessage.timeToLive,
|
|
96
|
+
restricted_package_name: nativeMessage.restrictedPackageName,
|
|
97
|
+
dry_run: nativeMessage.dryRun,
|
|
98
|
+
data: nativeMessage.data,
|
|
99
|
+
notification: buildFirebaseLegacyNativePayload(nativeMessage.notification),
|
|
100
|
+
};
|
|
101
|
+
return createFirebaseLegacyNotification({
|
|
102
|
+
body: JSON.stringify(jsonMessage),
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function buildAdmNativeNotification(nativeNotification) {
|
|
106
|
+
if (!isDefined(nativeNotification)) {
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
return {
|
|
110
|
+
title: nativeNotification.title,
|
|
111
|
+
body: nativeNotification.body,
|
|
112
|
+
icon: nativeNotification.icon,
|
|
113
|
+
color: nativeNotification.color,
|
|
114
|
+
sound: nativeNotification.sound,
|
|
115
|
+
tag: nativeNotification.tag,
|
|
116
|
+
click_action: nativeNotification.clickAction,
|
|
117
|
+
body_loc_key: nativeNotification.bodyLocKey,
|
|
118
|
+
body_loc_args: nativeNotification.bodyLocArgs,
|
|
119
|
+
title_loc_key: nativeNotification.titleLocKey,
|
|
120
|
+
title_loc_args: nativeNotification.titleLocArgs,
|
|
121
|
+
channel_id: nativeNotification.channelId,
|
|
122
|
+
ticker: nativeNotification.ticker,
|
|
123
|
+
sticky: nativeNotification.sticky,
|
|
124
|
+
event_time: nativeNotification.eventTime,
|
|
125
|
+
local_only: nativeNotification.localOnly,
|
|
126
|
+
notification_priority: nativeNotification.notificationPriority,
|
|
127
|
+
default_sound: nativeNotification.defaultSound,
|
|
128
|
+
visibility: nativeNotification.visibility,
|
|
129
|
+
notification_count: nativeNotification.notificationCount,
|
|
130
|
+
image: nativeNotification.image,
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Creates a AdmNotification from a native ADM payload.
|
|
135
|
+
* @param nativeMessage - The native message payload to send to Notification Hubs.
|
|
136
|
+
* @returns The AdmNotification to send to Notification Hubs.
|
|
137
|
+
*/
|
|
138
|
+
export function buildAdmNativeMessage(nativeMessage) {
|
|
139
|
+
const jsonObj = Object.assign({ notification: buildAdmNativeNotification(nativeMessage.notification), data: nativeMessage.data || {} }, nativeMessage);
|
|
140
|
+
return createAdmNotification({
|
|
141
|
+
body: JSON.stringify(jsonObj),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Creates a BaiduNotification from a native Baidu payload.
|
|
146
|
+
* @param nativeMessage - The native message payload to send to Notification Hubs.
|
|
147
|
+
* @param additionalProperties - Additional properties for Apple Baidu messages.
|
|
148
|
+
* @returns The BaiduNotification to send to Notification Hubs.
|
|
149
|
+
*/
|
|
150
|
+
export function buildBaiduNativeMessage(nativeMessage, additionalProperties) {
|
|
151
|
+
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);
|
|
152
|
+
return createBaiduNotification({
|
|
153
|
+
body: JSON.stringify(jsonObj),
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Builds a WindowsNotification from a Windows Badge.
|
|
158
|
+
* @param nativeMessage - The Windows Badge Message to build.
|
|
159
|
+
* @returns A WindowsNotification created with the badge information.
|
|
160
|
+
*/
|
|
161
|
+
export function buildWindowsBadgeNativeMessage(nativeMessage) {
|
|
162
|
+
const badge = {
|
|
163
|
+
$: { value: nativeMessage.value },
|
|
164
|
+
};
|
|
165
|
+
return createWindowsBadgeNotification({
|
|
166
|
+
body: stringifyXML(badge, { rootName: "badge" }),
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
//# sourceMappingURL=notificationBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notificationBuilder.js","sourceRoot":"","sources":["../../../src/models/notificationBuilder.ts"],"names":[],"mappings":"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","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AdmNotification,\n AppleNotification,\n BaiduNotification,\n FirebaseLegacyNotification,\n WindowsNotification,\n createAdmNotification,\n createAppleNotification,\n createBaiduNotification,\n createFirebaseLegacyNotification,\n createWindowsBadgeNotification,\n} from \"./notification.js\";\nimport { isDefined, isString } from \"../utils/utils.js\";\nimport { stringifyXML } from \"@azure/core-xml\";\n\n/**\n * Represents what is in the APNs alert body.\n */\nexport interface AppleAlert {\n /**\n * The title of the notification. Apple Watch displays this string in the short look notification\n * interface. Specify a string that’s quickly understood by the user.\n */\n title?: string;\n\n /**\n * Additional information that explains the purpose of the notification.\n */\n subtitle?: string;\n\n /**\n * The content of the alert message.\n */\n body?: string;\n\n /**\n * The name of the launch image file to display. If the user chooses to launch your app,\n * the contents of the specified image or storyboard file are displayed instead of your app’s normal launch image.\n */\n launchImage?: string;\n\n /**\n * The key for a localized title string. Specify this key instead of the title key to retrieve\n * the title from your app’s Localizable.strings files. The value must contain the name of a key in your strings file.\n */\n titleLocKey?: string;\n\n /**\n * An array of strings containing replacement values for variables in your title string.\n * Each %\\@ character in the string specified by the title-loc-key is replaced by a value\n * from this array. The first item in the array replaces the first instance\n * of the %\\@ character in the string, the second item replaces the second instance, and so on.\n */\n titleLocArgs?: string[];\n\n /**\n * The key for a localized subtitle string. Use this key, instead of the subtitle key, to\n * retrieve the subtitle from your app’s Localizable.strings file.\n * The value must contain the name of a key in your strings file.\n */\n subtitleLocKey?: string;\n\n /**\n * An array of strings containing replacement values for variables in your title string.\n * Each %\\@ character in the string specified by subtitle-loc-key is replaced by a value\n * from this array. The first item in the array replaces the first instance of the\n * %\\@ character in the string, the second item replaces the second instance, and so on.\n */\n subtitleLocArgs?: string[];\n\n /**\n * The key for a localized message string. Use this key, instead of the body key, to\n * retrieve the message text from your app’s Localizable.strings file. The value must contain\n * the name of a key in your strings file.\n */\n locKey?: string;\n\n /**\n * An array of strings containing replacement values for variables in your message text.\n * Each %\\@ character in the string specified by loc-key is replaced by a value from\n * this array. The first item in the array replaces the first instance of the %\\@ character\n * in the string, the second item replaces the second instance, and so on.\n */\n locArgs?: string[];\n}\n\n/**\n * Represents an APNs critical sound\n */\nexport interface AppleCriticalSound {\n /**\n * The critical alert flag. Set to 1 to enable the critical alert.\n */\n critical: number;\n\n /**\n * The name of a sound file in your app’s main bundle or in the Library/Sounds folder\n * of your app’s container directory. Specify the string “default” to play the system sound.\n */\n name: string;\n\n /**\n * The volume for the critical alert’s sound. Set this to a value between 0 (silent) and 1 (full volume).\n */\n volume: number;\n}\n\n/**\n * Represents a native APNs message.\n */\nexport interface AppleNativeMessage extends Record<string, any> {\n /**\n * The information for displaying an alert.\n */\n alert?: string | AppleAlert;\n\n /**\n * The number to display in a badge on your app’s icon.\n */\n badge?: number;\n\n /**\n * The name of a sound file in your app’s main bundle or in the Library/Sounds\n * folder of your app’s container directory. Specify the string “default” to\n * play the system sound. Use this key for regular notifications.\n * For critical alerts, use the sound dictionary instead.\n */\n sound?: string | AppleCriticalSound;\n\n /**\n * An app-specific identifier for grouping related notifications.\n */\n threadId?: string;\n\n /**\n * The notification’s type.\n */\n category?: string;\n\n /**\n * The background notification flag. To perform a silent background update,\n * specify the value 1 and don’t include the alert, badge, or sound keys in your payload.\n */\n contentAvailable?: number;\n\n /**\n * The notification service app extension flag. If the value is 1, the system passes\n * the notification to your notification service app extension before delivery.\n */\n mutableContent?: number;\n\n /**\n * The identifier of the window brought forward.\n */\n targetContentId?: string;\n\n /**\n * The importance and delivery timing of a notification.\n */\n interruptionLevel?: \"passive\" | \"active\" | \"time-sensitive\" | \"critical\";\n\n /**\n * The relevance score, a number between 0 and 1, that the system uses to sort the\n * notifications from your app. The highest score gets featured in the notification summary.\n */\n relevanceScore?: number;\n\n /**\n * The criteria the system evaluates to determine if it displays the notification in the current Focus.\n */\n filterCriteria?: string;\n}\n\nfunction createAppleNativeAlert(\n nativeAlert?: string | AppleAlert\n): Record<string, any> | string | undefined {\n if (!isDefined(nativeAlert)) {\n return undefined;\n }\n\n if (isString(nativeAlert)) {\n return nativeAlert;\n }\n\n const alert: Record<string, any> = {\n title: nativeAlert.title,\n subtitle: nativeAlert.subtitle,\n body: nativeAlert.body,\n \"launch-image\": nativeAlert.launchImage,\n \"title-loc-key\": nativeAlert.titleLocKey,\n \"title-loc-args\": nativeAlert.titleLocArgs,\n \"subtitle-loc-key\": nativeAlert.subtitleLocKey,\n \"subtitle-loc-args\": nativeAlert.subtitleLocArgs,\n \"loc-key\": nativeAlert.locKey,\n \"loc-args\": nativeAlert.locArgs,\n };\n\n return alert;\n}\n\n/**\n * Creates an APNs native message to send to Notification Hubs.\n * @param nativeMessage - The Apple native message properties to set.\n * @param additionalProperties - Additional properties for Apple messages.\n * @returns An AppleNotification to send to Notification Hubs.\n */\nexport function buildAppleNativeMessage(\n nativeMessage: AppleNativeMessage,\n additionalProperties?: Record<string, any>\n): AppleNotification {\n const headers: Record<string, string> = {};\n\n const message: Record<string, any> = {\n aps: {\n alert: createAppleNativeAlert(nativeMessage.alert),\n sound: nativeMessage.sound,\n badge: nativeMessage.badge,\n \"thread-id\": nativeMessage.threadId,\n category: nativeMessage.category,\n \"content-available\": nativeMessage.contentAvailable,\n \"mutable-content\": nativeMessage.mutableContent,\n \"target-content-id\": nativeMessage.targetContentId,\n \"interruption-level\": nativeMessage.interruptionLevel,\n \"relevance-score\": nativeMessage.relevanceScore,\n \"filter-criteria\": nativeMessage.filterCriteria,\n },\n ...additionalProperties,\n };\n\n const apnsPriority = nativeMessage?.contentAvailable === 1 ? \"5\" : \"10\";\n headers[\"apns-priority\"] = apnsPriority;\n\n return createAppleNotification({\n body: JSON.stringify(message),\n headers: headers,\n });\n}\n\n/**\n * Represents the targets, options, and payload for HTTP JSON messages for the Firebase Legacy HTTP interface.\n */\nexport interface FirebaseLegacyNativeMessage {\n /**\n * The recipient of a message.\n */\n to?: string;\n\n /**\n * The recipient of a multicast message, a message sent to more than one registration token.\n */\n registrationIds?: string[];\n\n /**\n * A logical expression of conditions that determine the message target.\n */\n condition?: string;\n\n /**\n * Used to identify a group of messages.\n */\n collapseKey?: string;\n\n /**\n * The priority of the message.\n */\n priority?: \"normal\" | \"high\";\n\n /**\n * The background notification flag. To perform a silent background update,\n * specify the value 1 and don’t include the alert, badge, or sound keys in your payload.\n */\n contentAvailable?: boolean;\n\n /**\n * The notification service app extension flag. If the value is 1, the system passes\n * the notification to your notification service app extension before delivery.\n */\n mutableContent?: number;\n\n /**\n * Specifies how long (in seconds) the message should be kept in FCM storage if the device is offline\n */\n timeToLive?: number;\n\n /**\n * The package name of the application where the registration tokens must match in order to receive the message.\n */\n restrictedPackageName?: string;\n\n /**\n * When set to true, allows developers to test a request without actually sending a message.\n */\n dryRun?: boolean;\n\n /**\n * Custom key-value pairs of the message's payload.\n */\n data?: Record<string, any>;\n\n /**\n * The predefined, user-visible key-value pairs of the notification payload.\n */\n notification?:\n | FirebaseLegacyAppleNativePayload\n | FirebaseLegacyAndroidNativePayload\n | FirebaseLegacyWebNativePayload;\n}\n\n/**\n * Represents an APNs native payload for the Firebase Legacy HTTP interface.\n */\nexport interface FirebaseLegacyAppleNativePayload {\n /**\n * The notification's title.\n */\n title?: string;\n\n /**\n * The notification's body text.\n */\n body?: string;\n\n /**\n * The sound to play when the device receives the notification.\n */\n sound?: string;\n\n /**\n * The value of the badge on the home screen app icon.\n */\n badge?: string;\n\n /**\n * The action associated with a user click on the notification which corresponds to the APNs category.\n */\n clickAction?: string;\n\n /**\n * The notification's subtitle.\n */\n subtitle?: string;\n\n /**\n * The key to the body string in the app's string resources to use to localize the body text to the user's current localization.\n */\n bodyLocKey?: string;\n\n /**\n * Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the body text to the user's current localization.\n */\n bodyLocArgs?: string[];\n\n /**\n * The key to the title string in the app's string resources to use to localize the title text to the user's current localization.\n */\n titleLocKey?: string;\n\n /**\n * Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the title text to the user's current localization.\n */\n titleLocArgs?: string[];\n}\n\n/**\n * Represents an Android native payload for the Firebase Legacy HTTP interface.\n */\nexport interface FirebaseLegacyAndroidNativePayload {\n /**\n * The notification's title.\n */\n title?: string;\n\n /**\n * The notification's body text.\n */\n body?: string;\n\n /**\n * The notification's channel ID.\n */\n androidChannelId?: string;\n\n /**\n * The notification's icon.\n */\n icon?: string;\n\n /**\n * The sound to play when the device receives the notification.\n */\n sound?: string;\n\n /**\n * Identifier used to replace existing notifications in the notification drawer.\n */\n tag?: string;\n\n /**\n * The notification's icon color, expressed in #rrggbb format.\n */\n color?: string;\n\n /**\n * The action associated with a user click on the notification.\n */\n clickAction?: string;\n\n /**\n * The key to the body string in the app's string resources to use to localize the body text to the user's current localization.\n */\n bodyLocKey?: string;\n\n /**\n * Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the body text to the user's current localization.\n */\n bodyLocArgs?: string[];\n\n /**\n * The key to the title string in the app's string resources to use to localize the title text to the user's current localization.\n */\n titleLocKey?: string;\n\n /**\n * Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the title text to the user's current localization.\n */\n titleLocArgs?: string[];\n}\n\n/**\n * Represents an Web Push native payload for the Firebase Legacy HTTP interface.\n */\nexport interface FirebaseLegacyWebNativePayload {\n /**\n * The notification's title.\n */\n title?: string;\n\n /**\n * The notification's body text.\n */\n body?: string;\n\n /**\n * The URL to use for the notification's icon.\n */\n icon?: string;\n\n /**\n * The action associated with a user click on the notification.\n */\n clickAction?: string;\n}\n\nfunction buildFirebaseLegacyNativePayload(\n nativeNotification?:\n | FirebaseLegacyAppleNativePayload\n | FirebaseLegacyAndroidNativePayload\n | FirebaseLegacyWebNativePayload\n): Record<string, any> | undefined {\n if (!isDefined(nativeNotification)) {\n return undefined;\n }\n\n const androidMessage = nativeNotification as FirebaseLegacyAndroidNativePayload;\n const appleMessage = nativeNotification as FirebaseLegacyAppleNativePayload;\n\n const notification: Record<string, any> = {\n title: nativeNotification.title,\n body: nativeNotification.body,\n click_action: nativeNotification.clickAction,\n\n // Apple/Android fields\n sound: appleMessage.sound,\n badge: appleMessage.badge,\n subtitle: appleMessage.subtitle,\n body_loc_key: appleMessage.bodyLocKey,\n body_loc_args: appleMessage.bodyLocArgs,\n title_loc_key: appleMessage.bodyLocKey,\n title_loc_args: appleMessage.bodyLocArgs,\n\n // Android/Web fields\n android_channel_id: androidMessage.androidChannelId,\n icon: androidMessage.icon,\n tag: androidMessage.tag,\n color: androidMessage.color,\n };\n\n return notification;\n}\n\n/**\n * Creates a FirebaseLegacyNotification from a native Firebase payload.\n * @param nativeMessage - The native message payload to send to Notification Hubs.\n * @returns The FirebaseLegacyNotification to send to Notification Hubs.\n */\nexport function buildFirebaseLegacyNativeMessage(\n nativeMessage: FirebaseLegacyNativeMessage\n): FirebaseLegacyNotification {\n const jsonMessage: Record<string, any> = {\n to: nativeMessage.to,\n registration_ids: nativeMessage.registrationIds,\n condition: nativeMessage.condition,\n collapse_key: nativeMessage.collapseKey,\n priority: nativeMessage.priority,\n content_available: nativeMessage.contentAvailable,\n mutable_content: nativeMessage.mutableContent,\n time_to_live: nativeMessage.timeToLive,\n restricted_package_name: nativeMessage.restrictedPackageName,\n dry_run: nativeMessage.dryRun,\n data: nativeMessage.data,\n notification: buildFirebaseLegacyNativePayload(nativeMessage.notification),\n };\n\n return createFirebaseLegacyNotification({\n body: JSON.stringify(jsonMessage),\n });\n}\n\n/**\n * Describes ADM notification messages.\n */\nexport interface AdmNativeNotification {\n /**\n * The notification's title.\n */\n title?: string;\n\n /**\n * The notification's body text.\n */\n body?: string;\n\n /**\n * The notification's icon.\n */\n icon?: string;\n\n /**\n * The notification's icon color, expressed in #rrggbb format.\n */\n color?: string;\n\n /**\n * The sound to play when the device receives the notification. Supports \"default\" or the filename of a sound resource bundled in the app.\n */\n sound?: string;\n\n /**\n * Identifier used to replace existing notifications in the notification drawer.\n */\n tag?: string;\n\n /**\n * The action associated with a user click on the notification.\n */\n clickAction?: string;\n\n /**\n * The key to the body string in the app's string resources to use to localize the body text to the user's current localization.\n */\n bodyLocKey?: string;\n\n /**\n * Variable string values to be used in place of the format specifiers in body_loc_key to use to localize the body text to the user's current localization.\n */\n bodyLocArgs?: string[];\n\n /**\n * The key to the title string in the app's string resources to use to localize the title text to the user's current localization.\n */\n titleLocKey?: string;\n\n /**\n * Variable string values to be used in place of the format specifiers in title_loc_key to use to localize the title text to the user's current localization.\n */\n titleLocArgs?: string[];\n\n /**\n * The notification's channel id.\n */\n channelId?: string;\n\n /**\n * Sets the \"ticker\" text, which is sent to accessibility services.\n */\n ticker?: string;\n\n /**\n * When set to false or unset, the notification is automatically dismissed when the user clicks it in the panel.\n */\n sticky?: boolean;\n\n /**\n * Set the time that the event in the notification occurred. Must be a timestamp in RFC3339 UTC \"Zulu\" format, accurate to nanoseconds. Example: \"2014-10-02T15:01:23.045123456Z\".\n */\n eventTime?: string;\n\n /**\n * Set whether or not this notification is relevant only to the current device.\n */\n localOnly?: boolean;\n\n /**\n * Set the relative priority for this notification.\n */\n notificationPriority?: number; // TODO: Enum?\n\n /**\n * If set to true, use the Android framework's default sound for the notification.\n */\n defaultSound?: boolean;\n\n /**\n * Set the Notification.visibility of the notification.\n */\n visibility?: number; // TODO: Enum?\n\n /**\n * Sets the number of items this notification represents.\n */\n notificationCount?: number;\n\n /**\n * Contains the URL of an image that is going to be displayed in a notification.\n */\n image?: string;\n}\n\n/**\n * Represents a native ADM notification message payload.\n */\nexport interface AdmNativeMessage {\n /**\n * The notification payload to send with the message.\n */\n notification?: AdmNativeNotification;\n\n /**\n * The payload data to send with the message.\n */\n data?: Record<string, string>;\n\n /**\n * The priority of the msssage.\n */\n priority?: \"normal\" | \"high\";\n\n /**\n * This is an arbitrary string used to indicate that multiple messages are logically the same\n * and that ADM is allowed to drop previously enqueued messages in favor of this new one.\n */\n consolidationKey?: string;\n\n /**\n * The number of seconds that ADM should retain the message if the device is offline.\n */\n expiresAfter?: number;\n\n /**\n * This is a base-64-encoded MD5 checksum of the data parameter.\n */\n md5?: string;\n}\n\nfunction buildAdmNativeNotification(\n nativeNotification?: AdmNativeNotification\n): Record<string, any> | undefined {\n if (!isDefined(nativeNotification)) {\n return undefined;\n }\n\n return {\n title: nativeNotification.title,\n body: nativeNotification.body,\n icon: nativeNotification.icon,\n color: nativeNotification.color,\n sound: nativeNotification.sound,\n tag: nativeNotification.tag,\n click_action: nativeNotification.clickAction,\n body_loc_key: nativeNotification.bodyLocKey,\n body_loc_args: nativeNotification.bodyLocArgs,\n title_loc_key: nativeNotification.titleLocKey,\n title_loc_args: nativeNotification.titleLocArgs,\n channel_id: nativeNotification.channelId,\n ticker: nativeNotification.ticker,\n sticky: nativeNotification.sticky,\n event_time: nativeNotification.eventTime,\n local_only: nativeNotification.localOnly,\n notification_priority: nativeNotification.notificationPriority,\n default_sound: nativeNotification.defaultSound,\n visibility: nativeNotification.visibility,\n notification_count: nativeNotification.notificationCount,\n image: nativeNotification.image,\n };\n}\n\n/**\n * Creates a AdmNotification from a native ADM payload.\n * @param nativeMessage - The native message payload to send to Notification Hubs.\n * @returns The AdmNotification to send to Notification Hubs.\n */\nexport function buildAdmNativeMessage(nativeMessage: AdmNativeMessage): AdmNotification {\n const jsonObj: Record<string, any> = {\n notification: buildAdmNativeNotification(nativeMessage.notification),\n data: nativeMessage.data || {},\n ...nativeMessage,\n };\n\n return createAdmNotification({\n body: JSON.stringify(jsonObj),\n });\n}\n\n/**\n * Represents the Baidu Apple native payload.\n */\nexport interface BaiduAppleNativePayload {\n /**\n * The alert string.\n */\n alert?: string;\n\n /**\n * The APNs sound to play.\n */\n sound?: string;\n\n /**\n * The APNs badge count.\n */\n badge?: number;\n}\n\n/**\n * Baidu Native Format:\n * https://stackoverflow.com/questions/42591815/customize-baidu-push-json-payload\n * http://www.tuicool.com/articles/ZnmANn\n */\nexport interface BaiduNativeMessage extends Record<string, any> {\n /**\n * Notification title for Android.\n */\n title?: string;\n\n /**\n * Baidu Notification description for Android.\n */\n description?: string;\n\n /**\n * Baidu Notification builder ID.\n */\n notificationBuilderId?: number;\n\n /**\n * Baidu Notification Android basic style.\n */\n notificationBasicStyle?: number;\n\n /**\n * Baidu Android open type.\n */\n openType?: number;\n\n /**\n * Baidu Android net support option.\n */\n netSupport?: number;\n\n /**\n * Baidu Android user confirm.\n */\n userConfirm?: number;\n\n /**\n * Baidu Android URL.\n */\n url?: string;\n\n /**\n * Baidu Android package content.\n */\n pkgContent?: string;\n\n /**\n * Baidu Android package version.\n */\n pkgVersion?: string;\n\n /**\n * Baidu Android custom content dictionary.\n */\n customContent?: Record<string, any>;\n\n /**\n * Baidu APNs support.\n */\n aps?: BaiduAppleNativePayload;\n}\n\n/**\n * Creates a BaiduNotification from a native Baidu payload.\n * @param nativeMessage - The native message payload to send to Notification Hubs.\n * @param additionalProperties - Additional properties for Apple Baidu messages.\n * @returns The BaiduNotification to send to Notification Hubs.\n */\nexport function buildBaiduNativeMessage(\n nativeMessage: BaiduNativeMessage,\n additionalProperties?: Record<string, any>\n): BaiduNotification {\n const jsonObj: Record<string, any> = {\n title: nativeMessage.title,\n description: nativeMessage.description,\n notification_builder_id: nativeMessage.notificationBuilderId,\n notification_basic_style: nativeMessage.notificationBasicStyle,\n open_type: nativeMessage.openType,\n net_support: nativeMessage.netSupport,\n user_confirm: nativeMessage.userConfirm,\n url: nativeMessage.url,\n pkg_content: nativeMessage.pkgContent,\n pkg_version: nativeMessage.pkgVersion,\n custom_content: nativeMessage.customContent,\n aps: nativeMessage.aps,\n ...additionalProperties,\n };\n\n return createBaiduNotification({\n body: JSON.stringify(jsonObj),\n });\n}\n\n/**\n * Represents the types of Windows Badge Glyphs\n */\nexport type WindowsBadgeGlyphType =\n | \"none\"\n | \"activity\"\n | \"alarm\"\n | \"alert\"\n | \"attention\"\n | \"available\"\n | \"away\"\n | \"busy\"\n | \"error\"\n | \"newMessage\"\n | \"paused\"\n | \"playing\"\n | \"unavailable\";\n\n/**\n * Represents the Windows Badge Message\n */\nexport interface WindowsBadgeNativeMessage {\n /**\n * Either a numeric value or a string value that specifies a predefined badge glyph.\n */\n value: WindowsBadgeGlyphType | number;\n}\n\n/**\n * Builds a WindowsNotification from a Windows Badge.\n * @param nativeMessage - The Windows Badge Message to build.\n * @returns A WindowsNotification created with the badge information.\n */\nexport function buildWindowsBadgeNativeMessage(\n nativeMessage: WindowsBadgeNativeMessage\n): WindowsNotification {\n const badge = {\n $: { value: nativeMessage.value },\n };\n\n return createWindowsBadgeNotification({\n body: stringifyXML(badge, { rootName: \"badge\" }),\n });\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notificationDetails.js","sourceRoot":"","sources":["../../../src/models/notificationDetails.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Represents the notification outcome states.\n */\nexport type NotificationOutcomeState =\n | \"Enqueued\"\n | \"DetailedStateAvailable\"\n | \"Processing\"\n | \"Completed\"\n | \"Abandoned\"\n | \"Unknown\"\n | \"NoTargetFound\"\n | \"Cancelled\";\n\n/**\n * The per platform count per state.\n */\nexport interface NotificationOutcomeCollectionItem {\n /**\n * The state of the notification.\n */\n state: string;\n\n /**\n * The count of notifications per state.\n */\n count: number;\n}\n\n/**\n * Represents Notification details.\n */\nexport interface NotificationDetails {\n /**\n * The unique notification identifier.\n */\n notificationId?: string;\n\n /**\n * The notification location.\n */\n location?: string;\n\n /**\n * The notification state.\n */\n state?: NotificationOutcomeState;\n\n /**\n * The enqueue time of the notification.\n */\n enqueueTime?: Date;\n\n /**\n * The notification send start time.\n */\n startTime?: Date;\n\n /**\n * The notification send end time.\n */\n endTime?: Date;\n\n /**\n * The notification body.\n */\n notificationBody?: string;\n\n /**\n * The notification tags.\n */\n tags?: string;\n\n /**\n * The notification platforms targeted.\n */\n targetPlatforms?: string;\n\n /**\n * The URL for the platform notification services errors.\n */\n pnsErrorDetailsUrl?: string;\n\n /**\n * APNs outcomes counts per state.\n */\n apnsOutcomeCounts?: NotificationOutcomeCollectionItem[];\n\n /**\n * WNS outcomes counts per state.\n */\n wnsOutcomeCounts?: NotificationOutcomeCollectionItem[];\n\n /**\n * FCM outcome counts per state.\n */\n fcmOutcomeCounts?: NotificationOutcomeCollectionItem[];\n\n /**\n * ADM outcome counts per state.\n */\n admOutcomeCounts?: NotificationOutcomeCollectionItem[];\n\n /**\n * Baidu outcome counts per state.\n */\n baiduOutcomeCounts?: NotificationOutcomeCollectionItem[];\n\n /**\n * Web Push outcome counts per state.\n */\n browserOutcomeCounts?: NotificationOutcomeCollectionItem[];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notificationHubJob.js","sourceRoot":"","sources":["../../../src/models/notificationHubJob.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Describes the types of notification hub jobs.\n */\nexport type NotificationHubJobType =\n /**\n * Job type to bulk get registrations.\n */\n | \"ExportRegistrations\"\n\n /**\n * Job type to bulk create registrations.\n */\n | \"ImportCreateRegistrations\"\n\n /**\n * Job type to bulk update registrations.\n */\n | \"ImportUpdateRegistrations\"\n\n /**\n * Job type to bulk delete registrations.\n */\n | \"ImportDeleteRegistrations\"\n\n /**\n * Job type to bulk upsert registrations.\n */\n | \"ImportUpsertRegistrations\";\n\n/**\n * Describes the types of notification hub job statuses.\n */\nexport type NotificationHubJobStatus =\n /**\n * Indicates that the NotificationHubJob was accepted.\n */\n | \"Started\"\n\n /**\n * Indicates that the NotificationHubJob is currently running. Depending on the amount of data,\n * a job may stay in this state for several hours.\n */\n | \"Running\"\n\n /**\n * Indicates that the NotificationHubJob was completed successfully. Any output\n * will be ready where configured via the NotificationHubJob object.\n */\n | \"Completed\"\n\n /**\n * Indicates that the NotificationHubJob has failed.\n */\n | \"Failed\";\n\n/**\n * Represents a Notification Hub Job.\n */\nexport interface NotificationHubJob {\n /**\n * The unique job identifier.\n */\n jobId?: string;\n\n /**\n * The output file name.\n */\n outputFileName?: string;\n\n /**\n * The file name for the job failures.\n */\n failuresFileName?: string;\n\n /**\n * The progress for the job.\n */\n progress?: number;\n\n /**\n * The type of job.\n */\n type: NotificationHubJobType;\n\n /**\n * The status of the job.\n */\n status?: NotificationHubJobStatus;\n\n /**\n * The output container URL.\n */\n outputContainerUrl: string;\n\n /**\n * The import file URL.\n */\n importFileUrl?: string;\n\n /**\n * The input properties for the notification hub job.\n */\n inputProperties?: Record<string, string>;\n\n /**\n * Gets the notification hub job failure message.\n */\n failure?: string;\n\n /**\n * The output properties for the notification hub job.\n */\n outputProperties?: Record<string, string>;\n\n /**\n * Notification hub job created date.\n */\n createdAt?: Date;\n\n /**\n * Notification hub job last updated date.\n */\n updatedAt?: Date;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/models/options.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { CommonClientOptions, OperationOptions } from \"@azure/core-client\";\n\n/**\n * Describes the options that can be provided while creating the NotificationHubsClientContext.\n */\nexport interface NotificationHubsClientOptions extends CommonClientOptions {}\n\n/**\n * Represents the send operation options that can be set.\n */\nexport interface SendOperationOptions extends OperationOptions {\n /**\n * Set to true to enable test send.\n */\n enableTestSend?: boolean;\n}\n\n/**\n * Represents entity update operation options that can be set.\n */\nexport interface EntityOperationOptions extends OperationOptions {\n /**\n * ETag as returned by creation, update, and retrieval, or ‘*’ (overwrite).\n */\n etag?: string;\n}\n\n/**\n * Represents query options to include $top support.\n */\nexport interface RegistrationQueryLimitOptions extends OperationOptions {\n /**\n * The $top query member to get a number of records.\n */\n top?: number;\n}\n\n/**\n * Represents query options to include both $top and $filter.\n */\nexport interface RegistrationQueryOptions extends RegistrationQueryLimitOptions {\n /**\n * The OData $filter operator query string.\n */\n filter?: string;\n}\n"]}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT license.
|
|
3
|
+
/**
|
|
4
|
+
* Creates an ADM registration description.
|
|
5
|
+
* @param description - A partial ADM registration description.
|
|
6
|
+
* @returns A created ADM registration description.
|
|
7
|
+
*/
|
|
8
|
+
export function createAdmRegistrationDescription(description) {
|
|
9
|
+
return Object.assign(Object.assign({}, description), { type: "Adm" });
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Creates an ADM template registration description.
|
|
13
|
+
* @param description - A partial ADM template registration description.
|
|
14
|
+
* @returns A created ADM template registration description.
|
|
15
|
+
*/
|
|
16
|
+
export function createAdmTemplateRegistrationDescription(description) {
|
|
17
|
+
return Object.assign(Object.assign({}, description), { type: "AdmTemplate" });
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Creates an Apple registration description.
|
|
21
|
+
* @param description - A partial Apple registration description.
|
|
22
|
+
* @returns A created Apple registration description.
|
|
23
|
+
*/
|
|
24
|
+
export function createAppleRegistrationDescription(description) {
|
|
25
|
+
return Object.assign(Object.assign({}, description), { type: "Apple" });
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Creates an Apple template registration description.
|
|
29
|
+
* @param description - A partial Apple template registration description.
|
|
30
|
+
* @returns A created Apple template registration description.
|
|
31
|
+
*/
|
|
32
|
+
export function createAppleTemplateRegistrationDescription(description) {
|
|
33
|
+
return Object.assign(Object.assign({}, description), { type: "AppleTemplate" });
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Creates a Baidu registration description.
|
|
37
|
+
* @param description - A partial Baidu registration description.
|
|
38
|
+
* @returns A created Baidu registration description.
|
|
39
|
+
*/
|
|
40
|
+
export function createBaiduRegistrationDescription(description) {
|
|
41
|
+
return Object.assign(Object.assign({}, description), { type: "Baidu" });
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Creates a Baidu template registration description.
|
|
45
|
+
* @param description - A partial Baidu template registration description.
|
|
46
|
+
* @returns A created Baidu template registration description.
|
|
47
|
+
*/
|
|
48
|
+
export function createBaiduTemplateRegistrationDescription(description) {
|
|
49
|
+
return Object.assign(Object.assign({}, description), { type: "BaiduTemplate" });
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Creates a Web Push registration description.
|
|
53
|
+
* @param description - A partial Web Push registration description.
|
|
54
|
+
* @returns A created Web Push registration description.
|
|
55
|
+
*/
|
|
56
|
+
export function createBrowserRegistrationDescription(description) {
|
|
57
|
+
return Object.assign(Object.assign({}, description), { type: "Browser" });
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Creates a Web Push registration description.
|
|
61
|
+
* @param description - A partial Web Push template registration description.
|
|
62
|
+
* @returns A created Web Push template registration description.
|
|
63
|
+
*/
|
|
64
|
+
export function createBrowserTemplateRegistrationDescription(description) {
|
|
65
|
+
return Object.assign(Object.assign({}, description), { type: "BrowserTemplate" });
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* @deprecated Use createFcmRegistrationDescription instead.
|
|
69
|
+
* Creates a GCM registration description.
|
|
70
|
+
* @param description - A partial GCM registration description.
|
|
71
|
+
* @returns A created GCM registration description.
|
|
72
|
+
*/
|
|
73
|
+
export function createGcmRegistrationDescription(description) {
|
|
74
|
+
return Object.assign(Object.assign({}, description), { type: "Gcm" });
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Use createFcmTemplateRegistrationDescription instead.
|
|
78
|
+
* Creates a GCM template registration description.
|
|
79
|
+
* @param description - A partial GCM template registration description.
|
|
80
|
+
* @returns A created GCM template registration description.
|
|
81
|
+
*/
|
|
82
|
+
export function createGcmTemplateRegistrationDescription(description) {
|
|
83
|
+
return Object.assign(Object.assign({}, description), { type: "GcmTemplate" });
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Creates an FCM registration description.
|
|
87
|
+
* @param description - A partial FCM registration description.
|
|
88
|
+
* @returns A created FCM registration description.
|
|
89
|
+
*/
|
|
90
|
+
export function createFcmRegistrationDescription(description) {
|
|
91
|
+
return Object.assign(Object.assign({}, description), { type: "Fcm" });
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Creates an FCM template registration description.
|
|
95
|
+
* @param description - A partial FCM template registration description.
|
|
96
|
+
* @returns A created FCM template registration description.
|
|
97
|
+
*/
|
|
98
|
+
export function createFcmTemplateRegistrationDescription(description) {
|
|
99
|
+
return Object.assign(Object.assign({}, description), { type: "FcmTemplate" });
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* @deprecated Windows Phone is no longer supported.
|
|
103
|
+
* Creates an MPNS registration description.
|
|
104
|
+
* @param description - A partial MPNS registration description.
|
|
105
|
+
* @returns A created MPNS registration description.
|
|
106
|
+
*/
|
|
107
|
+
export function createMpnsRegistrationDescription(description) {
|
|
108
|
+
return Object.assign(Object.assign({}, description), { type: "Mpns" });
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* @deprecated Windows Phone is no longer supported.
|
|
112
|
+
* Creates an MPNS template registration description.
|
|
113
|
+
* @param description - A partial MPNS template registration description.
|
|
114
|
+
* @returns A created MPNS template registration description.
|
|
115
|
+
*/
|
|
116
|
+
export function createMpnsTemplateRegistrationDescription(description) {
|
|
117
|
+
return Object.assign(Object.assign({}, description), { type: "MpnsTemplate" });
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Creates a Windows registration description.
|
|
121
|
+
* @param description - A partial Windows registration description.
|
|
122
|
+
* @returns A created Windows registration description.
|
|
123
|
+
*/
|
|
124
|
+
export function createWindowsRegistrationDescription(description) {
|
|
125
|
+
return Object.assign(Object.assign({}, description), { type: "Windows" });
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Creates a Windows template registration description.
|
|
129
|
+
* @param description - A partial Windows template registration description.
|
|
130
|
+
* @returns A created Windows template registration description.
|
|
131
|
+
*/
|
|
132
|
+
export function createWindowsTemplateRegistrationDescription(description) {
|
|
133
|
+
return Object.assign(Object.assign({}, description), { type: "WindowsTemplate" });
|
|
134
|
+
}
|
|
135
|
+
//# sourceMappingURL=registration.js.map
|