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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/README.md +4 -3
  2. package/dist/index.cjs +80 -3
  3. package/dist/index.cjs.map +1 -1
  4. package/dist-esm/src/api/createRegistrationId.js +8 -0
  5. package/dist-esm/src/api/createRegistrationId.js.map +1 -1
  6. package/dist-esm/src/models/installation.js +8 -0
  7. package/dist-esm/src/models/installation.js.map +1 -1
  8. package/dist-esm/src/models/notification.js +9 -1
  9. package/dist-esm/src/models/notification.js.map +1 -1
  10. package/dist-esm/src/models/notificationDetails.js.map +1 -1
  11. package/dist-esm/src/models/registration.js +16 -0
  12. package/dist-esm/src/models/registration.js.map +1 -1
  13. package/dist-esm/src/serializers/notificationDetailsSerializer.js +6 -1
  14. package/dist-esm/src/serializers/notificationDetailsSerializer.js.map +1 -1
  15. package/dist-esm/src/serializers/registrationSerializer.js +29 -0
  16. package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
  17. package/dist-esm/src/utils/constants.js +1 -1
  18. package/dist-esm/src/utils/constants.js.map +1 -1
  19. package/package.json +25 -12
  20. package/types/3.1/notification-hubs.d.ts +97 -6
  21. package/types/latest/notification-hubs.d.ts +108 -6
  22. package/types/latest/tsdoc-metadata.json +1 -1
  23. package/types/src/api/createRegistrationId.d.ts.map +1 -1
  24. package/types/src/models/installation.d.ts +16 -1
  25. package/types/src/models/installation.d.ts.map +1 -1
  26. package/types/src/models/notification.d.ts +17 -2
  27. package/types/src/models/notification.d.ts.map +1 -1
  28. package/types/src/models/notificationDetails.d.ts +4 -0
  29. package/types/src/models/notificationDetails.d.ts.map +1 -1
  30. package/types/src/models/registration.d.ts +60 -3
  31. package/types/src/models/registration.d.ts.map +1 -1
  32. package/types/src/serializers/notificationDetailsSerializer.d.ts.map +1 -1
  33. package/types/src/serializers/registrationSerializer.d.ts +21 -1
  34. package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
  35. package/types/src/utils/constants.d.ts.map +1 -1
@@ -1,6 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
3
  import { createRequest, sendRequest } from "./internal/_client.js";
4
+ import { RestError } from "@azure/core-rest-pipeline";
4
5
  import { tracingClient } from "../utils/tracing.js";
5
6
  const OPERATION_NAME = "createRegistrationId";
6
7
  /**
@@ -19,6 +20,13 @@ export function createRegistrationId(context, options = {}) {
19
20
  const response = await sendRequest(context, request, 201);
20
21
  // In the form: https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/<registrationId>
21
22
  const locationHeader = response.headers.get("Location");
23
+ if (!locationHeader || !locationHeader.startsWith("https://")) {
24
+ throw new RestError(`Location header ${locationHeader} is an invalid URL`, {
25
+ statusCode: 500,
26
+ request,
27
+ response,
28
+ });
29
+ }
22
30
  const locationUrl = new URL(locationHeader);
23
31
  const registrationId = locationUrl.pathname.split("/")[3];
24
32
  return registrationId;
@@ -1 +1 @@
1
- {"version":3,"file":"createRegistrationId.js","sourceRoot":"","sources":["../../../src/api/createRegistrationId.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAsC,EACtC,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,cAAc,EAAE,EACjD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,kBAAkB,CAAC;QAExC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,0CAA0C,CAAC,CAAC;QAExE,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,2GAA2G;QAC3G,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACxD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,cAAe,CAAC,CAAC;QAC7C,MAAM,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1D,OAAO,cAAc,CAAC;IACxB,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"createRegistrationId\";\n\n/**\n * Creates a new registration ID.\n * @param context - The Notification Hubs client.\n * @param options - The options for creating a new registration ID.\n * @returns The newly created registration ID.\n */\nexport function createRegistrationId(\n context: NotificationHubsClientContext,\n options: OperationOptions = {}\n): Promise<string> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext.${OPERATION_NAME}`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/registrationIDs\";\n\n const headers = await context.createHeaders(OPERATION_NAME);\n headers.set(\"Content-Type\", \"application/xml;type=entry;charset=utf-8\");\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n const response = await sendRequest(context, request, 201);\n\n // In the form: https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/<registrationId>\n const locationHeader = response.headers.get(\"Location\");\n const locationUrl = new URL(locationHeader!);\n const registrationId = locationUrl.pathname.split(\"/\")[3];\n\n return registrationId;\n }\n );\n}\n"]}
1
+ {"version":3,"file":"createRegistrationId.js","sourceRoot":"","sources":["../../../src/api/createRegistrationId.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAGnE,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,sBAAsB,CAAC;AAE9C;;;;;GAKG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAsC,EACtC,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,cAAc,EAAE,EACjD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,kBAAkB,CAAC;QAExC,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,0CAA0C,CAAC,CAAC;QAExE,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,2GAA2G;QAC3G,MAAM,cAAc,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC;QACxD,IAAI,CAAC,cAAc,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;YAC7D,MAAM,IAAI,SAAS,CAAC,mBAAmB,cAAc,oBAAoB,EAAE;gBACzE,UAAU,EAAE,GAAG;gBACf,OAAO;gBACP,QAAQ;aACT,CAAC,CAAC;SACJ;QACD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,cAAe,CAAC,CAAC;QAC7C,MAAM,cAAc,GAAG,WAAW,CAAC,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1D,OAAO,cAAc,CAAC;IACxB,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"createRegistrationId\";\n\n/**\n * Creates a new registration ID.\n * @param context - The Notification Hubs client.\n * @param options - The options for creating a new registration ID.\n * @returns The newly created registration ID.\n */\nexport function createRegistrationId(\n context: NotificationHubsClientContext,\n options: OperationOptions = {}\n): Promise<string> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext.${OPERATION_NAME}`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/registrationIDs\";\n\n const headers = await context.createHeaders(OPERATION_NAME);\n headers.set(\"Content-Type\", \"application/xml;type=entry;charset=utf-8\");\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n const response = await sendRequest(context, request, 201);\n\n // In the form: https://{namespace}.servicebus.windows.net/{NotificationHub}/registrations/<registrationId>\n const locationHeader = response.headers.get(\"Location\");\n if (!locationHeader || !locationHeader.startsWith(\"https://\")) {\n throw new RestError(`Location header ${locationHeader} is an invalid URL`, {\n statusCode: 500,\n request,\n response,\n });\n }\n const locationUrl = new URL(locationHeader!);\n const registrationId = locationUrl.pathname.split(\"/\")[3];\n\n return registrationId;\n }\n );\n}\n"]}
@@ -32,6 +32,14 @@ export function createBaiduInstallation(installation) {
32
32
  export function createFcmLegacyInstallation(installation) {
33
33
  return Object.assign(Object.assign({}, installation), { platform: "gcm" });
34
34
  }
35
+ /**
36
+ * Creates a Xiaomi based installation.
37
+ * @param installation - A partial installation used to create the Xiaomi installation.
38
+ * @returns The newly created Xiaomi installation.
39
+ */
40
+ export function createXiaomiInstallation(installation) {
41
+ return Object.assign(Object.assign({}, installation), { platform: "xiaomi" });
42
+ }
35
43
  /**
36
44
  * Creates a Windows Notification Services (WNS) based installation.
37
45
  * @param installation - A partial installation used to create the WNS installation.
@@ -1 +1 @@
1
- {"version":3,"file":"installation.js","sourceRoot":"","sources":["../../../src/models/installation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAyDlC;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAAqC;IAC3E,uCACK,YAAY,KACf,QAAQ,EAAE,MAAM,IAChB;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAqC;IACzE,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,IACf;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAAqC;IAC3E,uCACK,YAAY,KACf,QAAQ,EAAE,OAAO,IACjB;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,YAAqC;IAErC,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,IACf;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,YAAqC;IAErC,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,IACf;AACJ,CAAC;AA0CD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,YAAuC;IAEvC,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 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(installation: DeviceTokenInstallation): 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(installation: DeviceTokenInstallation): 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(installation: DeviceTokenInstallation): BaiduInstallation {\n return {\n ...installation,\n platform: \"baidu\",\n };\n}\n\n/**\n * Represents a Firebase Legacy HTTP installation.\n */\nexport interface FcmLegacyInstallation 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 createFcmLegacyInstallation(\n installation: DeviceTokenInstallation\n): FcmLegacyInstallation {\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: DeviceTokenInstallation\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 BrowserInstallationCommon extends InstallationCommon {\n /**\n * The push channel for the Web Push API.\n */\n pushChannel: BrowserPushChannel;\n}\n\n/**\n * Represents a Browser/Web Push based installation.\n */\nexport interface BrowserInstallation extends BrowserInstallationCommon {\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: BrowserInstallationCommon\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 | FcmLegacyInstallation\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"]}
1
+ {"version":3,"file":"installation.js","sourceRoot":"","sources":["../../../src/models/installation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAyDlC;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAAqC;IAC3E,uCACK,YAAY,KACf,QAAQ,EAAE,MAAM,IAChB;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAqC;IACzE,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,IACf;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAAqC;IAC3E,uCACK,YAAY,KACf,QAAQ,EAAE,OAAO,IACjB;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,YAAqC;IAErC,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,IACf;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CACtC,YAAqC;IAErC,uCACK,YAAY,KACf,QAAQ,EAAE,QAAQ,IAClB;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,YAAqC;IAErC,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,IACf;AACJ,CAAC;AA0CD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,YAAuC;IAEvC,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 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(installation: DeviceTokenInstallation): 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(installation: DeviceTokenInstallation): 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(installation: DeviceTokenInstallation): BaiduInstallation {\n return {\n ...installation,\n platform: \"baidu\",\n };\n}\n\n/**\n * Represents a Firebase Legacy HTTP installation.\n */\nexport interface FcmLegacyInstallation 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 createFcmLegacyInstallation(\n installation: DeviceTokenInstallation\n): FcmLegacyInstallation {\n return {\n ...installation,\n platform: \"gcm\",\n };\n}\n\n/**\n * Represents a Xiaomi based installation.\n */\nexport interface XiaomiInstallation extends DeviceTokenInstallation {\n /**\n * The platform for the installation.\n */\n platform: \"xiaomi\";\n}\n\n/**\n * Creates a Xiaomi based installation.\n * @param installation - A partial installation used to create the Xiaomi installation.\n * @returns The newly created Xiaomi installation.\n */\nexport function createXiaomiInstallation(\n installation: DeviceTokenInstallation\n): XiaomiInstallation {\n return {\n ...installation,\n platform: \"xiaomi\",\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: DeviceTokenInstallation\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 BrowserInstallationCommon extends InstallationCommon {\n /**\n * The push channel for the Web Push API.\n */\n pushChannel: BrowserPushChannel;\n}\n\n/**\n * Represents a Browser/Web Push based installation.\n */\nexport interface BrowserInstallation extends BrowserInstallationCommon {\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: BrowserInstallationCommon\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 | FcmLegacyInstallation\n | XiaomiInstallation\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"]}
@@ -36,11 +36,19 @@ export function createBrowserNotification(notification) {
36
36
  /**
37
37
  * Creates a notification to send to Firebase.
38
38
  * @param notification - A partial message used to create a message for Firebase.
39
- * @returns A newly created Firebase.
39
+ * @returns A newly created Firebase notification.
40
40
  */
41
41
  export function createFcmLegacyNotification(notification) {
42
42
  return Object.assign(Object.assign({}, notification), { platform: "gcm", contentType: Constants.JSON_CONTENT_TYPE });
43
43
  }
44
+ /**
45
+ * Creates a notification to send to Xiaomi.
46
+ * @param notification - A partial message used to create a message for Xiaomi.
47
+ * @returns A newly created Xiaomi notification.
48
+ */
49
+ export function createXiaomiNotification(notification) {
50
+ return Object.assign(Object.assign({}, notification), { platform: "xiaomi", contentType: Constants.JSON_CONTENT_TYPE });
51
+ }
44
52
  /**
45
53
  * Creates a notification to send to Firebase.
46
54
  * @param notification - A partial message used to create a message for Firebase.
@@ -1 +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/**\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(notification: NotificationCommon): 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(notification: NotificationCommon): 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(notification: NotificationCommon): 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(notification: NotificationCommon): 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 FcmLegacyNotification 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 createFcmLegacyNotification(\n notification: NotificationCommon\n): FcmLegacyNotification {\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(notification: NotificationCommon): 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: NotificationCommon\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: NotificationCommon\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: NotificationCommon\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: NotificationCommon\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 | FcmLegacyNotification\n | WindowsNotification\n | TemplateNotification;\n"]}
1
+ {"version":3,"file":"notification.js","sourceRoot":"","sources":["../../../src/models/notification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AAqCnD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAAgC;IACtE,uCACK,YAAY,KACf,QAAQ,EAAE,OAAO,EACjB,WAAW,EAAE,SAAS,CAAC,iBAAiB,IACxC;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CAAC,YAAgC;IACpE,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,SAAS,CAAC,iBAAiB,IACxC;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,YAAgC;IACtE,uCACK,YAAY,KACf,QAAQ,EAAE,OAAO,EACjB,WAAW,EAAE,SAAS,CAAC,iBAAiB,IACxC;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CAAC,YAAgC;IACxE,uCACK,YAAY,KACf,QAAQ,EAAE,SAAS,EACnB,WAAW,EAAE,SAAS,CAAC,iBAAiB,IACxC;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,2BAA2B,CACzC,YAAgC;IAEhC,uCACK,YAAY,KACf,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,SAAS,CAAC,iBAAiB,IACxC;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,wBAAwB,CAAC,YAAgC;IACvE,uCACK,YAAY,KACf,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,SAAS,CAAC,iBAAiB,IACxC;AACJ,CAAC;AAYD;;;;GAIG;AACH,MAAM,UAAU,0BAA0B,CAAC,YAAgC;IACzE,uCACK,YAAY,KACf,QAAQ,EAAE,UAAU,EACpB,WAAW,EAAE,SAAS,CAAC,iBAAiB,IACxC;AACJ,CAAC;AAsBD;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,YAAgC;IAEhC,MAAM,MAAM,mCACP,YAAY,KACf,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,SAAS,CAAC,gBAAgB,GACxC,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACnB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;KACrB;IAED,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC;IAE9D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,6BAA6B,CAC3C,YAAgC;IAEhC,MAAM,MAAM,mCACP,YAAY,KACf,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,SAAS,CAAC,gBAAgB,GACxC,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACnB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;KACrB;IAED,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC;IAE9D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,8BAA8B,CAC5C,YAAgC;IAEhC,MAAM,MAAM,mCACP,YAAY,KACf,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,SAAS,CAAC,gBAAgB,GACxC,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACnB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;KACrB;IAED,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,SAAS,CAAC;IAE9D,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,4BAA4B,CAC1C,YAAgC;IAEhC,MAAM,MAAM,mCACP,YAAY,KACf,QAAQ,EAAE,KAAK,EACf,WAAW,EAAE,SAAS,CAAC,mBAAmB,GAC3C,CAAC;IAEF,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;QACnB,MAAM,CAAC,OAAO,GAAG,EAAE,CAAC;KACrB;IAED,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,aAAa,CAAC,GAAG,SAAS,CAAC,OAAO,CAAC;IAE5D,OAAO,MAAM,CAAC;AAChB,CAAC","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/**\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(notification: NotificationCommon): 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(notification: NotificationCommon): 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(notification: NotificationCommon): 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(notification: NotificationCommon): 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 FcmLegacyNotification 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 notification.\n */\nexport function createFcmLegacyNotification(\n notification: NotificationCommon\n): FcmLegacyNotification {\n return {\n ...notification,\n platform: \"gcm\",\n contentType: Constants.JSON_CONTENT_TYPE,\n };\n}\n\n/**\n * Represents a Xiaomi push notification.\n */\nexport interface XiaomiNotification extends JsonNotification {\n /**\n * The platform for the push notification.\n */\n platform: \"xiaomi\";\n}\n\n/**\n * Creates a notification to send to Xiaomi.\n * @param notification - A partial message used to create a message for Xiaomi.\n * @returns A newly created Xiaomi notification.\n */\nexport function createXiaomiNotification(notification: NotificationCommon): XiaomiNotification {\n return {\n ...notification,\n platform: \"xiaomi\",\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(notification: NotificationCommon): 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: NotificationCommon\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: NotificationCommon\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: NotificationCommon\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: NotificationCommon\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 | FcmLegacyNotification\n | XiaomiNotification\n | WindowsNotification\n | TemplateNotification;\n"]}
@@ -1 +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 NotificationOutcome {\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?: NotificationOutcome[];\n\n /**\n * WNS outcomes counts per state.\n */\n wnsOutcomeCounts?: NotificationOutcome[];\n\n /**\n * FCM outcome counts per state.\n */\n fcmOutcomeCounts?: NotificationOutcome[];\n\n /**\n * ADM outcome counts per state.\n */\n admOutcomeCounts?: NotificationOutcome[];\n\n /**\n * Baidu outcome counts per state.\n */\n baiduOutcomeCounts?: NotificationOutcome[];\n\n /**\n * Web Push outcome counts per state.\n */\n browserOutcomeCounts?: NotificationOutcome[];\n}\n\n/**\n * Describes a response from the Notification Hubs which includes a tracking ID, correlation ID and location.\n */\nexport interface NotificationHubsResponse {\n /**\n * The Tracking ID of the operation.\n */\n trackingId?: string;\n\n /**\n * The correlation ID of the operation.\n */\n correlationId?: string;\n\n /**\n * The location of the operation.\n */\n location?: string;\n}\n\n/**\n * Represents the result of the registration.\n */\nexport interface RegistrationResult {\n /**\n * The application platform.\n */\n applicationPlatform: string;\n\n /**\n * The PNS handle.\n */\n pnsHandle: string;\n\n /**\n * The registration ID.\n */\n registrationId: string;\n\n /**\n * The outcome of the registration.\n */\n outcome: string;\n}\n\n/**\n * Describes a response from the Notification Hubs service for send operations.\n */\nexport interface NotificationHubsMessageResponse extends NotificationHubsResponse {\n /**\n * The notification ID from the operation. Note this is only available in Standard SKU and above.\n */\n notificationId?: string;\n\n /**\n * The number of devices that successfully received the notification.\n */\n successCount: number;\n\n /**\n * The number of devices that failed to receive a notification.\n */\n failureCount: number;\n\n /**\n * The list of notification outcome results for each device registered with the hub, to which this notification was sent.\n */\n results: RegistrationResult[];\n\n /**\n * The state of this notification outcome.\n */\n state: NotificationOutcomeState;\n}\n"]}
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 NotificationOutcome {\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?: NotificationOutcome[];\n\n /**\n * WNS outcomes counts per state.\n */\n wnsOutcomeCounts?: NotificationOutcome[];\n\n /**\n * FCM outcome counts per state.\n */\n fcmOutcomeCounts?: NotificationOutcome[];\n\n /**\n * ADM outcome counts per state.\n */\n admOutcomeCounts?: NotificationOutcome[];\n\n /**\n * Baidu outcome counts per state.\n */\n baiduOutcomeCounts?: NotificationOutcome[];\n\n /**\n * Web Push outcome counts per state.\n */\n browserOutcomeCounts?: NotificationOutcome[];\n\n /**\n * Xiaomi outcome counts per state.\n */\n xiaomiOutcomeCounts?: NotificationOutcome[];\n}\n\n/**\n * Describes a response from the Notification Hubs which includes a tracking ID, correlation ID and location.\n */\nexport interface NotificationHubsResponse {\n /**\n * The Tracking ID of the operation.\n */\n trackingId?: string;\n\n /**\n * The correlation ID of the operation.\n */\n correlationId?: string;\n\n /**\n * The location of the operation.\n */\n location?: string;\n}\n\n/**\n * Represents the result of the registration.\n */\nexport interface RegistrationResult {\n /**\n * The application platform.\n */\n applicationPlatform: string;\n\n /**\n * The PNS handle.\n */\n pnsHandle: string;\n\n /**\n * The registration ID.\n */\n registrationId: string;\n\n /**\n * The outcome of the registration.\n */\n outcome: string;\n}\n\n/**\n * Describes a response from the Notification Hubs service for send operations.\n */\nexport interface NotificationHubsMessageResponse extends NotificationHubsResponse {\n /**\n * The notification ID from the operation. Note this is only available in Standard SKU and above.\n */\n notificationId?: string;\n\n /**\n * The number of devices that successfully received the notification.\n */\n successCount: number;\n\n /**\n * The number of devices that failed to receive a notification.\n */\n failureCount: number;\n\n /**\n * The list of notification outcome results for each device registered with the hub, to which this notification was sent.\n */\n results: RegistrationResult[];\n\n /**\n * The state of this notification outcome.\n */\n state: NotificationOutcomeState;\n}\n"]}
@@ -96,4 +96,20 @@ export function createWindowsRegistrationDescription(description) {
96
96
  export function createWindowsTemplateRegistrationDescription(description) {
97
97
  return Object.assign(Object.assign({}, description), { kind: "WindowsTemplate" });
98
98
  }
99
+ /**
100
+ * Creates a Xiaomi registration description.
101
+ * @param description - A partial Xiaomi registration description.
102
+ * @returns A created Xiaomi registration description.
103
+ */
104
+ export function createXiaomiRegistrationDescription(description) {
105
+ return Object.assign(Object.assign({}, description), { kind: "Xiaomi" });
106
+ }
107
+ /**
108
+ * Creates a Xiaomi template registration description.
109
+ * @param description - A partial Xiaomi template registration description.
110
+ * @returns A created Xiaomi template registration description.
111
+ */
112
+ export function createXiaomiTemplateRegistrationDescription(description) {
113
+ return Object.assign(Object.assign({}, description), { kind: "XiaomiTemplate" });
114
+ }
99
115
  //# sourceMappingURL=registration.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/models/registration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAsFlC;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,WAA6C;IAE7C,uCACK,WAAW,KACd,IAAI,EAAE,KAAK,IACX;AACJ,CAAC;AAoBD;;;;GAIG;AACH,MAAM,UAAU,wCAAwC,CACtD,WAAqD;IAErD,uCACK,WAAW,KACd,IAAI,EAAE,aAAa,IACnB;AACJ,CAAC;AAsBD;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAChD,WAA+C;IAE/C,uCACK,WAAW,KACd,IAAI,EAAE,OAAO,IACb;AACJ,CAAC;AAmCD;;;;GAIG;AACH,MAAM,UAAU,0CAA0C,CACxD,WAAuD;IAEvD,uCACK,WAAW,KACd,IAAI,EAAE,eAAe,IACrB;AACJ,CAAC;AAwBD;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAChD,WAA+C;IAE/C,uCACK,WAAW,KACd,IAAI,EAAE,OAAO,IACb;AACJ,CAAC;AAoBD;;;;GAIG;AACH,MAAM,UAAU,0CAA0C,CACxD,WAAuD;IAEvD,uCACK,WAAW,KACd,IAAI,EAAE,eAAe,IACrB;AACJ,CAAC;AAgCD;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAClD,WAAiD;IAEjD,uCACK,WAAW,KACd,IAAI,EAAE,SAAS,IACf;AACJ,CAAC;AAoBD;;;;GAIG;AACH,MAAM,UAAU,4CAA4C,CAC1D,WAAyD;IAEzD,uCACK,WAAW,KACd,IAAI,EAAE,iBAAiB,IACvB;AACJ,CAAC;AAsBD;;;;GAIG;AACH,MAAM,UAAU,sCAAsC,CACpD,WAA6C;IAE7C,uCACK,WAAW,KACd,IAAI,EAAE,KAAK,IACX;AACJ,CAAC;AAoBD;;;;GAIG;AACH,MAAM,UAAU,8CAA8C,CAC5D,WAAqD;IAErD,uCACK,WAAW,KACd,IAAI,EAAE,aAAa,IACnB;AACJ,CAAC;AAuFD;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAClD,WAAiD;IAEjD,uCACK,WAAW,KACd,IAAI,EAAE,SAAS,IACf;AACJ,CAAC;AAyBD;;;;GAIG;AACH,MAAM,UAAU,4CAA4C,CAC1D,WAAyD;IAEzD,uCACK,WAAW,KACd,IAAI,EAAE,iBAAiB,IACvB;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Represents the types of registration descriptions.\n */\nexport type RegistrationType =\n | \"Adm\"\n | \"AdmTemplate\"\n | \"Apple\"\n | \"AppleTemplate\"\n | \"Baidu\"\n | \"BaiduTemplate\"\n | \"Browser\"\n | \"BrowserTemplate\"\n | \"Gcm\"\n | \"GcmTemplate\"\n | \"Mpns\"\n | \"MpnsTemplate\"\n | \"Windows\"\n | \"WindowsTemplate\";\n\n/**\n * Represents a registration description.\n */\nexport interface RegistrationDescriptionCommon {\n /**\n * The registration ID.\n */\n registrationId?: string;\n\n /**\n * The expiration time of the registration.\n */\n expirationTime?: Date;\n\n /**\n * The ETag associated with this description.\n */\n etag?: string;\n\n /**\n * The tags associated with the registration.\n */\n tags?: string[];\n\n /**\n * A dictionary of push variables associated with property bag.\n */\n pushVariables?: Record<string, string>;\n}\n\n/**\n * Represents the description of a template registration.\n */\nexport interface TemplateRegistrationDescription {\n /**\n * The body template.\n */\n bodyTemplate: string;\n\n /**\n * The name of the template.\n */\n templateName?: string;\n\n /**\n * Represents the description of the Amazon Device Messaging (ADM) registration.\n */\n}\nexport interface AdmRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The Amazon Device Messaging registration identifier.\n */\n admRegistrationId: string;\n}\n\n/**\n * Represents the description of the Amazon Device Messaging (ADM) registration.\n */\nexport interface AdmRegistrationDescription extends AdmRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Adm\";\n}\n\n/**\n * Creates an ADM registration description.\n * @param description - A partial ADM registration description.\n * @returns A created ADM registration description.\n */\nexport function createAdmRegistrationDescription(\n description: AdmRegistrationDescriptionCommon\n): AdmRegistrationDescription {\n return {\n ...description,\n kind: \"Adm\",\n };\n}\n\n/**\n * Represents the description of the Amazon Device Messaging (ADM) template registration.\n */\nexport interface AdmTemplateRegistrationDescriptionCommon\n extends AdmRegistrationDescriptionCommon,\n TemplateRegistrationDescription {}\n\n/**\n * Represents the description of the Amazon Device Messaging (ADM) template registration.\n */\nexport interface AdmTemplateRegistrationDescription\n extends AdmTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"AdmTemplate\";\n}\n\n/**\n * Creates an ADM template registration description.\n * @param description - A partial ADM template registration description.\n * @returns A created ADM template registration description.\n */\nexport function createAdmTemplateRegistrationDescription(\n description: AdmTemplateRegistrationDescriptionCommon\n): AdmTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"AdmTemplate\",\n };\n}\n\n/**\n * Represents the description of apple registration.\n */\nexport interface AppleRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The APNs device token.\n */\n deviceToken: string;\n}\n\n/**\n * Represents the description of apple registration.\n */\nexport interface AppleRegistrationDescription extends AppleRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Apple\";\n}\n\n/**\n * Creates an Apple registration description.\n * @param description - A partial Apple registration description.\n * @returns A created Apple registration description.\n */\nexport function createAppleRegistrationDescription(\n description: AppleRegistrationDescriptionCommon\n): AppleRegistrationDescription {\n return {\n ...description,\n kind: \"Apple\",\n };\n}\n\n/**\n * Represents the description of the Apple template registration.\n */\nexport interface AppleTemplateRegistrationDescriptionCommon\n extends AppleRegistrationDescriptionCommon,\n TemplateRegistrationDescription {\n /**\n * The expiry date.\n */\n expiry?: Date;\n\n /**\n * The notification priority.\n */\n priority?: \"10\" | \"5\";\n\n /**\n * The APNS headers.\n */\n apnsHeaders?: Record<string, string>;\n}\n\n/**\n * Represents the description of the Apple template registration.\n */\nexport interface AppleTemplateRegistrationDescription\n extends AppleTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"AppleTemplate\";\n}\n\n/**\n * Creates an Apple template registration description.\n * @param description - A partial Apple template registration description.\n * @returns A created Apple template registration description.\n */\nexport function createAppleTemplateRegistrationDescription(\n description: AppleTemplateRegistrationDescriptionCommon\n): AppleTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"AppleTemplate\",\n };\n}\n\nexport interface BaiduRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The Baidu user identifier.\n */\n baiduUserId: string;\n\n /**\n * The Baidu channel identifier.\n */\n baiduChannelId: string;\n}\n\n/**\n * Represents a Baidu registration description.\n */\nexport interface BaiduRegistrationDescription extends BaiduRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Baidu\";\n}\n\n/**\n * Creates a Baidu registration description.\n * @param description - A partial Baidu registration description.\n * @returns A created Baidu registration description.\n */\nexport function createBaiduRegistrationDescription(\n description: BaiduRegistrationDescriptionCommon\n): BaiduRegistrationDescription {\n return {\n ...description,\n kind: \"Baidu\",\n };\n}\n\n/**\n * Represents a Baidu template registration description.\n */\nexport interface BaiduTemplateRegistrationDescriptionCommon\n extends BaiduRegistrationDescriptionCommon,\n TemplateRegistrationDescription {}\n\n/**\n * Represents a Baidu template registration description.\n */\nexport interface BaiduTemplateRegistrationDescription\n extends BaiduTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"BaiduTemplate\";\n}\n\n/**\n * Creates a Baidu template registration description.\n * @param description - A partial Baidu template registration description.\n * @returns A created Baidu template registration description.\n */\nexport function createBaiduTemplateRegistrationDescription(\n description: BaiduTemplateRegistrationDescriptionCommon\n): BaiduTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"BaiduTemplate\",\n };\n}\n\n/**\n * Represents a Browser Push registration description.\n */\nexport interface BrowserRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The Browser push endpoint.\n */\n endpoint: string;\n\n /**\n * The Browser push P256DH.\n */\n p256dh: string;\n\n /**\n * The Browser push auth secret.\n */\n auth: string;\n}\n\n/**\n * Represents a Browser Push registration description.\n */\nexport interface BrowserRegistrationDescription extends BrowserRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Browser\";\n}\n\n/**\n * Creates a Web Push registration description.\n * @param description - A partial Web Push registration description.\n * @returns A created Web Push registration description.\n */\nexport function createBrowserRegistrationDescription(\n description: BrowserRegistrationDescriptionCommon\n): BrowserRegistrationDescription {\n return {\n ...description,\n kind: \"Browser\",\n };\n}\n\n/**\n * Represents a Browser Push remplate registration description.\n */\nexport interface BrowserTemplateRegistrationDescriptionCommon\n extends BrowserRegistrationDescriptionCommon,\n TemplateRegistrationDescription {}\n\n/**\n * Represents a Browser Push remplate registration description.\n */\nexport interface BrowserTemplateRegistrationDescription\n extends BrowserTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"BrowserTemplate\";\n}\n\n/**\n * Creates a Web Push registration description.\n * @param description - A partial Web Push template registration description.\n * @returns A created Web Push template registration description.\n */\nexport function createBrowserTemplateRegistrationDescription(\n description: BrowserTemplateRegistrationDescriptionCommon\n): BrowserTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"BrowserTemplate\",\n };\n}\n\n/**\n * Represents Notification Hub registration description for Google Cloud Messaging.\n */\nexport interface GcmRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * Registration id obtained from the Google Cloud Messaging service.\n */\n gcmRegistrationId: string;\n}\n\n/**\n * Represents Notification Hub registration description for Google Cloud Messaging.\n */\nexport interface GcmRegistrationDescription extends GcmRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Gcm\";\n}\n\n/**\n * Creates a Firebase Legacy registration description.\n * @param description - A partial GCM registration description.\n * @returns A created GCM registration description.\n */\nexport function createFcmLegacyRegistrationDescription(\n description: GcmRegistrationDescriptionCommon\n): GcmRegistrationDescription {\n return {\n ...description,\n kind: \"Gcm\",\n };\n}\n\n/**\n * Represents Notification Hub template registration description for Firebase Legacy Cloud Messaging.\n */\nexport interface GcmTemplateRegistrationDescriptionCommon\n extends GcmRegistrationDescriptionCommon,\n TemplateRegistrationDescription {}\n\n/**\n * Represents Notification Hub template registration description for Firebase Legacy Cloud Messaging.\n */\nexport interface GcmTemplateRegistrationDescription\n extends GcmTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"GcmTemplate\";\n}\n\n/**\n * Creates a GCM template registration description.\n * @param description - A partial GCM template registration description.\n * @returns A created GCM template registration description.\n */\nexport function createFcmLegacyTemplateRegistrationDescription(\n description: GcmTemplateRegistrationDescriptionCommon\n): GcmTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"GcmTemplate\",\n };\n}\n\n/**\n * Represents a Windows Phone Notification Services registration description.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The channel URI.\n */\n channelUri: string;\n}\n\n/**\n * Represents a Windows Phone Notification Services registration description.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsRegistrationDescription extends MpnsRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Mpns\";\n}\n\n/**\n * Represents a Windows Phone Notification Services template registration.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsTemplateRegistrationDescription\n extends MpnsRegistrationDescriptionCommon,\n TemplateRegistrationDescription {\n /**\n * The WNS headers.\n */\n mpnsHeaders?: Record<string, string>;\n\n /**\n * The kind of the registration.\n */\n kind: \"MpnsTemplate\";\n}\n\n/**\n * Represents a Windows Phone Notification Services template registration.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsTemplateRegistrationDescriptionCommon\n extends MpnsRegistrationDescriptionCommon,\n TemplateRegistrationDescription {\n /**\n * The WNS headers.\n */\n mpnsHeaders?: Record<string, string>;\n}\n\n/**\n * Represents a Windows Phone Notification Services template registration.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsTemplateRegistrationDescription\n extends MpnsTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"MpnsTemplate\";\n}\n\n/**\n * Represents a Windows Notification Services (WNS) registration description.\n */\nexport interface WindowsRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The channel URI.\n */\n channelUri: string;\n}\n\n/**\n * Represents a Windows Notification Services (WNS) registration description.\n */\nexport interface WindowsRegistrationDescription extends WindowsRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Windows\";\n}\n\n/**\n * Creates a Windows registration description.\n * @param description - A partial Windows registration description.\n * @returns A created Windows registration description.\n */\nexport function createWindowsRegistrationDescription(\n description: WindowsRegistrationDescriptionCommon\n): WindowsRegistrationDescription {\n return {\n ...description,\n kind: \"Windows\",\n };\n}\n\n/**\n * Represents a Windows Notification Services (WNS) template registration.\n */\nexport interface WindowsTemplateRegistrationDescriptionCommon\n extends WindowsRegistrationDescriptionCommon,\n TemplateRegistrationDescription {\n /**\n * The WNS headers.\n */\n wnsHeaders?: Record<string, string>;\n}\n\n/**\n * Represents a Windows Notification Services (WNS) template registration.\n */\nexport interface WindowsTemplateRegistrationDescription\n extends WindowsTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"WindowsTemplate\";\n}\n\n/**\n * Creates a Windows template registration description.\n * @param description - A partial Windows template registration description.\n * @returns A created Windows template registration description.\n */\nexport function createWindowsTemplateRegistrationDescription(\n description: WindowsTemplateRegistrationDescriptionCommon\n): WindowsTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"WindowsTemplate\",\n };\n}\n\n/**\n * Describes the types of registration descriptions.\n */\nexport type RegistrationDescription =\n | AdmRegistrationDescription\n | AdmTemplateRegistrationDescription\n | AppleRegistrationDescription\n | AppleTemplateRegistrationDescription\n | BaiduRegistrationDescription\n | BaiduTemplateRegistrationDescription\n | BrowserRegistrationDescription\n | BrowserTemplateRegistrationDescription\n | GcmRegistrationDescription\n | GcmTemplateRegistrationDescription\n | MpnsRegistrationDescription\n | MpnsTemplateRegistrationDescription\n | WindowsRegistrationDescription\n | WindowsTemplateRegistrationDescription;\n\n/**\n * Describes an ADM Registration channel query.\n */\nexport interface AdmRegistrationChannel {\n /**\n * The ADM Registration ID.\n */\n admRegistrationId: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"adm\";\n}\n\n/**\n * Describes an Apple Registration channel query.\n */\nexport interface AppleRegistrationChannel {\n /**\n * The APNs device token.\n */\n deviceToken: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"apple\";\n}\n\n/**\n * Describes an Baidu Registration channel query.\n */\nexport interface BaiduRegistrationChannel {\n /**\n * The Baidu Channel ID.\n */\n baiduChannelId: string;\n /**\n * The Baidu User ID.\n */\n baiduUserId: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"baidu\";\n}\n\n/**\n * Describes an Browser Registration channel query.\n */\nexport interface BrowserRegistrationChannel {\n /**\n * The Web Push endpoint URL.\n */\n endpoint: string;\n /**\n * The Web Push subscription P256DH.\n */\n p256dh: string;\n /**\n * The Web Push subscription auth secret.\n */\n auth: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"browser\";\n}\n\n/**\n * Describes an Firebase Legacy Registration channel query.\n */\nexport interface FirebaseLegacyRegistrationChannel {\n /**\n * The FCM Legacy registration ID.\n */\n gcmRegistrationId: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"gcm\";\n}\n\n/**\n * Describes an Windows Notification Services Registration channel query.\n */\nexport interface WindowsRegistrationChannel {\n /**\n * The WNS Channel URI.\n */\n channelUri: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"windows\";\n}\n\n/**\n * Describes a Registration query.\n */\nexport type RegistrationChannel =\n | AdmRegistrationChannel\n | AppleRegistrationChannel\n | BaiduRegistrationChannel\n | BrowserRegistrationChannel\n | FirebaseLegacyRegistrationChannel\n | WindowsRegistrationChannel;\n"]}
1
+ {"version":3,"file":"registration.js","sourceRoot":"","sources":["../../../src/models/registration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAwFlC;;;;GAIG;AACH,MAAM,UAAU,gCAAgC,CAC9C,WAA6C;IAE7C,uCACK,WAAW,KACd,IAAI,EAAE,KAAK,IACX;AACJ,CAAC;AAoBD;;;;GAIG;AACH,MAAM,UAAU,wCAAwC,CACtD,WAAqD;IAErD,uCACK,WAAW,KACd,IAAI,EAAE,aAAa,IACnB;AACJ,CAAC;AAsBD;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAChD,WAA+C;IAE/C,uCACK,WAAW,KACd,IAAI,EAAE,OAAO,IACb;AACJ,CAAC;AAmCD;;;;GAIG;AACH,MAAM,UAAU,0CAA0C,CACxD,WAAuD;IAEvD,uCACK,WAAW,KACd,IAAI,EAAE,eAAe,IACrB;AACJ,CAAC;AAwBD;;;;GAIG;AACH,MAAM,UAAU,kCAAkC,CAChD,WAA+C;IAE/C,uCACK,WAAW,KACd,IAAI,EAAE,OAAO,IACb;AACJ,CAAC;AAoBD;;;;GAIG;AACH,MAAM,UAAU,0CAA0C,CACxD,WAAuD;IAEvD,uCACK,WAAW,KACd,IAAI,EAAE,eAAe,IACrB;AACJ,CAAC;AAgCD;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAClD,WAAiD;IAEjD,uCACK,WAAW,KACd,IAAI,EAAE,SAAS,IACf;AACJ,CAAC;AAoBD;;;;GAIG;AACH,MAAM,UAAU,4CAA4C,CAC1D,WAAyD;IAEzD,uCACK,WAAW,KACd,IAAI,EAAE,iBAAiB,IACvB;AACJ,CAAC;AAsBD;;;;GAIG;AACH,MAAM,UAAU,sCAAsC,CACpD,WAA6C;IAE7C,uCACK,WAAW,KACd,IAAI,EAAE,KAAK,IACX;AACJ,CAAC;AAoBD;;;;GAIG;AACH,MAAM,UAAU,8CAA8C,CAC5D,WAAqD;IAErD,uCACK,WAAW,KACd,IAAI,EAAE,aAAa,IACnB;AACJ,CAAC;AAuFD;;;;GAIG;AACH,MAAM,UAAU,oCAAoC,CAClD,WAAiD;IAEjD,uCACK,WAAW,KACd,IAAI,EAAE,SAAS,IACf;AACJ,CAAC;AAyBD;;;;GAIG;AACH,MAAM,UAAU,4CAA4C,CAC1D,WAAyD;IAEzD,uCACK,WAAW,KACd,IAAI,EAAE,iBAAiB,IACvB;AACJ,CAAC;AAsBD;;;;GAIG;AACH,MAAM,UAAU,mCAAmC,CACjD,WAAgD;IAEhD,uCACK,WAAW,KACd,IAAI,EAAE,QAAQ,IACd;AACJ,CAAC;AAoBD;;;;GAIG;AACH,MAAM,UAAU,2CAA2C,CACzD,WAAwD;IAExD,uCACK,WAAW,KACd,IAAI,EAAE,gBAAgB,IACtB;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\n/**\n * Represents the types of registration descriptions.\n */\nexport type RegistrationType =\n | \"Adm\"\n | \"AdmTemplate\"\n | \"Apple\"\n | \"AppleTemplate\"\n | \"Baidu\"\n | \"BaiduTemplate\"\n | \"Browser\"\n | \"BrowserTemplate\"\n | \"Gcm\"\n | \"GcmTemplate\"\n | \"Mpns\"\n | \"MpnsTemplate\"\n | \"Xiaomi\"\n | \"XiaomiTemplate\"\n | \"Windows\"\n | \"WindowsTemplate\";\n\n/**\n * Represents a registration description.\n */\nexport interface RegistrationDescriptionCommon {\n /**\n * The registration ID.\n */\n registrationId?: string;\n\n /**\n * The expiration time of the registration.\n */\n expirationTime?: Date;\n\n /**\n * The ETag associated with this description.\n */\n etag?: string;\n\n /**\n * The tags associated with the registration.\n */\n tags?: string[];\n\n /**\n * A dictionary of push variables associated with property bag.\n */\n pushVariables?: Record<string, string>;\n}\n\n/**\n * Represents the description of a template registration.\n */\nexport interface TemplateRegistrationDescription {\n /**\n * The body template.\n */\n bodyTemplate: string;\n\n /**\n * The name of the template.\n */\n templateName?: string;\n\n /**\n * Represents the description of the Amazon Device Messaging (ADM) registration.\n */\n}\nexport interface AdmRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The Amazon Device Messaging registration identifier.\n */\n admRegistrationId: string;\n}\n\n/**\n * Represents the description of the Amazon Device Messaging (ADM) registration.\n */\nexport interface AdmRegistrationDescription extends AdmRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Adm\";\n}\n\n/**\n * Creates an ADM registration description.\n * @param description - A partial ADM registration description.\n * @returns A created ADM registration description.\n */\nexport function createAdmRegistrationDescription(\n description: AdmRegistrationDescriptionCommon\n): AdmRegistrationDescription {\n return {\n ...description,\n kind: \"Adm\",\n };\n}\n\n/**\n * Represents the description of the Amazon Device Messaging (ADM) template registration.\n */\nexport interface AdmTemplateRegistrationDescriptionCommon\n extends AdmRegistrationDescriptionCommon,\n TemplateRegistrationDescription {}\n\n/**\n * Represents the description of the Amazon Device Messaging (ADM) template registration.\n */\nexport interface AdmTemplateRegistrationDescription\n extends AdmTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"AdmTemplate\";\n}\n\n/**\n * Creates an ADM template registration description.\n * @param description - A partial ADM template registration description.\n * @returns A created ADM template registration description.\n */\nexport function createAdmTemplateRegistrationDescription(\n description: AdmTemplateRegistrationDescriptionCommon\n): AdmTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"AdmTemplate\",\n };\n}\n\n/**\n * Represents the description of apple registration.\n */\nexport interface AppleRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The APNs device token.\n */\n deviceToken: string;\n}\n\n/**\n * Represents the description of apple registration.\n */\nexport interface AppleRegistrationDescription extends AppleRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Apple\";\n}\n\n/**\n * Creates an Apple registration description.\n * @param description - A partial Apple registration description.\n * @returns A created Apple registration description.\n */\nexport function createAppleRegistrationDescription(\n description: AppleRegistrationDescriptionCommon\n): AppleRegistrationDescription {\n return {\n ...description,\n kind: \"Apple\",\n };\n}\n\n/**\n * Represents the description of the Apple template registration.\n */\nexport interface AppleTemplateRegistrationDescriptionCommon\n extends AppleRegistrationDescriptionCommon,\n TemplateRegistrationDescription {\n /**\n * The expiry date.\n */\n expiry?: Date;\n\n /**\n * The notification priority.\n */\n priority?: \"10\" | \"5\";\n\n /**\n * The APNS headers.\n */\n apnsHeaders?: Record<string, string>;\n}\n\n/**\n * Represents the description of the Apple template registration.\n */\nexport interface AppleTemplateRegistrationDescription\n extends AppleTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"AppleTemplate\";\n}\n\n/**\n * Creates an Apple template registration description.\n * @param description - A partial Apple template registration description.\n * @returns A created Apple template registration description.\n */\nexport function createAppleTemplateRegistrationDescription(\n description: AppleTemplateRegistrationDescriptionCommon\n): AppleTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"AppleTemplate\",\n };\n}\n\nexport interface BaiduRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The Baidu user identifier.\n */\n baiduUserId: string;\n\n /**\n * The Baidu channel identifier.\n */\n baiduChannelId: string;\n}\n\n/**\n * Represents a Baidu registration description.\n */\nexport interface BaiduRegistrationDescription extends BaiduRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Baidu\";\n}\n\n/**\n * Creates a Baidu registration description.\n * @param description - A partial Baidu registration description.\n * @returns A created Baidu registration description.\n */\nexport function createBaiduRegistrationDescription(\n description: BaiduRegistrationDescriptionCommon\n): BaiduRegistrationDescription {\n return {\n ...description,\n kind: \"Baidu\",\n };\n}\n\n/**\n * Represents a Baidu template registration description.\n */\nexport interface BaiduTemplateRegistrationDescriptionCommon\n extends BaiduRegistrationDescriptionCommon,\n TemplateRegistrationDescription {}\n\n/**\n * Represents a Baidu template registration description.\n */\nexport interface BaiduTemplateRegistrationDescription\n extends BaiduTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"BaiduTemplate\";\n}\n\n/**\n * Creates a Baidu template registration description.\n * @param description - A partial Baidu template registration description.\n * @returns A created Baidu template registration description.\n */\nexport function createBaiduTemplateRegistrationDescription(\n description: BaiduTemplateRegistrationDescriptionCommon\n): BaiduTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"BaiduTemplate\",\n };\n}\n\n/**\n * Represents a Browser Push registration description.\n */\nexport interface BrowserRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The Browser push endpoint.\n */\n endpoint: string;\n\n /**\n * The Browser push P256DH.\n */\n p256dh: string;\n\n /**\n * The Browser push auth secret.\n */\n auth: string;\n}\n\n/**\n * Represents a Browser Push registration description.\n */\nexport interface BrowserRegistrationDescription extends BrowserRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Browser\";\n}\n\n/**\n * Creates a Web Push registration description.\n * @param description - A partial Web Push registration description.\n * @returns A created Web Push registration description.\n */\nexport function createBrowserRegistrationDescription(\n description: BrowserRegistrationDescriptionCommon\n): BrowserRegistrationDescription {\n return {\n ...description,\n kind: \"Browser\",\n };\n}\n\n/**\n * Represents a Browser Push remplate registration description.\n */\nexport interface BrowserTemplateRegistrationDescriptionCommon\n extends BrowserRegistrationDescriptionCommon,\n TemplateRegistrationDescription {}\n\n/**\n * Represents a Browser Push remplate registration description.\n */\nexport interface BrowserTemplateRegistrationDescription\n extends BrowserTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"BrowserTemplate\";\n}\n\n/**\n * Creates a Web Push registration description.\n * @param description - A partial Web Push template registration description.\n * @returns A created Web Push template registration description.\n */\nexport function createBrowserTemplateRegistrationDescription(\n description: BrowserTemplateRegistrationDescriptionCommon\n): BrowserTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"BrowserTemplate\",\n };\n}\n\n/**\n * Represents Notification Hub registration description for Google Cloud Messaging.\n */\nexport interface GcmRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * Registration id obtained from the Google Cloud Messaging service.\n */\n gcmRegistrationId: string;\n}\n\n/**\n * Represents Notification Hub registration description for Google Cloud Messaging.\n */\nexport interface GcmRegistrationDescription extends GcmRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Gcm\";\n}\n\n/**\n * Creates a Firebase Legacy registration description.\n * @param description - A partial GCM registration description.\n * @returns A created GCM registration description.\n */\nexport function createFcmLegacyRegistrationDescription(\n description: GcmRegistrationDescriptionCommon\n): GcmRegistrationDescription {\n return {\n ...description,\n kind: \"Gcm\",\n };\n}\n\n/**\n * Represents Notification Hub template registration description for Firebase Legacy Cloud Messaging.\n */\nexport interface GcmTemplateRegistrationDescriptionCommon\n extends GcmRegistrationDescriptionCommon,\n TemplateRegistrationDescription {}\n\n/**\n * Represents Notification Hub template registration description for Firebase Legacy Cloud Messaging.\n */\nexport interface GcmTemplateRegistrationDescription\n extends GcmTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"GcmTemplate\";\n}\n\n/**\n * Creates a GCM template registration description.\n * @param description - A partial GCM template registration description.\n * @returns A created GCM template registration description.\n */\nexport function createFcmLegacyTemplateRegistrationDescription(\n description: GcmTemplateRegistrationDescriptionCommon\n): GcmTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"GcmTemplate\",\n };\n}\n\n/**\n * Represents a Windows Phone Notification Services registration description.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The channel URI.\n */\n channelUri: string;\n}\n\n/**\n * Represents a Windows Phone Notification Services registration description.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsRegistrationDescription extends MpnsRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Mpns\";\n}\n\n/**\n * Represents a Windows Phone Notification Services template registration.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsTemplateRegistrationDescription\n extends MpnsRegistrationDescriptionCommon,\n TemplateRegistrationDescription {\n /**\n * The WNS headers.\n */\n mpnsHeaders?: Record<string, string>;\n\n /**\n * The kind of the registration.\n */\n kind: \"MpnsTemplate\";\n}\n\n/**\n * Represents a Windows Phone Notification Services template registration.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsTemplateRegistrationDescriptionCommon\n extends MpnsRegistrationDescriptionCommon,\n TemplateRegistrationDescription {\n /**\n * The WNS headers.\n */\n mpnsHeaders?: Record<string, string>;\n}\n\n/**\n * Represents a Windows Phone Notification Services template registration.\n * @deprecated Windows Phone is no longer supported.\n */\nexport interface MpnsTemplateRegistrationDescription\n extends MpnsTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"MpnsTemplate\";\n}\n\n/**\n * Represents a Windows Notification Services (WNS) registration description.\n */\nexport interface WindowsRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The channel URI.\n */\n channelUri: string;\n}\n\n/**\n * Represents a Windows Notification Services (WNS) registration description.\n */\nexport interface WindowsRegistrationDescription extends WindowsRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Windows\";\n}\n\n/**\n * Creates a Windows registration description.\n * @param description - A partial Windows registration description.\n * @returns A created Windows registration description.\n */\nexport function createWindowsRegistrationDescription(\n description: WindowsRegistrationDescriptionCommon\n): WindowsRegistrationDescription {\n return {\n ...description,\n kind: \"Windows\",\n };\n}\n\n/**\n * Represents a Windows Notification Services (WNS) template registration.\n */\nexport interface WindowsTemplateRegistrationDescriptionCommon\n extends WindowsRegistrationDescriptionCommon,\n TemplateRegistrationDescription {\n /**\n * The WNS headers.\n */\n wnsHeaders?: Record<string, string>;\n}\n\n/**\n * Represents a Windows Notification Services (WNS) template registration.\n */\nexport interface WindowsTemplateRegistrationDescription\n extends WindowsTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"WindowsTemplate\";\n}\n\n/**\n * Creates a Windows template registration description.\n * @param description - A partial Windows template registration description.\n * @returns A created Windows template registration description.\n */\nexport function createWindowsTemplateRegistrationDescription(\n description: WindowsTemplateRegistrationDescriptionCommon\n): WindowsTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"WindowsTemplate\",\n };\n}\n\n/**\n * Represents a Xiaomi registration description.\n */\nexport interface XiaomiRegistrationDescriptionCommon extends RegistrationDescriptionCommon {\n /**\n * The Xiaomi registration ID.\n */\n xiaomiRegistrationId: string;\n}\n\n/**\n * Represents a Xiaomi registration description.\n */\nexport interface XiaomiRegistrationDescription extends XiaomiRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"Xiaomi\";\n}\n\n/**\n * Creates a Xiaomi registration description.\n * @param description - A partial Xiaomi registration description.\n * @returns A created Xiaomi registration description.\n */\nexport function createXiaomiRegistrationDescription(\n description: XiaomiRegistrationDescriptionCommon\n): XiaomiRegistrationDescription {\n return {\n ...description,\n kind: \"Xiaomi\",\n };\n}\n\n/**\n * Represents a Xiaomi template registration.\n */\nexport interface XiaomiTemplateRegistrationDescriptionCommon\n extends XiaomiRegistrationDescriptionCommon,\n TemplateRegistrationDescription {}\n\n/**\n * Represents a Windows Notification Services (WNS) template registration.\n */\nexport interface XiaomiTemplateRegistrationDescription\n extends XiaomiTemplateRegistrationDescriptionCommon {\n /**\n * The kind of the registration.\n */\n kind: \"XiaomiTemplate\";\n}\n\n/**\n * Creates a Xiaomi template registration description.\n * @param description - A partial Xiaomi template registration description.\n * @returns A created Xiaomi template registration description.\n */\nexport function createXiaomiTemplateRegistrationDescription(\n description: XiaomiTemplateRegistrationDescriptionCommon\n): XiaomiTemplateRegistrationDescription {\n return {\n ...description,\n kind: \"XiaomiTemplate\",\n };\n}\n\n/**\n * Describes the types of registration descriptions.\n */\nexport type RegistrationDescription =\n | AdmRegistrationDescription\n | AdmTemplateRegistrationDescription\n | AppleRegistrationDescription\n | AppleTemplateRegistrationDescription\n | BaiduRegistrationDescription\n | BaiduTemplateRegistrationDescription\n | BrowserRegistrationDescription\n | BrowserTemplateRegistrationDescription\n | GcmRegistrationDescription\n | GcmTemplateRegistrationDescription\n | MpnsRegistrationDescription\n | MpnsTemplateRegistrationDescription\n | XiaomiRegistrationDescription\n | XiaomiTemplateRegistrationDescription\n | WindowsRegistrationDescription\n | WindowsTemplateRegistrationDescription;\n\n/**\n * Describes an ADM Registration channel query.\n */\nexport interface AdmRegistrationChannel {\n /**\n * The ADM Registration ID.\n */\n admRegistrationId: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"adm\";\n}\n\n/**\n * Describes an Apple Registration channel query.\n */\nexport interface AppleRegistrationChannel {\n /**\n * The APNs device token.\n */\n deviceToken: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"apple\";\n}\n\n/**\n * Describes an Baidu Registration channel query.\n */\nexport interface BaiduRegistrationChannel {\n /**\n * The Baidu Channel ID.\n */\n baiduChannelId: string;\n /**\n * The Baidu User ID.\n */\n baiduUserId: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"baidu\";\n}\n\n/**\n * Describes an Browser Registration channel query.\n */\nexport interface BrowserRegistrationChannel {\n /**\n * The Web Push endpoint URL.\n */\n endpoint: string;\n /**\n * The Web Push subscription P256DH.\n */\n p256dh: string;\n /**\n * The Web Push subscription auth secret.\n */\n auth: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"browser\";\n}\n\n/**\n * Describes an Firebase Legacy Registration channel query.\n */\nexport interface FirebaseLegacyRegistrationChannel {\n /**\n * The FCM Legacy registration ID.\n */\n gcmRegistrationId: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"gcm\";\n}\n\n/**\n * Describes an Windows Notification Services Registration channel query.\n */\nexport interface WindowsRegistrationChannel {\n /**\n * The WNS Channel URI.\n */\n channelUri: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"windows\";\n}\n\n/**\n * Describes an Xiaomi Registration channel query.\n */\nexport interface XiaomiRegistrationChannel {\n /**\n * The Xiaomi registration ID.\n */\n xiaomiRegistrationId: string;\n /**\n * The kind of the registration channel.\n */\n kind: \"xiaomi\";\n}\n\n/**\n * Describes a Registration query.\n */\nexport type RegistrationChannel =\n | AdmRegistrationChannel\n | AppleRegistrationChannel\n | BaiduRegistrationChannel\n | BrowserRegistrationChannel\n | FirebaseLegacyRegistrationChannel\n | XiaomiRegistrationChannel\n | WindowsRegistrationChannel;\n"]}
@@ -9,7 +9,6 @@ import { parseXML } from "@azure/core-xml";
9
9
  export async function parseNotificationDetails(bodyText) {
10
10
  const xml = await parseXML(bodyText, {
11
11
  includeRoot: true,
12
- stopNodes: ["NotificationDetails.NotificationBody"],
13
12
  });
14
13
  const notificationDetails = xml["NotificationDetails"];
15
14
  let apnsOutcomeCounts;
@@ -28,6 +27,10 @@ export async function parseNotificationDetails(bodyText) {
28
27
  if (isDefined(notificationDetails["GcmOutcomeCounts"])) {
29
28
  fcmOutcomeCounts = parseOutcomeCounts(notificationDetails["GcmOutcomeCounts"]["Outcome"]);
30
29
  }
30
+ let xiaomiOutcomeCounts;
31
+ if (isDefined(notificationDetails["XiaomiOutcomeCounts"])) {
32
+ xiaomiOutcomeCounts = parseOutcomeCounts(notificationDetails["XiaomiOutcomeCounts"]["Outcome"]);
33
+ }
31
34
  let wnsOutcomeCounts;
32
35
  if (isDefined(notificationDetails["WnsOutcomeCounts"])) {
33
36
  wnsOutcomeCounts = parseOutcomeCounts(notificationDetails["WnsOutcomeCounts"]["Outcome"]);
@@ -41,10 +44,12 @@ export async function parseNotificationDetails(bodyText) {
41
44
  endTime: getDateOrUndefined(notificationDetails["EndTime"]),
42
45
  pnsErrorDetailsUrl: getStringOrUndefined(notificationDetails["PnsErrorDetailsUri"]),
43
46
  targetPlatforms: getStringOrUndefined(notificationDetails["TargetPlatforms"]),
47
+ notificationBody: getStringOrUndefined(notificationDetails["NotificationBody"]),
44
48
  apnsOutcomeCounts,
45
49
  admOutcomeCounts,
46
50
  baiduOutcomeCounts,
47
51
  fcmOutcomeCounts,
52
+ xiaomiOutcomeCounts,
48
53
  wnsOutcomeCounts,
49
54
  };
50
55
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notificationDetailsSerializer.js","sourceRoot":"","sources":["../../../src/serializers/notificationDetailsSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,QAAgB;IAC7D,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE;QACnC,WAAW,EAAE,IAAI;QACjB,SAAS,EAAE,CAAC,sCAAsC,CAAC;KACpD,CAAC,CAAC;IACH,MAAM,mBAAmB,GAAG,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAEvD,IAAI,iBAAoD,CAAC;IACzD,IAAI,SAAS,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,EAAE;QACvD,iBAAiB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC7F;IAED,IAAI,gBAAmD,CAAC;IACxD,IAAI,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,EAAE;QACtD,gBAAgB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC3F;IAED,IAAI,kBAAqD,CAAC;IAC1D,IAAI,SAAS,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,EAAE;QACxD,kBAAkB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC/F;IAED,IAAI,gBAAmD,CAAC;IACxD,IAAI,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,EAAE;QACtD,gBAAgB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC3F;IAED,IAAI,gBAAmD,CAAC;IACxD,IAAI,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,EAAE;QACtD,gBAAgB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC3F;IAED,OAAO;QACL,cAAc,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;QAC3E,QAAQ,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC/D,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAA6B;QACrF,WAAW,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QACnE,SAAS,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;QAC/D,OAAO,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAC3D,kBAAkB,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;QACnF,eAAe,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;QAC7E,iBAAiB;QACjB,gBAAgB;QAChB,kBAAkB;QAClB,gBAAgB;QAChB,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAmD;IAEnD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,OAAO,GAA0B,EAAE,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;KAClF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n NotificationDetails,\n NotificationOutcome,\n NotificationOutcomeState,\n} from \"../models/notificationDetails.js\";\nimport { getDateOrUndefined, getInteger, getStringOrUndefined, isDefined } from \"../utils/utils.js\";\nimport { parseXML } from \"@azure/core-xml\";\n\n/**\n * @internal\n * Parses a NotificationDetails from incoming XML.\n */\nexport async function parseNotificationDetails(bodyText: string): Promise<NotificationDetails> {\n const xml = await parseXML(bodyText, {\n includeRoot: true,\n stopNodes: [\"NotificationDetails.NotificationBody\"],\n });\n const notificationDetails = xml[\"NotificationDetails\"];\n\n let apnsOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"ApnsOutcomeCounts\"])) {\n apnsOutcomeCounts = parseOutcomeCounts(notificationDetails[\"ApnsOutcomeCounts\"][\"Outcome\"]);\n }\n\n let admOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"AdmOutcomeCounts\"])) {\n admOutcomeCounts = parseOutcomeCounts(notificationDetails[\"AdmOutcomeCounts\"][\"Outcome\"]);\n }\n\n let baiduOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"BaiduOutcomeCounts\"])) {\n baiduOutcomeCounts = parseOutcomeCounts(notificationDetails[\"BaiduOutcomeCounts\"][\"Outcome\"]);\n }\n\n let fcmOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"GcmOutcomeCounts\"])) {\n fcmOutcomeCounts = parseOutcomeCounts(notificationDetails[\"GcmOutcomeCounts\"][\"Outcome\"]);\n }\n\n let wnsOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"WnsOutcomeCounts\"])) {\n wnsOutcomeCounts = parseOutcomeCounts(notificationDetails[\"WnsOutcomeCounts\"][\"Outcome\"]);\n }\n\n return {\n notificationId: getStringOrUndefined(notificationDetails[\"NotificationId\"]),\n location: getStringOrUndefined(notificationDetails[\"Location\"]),\n state: getStringOrUndefined(notificationDetails[\"State\"]) as NotificationOutcomeState,\n enqueueTime: getDateOrUndefined(notificationDetails[\"EnqueueTime\"]),\n startTime: getDateOrUndefined(notificationDetails[\"StartTime\"]),\n endTime: getDateOrUndefined(notificationDetails[\"EndTime\"]),\n pnsErrorDetailsUrl: getStringOrUndefined(notificationDetails[\"PnsErrorDetailsUri\"]),\n targetPlatforms: getStringOrUndefined(notificationDetails[\"TargetPlatforms\"]),\n apnsOutcomeCounts,\n admOutcomeCounts,\n baiduOutcomeCounts,\n fcmOutcomeCounts,\n wnsOutcomeCounts,\n };\n}\n\nfunction parseOutcomeCounts(\n counts: Record<string, any>[] | Record<string, any>\n): NotificationOutcome[] {\n const items = Array.isArray(counts) ? counts : [counts];\n const results: NotificationOutcome[] = [];\n for (const item of items) {\n results.push({ state: item[\"Name\"], count: getInteger(item[\"Count\"], \"Count\") });\n }\n\n return results;\n}\n"]}
1
+ {"version":3,"file":"notificationDetailsSerializer.js","sourceRoot":"","sources":["../../../src/serializers/notificationDetailsSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpG,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAAC,QAAgB;IAC7D,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE;QACnC,WAAW,EAAE,IAAI;KAClB,CAAC,CAAC;IACH,MAAM,mBAAmB,GAAG,GAAG,CAAC,qBAAqB,CAAC,CAAC;IAEvD,IAAI,iBAAoD,CAAC;IACzD,IAAI,SAAS,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,EAAE;QACvD,iBAAiB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC7F;IAED,IAAI,gBAAmD,CAAC;IACxD,IAAI,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,EAAE;QACtD,gBAAgB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC3F;IAED,IAAI,kBAAqD,CAAC;IAC1D,IAAI,SAAS,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,EAAE;QACxD,kBAAkB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC/F;IAED,IAAI,gBAAmD,CAAC;IACxD,IAAI,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,EAAE;QACtD,gBAAgB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC3F;IAED,IAAI,mBAAsD,CAAC;IAC3D,IAAI,SAAS,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,CAAC,EAAE;QACzD,mBAAmB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,qBAAqB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KACjG;IAED,IAAI,gBAAmD,CAAC;IACxD,IAAI,SAAS,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,EAAE;QACtD,gBAAgB,GAAG,kBAAkB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC;KAC3F;IAED,OAAO;QACL,cAAc,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,gBAAgB,CAAC,CAAC;QAC3E,QAAQ,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,UAAU,CAAC,CAAC;QAC/D,KAAK,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,OAAO,CAAC,CAA6B;QACrF,WAAW,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,aAAa,CAAC,CAAC;QACnE,SAAS,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;QAC/D,OAAO,EAAE,kBAAkB,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC;QAC3D,kBAAkB,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,oBAAoB,CAAC,CAAC;QACnF,eAAe,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;QAC7E,gBAAgB,EAAE,oBAAoB,CAAC,mBAAmB,CAAC,kBAAkB,CAAC,CAAC;QAC/E,iBAAiB;QACjB,gBAAgB;QAChB,kBAAkB;QAClB,gBAAgB;QAChB,mBAAmB;QACnB,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,SAAS,kBAAkB,CACzB,MAAmD;IAEnD,MAAM,KAAK,GAAG,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC;IACxD,MAAM,OAAO,GAA0B,EAAE,CAAC;IAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;QACxB,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO,CAAC,EAAE,CAAC,CAAC;KAClF;IAED,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n NotificationDetails,\n NotificationOutcome,\n NotificationOutcomeState,\n} from \"../models/notificationDetails.js\";\nimport { getDateOrUndefined, getInteger, getStringOrUndefined, isDefined } from \"../utils/utils.js\";\nimport { parseXML } from \"@azure/core-xml\";\n\n/**\n * @internal\n * Parses a NotificationDetails from incoming XML.\n */\nexport async function parseNotificationDetails(bodyText: string): Promise<NotificationDetails> {\n const xml = await parseXML(bodyText, {\n includeRoot: true,\n });\n const notificationDetails = xml[\"NotificationDetails\"];\n\n let apnsOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"ApnsOutcomeCounts\"])) {\n apnsOutcomeCounts = parseOutcomeCounts(notificationDetails[\"ApnsOutcomeCounts\"][\"Outcome\"]);\n }\n\n let admOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"AdmOutcomeCounts\"])) {\n admOutcomeCounts = parseOutcomeCounts(notificationDetails[\"AdmOutcomeCounts\"][\"Outcome\"]);\n }\n\n let baiduOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"BaiduOutcomeCounts\"])) {\n baiduOutcomeCounts = parseOutcomeCounts(notificationDetails[\"BaiduOutcomeCounts\"][\"Outcome\"]);\n }\n\n let fcmOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"GcmOutcomeCounts\"])) {\n fcmOutcomeCounts = parseOutcomeCounts(notificationDetails[\"GcmOutcomeCounts\"][\"Outcome\"]);\n }\n\n let xiaomiOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"XiaomiOutcomeCounts\"])) {\n xiaomiOutcomeCounts = parseOutcomeCounts(notificationDetails[\"XiaomiOutcomeCounts\"][\"Outcome\"]);\n }\n\n let wnsOutcomeCounts: NotificationOutcome[] | undefined;\n if (isDefined(notificationDetails[\"WnsOutcomeCounts\"])) {\n wnsOutcomeCounts = parseOutcomeCounts(notificationDetails[\"WnsOutcomeCounts\"][\"Outcome\"]);\n }\n\n return {\n notificationId: getStringOrUndefined(notificationDetails[\"NotificationId\"]),\n location: getStringOrUndefined(notificationDetails[\"Location\"]),\n state: getStringOrUndefined(notificationDetails[\"State\"]) as NotificationOutcomeState,\n enqueueTime: getDateOrUndefined(notificationDetails[\"EnqueueTime\"]),\n startTime: getDateOrUndefined(notificationDetails[\"StartTime\"]),\n endTime: getDateOrUndefined(notificationDetails[\"EndTime\"]),\n pnsErrorDetailsUrl: getStringOrUndefined(notificationDetails[\"PnsErrorDetailsUri\"]),\n targetPlatforms: getStringOrUndefined(notificationDetails[\"TargetPlatforms\"]),\n notificationBody: getStringOrUndefined(notificationDetails[\"NotificationBody\"]),\n apnsOutcomeCounts,\n admOutcomeCounts,\n baiduOutcomeCounts,\n fcmOutcomeCounts,\n xiaomiOutcomeCounts,\n wnsOutcomeCounts,\n };\n}\n\nfunction parseOutcomeCounts(\n counts: Record<string, any>[] | Record<string, any>\n): NotificationOutcome[] {\n const items = Array.isArray(counts) ? counts : [counts];\n const results: NotificationOutcome[] = [];\n for (const item of items) {\n results.push({ state: item[\"Name\"], count: getInteger(item[\"Count\"], \"Count\") });\n }\n\n return results;\n}\n"]}
@@ -11,6 +11,7 @@ export const registrationDescriptionParser = {
11
11
  */
12
12
  async parseRegistrationEntry(bodyText) {
13
13
  const xml = await parseXML(bodyText, { includeRoot: true });
14
+ delete xml.entry.content["$"];
14
15
  const keyName = Object.keys(xml.entry.content)[0];
15
16
  const content = xml.entry.content[keyName];
16
17
  const methodName = `create${keyName}`;
@@ -130,6 +131,20 @@ export const registrationDescriptionParser = {
130
131
  var _a;
131
132
  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" });
132
133
  },
134
+ /**
135
+ * @internal
136
+ * Creates a Xiaomi registration description from incoming XML property bag.
137
+ */
138
+ createXiaomiRegistrationDescription(rawRegistrationDescription) {
139
+ return Object.assign(Object.assign({ xiaomiRegistrationId: getString(rawRegistrationDescription["XiaomiRegistrationId"], "xiaomiRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { kind: "Xiaomi" });
140
+ },
141
+ /**
142
+ * @internal
143
+ * Creates a Xiaomi template registration description from incoming XML property bag.
144
+ */
145
+ createXiaomiTemplateRegistrationDescription(rawRegistrationDescription) {
146
+ return Object.assign(Object.assign(Object.assign({}, this.createXiaomiRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { kind: "XiaomiTemplate" });
147
+ },
133
148
  /**
134
149
  * @internal
135
150
  * Creates a Windows registration description from incoming XML property bag.
@@ -300,6 +315,20 @@ export const registrationDescriptionSerializer = {
300
315
  }
301
316
  return Object.assign(Object.assign(Object.assign({}, this.serializeMpnsRegistrationDescription(description)), serializeTemplateRegistrationDescription(description)), { MpnsHeaders: mpnsHeaders });
302
317
  },
318
+ /**
319
+ * @internal
320
+ * Serializes an existing Xiaomi registration description to an object for serialization.
321
+ */
322
+ serializeXiaomiRegistrationDescription(description) {
323
+ return Object.assign(Object.assign({}, serializeRegistrationDescription(description)), { XiaomiRegistrationId: getString(description.xiaomiRegistrationId, "xiaomiRegistrationId") });
324
+ },
325
+ /**
326
+ * @internal
327
+ * Serializes an existing Xiaomi template registration description to an object for serialization.
328
+ */
329
+ serializeXiaomiTemplateRegistrationDescription(description) {
330
+ return Object.assign(Object.assign({}, this.serializeXiaomiRegistrationDescription(description)), serializeTemplateRegistrationDescription(description));
331
+ },
303
332
  /**
304
333
  * @internal
305
334
  * Serializes an existing Windows registration description to an object for serialization.