@azure/notification-hubs 1.0.0-beta.1 → 1.0.0-beta.4

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 (165) hide show
  1. package/README.md +15 -20
  2. package/dist/{index.js → index.cjs} +245 -146
  3. package/dist/index.cjs.map +1 -0
  4. package/dist-esm/src/{utils → auth}/connectionStringUtils.js +37 -1
  5. package/dist-esm/src/auth/connectionStringUtils.js.map +1 -0
  6. package/dist-esm/src/auth/hmacSha256.browser.js +12 -0
  7. package/dist-esm/src/auth/hmacSha256.browser.js.map +1 -0
  8. package/dist-esm/src/auth/hmacSha256.js +8 -0
  9. package/dist-esm/src/auth/hmacSha256.js.map +1 -0
  10. package/dist-esm/src/auth/sasTokenProvider.js +58 -0
  11. package/dist-esm/src/auth/sasTokenProvider.js.map +1 -0
  12. package/dist-esm/src/client/cancelScheduledNotification.js +3 -2
  13. package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
  14. package/dist-esm/src/client/createOrUpdateInstallation.js +3 -2
  15. package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
  16. package/dist-esm/src/client/createOrUpdateRegistration.js +2 -1
  17. package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -1
  18. package/dist-esm/src/client/createRegistration.js +2 -1
  19. package/dist-esm/src/client/createRegistration.js.map +1 -1
  20. package/dist-esm/src/client/createRegistrationId.js +3 -2
  21. package/dist-esm/src/client/createRegistrationId.js.map +1 -1
  22. package/dist-esm/src/client/deleteInstallation.js +3 -2
  23. package/dist-esm/src/client/deleteInstallation.js.map +1 -1
  24. package/dist-esm/src/client/deleteRegistration.js +3 -2
  25. package/dist-esm/src/client/deleteRegistration.js.map +1 -1
  26. package/dist-esm/src/client/getFeedbackContainerUrl.js +3 -2
  27. package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -1
  28. package/dist-esm/src/client/getInstallation.js +3 -2
  29. package/dist-esm/src/client/getInstallation.js.map +1 -1
  30. package/dist-esm/src/client/getNotificationHubJob.js +3 -2
  31. package/dist-esm/src/client/getNotificationHubJob.js.map +1 -1
  32. package/dist-esm/src/client/getNotificationOutcomeDetails.js +3 -2
  33. package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -1
  34. package/dist-esm/src/client/getRegistration.js +3 -2
  35. package/dist-esm/src/client/getRegistration.js.map +1 -1
  36. package/dist-esm/src/client/index.js +7 -3
  37. package/dist-esm/src/client/index.js.map +1 -1
  38. package/dist-esm/src/client/internal/_client.js +23 -7
  39. package/dist-esm/src/client/internal/_client.js.map +1 -1
  40. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js +1 -1
  41. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +1 -1
  42. package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +3 -2
  43. package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +1 -1
  44. package/dist-esm/src/client/internal/_sendNotificationPayload.js +2 -2
  45. package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +1 -1
  46. package/dist-esm/src/client/listNotificationHubJobs.js +3 -2
  47. package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -1
  48. package/dist-esm/src/client/listRegistrations.js +3 -2
  49. package/dist-esm/src/client/listRegistrations.js.map +1 -1
  50. package/dist-esm/src/client/listRegistrationsByTag.js +3 -2
  51. package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -1
  52. package/dist-esm/src/client/scheduleBroadcastNotification.js.map +1 -1
  53. package/dist-esm/src/client/scheduleNotification.js.map +1 -1
  54. package/dist-esm/src/client/sendBroadcastNotification.js.map +1 -1
  55. package/dist-esm/src/client/sendDirectNotification.js +1 -2
  56. package/dist-esm/src/client/sendDirectNotification.js.map +1 -1
  57. package/dist-esm/src/client/sendNotification.js.map +1 -1
  58. package/dist-esm/src/client/submitNotificationHubJob.js +3 -2
  59. package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -1
  60. package/dist-esm/src/client/updateInstallation.js +3 -2
  61. package/dist-esm/src/client/updateInstallation.js.map +1 -1
  62. package/dist-esm/src/client/updateRegistration.js +2 -1
  63. package/dist-esm/src/client/updateRegistration.js.map +1 -1
  64. package/dist-esm/src/models/installation.js +1 -1
  65. package/dist-esm/src/models/installation.js.map +1 -1
  66. package/dist-esm/src/models/notification.js +1 -1
  67. package/dist-esm/src/models/notification.js.map +1 -1
  68. package/dist-esm/src/models/notificationBuilder.js +6 -6
  69. package/dist-esm/src/models/notificationBuilder.js.map +1 -1
  70. package/dist-esm/src/models/notificationDetails.js.map +1 -1
  71. package/dist-esm/src/models/registration.js +3 -39
  72. package/dist-esm/src/models/registration.js.map +1 -1
  73. package/dist-esm/src/models/response.js.map +1 -1
  74. package/dist-esm/src/notificationHubsClient.js +1 -2
  75. package/dist-esm/src/notificationHubsClient.js.map +1 -1
  76. package/dist-esm/src/serializers/notificationHubJobSerializer.js +3 -0
  77. package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -1
  78. package/dist-esm/src/serializers/notificationOutcomeSerializer.js +31 -0
  79. package/dist-esm/src/serializers/notificationOutcomeSerializer.js.map +1 -0
  80. package/dist-esm/src/serializers/registrationSerializer.js +3 -28
  81. package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
  82. package/dist-esm/src/utils/constants.js +1 -0
  83. package/dist-esm/src/utils/constants.js.map +1 -1
  84. package/dist-esm/src/utils/retryPolicy.js +2 -2
  85. package/dist-esm/src/utils/retryPolicy.js.map +1 -1
  86. package/dist-esm/src/utils/tracing.js +2 -1
  87. package/dist-esm/src/utils/tracing.js.map +1 -1
  88. package/package.json +18 -13
  89. package/types/3.1/notification-hubs.d.ts +60 -77
  90. package/types/latest/notification-hubs.d.ts +61 -83
  91. package/types/latest/tsdoc-metadata.json +1 -1
  92. package/types/src/{utils → auth}/connectionStringUtils.d.ts +7 -1
  93. package/types/src/auth/connectionStringUtils.d.ts.map +1 -0
  94. package/types/src/auth/hmacSha256.browser.d.ts +3 -0
  95. package/types/src/auth/hmacSha256.browser.d.ts.map +1 -0
  96. package/types/src/auth/hmacSha256.d.ts +2 -0
  97. package/types/src/auth/hmacSha256.d.ts.map +1 -0
  98. package/types/src/auth/sasTokenProvider.d.ts +77 -0
  99. package/types/src/auth/sasTokenProvider.d.ts.map +1 -0
  100. package/types/src/client/cancelScheduledNotification.d.ts +1 -1
  101. package/types/src/client/cancelScheduledNotification.d.ts.map +1 -1
  102. package/types/src/client/createOrUpdateInstallation.d.ts +1 -1
  103. package/types/src/client/createOrUpdateInstallation.d.ts.map +1 -1
  104. package/types/src/client/createOrUpdateRegistration.d.ts.map +1 -1
  105. package/types/src/client/createRegistration.d.ts.map +1 -1
  106. package/types/src/client/createRegistrationId.d.ts.map +1 -1
  107. package/types/src/client/deleteInstallation.d.ts +1 -1
  108. package/types/src/client/deleteInstallation.d.ts.map +1 -1
  109. package/types/src/client/deleteRegistration.d.ts +1 -1
  110. package/types/src/client/deleteRegistration.d.ts.map +1 -1
  111. package/types/src/client/getFeedbackContainerUrl.d.ts.map +1 -1
  112. package/types/src/client/getInstallation.d.ts.map +1 -1
  113. package/types/src/client/getNotificationHubJob.d.ts.map +1 -1
  114. package/types/src/client/getNotificationOutcomeDetails.d.ts.map +1 -1
  115. package/types/src/client/getRegistration.d.ts.map +1 -1
  116. package/types/src/client/index.d.ts +2 -3
  117. package/types/src/client/index.d.ts.map +1 -1
  118. package/types/src/client/internal/_client.d.ts +8 -8
  119. package/types/src/client/internal/_client.d.ts.map +1 -1
  120. package/types/src/client/internal/_scheduleNotificationPayload.d.ts +1 -1
  121. package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +1 -1
  122. package/types/src/client/internal/_sendNotificationPayload.d.ts +1 -1
  123. package/types/src/client/internal/_sendNotificationPayload.d.ts.map +1 -1
  124. package/types/src/client/listNotificationHubJobs.d.ts.map +1 -1
  125. package/types/src/client/listRegistrations.d.ts.map +1 -1
  126. package/types/src/client/listRegistrationsByTag.d.ts.map +1 -1
  127. package/types/src/client/scheduleBroadcastNotification.d.ts +1 -1
  128. package/types/src/client/scheduleBroadcastNotification.d.ts.map +1 -1
  129. package/types/src/client/scheduleNotification.d.ts +1 -1
  130. package/types/src/client/scheduleNotification.d.ts.map +1 -1
  131. package/types/src/client/sendBroadcastNotification.d.ts +1 -1
  132. package/types/src/client/sendBroadcastNotification.d.ts.map +1 -1
  133. package/types/src/client/sendDirectNotification.d.ts +4 -5
  134. package/types/src/client/sendDirectNotification.d.ts.map +1 -1
  135. package/types/src/client/sendNotification.d.ts +1 -1
  136. package/types/src/client/sendNotification.d.ts.map +1 -1
  137. package/types/src/client/submitNotificationHubJob.d.ts.map +1 -1
  138. package/types/src/client/updateInstallation.d.ts +1 -1
  139. package/types/src/client/updateInstallation.d.ts.map +1 -1
  140. package/types/src/client/updateRegistration.d.ts.map +1 -1
  141. package/types/src/models/installation.d.ts +3 -3
  142. package/types/src/models/installation.d.ts.map +1 -1
  143. package/types/src/models/notification.d.ts +3 -3
  144. package/types/src/models/notification.d.ts.map +1 -1
  145. package/types/src/models/notificationBuilder.d.ts +4 -4
  146. package/types/src/models/notificationBuilder.d.ts.map +1 -1
  147. package/types/src/models/notificationDetails.d.ts +63 -0
  148. package/types/src/models/notificationDetails.d.ts.map +1 -1
  149. package/types/src/models/registration.d.ts +6 -59
  150. package/types/src/models/registration.d.ts.map +1 -1
  151. package/types/src/models/response.d.ts +0 -26
  152. package/types/src/models/response.d.ts.map +1 -1
  153. package/types/src/notificationHubsClient.d.ts +3 -5
  154. package/types/src/notificationHubsClient.d.ts.map +1 -1
  155. package/types/src/serializers/notificationHubJobSerializer.d.ts.map +1 -1
  156. package/types/src/serializers/notificationOutcomeSerializer.d.ts +3 -0
  157. package/types/src/serializers/notificationOutcomeSerializer.d.ts.map +1 -0
  158. package/types/src/serializers/registrationSerializer.d.ts +1 -21
  159. package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
  160. package/types/src/utils/constants.d.ts +1 -0
  161. package/types/src/utils/constants.d.ts.map +1 -1
  162. package/types/src/utils/tracing.d.ts.map +1 -1
  163. package/dist/index.js.map +0 -1
  164. package/dist-esm/src/utils/connectionStringUtils.js.map +0 -1
  165. package/types/src/utils/connectionStringUtils.d.ts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"notificationHubsClient.js","sourceRoot":"","sources":["../../src/notificationHubsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAiC,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAcvF,OAAO,EAAE,2BAA2B,IAAI,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAC3H,OAAO,EAAE,0BAA0B,IAAI,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AACxH,OAAO,EAAE,0BAA0B,IAAI,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AACxH,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACtG,OAAO,EAAE,kBAAkB,IAAI,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAChG,OAAO,EAAE,kBAAkB,IAAI,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAChG,OAAO,EAAE,uBAAuB,IAAI,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AAC/G,OAAO,EAAE,eAAe,IAAI,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,qBAAqB,IAAI,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AACzG,OAAO,EAAE,6BAA6B,IAAI,mCAAmC,EAAE,MAAM,2CAA2C,CAAC;AACjI,OAAO,EAAE,eAAe,IAAI,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,uBAAuB,IAAI,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AAC/G,OAAO,EAAE,sBAAsB,IAAI,4BAA4B,EAAE,MAAM,oCAAoC,CAAC;AAC5G,OAAO,EAAE,iBAAiB,IAAI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6B,CAC3B,cAAsB,EACtB,UAA4B,EAAE;QAE9B,OAAO,mCAAmC,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;IAED;;;;;OAKG;IACH,qBAAqB,CACnB,KAAa,EACb,UAA4B,EAAE;QAE9B,OAAO,2BAA2B,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAED;;;;;OAKG;IACH,wBAAwB,CACtB,GAAuB,EACvB,UAA4B,EAAE;QAE9B,OAAO,8BAA8B,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,uBAAuB,CAAC,UAA4B,EAAE;QACpD,OAAO,6BAA6B,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Installation, JsonPatch, PushHandle } from \"./models/installation.js\";\nimport { NotificationHubsClientContext, createClientContext } from \"./client/index.js\";\nimport {\n NotificationHubsClientOptions,\n RegistrationQueryLimitOptions,\n RegistrationQueryOptions,\n SendOperationOptions,\n} from \"./models/options.js\";\nimport { NotificationHubsMessageResponse, NotificationHubsResponse } from \"./models/response.js\";\nimport { Notification } from \"./models/notification.js\";\nimport { NotificationDetails } from \"./models/notificationDetails.js\";\nimport { NotificationHubJob } from \"./models/notificationHubJob.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { RegistrationDescription } from \"./models/registration.js\";\nimport { cancelScheduledNotification as cancelScheduledNotificationMethod } from \"./client/cancelScheduledNotification.js\";\nimport { createOrUpdateInstallation as createOrUpdateInstallationMethod } from \"./client/createOrUpdateInstallation.js\";\nimport { createOrUpdateRegistration as createOrUpdateRegistrationMethod } from \"./client/createOrUpdateRegistration.js\";\nimport { createRegistrationId as createRegistrationIdMethod } from \"./client/createRegistrationId.js\";\nimport { createRegistration as createRegistrationMethod } from \"./client/createRegistration.js\";\nimport { deleteInstallation as deleteInstallationMethod } from \"./client/deleteInstallation.js\";\nimport { getFeedbackContainerUrl as getFeedbackContainerUrlMethod } from \"./client/getFeedbackContainerUrl.js\";\nimport { getInstallation as getInstallationMethod } from \"./client/getInstallation.js\";\nimport { getNotificationHubJob as getNotificationHubJobMethod } from \"./client/getNotificationHubJob.js\";\nimport { getNotificationOutcomeDetails as getNotificationOutcomeDetailsMethod } from \"./client/getNotificationOutcomeDetails.js\";\nimport { getRegistration as getRegistrationMethod } from \"./client/getRegistration.js\";\nimport { listNotificationHubJobs as listNotificationHubJobsMethod } from \"./client/listNotificationHubJobs.js\";\nimport { listRegistrationsByTag as listRegistrationsByTagMethod } from \"./client/listRegistrationsByTag.js\";\nimport { listRegistrations as listRegistrationsMethod } from \"./client/listRegistrations.js\";\nimport { scheduleBroadcastNotification as scheduleBroadcastNotificationMethod } from \"./client/scheduleBroadcastNotification.js\";\nimport { scheduleNotification as scheduleNotificationMethod } from \"./client/scheduleNotification.js\";\nimport { sendBroadcastNotification as sendBroadcastNotificationMethod } from \"./client/sendBroadcastNotification.js\";\nimport { sendDirectNotification as sendDirectNotificationMethod } from \"./client/sendDirectNotification.js\";\nimport { sendNotification as sendNotificationMethod } from \"./client/sendNotification.js\";\nimport { submitNotificationHubJob as submitNotificationHubJobMethod } from \"./client/submitNotificationHubJob.js\";\nimport { updateInstallation as updateInstallationMethod } from \"./client/updateInstallation.js\";\nimport { updateRegistration as updateRegistrationMethod } from \"./client/updateRegistration.js\";\n\n/**\n * This represents a client for Azure Notification Hubs to manage installations and send\n * messages to devices.\n */\nexport class NotificationHubsServiceClient {\n private _client: NotificationHubsClientContext;\n\n /**\n * Creates a new instance of the NotificationClient with a connection string, hub name and options.\n * @param connectionString - The Notification Hub Access Policy connection string.\n * @param hubName - The name of the Azure Notification Hub.\n * @param options - Options for configuring the Azure Notification Hubs client.\n */\n constructor(\n connectionString: string,\n hubName: string,\n options: NotificationHubsClientOptions = {}\n ) {\n this._client = createClientContext(connectionString, hubName, options);\n }\n\n /**\n * Creates or overwrites an installation to a Notification Hub.\n * @param installation - The installation to create or overwrite.\n * @param options - Configuration options for the create or update installation operation.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n createOrUpdateInstallation(\n installation: Installation,\n options: OperationOptions = {}\n ): Promise<NotificationHubsResponse> {\n return createOrUpdateInstallationMethod(this._client, installation, options);\n }\n\n /**\n * Deletes an installation from a Notification Hub.\n * @param installationId - The installation ID of the installation to delete.\n * @param options - Configuration options for the installation delete operation.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n deleteInstallation(\n installationId: string,\n options: OperationOptions = {}\n ): Promise<NotificationHubsResponse> {\n return deleteInstallationMethod(this._client, installationId, options);\n }\n\n /**\n * Gets an Azure Notification Hub installation by the installation ID.\n * @param installationId - The ID of the installation to get.\n * @param options - Configuration options for the get installation operation.\n * @returns The installation that matches the installation ID.\n */\n getInstallation(installationId: string, options: OperationOptions = {}): Promise<Installation> {\n return getInstallationMethod(this._client, installationId, options);\n }\n\n /**\n * Updates an installation using the JSON-Patch standard in RFC6902.\n * @param installationId - The ID of the installation to update.\n * @param patches - An array of patches following the JSON-Patch standard.\n * @param options - Configuration options for the patch installation operation.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n updateInstallation(\n installationId: string,\n patches: JsonPatch[],\n options: OperationOptions = {}\n ): Promise<NotificationHubsResponse> {\n return updateInstallationMethod(this._client, installationId, patches, options);\n }\n\n /**\n * Creates a new registration ID.\n * @param options - The options for creating a new registration ID.\n * @returns The newly created registration ID.\n */\n createRegistrationId(options: OperationOptions = {}): Promise<string> {\n return createRegistrationIdMethod(this._client, options);\n }\n\n /**\n * Creates a new registration. This method generates a registration ID,\n * which you can subsequently use to retrieve, update, and delete this registration.\n * @param registration - The registration to create.\n * @param options - Options for creating a new registration.\n * @returns The newly created registration description.\n */\n createRegistration(\n registration: RegistrationDescription,\n options: OperationOptions = {}\n ): Promise<RegistrationDescription> {\n return createRegistrationMethod(this._client, registration, options);\n }\n\n /**\n * Creates or updates a registration.\n * @param registration - The registration to create or update.\n * @param options - The operation options.\n * @returns The created or updated registration description.\n */\n createOrUpdateRegistration(\n registration: RegistrationDescription,\n options: OperationOptions = {}\n ): Promise<RegistrationDescription> {\n return createOrUpdateRegistrationMethod(this._client, registration, options);\n }\n\n /**\n * Updates an existing registration.\n * @param registration - The registration to update.\n * @param options - The operation options.\n * @returns The updated registration description.\n */\n updateRegistration(\n registration: RegistrationDescription,\n options: OperationOptions = {}\n ): Promise<RegistrationDescription> {\n return updateRegistrationMethod(this._client, registration, options);\n }\n\n /**\n * Gets a registration by the given registration ID.\n * @param registrationId - The ID of the registration to get.\n * @param options - The options for getting a registration by ID.\n * @returns A RegistrationDescription that has the given registration ID.\n */\n getRegistration(\n registrationId: string,\n options: OperationOptions = {}\n ): Promise<RegistrationDescription> {\n return getRegistrationMethod(this._client, registrationId, options);\n }\n\n /**\n * Gets all registrations for the notification hub with the given query options.\n * @param options - The options for querying the registrations such as $top and $filter.\n * @returns A paged async iterable containing all of the registrations for the notification hub.\n */\n listRegistrations(\n options: RegistrationQueryOptions = {}\n ): PagedAsyncIterableIterator<RegistrationDescription> {\n return listRegistrationsMethod(this._client, options);\n }\n\n /**\n * Lists all registrations with the matching tag.\n * @param tag - The tag to query for matching registrations.\n * @param options - The query options such as $top.\n * @returns A paged async iterable containing the matching registrations for the notification hub.\n */\n listRegistrationsByTag(\n tag: string,\n options: RegistrationQueryLimitOptions = {}\n ): PagedAsyncIterableIterator<RegistrationDescription> {\n return listRegistrationsByTagMethod(this._client, tag, options);\n }\n\n /**\n * Sends a direct push notification to a device with the given push handle.\n * @param pushHandle - The push handle which is the unique identifier for the device.\n * @param notification - The notification to send to the device.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n sendDirectNotification(\n pushHandle: PushHandle,\n notification: Notification,\n options: SendOperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return sendDirectNotificationMethod(this._client, pushHandle, notification, options);\n }\n\n /**\n * Sends push notifications to devices that match the given tags or tag expression.\n * @param tags - The tags used to target the device for push notifications in either an array or tag expression.\n * @param notification - The notification to send to the matching devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n sendNotification(\n tags: string[] | string,\n notification: Notification,\n options: SendOperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return sendNotificationMethod(this._client, tags, notification, options);\n }\n\n /**\n * Sends push notifications to all devices on the Notification Hub.\n * @param notification - The notification to send to all devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n sendBroadcastNotification(\n notification: Notification,\n options: SendOperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return sendBroadcastNotificationMethod(this._client, notification, options);\n }\n\n /**\n * Schedules a push notification to devices that match the given tags or tag expression at the specified time.\n * NOTE: This is only available in Standard SKU Azure Notification Hubs.\n * @param scheduledTime - The Date to send the push notification.\n * @param tags - The tags used to target the device for push notifications in either an array or tag expression.\n * @param notification - The notification to send to the matching devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n scheduleNotification(\n scheduledTime: Date,\n tags: string[] | string,\n notification: Notification,\n options: OperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return scheduleNotificationMethod(this._client, scheduledTime, tags, notification, options);\n }\n\n /**\n * Schedules a push notification to all devices registered on the Notification Hub.\n * NOTE: This is only available in Standard SKU Azure Notification Hubs.\n * @param scheduledTime - The Date to send the push notification.\n * @param notification - The notification to send to the matching devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n scheduleBroadcastNotification(\n scheduledTime: Date,\n notification: Notification,\n options: OperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return scheduleBroadcastNotificationMethod(this._client, scheduledTime, notification, options);\n }\n\n /**\n * Cancels the scheduled notification with the given notification ID.\n * @param notificationId - The notification ID from the scheduled notification.\n * @param options - The operation options.\n * @returns A notification hub response with correlation ID and tracking ID.\n */\n cancelScheduledNotification(\n notificationId: string,\n options: OperationOptions = {}\n ): Promise<NotificationHubsResponse> {\n return cancelScheduledNotificationMethod(this._client, notificationId, options);\n }\n\n /**\n * Retrieves an Azure Storage container URL. The container has feedback data for the notification hub.\n * The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.\n * @param options - The options for getting the push notification feedback container URL.\n * @returns The URL of the Azure Storage Container containing the feedback data.\n */\n getFeedbackContainerUrl(options: OperationOptions = {}): Promise<string> {\n return getFeedbackContainerUrlMethod(this._client, options);\n }\n\n /**\n * Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed\n * or final results if the Send* has completed. This API can only be called for Standard SKU and above.\n * @param notificationId - The notification ID returned from the send operation.\n * @param options - The operation options.\n * @returns The results of the send operation.\n */\n getNotificationOutcomeDetails(\n notificationId: string,\n options: OperationOptions = {}\n ): Promise<NotificationDetails> {\n return getNotificationOutcomeDetailsMethod(this._client, notificationId, options);\n }\n\n /**\n * Gets a Notification Hub Job by the ID.\n * @param jobId - The Notification Hub Job ID.\n * @param options - The operation options.\n * @returns The Notification Hub Job with the matching ID.\n */\n getNotificationHubJob(\n jobId: string,\n options: OperationOptions = {}\n ): Promise<NotificationHubJob> {\n return getNotificationHubJobMethod(this._client, jobId, options);\n }\n\n /**\n * Submits a Notification Hub Job. Note this is available to Standard SKU namespace and above.\n * @param job - The notification hub job to submit.\n * @param options - The operation options.\n * @returns The notification hub job details including job ID and status.\n */\n submitNotificationHubJob(\n job: NotificationHubJob,\n options: OperationOptions = {}\n ): Promise<NotificationHubJob> {\n return submitNotificationHubJobMethod(this._client, job, options);\n }\n\n /**\n * Gets all Notification Hub Jobs for this Notification Hub.\n * @param options - The operation options.\n * @returns An array of all Notification Hub Jobs for this Notification Hub.\n */\n listNotificationHubJobs(options: OperationOptions = {}): Promise<NotificationHubJob[]> {\n return listNotificationHubJobsMethod(this._client, options);\n }\n}\n"]}
1
+ {"version":3,"file":"notificationHubsClient.js","sourceRoot":"","sources":["../../src/notificationHubsClient.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAQlC,OAAO,EAAiC,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAYvF,OAAO,EAAE,2BAA2B,IAAI,iCAAiC,EAAE,MAAM,yCAAyC,CAAC;AAC3H,OAAO,EAAE,0BAA0B,IAAI,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AACxH,OAAO,EAAE,0BAA0B,IAAI,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AACxH,OAAO,EAAE,oBAAoB,IAAI,0BAA0B,EAAE,MAAM,kCAAkC,CAAC;AACtG,OAAO,EAAE,kBAAkB,IAAI,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAChG,OAAO,EAAE,kBAAkB,IAAI,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAChG,OAAO,EAAE,uBAAuB,IAAI,6BAA6B,EAAE,MAAM,qCAAqC,CAAC;AAC/G,OAAO,EAAE,eAAe,IAAI,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AACvF,OAAO,EAAE,qBAAqB,IAAI,2BAA2B,EAAE,MAAM,mCAAmC,CAAC;AACzG,OAAO,EAAE,6BAA6B,IA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B,EACtB,UAA4B,EAAE;QAE9B,OAAO,iCAAiC,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IAClF,CAAC;IAED;;;;;OAKG;IACH,uBAAuB,CAAC,UAA4B,EAAE;QACpD,OAAO,6BAA6B,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;IAED;;;;;;OAMG;IACH,6BAA6B,CAC3B,cAAsB,EACtB,UAA4B,EAAE;QAE9B,OAAO,mCAAmC,CAAC,IAAI,CAAC,OAAO,EAAE,cAAc,EAAE,OAAO,CAAC,CAAC;IACpF,CAAC;IAED;;;;;OAKG;IACH,qBAAqB,CACnB,KAAa,EACb,UAA4B,EAAE;QAE9B,OAAO,2BAA2B,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAED;;;;;OAKG;IACH,wBAAwB,CACtB,GAAuB,EACvB,UAA4B,EAAE;QAE9B,OAAO,8BAA8B,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACpE,CAAC;IAED;;;;OAIG;IACH,uBAAuB,CAAC,UAA4B,EAAE;QACpD,OAAO,6BAA6B,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Installation, JsonPatch, PushHandle } from \"./models/installation.js\";\nimport {\n NotificationDetails,\n NotificationHubsMessageResponse,\n NotificationHubsResponse,\n} from \"./models/notificationDetails.js\";\nimport { NotificationHubsClientContext, createClientContext } from \"./client/index.js\";\nimport {\n NotificationHubsClientOptions,\n RegistrationQueryLimitOptions,\n RegistrationQueryOptions,\n SendOperationOptions,\n} from \"./models/options.js\";\nimport { Notification } from \"./models/notification.js\";\nimport { NotificationHubJob } from \"./models/notificationHubJob.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { RegistrationDescription } from \"./models/registration.js\";\nimport { cancelScheduledNotification as cancelScheduledNotificationMethod } from \"./client/cancelScheduledNotification.js\";\nimport { createOrUpdateInstallation as createOrUpdateInstallationMethod } from \"./client/createOrUpdateInstallation.js\";\nimport { createOrUpdateRegistration as createOrUpdateRegistrationMethod } from \"./client/createOrUpdateRegistration.js\";\nimport { createRegistrationId as createRegistrationIdMethod } from \"./client/createRegistrationId.js\";\nimport { createRegistration as createRegistrationMethod } from \"./client/createRegistration.js\";\nimport { deleteInstallation as deleteInstallationMethod } from \"./client/deleteInstallation.js\";\nimport { getFeedbackContainerUrl as getFeedbackContainerUrlMethod } from \"./client/getFeedbackContainerUrl.js\";\nimport { getInstallation as getInstallationMethod } from \"./client/getInstallation.js\";\nimport { getNotificationHubJob as getNotificationHubJobMethod } from \"./client/getNotificationHubJob.js\";\nimport { getNotificationOutcomeDetails as getNotificationOutcomeDetailsMethod } from \"./client/getNotificationOutcomeDetails.js\";\nimport { getRegistration as getRegistrationMethod } from \"./client/getRegistration.js\";\nimport { listNotificationHubJobs as listNotificationHubJobsMethod } from \"./client/listNotificationHubJobs.js\";\nimport { listRegistrationsByTag as listRegistrationsByTagMethod } from \"./client/listRegistrationsByTag.js\";\nimport { listRegistrations as listRegistrationsMethod } from \"./client/listRegistrations.js\";\nimport { scheduleBroadcastNotification as scheduleBroadcastNotificationMethod } from \"./client/scheduleBroadcastNotification.js\";\nimport { scheduleNotification as scheduleNotificationMethod } from \"./client/scheduleNotification.js\";\nimport { sendBroadcastNotification as sendBroadcastNotificationMethod } from \"./client/sendBroadcastNotification.js\";\nimport { sendDirectNotification as sendDirectNotificationMethod } from \"./client/sendDirectNotification.js\";\nimport { sendNotification as sendNotificationMethod } from \"./client/sendNotification.js\";\nimport { submitNotificationHubJob as submitNotificationHubJobMethod } from \"./client/submitNotificationHubJob.js\";\nimport { updateInstallation as updateInstallationMethod } from \"./client/updateInstallation.js\";\nimport { updateRegistration as updateRegistrationMethod } from \"./client/updateRegistration.js\";\n\n/**\n * This represents a client for Azure Notification Hubs to manage installations and send\n * messages to devices.\n */\nexport class NotificationHubsServiceClient {\n private _client: NotificationHubsClientContext;\n\n /**\n * Creates a new instance of the NotificationClient with a connection string, hub name and options.\n * @param connectionString - The Notification Hub Access Policy connection string.\n * @param hubName - The name of the Azure Notification Hub.\n * @param options - Options for configuring the Azure Notification Hubs client.\n */\n constructor(\n connectionString: string,\n hubName: string,\n options: NotificationHubsClientOptions = {}\n ) {\n this._client = createClientContext(connectionString, hubName, options);\n }\n\n /**\n * Creates or overwrites an installation to a Notification Hub.\n * @param installation - The installation to create or overwrite.\n * @param options - Configuration options for the create or update installation operation.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n createOrUpdateInstallation(\n installation: Installation,\n options: OperationOptions = {}\n ): Promise<NotificationHubsResponse> {\n return createOrUpdateInstallationMethod(this._client, installation, options);\n }\n\n /**\n * Deletes an installation from a Notification Hub.\n * @param installationId - The installation ID of the installation to delete.\n * @param options - Configuration options for the installation delete operation.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n deleteInstallation(\n installationId: string,\n options: OperationOptions = {}\n ): Promise<NotificationHubsResponse> {\n return deleteInstallationMethod(this._client, installationId, options);\n }\n\n /**\n * Gets an Azure Notification Hub installation by the installation ID.\n * @param installationId - The ID of the installation to get.\n * @param options - Configuration options for the get installation operation.\n * @returns The installation that matches the installation ID.\n */\n getInstallation(installationId: string, options: OperationOptions = {}): Promise<Installation> {\n return getInstallationMethod(this._client, installationId, options);\n }\n\n /**\n * Updates an installation using the JSON-Patch standard in RFC6902.\n * @param installationId - The ID of the installation to update.\n * @param patches - An array of patches following the JSON-Patch standard.\n * @param options - Configuration options for the patch installation operation.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n updateInstallation(\n installationId: string,\n patches: JsonPatch[],\n options: OperationOptions = {}\n ): Promise<NotificationHubsResponse> {\n return updateInstallationMethod(this._client, installationId, patches, options);\n }\n\n /**\n * Creates a new registration ID.\n * @param options - The options for creating a new registration ID.\n * @returns The newly created registration ID.\n */\n createRegistrationId(options: OperationOptions = {}): Promise<string> {\n return createRegistrationIdMethod(this._client, options);\n }\n\n /**\n * Creates a new registration. This method generates a registration ID,\n * which you can subsequently use to retrieve, update, and delete this registration.\n * @param registration - The registration to create.\n * @param options - Options for creating a new registration.\n * @returns The newly created registration description.\n */\n createRegistration(\n registration: RegistrationDescription,\n options: OperationOptions = {}\n ): Promise<RegistrationDescription> {\n return createRegistrationMethod(this._client, registration, options);\n }\n\n /**\n * Creates or updates a registration.\n * @param registration - The registration to create or update.\n * @param options - The operation options.\n * @returns The created or updated registration description.\n */\n createOrUpdateRegistration(\n registration: RegistrationDescription,\n options: OperationOptions = {}\n ): Promise<RegistrationDescription> {\n return createOrUpdateRegistrationMethod(this._client, registration, options);\n }\n\n /**\n * Updates an existing registration.\n * @param registration - The registration to update.\n * @param options - The operation options.\n * @returns The updated registration description.\n */\n updateRegistration(\n registration: RegistrationDescription,\n options: OperationOptions = {}\n ): Promise<RegistrationDescription> {\n return updateRegistrationMethod(this._client, registration, options);\n }\n\n /**\n * Gets a registration by the given registration ID.\n * @param registrationId - The ID of the registration to get.\n * @param options - The options for getting a registration by ID.\n * @returns A RegistrationDescription that has the given registration ID.\n */\n getRegistration(\n registrationId: string,\n options: OperationOptions = {}\n ): Promise<RegistrationDescription> {\n return getRegistrationMethod(this._client, registrationId, options);\n }\n\n /**\n * Gets all registrations for the notification hub with the given query options.\n * @param options - The options for querying the registrations such as $top and $filter.\n * @returns A paged async iterable containing all of the registrations for the notification hub.\n */\n listRegistrations(\n options: RegistrationQueryOptions = {}\n ): PagedAsyncIterableIterator<RegistrationDescription> {\n return listRegistrationsMethod(this._client, options);\n }\n\n /**\n * Lists all registrations with the matching tag.\n * @param tag - The tag to query for matching registrations.\n * @param options - The query options such as $top.\n * @returns A paged async iterable containing the matching registrations for the notification hub.\n */\n listRegistrationsByTag(\n tag: string,\n options: RegistrationQueryLimitOptions = {}\n ): PagedAsyncIterableIterator<RegistrationDescription> {\n return listRegistrationsByTagMethod(this._client, tag, options);\n }\n\n /**\n * Sends a direct push notification to a device with the given push handle.\n * @param pushHandle - The push handle which is the unique identifier for the device.\n * @param notification - The notification to send to the device.\n * @param options - The options for sending a direct notification.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n sendDirectNotification(\n pushHandle: PushHandle,\n notification: Notification,\n options: OperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return sendDirectNotificationMethod(this._client, pushHandle, notification, options);\n }\n\n /**\n * Sends push notifications to devices that match the given tags or tag expression.\n * @param tags - The tags used to target the device for push notifications in either an array or tag expression.\n * @param notification - The notification to send to the matching devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n sendNotification(\n tags: string[] | string,\n notification: Notification,\n options: SendOperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return sendNotificationMethod(this._client, tags, notification, options);\n }\n\n /**\n * Sends push notifications to all devices on the Notification Hub.\n * @param notification - The notification to send to all devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n sendBroadcastNotification(\n notification: Notification,\n options: SendOperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return sendBroadcastNotificationMethod(this._client, notification, options);\n }\n\n /**\n * Schedules a push notification to devices that match the given tags or tag expression at the specified time.\n * NOTE: This is only available in Standard SKU Azure Notification Hubs.\n * @param scheduledTime - The Date to send the push notification.\n * @param tags - The tags used to target the device for push notifications in either an array or tag expression.\n * @param notification - The notification to send to the matching devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n scheduleNotification(\n scheduledTime: Date,\n tags: string[] | string,\n notification: Notification,\n options: OperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return scheduleNotificationMethod(this._client, scheduledTime, tags, notification, options);\n }\n\n /**\n * Schedules a push notification to all devices registered on the Notification Hub.\n * NOTE: This is only available in Standard SKU Azure Notification Hubs.\n * @param scheduledTime - The Date to send the push notification.\n * @param notification - The notification to send to the matching devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\n scheduleBroadcastNotification(\n scheduledTime: Date,\n notification: Notification,\n options: OperationOptions = {}\n ): Promise<NotificationHubsMessageResponse> {\n return scheduleBroadcastNotificationMethod(this._client, scheduledTime, notification, options);\n }\n\n /**\n * Cancels the scheduled notification with the given notification ID.\n * @param notificationId - The notification ID from the scheduled notification.\n * @param options - The operation options.\n * @returns A notification hub response with correlation ID and tracking ID.\n */\n cancelScheduledNotification(\n notificationId: string,\n options: OperationOptions = {}\n ): Promise<NotificationHubsResponse> {\n return cancelScheduledNotificationMethod(this._client, notificationId, options);\n }\n\n /**\n * Retrieves an Azure Storage container URL. The container has feedback data for the notification hub.\n * The caller can then use the Azure Storage Services SDK to retrieve the contents of the container.\n * @param options - The options for getting the push notification feedback container URL.\n * @returns The URL of the Azure Storage Container containing the feedback data.\n */\n getFeedbackContainerUrl(options: OperationOptions = {}): Promise<string> {\n return getFeedbackContainerUrlMethod(this._client, options);\n }\n\n /**\n * Retrieves the results of a send operation. This can retrieve intermediate results if the send is being processed\n * or final results if the Send* has completed. This API can only be called for Standard SKU and above.\n * @param notificationId - The notification ID returned from the send operation.\n * @param options - The operation options.\n * @returns The results of the send operation.\n */\n getNotificationOutcomeDetails(\n notificationId: string,\n options: OperationOptions = {}\n ): Promise<NotificationDetails> {\n return getNotificationOutcomeDetailsMethod(this._client, notificationId, options);\n }\n\n /**\n * Gets a Notification Hub Job by the ID.\n * @param jobId - The Notification Hub Job ID.\n * @param options - The operation options.\n * @returns The Notification Hub Job with the matching ID.\n */\n getNotificationHubJob(\n jobId: string,\n options: OperationOptions = {}\n ): Promise<NotificationHubJob> {\n return getNotificationHubJobMethod(this._client, jobId, options);\n }\n\n /**\n * Submits a Notification Hub Job. Note this is available to Standard SKU namespace and above.\n * @param job - The notification hub job to submit.\n * @param options - The operation options.\n * @returns The notification hub job details including job ID and status.\n */\n submitNotificationHubJob(\n job: NotificationHubJob,\n options: OperationOptions = {}\n ): Promise<NotificationHubJob> {\n return submitNotificationHubJobMethod(this._client, job, options);\n }\n\n /**\n * Gets all Notification Hub Jobs for this Notification Hub.\n * @param options - The operation options.\n * @returns An array of all Notification Hub Jobs for this Notification Hub.\n */\n listNotificationHubJobs(options: OperationOptions = {}): Promise<NotificationHubJob[]> {\n return listNotificationHubJobsMethod(this._client, options);\n }\n}\n"]}
@@ -36,6 +36,9 @@ export async function parseNotificationHubJobEntry(bodyText) {
36
36
  export async function parseNotificationHubJobFeed(bodyText) {
37
37
  const xml = await parseXML(bodyText, { includeRoot: true });
38
38
  const results = [];
39
+ if (!isDefined(xml.feed.entry)) {
40
+ return results;
41
+ }
39
42
  for (const item of xml.feed.entry) {
40
43
  results.push(createNotificationHubJob(item.content.NotificationHubJob));
41
44
  }
@@ -1 +1 @@
1
- {"version":3,"file":"notificationHubJobSerializer.js","sourceRoot":"","sources":["../../../src/serializers/notificationHubJobSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,oBAAoB,EACpB,SAAS,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM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AAC,CAAC;QACnD,eAAe;QACf,gBAAgB;KACjB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n NotificationHubJob,\n NotificationHubJobStatus,\n NotificationHubJobType,\n} from \"../models/notificationHubJob.js\";\nimport {\n getDateOrUndefined,\n getFloatOrUndefined,\n getString,\n getStringOrUndefined,\n isDefined,\n} from \"../utils/utils.js\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\nimport { serializeToAtomXmlRequest } from \"../utils/xmlUtils.js\";\n\n/**\n * @internal\n * Serializes a NotificationHubJob into an Atom XML entry.\n * @param entry - The NotificationHubJob to turn into an Atom XML entry.\n * @returns An Atom XML entry containing the notification hub job.\n */\nexport function serializeNotificationHubJobEntry(entry: NotificationHubJob): string {\n const job: Record<string, any> = {\n Type: entry.type,\n OutputContainerUri: { __cdata: entry.outputContainerUrl },\n ImportFileUri: isDefined(entry.importFileUrl) ? { __cdata: entry.importFileUrl } : undefined,\n };\n\n const requestObject = serializeToAtomXmlRequest(\"NotificationHubJob\", job);\n\n return stringifyXML(requestObject, { rootName: \"entry\", cdataPropName: \"__cdata\" });\n}\n\n/**\n * Parses an Atom XML of an notification hub job entry.\n * @param bodyText - The incoming Atom XML entry to parse into a notification hub job.\n * @returns A parsed NotificationHubJob.\n */\nexport async function parseNotificationHubJobEntry(bodyText: string): Promise<NotificationHubJob> {\n const xml = await parseXML(bodyText, { includeRoot: true });\n const content = xml.entry.content.NotificationHubJob;\n return createNotificationHubJob(content);\n}\n\n/**\n * Parses an Atom XML feed of notification hub jobs.\n * @param bodyText - The incoming Atom XML feed to parse into notification hub jobs.\n * @returns A list of notification hub jobs.\n */\nexport async function parseNotificationHubJobFeed(bodyText: string): Promise<NotificationHubJob[]> {\n const xml = await parseXML(bodyText, { includeRoot: true });\n const results = [];\n for (const item of xml.feed.entry) {\n results.push(createNotificationHubJob(item.content.NotificationHubJob));\n }\n\n return results;\n}\n\nfunction createInputOutputProperties(content: Record<string, any>): Record<string, string> {\n const props: Record<string, string> = {};\n for (const item of content[\"d3p1:KeyValueOfstringstring\"]) {\n props[item[\"d3p1:Key\"]] = item[\"d3p1:Value\"];\n }\n\n return props;\n}\n\nfunction createNotificationHubJob(content: Record<string, any>): NotificationHubJob {\n let outputProperties: Record<string, string> | undefined;\n if (isDefined(content[\"OutputProperties\"])) {\n outputProperties = createInputOutputProperties(content[\"OutputProperties\"]);\n }\n\n let inputProperties: Record<string, string> | undefined;\n if (isDefined(content[\"InputProperties\"])) {\n inputProperties = createInputOutputProperties(content[\"InputProperties\"]);\n }\n\n return {\n jobId: getStringOrUndefined(content[\"JobId\"]),\n type: getString(content[\"Type\"], \"type\") as NotificationHubJobType,\n status: getStringOrUndefined(content[\"Status\"]) as NotificationHubJobStatus,\n progress: getFloatOrUndefined(content[\"Progress\"]),\n outputContainerUrl: getString(content[\"OutputContainerUri\"], \"outputContainerUrl\"),\n importFileUrl: getStringOrUndefined(content[\"ImportFileUri\"]),\n failure: getStringOrUndefined(content[\"Failure\"]),\n createdAt: getDateOrUndefined(content[\"CreatedAt\"]),\n updatedAt: getDateOrUndefined(content[\"UpdatedAt\"]),\n inputProperties,\n outputProperties,\n };\n}\n"]}
1
+ {"version":3,"file":"notificationHubJobSerializer.js","sourceRoot":"","sources":["../../../src/serializers/notificationHubJobSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,oBAAoB,EACpB,SAAS,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,UAAU,gCAAgC,CAAC,KAAyB;IACxE,MAAM,GAAG,GAAwB;QAC/B,IAAI,EAAE,KAAK,CAAC,IAAI;QACh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B;KACjB,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n NotificationHubJob,\n NotificationHubJobStatus,\n NotificationHubJobType,\n} from \"../models/notificationHubJob.js\";\nimport {\n getDateOrUndefined,\n getFloatOrUndefined,\n getString,\n getStringOrUndefined,\n isDefined,\n} from \"../utils/utils.js\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\nimport { serializeToAtomXmlRequest } from \"../utils/xmlUtils.js\";\n\n/**\n * @internal\n * Serializes a NotificationHubJob into an Atom XML entry.\n * @param entry - The NotificationHubJob to turn into an Atom XML entry.\n * @returns An Atom XML entry containing the notification hub job.\n */\nexport function serializeNotificationHubJobEntry(entry: NotificationHubJob): string {\n const job: Record<string, any> = {\n Type: entry.type,\n OutputContainerUri: { __cdata: entry.outputContainerUrl },\n ImportFileUri: isDefined(entry.importFileUrl) ? { __cdata: entry.importFileUrl } : undefined,\n };\n\n const requestObject = serializeToAtomXmlRequest(\"NotificationHubJob\", job);\n\n return stringifyXML(requestObject, { rootName: \"entry\", cdataPropName: \"__cdata\" });\n}\n\n/**\n * Parses an Atom XML of an notification hub job entry.\n * @param bodyText - The incoming Atom XML entry to parse into a notification hub job.\n * @returns A parsed NotificationHubJob.\n */\nexport async function parseNotificationHubJobEntry(bodyText: string): Promise<NotificationHubJob> {\n const xml = await parseXML(bodyText, { includeRoot: true });\n const content = xml.entry.content.NotificationHubJob;\n return createNotificationHubJob(content);\n}\n\n/**\n * Parses an Atom XML feed of notification hub jobs.\n * @param bodyText - The incoming Atom XML feed to parse into notification hub jobs.\n * @returns A list of notification hub jobs.\n */\nexport async function parseNotificationHubJobFeed(bodyText: string): Promise<NotificationHubJob[]> {\n const xml = await parseXML(bodyText, { includeRoot: true });\n const results: NotificationHubJob[] = [];\n\n if (!isDefined(xml.feed.entry)) {\n return results;\n }\n\n for (const item of xml.feed.entry) {\n results.push(createNotificationHubJob(item.content.NotificationHubJob));\n }\n\n return results;\n}\n\nfunction createInputOutputProperties(content: Record<string, any>): Record<string, string> {\n const props: Record<string, string> = {};\n for (const item of content[\"d3p1:KeyValueOfstringstring\"]) {\n props[item[\"d3p1:Key\"]] = item[\"d3p1:Value\"];\n }\n\n return props;\n}\n\nfunction createNotificationHubJob(content: Record<string, any>): NotificationHubJob {\n let outputProperties: Record<string, string> | undefined;\n if (isDefined(content[\"OutputProperties\"])) {\n outputProperties = createInputOutputProperties(content[\"OutputProperties\"]);\n }\n\n let inputProperties: Record<string, string> | undefined;\n if (isDefined(content[\"InputProperties\"])) {\n inputProperties = createInputOutputProperties(content[\"InputProperties\"]);\n }\n\n return {\n jobId: getStringOrUndefined(content[\"JobId\"]),\n type: getString(content[\"Type\"], \"type\") as NotificationHubJobType,\n status: getStringOrUndefined(content[\"Status\"]) as NotificationHubJobStatus,\n progress: getFloatOrUndefined(content[\"Progress\"]),\n outputContainerUrl: getString(content[\"OutputContainerUri\"], \"outputContainerUrl\"),\n importFileUrl: getStringOrUndefined(content[\"ImportFileUri\"]),\n failure: getStringOrUndefined(content[\"Failure\"]),\n createdAt: getDateOrUndefined(content[\"CreatedAt\"]),\n updatedAt: getDateOrUndefined(content[\"UpdatedAt\"]),\n inputProperties,\n outputProperties,\n };\n}\n"]}
@@ -0,0 +1,31 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT license.
3
+ import { getInteger, getString, isDefined } from "../utils/utils.js";
4
+ import { parseXML } from "@azure/core-xml";
5
+ export async function parseNotificationOutcome(bodyText) {
6
+ const xml = await parseXML(bodyText, { includeRoot: true });
7
+ const outcome = xml.NotificationOutcome;
8
+ return {
9
+ success: getInteger(outcome.Success, "Success"),
10
+ failure: getInteger(outcome.Failure, "Failure"),
11
+ results: parseRegistrationResults(outcome.Results.RegistrationResult),
12
+ state: "DetailedStateAvailable",
13
+ };
14
+ }
15
+ function parseRegistrationResults(results) {
16
+ const registrationResults = [];
17
+ if (!isDefined(results)) {
18
+ return registrationResults;
19
+ }
20
+ const resultsArray = Array.isArray(results) ? results : [results];
21
+ for (const result of resultsArray) {
22
+ registrationResults.push({
23
+ applicationPlatform: getString(result.ApplicationPlatform, "ApplicationPlatform"),
24
+ registrationId: getString(result.RegistrationId, "RegistrationId"),
25
+ outcome: getString(result.Outcome, "Outcome"),
26
+ pnsHandle: getString(result.PnsHandle, "PnsHandle"),
27
+ });
28
+ }
29
+ return registrationResults;
30
+ }
31
+ //# sourceMappingURL=notificationOutcomeSerializer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"notificationOutcomeSerializer.js","sourceRoot":"","sources":["../../../src/serializers/notificationOutcomeSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,CAAC,KAAK,UAAU,wBAAwB,CAC5C,QAAgB;IAEhB,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,GAAG,CAAC,mBAAmB,CAAC;IAExC,OAAO;QACL,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC;QAC/C,OAAO,EAAE,UAAU,CAAC,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC;QAC/C,OAAO,EAAE,wBAAwB,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC;QACrE,KAAK,EAAE,wBAAwB;KAChC,CAAC;AACJ,CAAC;AAED,SAAS,wBAAwB,CAAC,OAA6B;IAC7D,MAAM,mBAAmB,GAAyB,EAAE,CAAC;IAErD,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QACvB,OAAO,mBAAmB,CAAC;KAC5B;IAED,MAAM,YAAY,GAAG,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAElE,KAAK,MAAM,MAAM,IAAI,YAAY,EAAE;QACjC,mBAAmB,CAAC,IAAI,CAAC;YACvB,mBAAmB,EAAE,SAAS,CAAC,MAAM,CAAC,mBAAmB,EAAE,qBAAqB,CAAC;YACjF,cAAc,EAAE,SAAS,CAAC,MAAM,CAAC,cAAc,EAAE,gBAAgB,CAAC;YAClE,OAAO,EAAE,SAAS,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC;YAC7C,SAAS,EAAE,SAAS,CAAC,MAAM,CAAC,SAAS,EAAE,WAAW,CAAC;SACpD,CAAC,CAAC;KACJ;IAED,OAAO,mBAAmB,CAAC;AAC7B,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n NotificationHubsMessageResponse,\n RegistrationResult,\n} from \"../models/notificationDetails.js\";\nimport { getInteger, getString, isDefined } from \"../utils/utils.js\";\nimport { parseXML } from \"@azure/core-xml\";\n\nexport async function parseNotificationOutcome(\n bodyText: string\n): Promise<NotificationHubsMessageResponse> {\n const xml = await parseXML(bodyText, { includeRoot: true });\n const outcome = xml.NotificationOutcome;\n\n return {\n success: getInteger(outcome.Success, \"Success\"),\n failure: getInteger(outcome.Failure, \"Failure\"),\n results: parseRegistrationResults(outcome.Results.RegistrationResult),\n state: \"DetailedStateAvailable\",\n };\n}\n\nfunction parseRegistrationResults(results?: Record<string, any>): RegistrationResult[] {\n const registrationResults: RegistrationResult[] = [];\n\n if (!isDefined(results)) {\n return registrationResults;\n }\n\n const resultsArray = Array.isArray(results) ? results : [results];\n\n for (const result of resultsArray) {\n registrationResults.push({\n applicationPlatform: getString(result.ApplicationPlatform, \"ApplicationPlatform\"),\n registrationId: getString(result.RegistrationId, \"RegistrationId\"),\n outcome: getString(result.Outcome, \"Outcome\"),\n pnsHandle: getString(result.PnsHandle, \"PnsHandle\"),\n });\n }\n\n return registrationResults;\n}\n"]}
@@ -27,6 +27,9 @@ export const registrationDescriptionParser = {
27
27
  async parseRegistrationFeed(bodyText) {
28
28
  const xml = await parseXML(bodyText, { includeRoot: true });
29
29
  const results = [];
30
+ if (!isDefined(xml.feed.entry)) {
31
+ return results;
32
+ }
30
33
  for (const entry of xml.feed.entry) {
31
34
  delete entry.content["$"];
32
35
  const keyName = Object.keys(entry.content)[0];
@@ -111,20 +114,6 @@ export const registrationDescriptionParser = {
111
114
  createGcmTemplateRegistrationDescription(rawRegistrationDescription) {
112
115
  return Object.assign(Object.assign(Object.assign({}, this.createGcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "GcmTemplate" });
113
116
  },
114
- /**
115
- * @internal
116
- * Creates an FCM registration description from incoming XML property bag.
117
- */
118
- createFcmRegistrationDescription(rawRegistrationDescription) {
119
- return Object.assign(Object.assign({ fcmRegistrationId: getString(rawRegistrationDescription["FcmRegistrationId"], "fcmRegistrationId") }, createRegistrationDescription(rawRegistrationDescription)), { type: "Fcm" });
120
- },
121
- /**
122
- * @internal
123
- * Creates an FCM template registration description from incoming XML property bag.
124
- */
125
- createFcmTemplateRegistrationDescription(rawRegistrationDescription) {
126
- return Object.assign(Object.assign(Object.assign({}, this.createFcmRegistrationDescription(rawRegistrationDescription)), createTemplateRegistrationDescription(rawRegistrationDescription)), { type: "FcmTemplate" });
127
- },
128
117
  /**
129
118
  * @internal
130
119
  * Creates a Windows Phone registration description from incoming XML property bag.
@@ -282,20 +271,6 @@ export const registrationDescriptionSerializer = {
282
271
  serializeGcmTemplateRegistrationDescription(description) {
283
272
  return Object.assign(Object.assign({}, this.serializeGcmRegistrationDescription(description)), serializeTemplateRegistrationDescription(description));
284
273
  },
285
- /**
286
- * @internal
287
- * Serializes an existing FCM registration description to an object for serialization.
288
- */
289
- serializeFcmRegistrationDescription(description) {
290
- return Object.assign(Object.assign({}, serializeRegistrationDescription(description)), { FcmRegistrationId: description.fcmRegistrationId });
291
- },
292
- /**
293
- * @internal
294
- * Serializes an existing FCM template registration description to an object for serialization.
295
- */
296
- serializeFcmTemplateRegistrationDescription(description) {
297
- return Object.assign(Object.assign({}, this.serializeFcmRegistrationDescription(description)), serializeTemplateRegistrationDescription(description));
298
- },
299
274
  /**
300
275
  * @internal
301
276
  * @deprecated Windows Phone is no longer supported.
@@ -1 +1 @@
1
- {"version":3,"file":"registrationSerializer.js","sourceRoot":"","sources":["../../../src/serializers/registrationSerializer.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAwBlC,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,oBAAoB,EACpB,kBAAkB,EAClB,SAAS,GACV,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAkIjE,MAAM,CAAC,MAAM,6BAA6B,GAAkC;IAC1E;;;OAGG;IACH,KAAK,CAAC,sBAAsB,CAAC,QAAgB;QAC3C,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,MAAM,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;QAClD,MAAM,OAAO,GAAG,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;QAC3C,MAAM,UAAU,GAAG,SAAS,OAAO,EAAE,CAAC;QAEtC,MAAM,MAAM,GAAG,IAAI,CAAC,UAAiD,CAAQ,CAAC;QAC9E,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,SAAS,CAAC,GAAG,OAAO,uCAAuC,EAAE,EAAE,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,WAAW,CAAC,UAAU,CAAC,MAAM,CAAC;iBACtC,CAAC,CAAC;aACJ;SACF;QAED,qDACK,IAAI,CAAC,uCAAuC,CAAC,WAAW,CAAC,GACzD,wCAAwC,CAAC,WAAW,CAAC,KACxD,UAAU,EAAE,UAAU,IACtB;IACJ,CAAC;CACF,CAAC;AAEF,SAAS,gCAAgC,CACvC,WAAwD;IAExD,IAAI,IAAwB,CAAC;IAC7B,IAAI,WAAW,CAAC,IAAI,EAAE;QACpB,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;KACnC;IAED,IAAI,aAAiC,CAAC;IACtC,IAAI,WAAW,CAAC,aAAa,EAAE;QAC7B,aAAa,GAAG,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC;KAC3D;IAED,OAAO;QACL,cAAc,EAAE,oBAAoB,CAAC,WAAW,CAAC,cAAc,CAAC;QAChE,IAAI,EAAE,IAAI;QACV,aAAa,EAAE,aAAa;KAC7B,CAAC;AACJ,CAAC;AAED,SAAS,wCAAwC,CAC/C,WAA4C;IAE5C,OAAO;QACL,YAAY,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,YAAY,EAAE;QACnD,YAAY,EAAE,oBAAoB,CAAC,WAAW,CAAC,YAAY,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n AdmRegistrationDescription,\n AdmTemplateRegistrationDescription,\n ApplePriority,\n AppleRegistrationDescription,\n AppleTemplateRegistrationDescription,\n BaiduRegistrationDescription,\n BaiduTemplateRegistrationDescription,\n BrowserRegistrationDescription,\n BrowserTemplateRegistrationDescription,\n FcmRegistrationDescription,\n FcmTemplateRegistrationDescription,\n GcmRegistrationDescription,\n GcmTemplateRegistrationDescription,\n MpnsRegistrationDescription,\n MpnsTemplateRegistrationDescription,\n RegistrationDescription,\n RegistrationDescriptionCommon,\n TemplateRegistrationDescription,\n WindowsRegistrationDescription,\n WindowsTemplateRegistrationDescription,\n} from \"../models/registration.js\";\nimport {\n getDateOrUndefined,\n getString,\n getStringOrUndefined,\n getTagsOrUndefined,\n isDefined,\n} from \"../utils/utils.js\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { serializeToAtomXmlRequest } from \"../utils/xmlUtils.js\";\n\n/**\n * Represents a registration description parser from the incoming XML.\n */\nexport interface RegistrationDescriptionParser {\n /**\n * @internal\n * Creates a registration type from the incoming entry.\n */\n parseRegistrationEntry: (bodyText: string) => Promise<RegistrationDescription>;\n /**\n * @internal\n * Creates a list of registrations from an incoming ATOM XML Feed.\n */\n parseRegistrationFeed: (bodyText: string) => Promise<RegistrationDescription[]>;\n /**\n * @internal\n * Creates an Amazon Device Messaging (ADM) registration description from the incoming parsed XML.\n */\n createAdmRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => AdmRegistrationDescription;\n /**\n * @internal\n * Creates an Amazon Device Messaging (ADM) template registration description from the incoming parsed XML.\n */\n createAdmTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => AdmTemplateRegistrationDescription;\n /**\n * @internal\n * Creates an Apple Platform Notification Services (APNs) registration description from the incoming parsed XML.\n */\n createAppleRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => AppleRegistrationDescription;\n /**\n * @internal\n * Creates an Apple Platform Notification Services (APNs) template registration description from the incoming parsed XML.\n */\n createAppleTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => AppleTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Baidu registration description from the incoming parsed XML.\n */\n createBaiduRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => BaiduRegistrationDescription;\n /**\n * @internal\n * Creates a Baidu template registration description from the incoming parsed XML.\n */\n createBaiduTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => BaiduTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Web Push registration description from the incoming parsed XML.\n */\n createBrowserRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => BrowserRegistrationDescription;\n /**\n * @internal\n * Creates a Web Push template registration description from the incoming parsed XML.\n */\n createBrowserTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => BrowserTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Google Cloud Messaging (GCM) registration description from the incoming parsed XML.\n */\n createGcmRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => GcmRegistrationDescription;\n /**\n * @internal\n * Creates a Google Cloud Messaging (GCM) template registration description from the incoming parsed XML.\n */\n createGcmTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => GcmTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Firebase Cloud Messaging (GCM) registration description from the incoming parsed XML.\n */\n createFcmRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => FcmRegistrationDescription;\n /**\n * @internal\n * Creates a Firebase Cloud Messaging (GCM) template registration description from the incoming parsed XML.\n */\n createFcmTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => FcmTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Microsoft Phone Notification Services (MPNS) registration description from the incoming parsed XML.\n */\n createMpnsRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => MpnsRegistrationDescription;\n /**\n * @internal\n * Creates a Microsoft Phone Notification Services (MPNS) template registration description from the incoming parsed XML.\n */\n createMpnsTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => MpnsTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Windows Notification Services (WNS) registration description from the incoming parsed XML.\n */\n createWindowsRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => WindowsRegistrationDescription;\n /**\n * @internal\n * Creates a Windows Notification Services (WNS) template registration description from the incoming parsed XML.\n */\n createWindowsTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => WindowsTemplateRegistrationDescription;\n}\n\nexport const registrationDescriptionParser: RegistrationDescriptionParser = {\n /**\n * @internal\n * Creates a registration type from the incoming entry.\n */\n async parseRegistrationEntry(bodyText: string): Promise<RegistrationDescription> {\n const xml = await parseXML(bodyText, { includeRoot: true });\n const keyName = Object.keys(xml.entry.content)[0];\n const content = xml.entry.content[keyName];\n const methodName = `create${keyName}`;\n\n const method = this[methodName as keyof RegistrationDescriptionParser] as any;\n if (!methodName) {\n throw new RestError(`${keyName} is not a supported registration type`, { statusCode: 500 });\n }\n\n return method.call(this, content) as RegistrationDescription;\n },\n\n /**\n * @internal\n * Creates a list of registrations from an incoming ATOM XML Feed.\n */\n async parseRegistrationFeed(bodyText: string): Promise<RegistrationDescription[]> {\n const xml = await parseXML(bodyText, { includeRoot: true });\n const results = [];\n for (const entry of xml.feed.entry) {\n delete entry.content[\"$\"];\n\n const keyName = Object.keys(entry.content)[0];\n const methodName = `create${keyName}`;\n const content = entry.content[keyName];\n const method = this[methodName as keyof RegistrationDescriptionParser] as any;\n if (!methodName) {\n throw new RestError(`${keyName} is not a supported registration type`, { statusCode: 500 });\n }\n\n results.push(method.call(this, content) as RegistrationDescription);\n }\n\n return results;\n },\n\n /**\n * @internal\n * Creates an ADM registration description from incoming XML property bag.\n */\n createAdmRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): AdmRegistrationDescription {\n return {\n admRegistrationId: getString(\n rawRegistrationDescription[\"AdmRegistrationId\"],\n \"admRegistrationId\"\n ),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Adm\",\n };\n },\n\n /**\n * @internal\n * Creates an ADM template registration description from incoming XML property bag.\n */\n createAdmTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): AdmTemplateRegistrationDescription {\n return {\n ...this.createAdmRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"AdmTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates an Apple registration description from incoming XML property bag.\n */\n createAppleRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): AppleRegistrationDescription {\n return {\n deviceToken: getString(rawRegistrationDescription[\"DeviceToken\"], \"deviceToken\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Apple\",\n };\n },\n\n /**\n * @internal\n * Creates an Apple template registration description from incoming XML property bag.\n */\n createAppleTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): AppleTemplateRegistrationDescription {\n return {\n priority: getStringOrUndefined(rawRegistrationDescription[\"Priority\"]) as ApplePriority,\n apnsHeaders: getHeadersOrUndefined(rawRegistrationDescription[\"ApnsHeaders\"]?.[\"ApnsHeader\"]),\n ...this.createAppleRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"AppleTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates a Baidu registration description from incoming XML property bag.\n */\n createBaiduRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): BaiduRegistrationDescription {\n return {\n baiduChannelId: getString(rawRegistrationDescription[\"BaiduChannelId\"], \"baiduChannelId\"),\n baiduUserId: getString(rawRegistrationDescription[\"BaiduUserId\"], \"baiduUserId\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Baidu\",\n };\n },\n\n /**\n * @internal\n * Creates a Baidu template registration description from incoming XML property bag.\n */\n createBaiduTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): BaiduTemplateRegistrationDescription {\n return {\n ...this.createBaiduRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"BaiduTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates a Browser registration description from incoming XML property bag.\n */\n createBrowserRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): BrowserRegistrationDescription {\n return {\n endpoint: getString(rawRegistrationDescription[\"Endpoint\"], \"endpoint\"),\n p256dh: getString(rawRegistrationDescription[\"P256DH\"], \"p256dh\"),\n auth: getString(rawRegistrationDescription[\"Auth\"], \"auth\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Browser\",\n };\n },\n\n /**\n * @internal\n * Creates a Browser template registration description from incoming XML property bag.\n */\n createBrowserTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): BrowserTemplateRegistrationDescription {\n return {\n ...this.createBrowserRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"BrowserTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates an GCM registration description from incoming XML property bag.\n */\n createGcmRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): GcmRegistrationDescription {\n return {\n gcmRegistrationId: getString(\n rawRegistrationDescription[\"GcmRegistrationId\"],\n \"gcmRegistrationId\"\n ),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Gcm\",\n };\n },\n\n /**\n * @internal\n * Creates an FCM template registration description from incoming XML property bag.\n */\n createGcmTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): GcmTemplateRegistrationDescription {\n return {\n ...this.createGcmRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"GcmTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates an FCM registration description from incoming XML property bag.\n */\n createFcmRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): FcmRegistrationDescription {\n return {\n fcmRegistrationId: getString(\n rawRegistrationDescription[\"FcmRegistrationId\"],\n \"fcmRegistrationId\"\n ),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Fcm\",\n };\n },\n\n /**\n * @internal\n * Creates an FCM template registration description from incoming XML property bag.\n */\n createFcmTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): FcmTemplateRegistrationDescription {\n return {\n ...this.createFcmRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"FcmTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates a Windows Phone registration description from incoming XML property bag.\n */\n createMpnsRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): MpnsRegistrationDescription {\n return {\n channelUri: getString(rawRegistrationDescription[\"ChannelUri\"], \"channelUri\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Mpns\",\n };\n },\n\n /**\n * @internal\n * Creates a Windows Phone template registration description from incoming XML property bag.\n */\n createMpnsTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): MpnsTemplateRegistrationDescription {\n return {\n mpnsHeaders: getHeadersOrUndefined(rawRegistrationDescription[\"MpnsHeaders\"]?.[\"MpnsHeader\"]),\n ...this.createWindowsRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"MpnsTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates a Windows registration description from incoming XML property bag.\n */\n createWindowsRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): WindowsRegistrationDescription {\n return {\n channelUri: getString(rawRegistrationDescription[\"ChannelUri\"], \"channelUri\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Windows\",\n };\n },\n\n /**\n * @internal\n * Creates a Windows template registration description from incoming XML property bag.\n */\n createWindowsTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): WindowsTemplateRegistrationDescription {\n return {\n wnsHeaders: getHeadersOrUndefined(rawRegistrationDescription[\"WnsHeaders\"]?.[\"WnsHeader\"]),\n ...this.createWindowsRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"WindowsTemplate\",\n };\n },\n};\n\nfunction getHeadersOrUndefined(\n value?: { Header: string; Value: string }[]\n): Record<string, string> | undefined {\n if (!isDefined(value)) {\n return undefined;\n }\n\n const headerObj: Record<string, string> = {};\n for (const { Header, Value } of value) {\n headerObj[Header] = Value;\n }\n\n return headerObj;\n}\n\nfunction createRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n): Omit<RegistrationDescriptionCommon, \"type\"> {\n let pushVariables: Record<string, string> | undefined;\n const unparsed = getStringOrUndefined(rawRegistrationDescription[\"PushVariables\"]);\n if (unparsed) {\n pushVariables = JSON.parse(unparsed) as Record<string, string>;\n }\n\n return {\n registrationId: getStringOrUndefined(rawRegistrationDescription[\"RegistrationId\"]),\n expirationTime: getDateOrUndefined(rawRegistrationDescription[\"ExpirationTime\"]),\n etag: getStringOrUndefined(rawRegistrationDescription[\"ETag\"]),\n tags: getTagsOrUndefined(rawRegistrationDescription[\"Tags\"]),\n pushVariables: pushVariables,\n };\n}\n\nfunction createTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n): TemplateRegistrationDescription {\n return {\n bodyTemplate: getString(rawRegistrationDescription[\"BodyTemplate\"], \"bodyTemplate\"),\n templateName: getStringOrUndefined(rawRegistrationDescription[\"TemplateName\"]),\n ...createRegistrationDescription(rawRegistrationDescription),\n };\n}\n\n/**\n * @internal\n * Represents a serializer for all registration descriptions.\n */\nexport interface RegistrationDescriptionSerializer {\n /**\n * @internal\n * Serializes a registration description into an ATOM XML string.\n */\n serializeRegistrationDescription(description: RegistrationDescription): string;\n /**\n * @internal\n * Serializes an Amazon Device Messaging (ADM) registration description into an XML object for serialization.\n */\n serializeAdmRegistrationDescription(\n description: Omit<AdmRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes an Amazon Device Messaging (ADM) template registration description into an XML object for serialization.\n */\n serializeAdmTemplateRegistrationDescription(\n description: Omit<AdmTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes an Apple registration description into an XML object for serialization.\n */\n serializeAppleRegistrationDescription(\n description: Omit<AppleRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes an Apple template registration description into an XML object for serialization.\n */\n serializeAppleTemplateRegistrationDescription(\n description: Omit<AppleRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Baidu registration description into an XML object for serialization.\n */\n serializeBaiduRegistrationDescription(\n description: Omit<BaiduRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Baidu template registration description into an XML object for serialization.\n */\n serializeBaiduTemplateRegistrationDescription(\n description: Omit<BaiduTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Web Push registration description into an XML object for serialization.\n */\n serializeBrowserRegistrationDescription(\n description: Omit<BrowserRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Web Push template registration description into an XML object for serialization.\n */\n serializeBrowserTemplateRegistrationDescription(\n description: Omit<BrowserTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Google Cloud Messaging (GCM) registration description into an XML object for serialization.\n */\n serializeGcmRegistrationDescription(\n description: Omit<GcmRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Google Cloud Messaging (GCM) template registration description into an XML object for serialization.\n */\n serializeGcmTemplateRegistrationDescription(\n description: Omit<GcmTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Firebase registration description into an XML object for serialization.\n */\n serializeFcmRegistrationDescription(\n description: Omit<FcmRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Firebase template registration description into an XML object for serialization.\n */\n serializeFcmTemplateRegistrationDescription(\n description: Omit<FcmRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Windows Phone registration description into an XML object for serialization.\n */\n serializeMpnsRegistrationDescription(\n description: Omit<MpnsRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Windows Phone template registration description into an XML object for serialization.\n */\n serializeMpnsTemplateRegistrationDescription(\n description: Omit<MpnsTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Windows Notification Services (WNS) registration description into an XML object for serialization.\n */\n serializeWindowsRegistrationDescription(\n description: Omit<WindowsRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Windows Notification Services (WNS) template registration description into an XML object for serialization.\n */\n serializeWindowsTemplateRegistrationDescription(\n description: Omit<WindowsTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n}\n\n/**\n * Represents a RegistrationDescription serializer.\n */\nexport const registrationDescriptionSerializer: RegistrationDescriptionSerializer = {\n serializeRegistrationDescription(description: RegistrationDescription): string {\n const rootName = `${description.type}RegistrationDescription`;\n const methodName = `serialize${rootName}`;\n\n const method = this[methodName as keyof RegistrationDescriptionSerializer].bind(this) as (\n description: RegistrationDescription\n ) => Record<string, any>;\n if (!isDefined(method)) {\n throw new RestError(`Undefined platform ${description.type}`, { statusCode: 400 });\n }\n\n const registration = method(description) as Record<string, any>;\n const requestObject = serializeToAtomXmlRequest(rootName, registration);\n\n return stringifyXML(requestObject, { rootName: \"entry\" });\n },\n\n /**\n * @internal\n * Serializes an existing ADM registration description to an object for serialization.\n */\n serializeAdmRegistrationDescription(\n description: Omit<AdmRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n AdmRegistrationId: getString(description.admRegistrationId, \"admRegistrationId\"),\n };\n },\n\n /**\n * @internal\n * Serializes an existing ADM template registration description to an object for serialization.\n */\n serializeAdmTemplateRegistrationDescription(\n description: Omit<AdmTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...this.serializeAdmRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n };\n },\n\n /**\n * @internal\n * Serializes an existing Apple registration description to an object for serialization.\n */\n serializeAppleRegistrationDescription(\n description: Omit<AppleRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n DeviceToken: getString(description.deviceToken, \"deviceToken\"),\n };\n },\n\n /**\n * @internal\n * Serializes an existing Apple template registration description to an object for serialization.\n */\n serializeAppleTemplateRegistrationDescription(\n description: AppleTemplateRegistrationDescription\n ): Record<string, any> {\n let apnsHeaders: Record<string, any> | undefined;\n if (description.apnsHeaders) {\n apnsHeaders = {\n ApnsHeader: [],\n };\n\n for (const header of Object.keys(description.apnsHeaders)) {\n apnsHeaders[\"ApnsHeader\"].push({\n Header: header,\n Value: description.apnsHeaders[header],\n });\n }\n }\n\n return {\n ...this.serializeAppleRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n Expiry: getStringOrUndefined(description.expiry),\n ApnsHeaders: apnsHeaders,\n };\n },\n\n /**\n * @internal\n * Serializes an existing Baidu registration description to an object for serialization.\n */\n serializeBaiduRegistrationDescription(\n description: Omit<BaiduRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n BaiduChannelId: getString(description.baiduChannelId, \"baiduChannelId\"),\n BaiduUserId: getString(description.baiduUserId, \"baiduUserId\"),\n };\n },\n\n /**\n * @internal\n * Serializes an existing Baidu template registration description to an object for serialization.\n */\n serializeBaiduTemplateRegistrationDescription(\n description: Omit<BaiduTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...this.serializeBaiduRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n };\n },\n\n /**\n * @internal\n * Serializes an existing Browser registration description to an object for serialization.\n */\n serializeBrowserRegistrationDescription(\n description: Omit<BrowserRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n Endpoint: description.endpoint,\n Auth: description.auth,\n P256DH: description.p256dh,\n };\n },\n\n /**\n * @internal\n * Serializes an existing Browser template registration description to an object for serialization.\n */\n serializeBrowserTemplateRegistrationDescription(\n description: Omit<BrowserTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...this.serializeBrowserRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n };\n },\n\n /**\n * @internal\n * @deprecated Should use FCM registrations instead of GCM.\n * Serializes an existing GCM registration description to an object for serialization.\n */\n serializeGcmRegistrationDescription(\n description: Omit<GcmRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n GcmRegistrationId: getString(description.gcmRegistrationId, \"gcmRegistrationId\"),\n };\n },\n\n /**\n * @internal\n * @deprecated Should use FCM template registrations instead of GCM.\n * Serializes an existing GCM template registration description to an object for serialization.\n */\n serializeGcmTemplateRegistrationDescription(\n description: Omit<GcmTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...this.serializeGcmRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n };\n },\n\n /**\n * @internal\n * Serializes an existing FCM registration description to an object for serialization.\n */\n serializeFcmRegistrationDescription(\n description: Omit<FcmRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n FcmRegistrationId: description.fcmRegistrationId,\n };\n },\n\n /**\n * @internal\n * Serializes an existing FCM template registration description to an object for serialization.\n */\n serializeFcmTemplateRegistrationDescription(\n description: Omit<FcmTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...this.serializeFcmRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n };\n },\n\n /**\n * @internal\n * @deprecated Windows Phone is no longer supported.\n * Serializes an existing MPNS registration description to an object for serialization.\n */\n serializeMpnsRegistrationDescription(\n description: Omit<MpnsRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n ChannelUri: description.channelUri,\n };\n },\n\n /**\n * @internal\n * @deprecated Windows Phone is no longer supported.\n * Serializes an existing MPNS template registration description to an object for serialization.\n */\n serializeMpnsTemplateRegistrationDescription(\n description: Omit<MpnsTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n let mpnsHeaders: Record<string, any> | undefined;\n if (description.mpnsHeaders) {\n mpnsHeaders = {\n MpnsHeader: [],\n };\n\n for (const header of Object.keys(description.mpnsHeaders)) {\n mpnsHeaders[\"MpnsHeader\"].push({\n Header: header,\n Value: description.mpnsHeaders[header],\n });\n }\n }\n\n return {\n ...this.serializeMpnsRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n MpnsHeaders: mpnsHeaders,\n };\n },\n\n /**\n * @internal\n * Serializes an existing Windows registration description to an object for serialization.\n */\n serializeWindowsRegistrationDescription(\n description: Omit<WindowsRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n ChannelUri: description.channelUri,\n };\n },\n\n /**\n * @internal\n * Serializes an existing Windows template registration description to an object for serialization.\n */\n serializeWindowsTemplateRegistrationDescription(\n description: Omit<WindowsTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n let wnsHeaders: Record<string, any> | undefined;\n if (description.wnsHeaders) {\n wnsHeaders = {\n WnsHeader: [],\n };\n\n for (const header of Object.keys(description.wnsHeaders)) {\n wnsHeaders[\"WnsHeader\"].push({\n Header: header,\n Value: description.wnsHeaders[header],\n });\n }\n }\n\n return {\n ...this.serializeWindowsRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n WnsHeaders: wnsHeaders,\n };\n },\n};\n\nfunction serializeRegistrationDescription(\n description: Omit<RegistrationDescriptionCommon, \"type\">\n): Record<string, any> {\n let tags: string | undefined;\n if (description.tags) {\n tags = description.tags.join(\",\");\n }\n\n let pushVariables: string | undefined;\n if (description.pushVariables) {\n pushVariables = JSON.stringify(description.pushVariables);\n }\n\n return {\n RegistrationId: getStringOrUndefined(description.registrationId),\n Tags: tags,\n PushVariables: pushVariables,\n };\n}\n\nfunction serializeTemplateRegistrationDescription(\n description: TemplateRegistrationDescription\n): Record<string, any> {\n return {\n BodyTemplate: { __cdata: description.bodyTemplate },\n TemplateName: getStringOrUndefined(description.templateName),\n };\n}\n"]}
1
+ {"version":3,"file":"registrationSerializer.js","sourceRoot":"","sources":["../../../src/serializers/registrationSerializer.ts"],"names":[],"mappings":"AAAA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egistrationDescription,\n AdmTemplateRegistrationDescription,\n ApplePriority,\n AppleRegistrationDescription,\n AppleTemplateRegistrationDescription,\n BaiduRegistrationDescription,\n BaiduTemplateRegistrationDescription,\n BrowserRegistrationDescription,\n BrowserTemplateRegistrationDescription,\n GcmRegistrationDescription,\n GcmTemplateRegistrationDescription,\n MpnsRegistrationDescription,\n MpnsTemplateRegistrationDescription,\n RegistrationDescription,\n RegistrationDescriptionCommon,\n TemplateRegistrationDescription,\n WindowsRegistrationDescription,\n WindowsTemplateRegistrationDescription,\n} from \"../models/registration.js\";\nimport {\n getDateOrUndefined,\n getString,\n getStringOrUndefined,\n getTagsOrUndefined,\n isDefined,\n} from \"../utils/utils.js\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { serializeToAtomXmlRequest } from \"../utils/xmlUtils.js\";\n\n/**\n * Represents a registration description parser from the incoming XML.\n */\nexport interface RegistrationDescriptionParser {\n /**\n * @internal\n * Creates a registration type from the incoming entry.\n */\n parseRegistrationEntry: (bodyText: string) => Promise<RegistrationDescription>;\n /**\n * @internal\n * Creates a list of registrations from an incoming ATOM XML Feed.\n */\n parseRegistrationFeed: (bodyText: string) => Promise<RegistrationDescription[]>;\n /**\n * @internal\n * Creates an Amazon Device Messaging (ADM) registration description from the incoming parsed XML.\n */\n createAdmRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => AdmRegistrationDescription;\n /**\n * @internal\n * Creates an Amazon Device Messaging (ADM) template registration description from the incoming parsed XML.\n */\n createAdmTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => AdmTemplateRegistrationDescription;\n /**\n * @internal\n * Creates an Apple Platform Notification Services (APNs) registration description from the incoming parsed XML.\n */\n createAppleRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => AppleRegistrationDescription;\n /**\n * @internal\n * Creates an Apple Platform Notification Services (APNs) template registration description from the incoming parsed XML.\n */\n createAppleTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => AppleTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Baidu registration description from the incoming parsed XML.\n */\n createBaiduRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => BaiduRegistrationDescription;\n /**\n * @internal\n * Creates a Baidu template registration description from the incoming parsed XML.\n */\n createBaiduTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => BaiduTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Web Push registration description from the incoming parsed XML.\n */\n createBrowserRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => BrowserRegistrationDescription;\n /**\n * @internal\n * Creates a Web Push template registration description from the incoming parsed XML.\n */\n createBrowserTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => BrowserTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Google Cloud Messaging (GCM) registration description from the incoming parsed XML.\n */\n createGcmRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => GcmRegistrationDescription;\n /**\n * @internal\n * Creates a Google Cloud Messaging (GCM) template registration description from the incoming parsed XML.\n */\n createGcmTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => GcmTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Microsoft Phone Notification Services (MPNS) registration description from the incoming parsed XML.\n */\n createMpnsRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => MpnsRegistrationDescription;\n /**\n * @internal\n * Creates a Microsoft Phone Notification Services (MPNS) template registration description from the incoming parsed XML.\n */\n createMpnsTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => MpnsTemplateRegistrationDescription;\n /**\n * @internal\n * Creates a Windows Notification Services (WNS) registration description from the incoming parsed XML.\n */\n createWindowsRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => WindowsRegistrationDescription;\n /**\n * @internal\n * Creates a Windows Notification Services (WNS) template registration description from the incoming parsed XML.\n */\n createWindowsTemplateRegistrationDescription: (\n rawRegistrationDescription: Record<string, any>\n ) => WindowsTemplateRegistrationDescription;\n}\n\nexport const registrationDescriptionParser: RegistrationDescriptionParser = {\n /**\n * @internal\n * Creates a registration type from the incoming entry.\n */\n async parseRegistrationEntry(bodyText: string): Promise<RegistrationDescription> {\n const xml = await parseXML(bodyText, { includeRoot: true });\n const keyName = Object.keys(xml.entry.content)[0];\n const content = xml.entry.content[keyName];\n const methodName = `create${keyName}`;\n\n const method = this[methodName as keyof RegistrationDescriptionParser] as any;\n if (!methodName) {\n throw new RestError(`${keyName} is not a supported registration type`, { statusCode: 500 });\n }\n\n return method.call(this, content) as RegistrationDescription;\n },\n\n /**\n * @internal\n * Creates a list of registrations from an incoming ATOM XML Feed.\n */\n async parseRegistrationFeed(bodyText: string): Promise<RegistrationDescription[]> {\n const xml = await parseXML(bodyText, { includeRoot: true });\n const results: RegistrationDescription[] = [];\n if (!isDefined(xml.feed.entry)) {\n return results;\n }\n\n for (const entry of xml.feed.entry) {\n delete entry.content[\"$\"];\n\n const keyName = Object.keys(entry.content)[0];\n const methodName = `create${keyName}`;\n const content = entry.content[keyName];\n const method = this[methodName as keyof RegistrationDescriptionParser] as any;\n if (!methodName) {\n throw new RestError(`${keyName} is not a supported registration type`, { statusCode: 500 });\n }\n\n results.push(method.call(this, content) as RegistrationDescription);\n }\n\n return results;\n },\n\n /**\n * @internal\n * Creates an ADM registration description from incoming XML property bag.\n */\n createAdmRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): AdmRegistrationDescription {\n return {\n admRegistrationId: getString(\n rawRegistrationDescription[\"AdmRegistrationId\"],\n \"admRegistrationId\"\n ),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Adm\",\n };\n },\n\n /**\n * @internal\n * Creates an ADM template registration description from incoming XML property bag.\n */\n createAdmTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): AdmTemplateRegistrationDescription {\n return {\n ...this.createAdmRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"AdmTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates an Apple registration description from incoming XML property bag.\n */\n createAppleRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): AppleRegistrationDescription {\n return {\n deviceToken: getString(rawRegistrationDescription[\"DeviceToken\"], \"deviceToken\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Apple\",\n };\n },\n\n /**\n * @internal\n * Creates an Apple template registration description from incoming XML property bag.\n */\n createAppleTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): AppleTemplateRegistrationDescription {\n return {\n priority: getStringOrUndefined(rawRegistrationDescription[\"Priority\"]) as ApplePriority,\n apnsHeaders: getHeadersOrUndefined(rawRegistrationDescription[\"ApnsHeaders\"]?.[\"ApnsHeader\"]),\n ...this.createAppleRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"AppleTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates a Baidu registration description from incoming XML property bag.\n */\n createBaiduRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): BaiduRegistrationDescription {\n return {\n baiduChannelId: getString(rawRegistrationDescription[\"BaiduChannelId\"], \"baiduChannelId\"),\n baiduUserId: getString(rawRegistrationDescription[\"BaiduUserId\"], \"baiduUserId\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Baidu\",\n };\n },\n\n /**\n * @internal\n * Creates a Baidu template registration description from incoming XML property bag.\n */\n createBaiduTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): BaiduTemplateRegistrationDescription {\n return {\n ...this.createBaiduRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"BaiduTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates a Browser registration description from incoming XML property bag.\n */\n createBrowserRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): BrowserRegistrationDescription {\n return {\n endpoint: getString(rawRegistrationDescription[\"Endpoint\"], \"endpoint\"),\n p256dh: getString(rawRegistrationDescription[\"P256DH\"], \"p256dh\"),\n auth: getString(rawRegistrationDescription[\"Auth\"], \"auth\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Browser\",\n };\n },\n\n /**\n * @internal\n * Creates a Browser template registration description from incoming XML property bag.\n */\n createBrowserTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): BrowserTemplateRegistrationDescription {\n return {\n ...this.createBrowserRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"BrowserTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates an GCM registration description from incoming XML property bag.\n */\n createGcmRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): GcmRegistrationDescription {\n return {\n gcmRegistrationId: getString(\n rawRegistrationDescription[\"GcmRegistrationId\"],\n \"gcmRegistrationId\"\n ),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Gcm\",\n };\n },\n\n /**\n * @internal\n * Creates an FCM template registration description from incoming XML property bag.\n */\n createGcmTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): GcmTemplateRegistrationDescription {\n return {\n ...this.createGcmRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"GcmTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates a Windows Phone registration description from incoming XML property bag.\n */\n createMpnsRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): MpnsRegistrationDescription {\n return {\n channelUri: getString(rawRegistrationDescription[\"ChannelUri\"], \"channelUri\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Mpns\",\n };\n },\n\n /**\n * @internal\n * Creates a Windows Phone template registration description from incoming XML property bag.\n */\n createMpnsTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): MpnsTemplateRegistrationDescription {\n return {\n mpnsHeaders: getHeadersOrUndefined(rawRegistrationDescription[\"MpnsHeaders\"]?.[\"MpnsHeader\"]),\n ...this.createWindowsRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"MpnsTemplate\",\n };\n },\n\n /**\n * @internal\n * Creates a Windows registration description from incoming XML property bag.\n */\n createWindowsRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): WindowsRegistrationDescription {\n return {\n channelUri: getString(rawRegistrationDescription[\"ChannelUri\"], \"channelUri\"),\n ...createRegistrationDescription(rawRegistrationDescription),\n type: \"Windows\",\n };\n },\n\n /**\n * @internal\n * Creates a Windows template registration description from incoming XML property bag.\n */\n createWindowsTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n ): WindowsTemplateRegistrationDescription {\n return {\n wnsHeaders: getHeadersOrUndefined(rawRegistrationDescription[\"WnsHeaders\"]?.[\"WnsHeader\"]),\n ...this.createWindowsRegistrationDescription(rawRegistrationDescription),\n ...createTemplateRegistrationDescription(rawRegistrationDescription),\n type: \"WindowsTemplate\",\n };\n },\n};\n\nfunction getHeadersOrUndefined(\n value?: { Header: string; Value: string }[]\n): Record<string, string> | undefined {\n if (!isDefined(value)) {\n return undefined;\n }\n\n const headerObj: Record<string, string> = {};\n for (const { Header, Value } of value) {\n headerObj[Header] = Value;\n }\n\n return headerObj;\n}\n\nfunction createRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n): Omit<RegistrationDescriptionCommon, \"type\"> {\n let pushVariables: Record<string, string> | undefined;\n const unparsed = getStringOrUndefined(rawRegistrationDescription[\"PushVariables\"]);\n if (unparsed) {\n pushVariables = JSON.parse(unparsed) as Record<string, string>;\n }\n\n return {\n registrationId: getStringOrUndefined(rawRegistrationDescription[\"RegistrationId\"]),\n expirationTime: getDateOrUndefined(rawRegistrationDescription[\"ExpirationTime\"]),\n etag: getStringOrUndefined(rawRegistrationDescription[\"ETag\"]),\n tags: getTagsOrUndefined(rawRegistrationDescription[\"Tags\"]),\n pushVariables: pushVariables,\n };\n}\n\nfunction createTemplateRegistrationDescription(\n rawRegistrationDescription: Record<string, any>\n): TemplateRegistrationDescription {\n return {\n bodyTemplate: getString(rawRegistrationDescription[\"BodyTemplate\"], \"bodyTemplate\"),\n templateName: getStringOrUndefined(rawRegistrationDescription[\"TemplateName\"]),\n ...createRegistrationDescription(rawRegistrationDescription),\n };\n}\n\n/**\n * @internal\n * Represents a serializer for all registration descriptions.\n */\nexport interface RegistrationDescriptionSerializer {\n /**\n * @internal\n * Serializes a registration description into an ATOM XML string.\n */\n serializeRegistrationDescription(description: RegistrationDescription): string;\n /**\n * @internal\n * Serializes an Amazon Device Messaging (ADM) registration description into an XML object for serialization.\n */\n serializeAdmRegistrationDescription(\n description: Omit<AdmRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes an Amazon Device Messaging (ADM) template registration description into an XML object for serialization.\n */\n serializeAdmTemplateRegistrationDescription(\n description: Omit<AdmTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes an Apple registration description into an XML object for serialization.\n */\n serializeAppleRegistrationDescription(\n description: Omit<AppleRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes an Apple template registration description into an XML object for serialization.\n */\n serializeAppleTemplateRegistrationDescription(\n description: Omit<AppleRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Baidu registration description into an XML object for serialization.\n */\n serializeBaiduRegistrationDescription(\n description: Omit<BaiduRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Baidu template registration description into an XML object for serialization.\n */\n serializeBaiduTemplateRegistrationDescription(\n description: Omit<BaiduTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Web Push registration description into an XML object for serialization.\n */\n serializeBrowserRegistrationDescription(\n description: Omit<BrowserRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Web Push template registration description into an XML object for serialization.\n */\n serializeBrowserTemplateRegistrationDescription(\n description: Omit<BrowserTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Google Cloud Messaging (GCM) registration description into an XML object for serialization.\n */\n serializeGcmRegistrationDescription(\n description: Omit<GcmRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Google Cloud Messaging (GCM) template registration description into an XML object for serialization.\n */\n serializeGcmTemplateRegistrationDescription(\n description: Omit<GcmTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Windows Phone registration description into an XML object for serialization.\n */\n serializeMpnsRegistrationDescription(\n description: Omit<MpnsRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Windows Phone template registration description into an XML object for serialization.\n */\n serializeMpnsTemplateRegistrationDescription(\n description: Omit<MpnsTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Windows Notification Services (WNS) registration description into an XML object for serialization.\n */\n serializeWindowsRegistrationDescription(\n description: Omit<WindowsRegistrationDescription, \"type\">\n ): Record<string, any>;\n /**\n * @internal\n * Serializes a Windows Notification Services (WNS) template registration description into an XML object for serialization.\n */\n serializeWindowsTemplateRegistrationDescription(\n description: Omit<WindowsTemplateRegistrationDescription, \"type\">\n ): Record<string, any>;\n}\n\n/**\n * Represents a RegistrationDescription serializer.\n */\nexport const registrationDescriptionSerializer: RegistrationDescriptionSerializer = {\n serializeRegistrationDescription(description: RegistrationDescription): string {\n const rootName = `${description.type}RegistrationDescription`;\n const methodName = `serialize${rootName}`;\n\n const method = this[methodName as keyof RegistrationDescriptionSerializer].bind(this) as (\n description: RegistrationDescription\n ) => Record<string, any>;\n if (!isDefined(method)) {\n throw new RestError(`Undefined platform ${description.type}`, { statusCode: 400 });\n }\n\n const registration = method(description) as Record<string, any>;\n const requestObject = serializeToAtomXmlRequest(rootName, registration);\n\n return stringifyXML(requestObject, { rootName: \"entry\" });\n },\n\n /**\n * @internal\n * Serializes an existing ADM registration description to an object for serialization.\n */\n serializeAdmRegistrationDescription(\n description: Omit<AdmRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n AdmRegistrationId: getString(description.admRegistrationId, \"admRegistrationId\"),\n };\n },\n\n /**\n * @internal\n * Serializes an existing ADM template registration description to an object for serialization.\n */\n serializeAdmTemplateRegistrationDescription(\n description: Omit<AdmTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...this.serializeAdmRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n };\n },\n\n /**\n * @internal\n * Serializes an existing Apple registration description to an object for serialization.\n */\n serializeAppleRegistrationDescription(\n description: Omit<AppleRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n DeviceToken: getString(description.deviceToken, \"deviceToken\"),\n };\n },\n\n /**\n * @internal\n * Serializes an existing Apple template registration description to an object for serialization.\n */\n serializeAppleTemplateRegistrationDescription(\n description: AppleTemplateRegistrationDescription\n ): Record<string, any> {\n let apnsHeaders: Record<string, any> | undefined;\n if (description.apnsHeaders) {\n apnsHeaders = {\n ApnsHeader: [],\n };\n\n for (const header of Object.keys(description.apnsHeaders)) {\n apnsHeaders[\"ApnsHeader\"].push({\n Header: header,\n Value: description.apnsHeaders[header],\n });\n }\n }\n\n return {\n ...this.serializeAppleRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n Expiry: getStringOrUndefined(description.expiry),\n ApnsHeaders: apnsHeaders,\n };\n },\n\n /**\n * @internal\n * Serializes an existing Baidu registration description to an object for serialization.\n */\n serializeBaiduRegistrationDescription(\n description: Omit<BaiduRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n BaiduChannelId: getString(description.baiduChannelId, \"baiduChannelId\"),\n BaiduUserId: getString(description.baiduUserId, \"baiduUserId\"),\n };\n },\n\n /**\n * @internal\n * Serializes an existing Baidu template registration description to an object for serialization.\n */\n serializeBaiduTemplateRegistrationDescription(\n description: Omit<BaiduTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...this.serializeBaiduRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n };\n },\n\n /**\n * @internal\n * Serializes an existing Browser registration description to an object for serialization.\n */\n serializeBrowserRegistrationDescription(\n description: Omit<BrowserRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n Endpoint: description.endpoint,\n Auth: description.auth,\n P256DH: description.p256dh,\n };\n },\n\n /**\n * @internal\n * Serializes an existing Browser template registration description to an object for serialization.\n */\n serializeBrowserTemplateRegistrationDescription(\n description: Omit<BrowserTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...this.serializeBrowserRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n };\n },\n\n /**\n * @internal\n * @deprecated Should use FCM registrations instead of GCM.\n * Serializes an existing GCM registration description to an object for serialization.\n */\n serializeGcmRegistrationDescription(\n description: Omit<GcmRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n GcmRegistrationId: getString(description.gcmRegistrationId, \"gcmRegistrationId\"),\n };\n },\n\n /**\n * @internal\n * @deprecated Should use FCM template registrations instead of GCM.\n * Serializes an existing GCM template registration description to an object for serialization.\n */\n serializeGcmTemplateRegistrationDescription(\n description: Omit<GcmTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...this.serializeGcmRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n };\n },\n\n /**\n * @internal\n * @deprecated Windows Phone is no longer supported.\n * Serializes an existing MPNS registration description to an object for serialization.\n */\n serializeMpnsRegistrationDescription(\n description: Omit<MpnsRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n ChannelUri: description.channelUri,\n };\n },\n\n /**\n * @internal\n * @deprecated Windows Phone is no longer supported.\n * Serializes an existing MPNS template registration description to an object for serialization.\n */\n serializeMpnsTemplateRegistrationDescription(\n description: Omit<MpnsTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n let mpnsHeaders: Record<string, any> | undefined;\n if (description.mpnsHeaders) {\n mpnsHeaders = {\n MpnsHeader: [],\n };\n\n for (const header of Object.keys(description.mpnsHeaders)) {\n mpnsHeaders[\"MpnsHeader\"].push({\n Header: header,\n Value: description.mpnsHeaders[header],\n });\n }\n }\n\n return {\n ...this.serializeMpnsRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n MpnsHeaders: mpnsHeaders,\n };\n },\n\n /**\n * @internal\n * Serializes an existing Windows registration description to an object for serialization.\n */\n serializeWindowsRegistrationDescription(\n description: Omit<WindowsRegistrationDescription, \"type\">\n ): Record<string, any> {\n return {\n ...serializeRegistrationDescription(description),\n ChannelUri: description.channelUri,\n };\n },\n\n /**\n * @internal\n * Serializes an existing Windows template registration description to an object for serialization.\n */\n serializeWindowsTemplateRegistrationDescription(\n description: Omit<WindowsTemplateRegistrationDescription, \"type\">\n ): Record<string, any> {\n let wnsHeaders: Record<string, any> | undefined;\n if (description.wnsHeaders) {\n wnsHeaders = {\n WnsHeader: [],\n };\n\n for (const header of Object.keys(description.wnsHeaders)) {\n wnsHeaders[\"WnsHeader\"].push({\n Header: header,\n Value: description.wnsHeaders[header],\n });\n }\n }\n\n return {\n ...this.serializeWindowsRegistrationDescription(description),\n ...serializeTemplateRegistrationDescription(description),\n WnsHeaders: wnsHeaders,\n };\n },\n};\n\nfunction serializeRegistrationDescription(\n description: Omit<RegistrationDescriptionCommon, \"type\">\n): Record<string, any> {\n let tags: string | undefined;\n if (description.tags) {\n tags = description.tags.join(\",\");\n }\n\n let pushVariables: string | undefined;\n if (description.pushVariables) {\n pushVariables = JSON.stringify(description.pushVariables);\n }\n\n return {\n RegistrationId: getStringOrUndefined(description.registrationId),\n Tags: tags,\n PushVariables: pushVariables,\n };\n}\n\nfunction serializeTemplateRegistrationDescription(\n description: TemplateRegistrationDescription\n): Record<string, any> {\n return {\n BodyTemplate: { __cdata: description.bodyTemplate },\n TemplateName: getStringOrUndefined(description.templateName),\n };\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
+ export const SDK_VERSION = "1.0.0-beta.4";
3
4
  export const JSON_CONTENT_TYPE = "application/json;charset=utf-8";
4
5
  export const XML_CONTENT_TYPE = "application/xml";
5
6
  export const STREAM_CONTENT_TYPE = "application/octet-stream";
@@ -1 +1 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,iBAAiB,GAAG,gCAAgC,CAAC;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAE9D,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAC1C,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;AACpC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const JSON_CONTENT_TYPE = \"application/json;charset=utf-8\";\nexport const XML_CONTENT_TYPE = \"application/xml\";\nexport const STREAM_CONTENT_TYPE = \"application/octet-stream\";\n\nexport const WNS_TYPE_NAME = \"X-WNS-Type\";\nexport const WNS_RAW = \"wns/raw\";\nexport const WNS_BADGE = \"wns/badge\";\nexport const WNS_TITLE = \"wns/tile\";\nexport const WNS_TOAST = \"wns/toast\";\n"]}
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/utils/constants.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,MAAM,CAAC,MAAM,WAAW,GAAW,cAAc,CAAC;AAElD,MAAM,CAAC,MAAM,iBAAiB,GAAG,gCAAgC,CAAC;AAClE,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAClD,MAAM,CAAC,MAAM,mBAAmB,GAAG,0BAA0B,CAAC;AAE9D,MAAM,CAAC,MAAM,aAAa,GAAG,YAAY,CAAC;AAC1C,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAC;AACjC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,MAAM,SAAS,GAAG,UAAU,CAAC;AACpC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nexport const SDK_VERSION: string = \"1.0.0-beta.4\";\n\nexport const JSON_CONTENT_TYPE = \"application/json;charset=utf-8\";\nexport const XML_CONTENT_TYPE = \"application/xml\";\nexport const STREAM_CONTENT_TYPE = \"application/octet-stream\";\n\nexport const WNS_TYPE_NAME = \"X-WNS-Type\";\nexport const WNS_RAW = \"wns/raw\";\nexport const WNS_BADGE = \"wns/badge\";\nexport const WNS_TITLE = \"wns/tile\";\nexport const WNS_TOAST = \"wns/toast\";\n"]}
@@ -1,7 +1,7 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
3
  import { AbortError } from "@azure/abort-controller";
4
- import { delay } from "@azure/core-amqp";
4
+ import { delay } from "@azure/core-util";
5
5
  import { isDefined } from "./utils.js";
6
6
  import { isError } from "@azure/core-util";
7
7
  import { isRestError } from "@azure/core-rest-pipeline";
@@ -50,7 +50,7 @@ export function createBaseRetryPolicy(calculateRetryDelay) {
50
50
  ++failedAttemptCount;
51
51
  const retryDelay = calculateRetryDelay(err, failedAttemptCount);
52
52
  if (isDefined(retryDelay)) {
53
- await delay(retryDelay, signal);
53
+ await delay(retryDelay);
54
54
  }
55
55
  else {
56
56
  throw err;
@@ -1 +1 @@
1
- {"version":3,"file":"retryPolicy.js","sourceRoot":"","sources":["../../../src/utils/retryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAe,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,SAAS,YAAY,CAAC,CAAU;IAC9B,IAAI,CAAC,YAAY,UAAU,EAAE;QAC3B,OAAO,IAAI,CAAC;KACb;IAED,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACnB;;OAEG;IACH,2CAAK,CAAA;IACL;;OAEG;IACH,uDAAW,CAAA;AACb,CAAC,EATW,SAAS,GAAT,SAAS,KAAT,SAAS,QASpB;AA2BD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA+B;IAChE,uBACE,IAAI,EAAE,SAAS,CAAC,KAAK,EACrB,UAAU,EAAE,CAAC,EACb,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,IAAI,GAAG,EAAE,IAChB,OAAO,EACV;AACJ,CAAC;AAyBD;;;;GAIG;AACH,MAAM,UAAU,qBAAqB,CACnC,mBAA4E;IAE5E,KAAK,UAAU,YAAY,CACzB,SAAqD,EACrD,MAAoB;QAEpB,IAAI,kBAAkB,GAAG,CAAC,CAAC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AC/B,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG,EAAE;YAClD,OAAO,IAAI,CAAC;SACb;QACD,kBAAkB;QAClB,IACE,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG,EACrB;YACA,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,gBAAwB,EAAE,iBAAyB;IAC9E,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAC;AACvE,CAAC;AAED,SAAS,yBAAyB,CAChC,YAAoB,EACpB,gBAAwB,EACxB,iBAAyB;IAEzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAC;AACnG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError, AbortSignal } from \"@azure/abort-controller\";\nimport { delay } from \"@azure/core-amqp\";\nimport { isDefined } from \"./utils.js\";\nimport { isError } from \"@azure/core-util\";\nimport { isRestError } from \"@azure/core-rest-pipeline\";\n\nconst JITTER_FACTOR = 0.08;\n\nfunction isAbortError(e: unknown): e is AbortError {\n if (e instanceof AbortError) {\n return true;\n }\n\n return isError(e) && e.name === \"AbortError\";\n}\n\n/**\n * Represents the retry delay calculation either fixed or exponential.\n */\nexport enum RetryMode {\n /**\n * Fixed interval between retries.\n */\n Fixed,\n /**\n * Exporation interval between retries.\n */\n Exponential,\n}\n\n/**\n * Represents the retry options for an operation.\n */\nexport interface RetryOptions {\n /**\n * The retry mode.\n */\n mode: RetryMode;\n\n /**\n * The number of maximum retries.\n */\n maxRetries: number;\n\n /**\n * The delay in milliseconds between retries.\n */\n delay: number;\n\n /**\n * The maximum delay in milliseconds between retries.\n */\n maxDelay: number;\n}\n\n/**\n * Creates a set of retry options with defaults.\n * @param options - The options for the retry behavior.\n * @returns The retry options.\n */\nexport function createRetryOptions(options?: Partial<RetryOptions>): RetryOptions {\n return {\n mode: RetryMode.Fixed,\n maxRetries: 3,\n delay: 1000,\n maxDelay: 1000 * 60,\n ...options,\n };\n}\n\n/**\n * Represents a retry policy with a run operation and define a retry time calculation.\n */\nexport interface RetryPolicy {\n /**\n * Calculates the retry delay based upon the error and retry attempt.\n * @param error - The error from the operation.\n * @param attempt - The retry attempt number.\n */\n calculateRetryDelay: (error: unknown, attempt: number) => number | undefined;\n\n /**\n * Runs an operation and retries based upon the retry policy.\n * @param operation - The operation to run and retry if necessary.\n * @param signal - An AbortSignal to check for cancellation.\n * @returns The result of the operation.\n */\n runOperation<TResult>(\n operation: (signal?: AbortSignal) => Promise<TResult>,\n signal?: AbortSignal\n ): Promise<TResult>;\n}\n\n/**\n * Creates a base retry policy with the incoming calculateRetryDelay method.\n * @param calculateRetryDelay - The retry calculation behavior based upon attempt number and error.\n * @returns A retry policy with the given calculateRetryDelay method.\n */\nexport function createBaseRetryPolicy(\n calculateRetryDelay: (error: unknown, attempt: number) => number | undefined\n): RetryPolicy {\n async function runOperation<TResult>(\n operation: (signal?: AbortSignal) => Promise<TResult>,\n signal?: AbortSignal\n ): Promise<TResult> {\n let failedAttemptCount = 0;\n\n while (!signal?.aborted) {\n try {\n return await operation(signal);\n } catch (err) {\n ++failedAttemptCount;\n const retryDelay = calculateRetryDelay(err, failedAttemptCount);\n if (isDefined(retryDelay)) {\n await delay(retryDelay, signal);\n } else {\n throw err;\n }\n }\n }\n\n throw new AbortError(\"The operation has been aborted\");\n }\n\n return {\n calculateRetryDelay,\n runOperation,\n };\n}\n\n/**\n * Creates a retry policy configured with the given retry options.\n * @param options - The retry options including delay, max attempts and backoff behavior.\n * @returns A retry policy configured with the given options.\n */\nexport function createDefaultRetryPolicy(options: RetryOptions): RetryPolicy {\n function calculateRetryDelay(error: unknown, attempt: number): number | undefined {\n if (\n options.maxRetries <= 0 ||\n options.delay === 0 ||\n options.maxDelay === 0 ||\n attempt > options.maxRetries ||\n !shouldRetryError(error)\n ) {\n return undefined;\n }\n\n const baseJitterSeconds = (options.delay / 1000) * JITTER_FACTOR;\n\n let retryDelay: number | undefined;\n if (isRestError(error)) {\n retryDelay = parseRetryAfter(error.response?.headers.get(\"retry-after\"));\n }\n\n if (!isDefined(retryDelay)) {\n if (options.mode === RetryMode.Exponential) {\n retryDelay = calculateExponentialDelay(attempt, options.delay / 1000, baseJitterSeconds);\n } else {\n retryDelay = calculateFixedDelay(options.delay / 1000, baseJitterSeconds);\n }\n }\n\n if (options.maxDelay < retryDelay) {\n return options.maxDelay;\n }\n\n return retryDelay;\n }\n\n return createBaseRetryPolicy(calculateRetryDelay);\n}\n\nfunction parseRetryAfter(headerValue: string | undefined): number | undefined {\n if (!isDefined(headerValue)) {\n return undefined;\n }\n\n // Retry-After is defined in seconds\n const number = new Number(headerValue);\n if (Number.isFinite(number) && number >= 0) {\n return number.valueOf() * 1000;\n }\n\n // Retry-After is defined as a Date\n const retryDate = Date.parse(headerValue);\n if (Number.isNaN(retryDate)) {\n return undefined;\n }\n\n const diff = retryDate - Date.now();\n return diff <= 0 ? undefined : diff;\n}\n\nfunction shouldRetryError(e: unknown): boolean {\n if (isAbortError(e)) {\n return false;\n }\n\n if (isRestError(e)) {\n // Throttle and legacy throttle\n if (e?.statusCode === 429 || e?.statusCode === 403) {\n return true;\n }\n // Network hiccups\n if (\n e?.statusCode === 500 ||\n e?.statusCode === 503 ||\n e?.statusCode === 504 ||\n e?.statusCode === 408\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction calculateFixedDelay(baseDelaySeconds: number, baseJitterSeconds: number): number {\n return (baseDelaySeconds + Math.random() * baseJitterSeconds) * 1000;\n}\n\nfunction calculateExponentialDelay(\n attemptCount: number,\n baseDelaySeconds: number,\n baseJitterSeconds: number\n): number {\n return (Math.pow(2, attemptCount) * baseDelaySeconds + Math.random() * baseJitterSeconds) * 1000;\n}\n"]}
1
+ {"version":3,"file":"retryPolicy.js","sourceRoot":"","sources":["../../../src/utils/retryPolicy.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,UAAU,EAAe,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAExD,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,SAAS,YAAY,CAAC,CAAU;IAC9B,IAAI,CAAC,YAAY,UAAU,EAAE;QAC3B,OAAO,IAAI,CAAC;KACb;IAED,OAAO,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC;AAC/C,CAAC;AAED;;GAEG;AACH,MAAM,CAAN,IAAY,SASX;AATD,WAAY,SAAS;IACnB;;OAEG;IACH,2CAAK,CAAA;IACL;;OAEG;IACH,uDAAW,CAAA;AACb,CAAC,EATW,SAAS,GAAT,SAAS,KAAT,SAAS,QASpB;AA2BD;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,OAA+B;IAChE,uBACE,IAAI,EAAE,SAAS,CAAC,KAAK,EACrB,UAAU,EAAE,CAAC,EACb,KA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C,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;AACtC,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAU;IAClC,IAAI,YAAY,CAAC,CAAC,CAAC,EAAE;QACnB,OAAO,KAAK,CAAC;KACd;IAED,IAAI,WAAW,CAAC,CAAC,CAAC,EAAE;QAClB,+BAA+B;QAC/B,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG,IAAI,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG,EAAE;YAClD,OAAO,IAAI,CAAC;SACb;QACD,kBAAkB;QAClB,IACE,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG;YACrB,CAAA,CAAC,aAAD,CAAC,uBAAD,CAAC,CAAE,UAAU,MAAK,GAAG,EACrB;YACA,OAAO,IAAI,CAAC;SACb;KACF;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,mBAAmB,CAAC,gBAAwB,EAAE,iBAAyB;IAC9E,OAAO,CAAC,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAC;AACvE,CAAC;AAED,SAAS,yBAAyB,CAChC,YAAoB,EACpB,gBAAwB,EACxB,iBAAyB;IAEzB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,YAAY,CAAC,GAAG,gBAAgB,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,iBAAiB,CAAC,GAAG,IAAI,CAAC;AACnG,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { AbortError, AbortSignal } from \"@azure/abort-controller\";\nimport { delay } from \"@azure/core-util\";\nimport { isDefined } from \"./utils.js\";\nimport { isError } from \"@azure/core-util\";\nimport { isRestError } from \"@azure/core-rest-pipeline\";\n\nconst JITTER_FACTOR = 0.08;\n\nfunction isAbortError(e: unknown): e is AbortError {\n if (e instanceof AbortError) {\n return true;\n }\n\n return isError(e) && e.name === \"AbortError\";\n}\n\n/**\n * Represents the retry delay calculation either fixed or exponential.\n */\nexport enum RetryMode {\n /**\n * Fixed interval between retries.\n */\n Fixed,\n /**\n * Exporation interval between retries.\n */\n Exponential,\n}\n\n/**\n * Represents the retry options for an operation.\n */\nexport interface RetryOptions {\n /**\n * The retry mode.\n */\n mode: RetryMode;\n\n /**\n * The number of maximum retries.\n */\n maxRetries: number;\n\n /**\n * The delay in milliseconds between retries.\n */\n delay: number;\n\n /**\n * The maximum delay in milliseconds between retries.\n */\n maxDelay: number;\n}\n\n/**\n * Creates a set of retry options with defaults.\n * @param options - The options for the retry behavior.\n * @returns The retry options.\n */\nexport function createRetryOptions(options?: Partial<RetryOptions>): RetryOptions {\n return {\n mode: RetryMode.Fixed,\n maxRetries: 3,\n delay: 1000,\n maxDelay: 1000 * 60,\n ...options,\n };\n}\n\n/**\n * Represents a retry policy with a run operation and define a retry time calculation.\n */\nexport interface RetryPolicy {\n /**\n * Calculates the retry delay based upon the error and retry attempt.\n * @param error - The error from the operation.\n * @param attempt - The retry attempt number.\n */\n calculateRetryDelay: (error: unknown, attempt: number) => number | undefined;\n\n /**\n * Runs an operation and retries based upon the retry policy.\n * @param operation - The operation to run and retry if necessary.\n * @param signal - An AbortSignal to check for cancellation.\n * @returns The result of the operation.\n */\n runOperation<TResult>(\n operation: (signal?: AbortSignal) => Promise<TResult>,\n signal?: AbortSignal\n ): Promise<TResult>;\n}\n\n/**\n * Creates a base retry policy with the incoming calculateRetryDelay method.\n * @param calculateRetryDelay - The retry calculation behavior based upon attempt number and error.\n * @returns A retry policy with the given calculateRetryDelay method.\n */\nexport function createBaseRetryPolicy(\n calculateRetryDelay: (error: unknown, attempt: number) => number | undefined\n): RetryPolicy {\n async function runOperation<TResult>(\n operation: (signal?: AbortSignal) => Promise<TResult>,\n signal?: AbortSignal\n ): Promise<TResult> {\n let failedAttemptCount = 0;\n\n while (!signal?.aborted) {\n try {\n return await operation(signal);\n } catch (err) {\n ++failedAttemptCount;\n const retryDelay = calculateRetryDelay(err, failedAttemptCount);\n if (isDefined(retryDelay)) {\n await delay(retryDelay);\n } else {\n throw err;\n }\n }\n }\n\n throw new AbortError(\"The operation has been aborted\");\n }\n\n return {\n calculateRetryDelay,\n runOperation,\n };\n}\n\n/**\n * Creates a retry policy configured with the given retry options.\n * @param options - The retry options including delay, max attempts and backoff behavior.\n * @returns A retry policy configured with the given options.\n */\nexport function createDefaultRetryPolicy(options: RetryOptions): RetryPolicy {\n function calculateRetryDelay(error: unknown, attempt: number): number | undefined {\n if (\n options.maxRetries <= 0 ||\n options.delay === 0 ||\n options.maxDelay === 0 ||\n attempt > options.maxRetries ||\n !shouldRetryError(error)\n ) {\n return undefined;\n }\n\n const baseJitterSeconds = (options.delay / 1000) * JITTER_FACTOR;\n\n let retryDelay: number | undefined;\n if (isRestError(error)) {\n retryDelay = parseRetryAfter(error.response?.headers.get(\"retry-after\"));\n }\n\n if (!isDefined(retryDelay)) {\n if (options.mode === RetryMode.Exponential) {\n retryDelay = calculateExponentialDelay(attempt, options.delay / 1000, baseJitterSeconds);\n } else {\n retryDelay = calculateFixedDelay(options.delay / 1000, baseJitterSeconds);\n }\n }\n\n if (options.maxDelay < retryDelay) {\n return options.maxDelay;\n }\n\n return retryDelay;\n }\n\n return createBaseRetryPolicy(calculateRetryDelay);\n}\n\nfunction parseRetryAfter(headerValue: string | undefined): number | undefined {\n if (!isDefined(headerValue)) {\n return undefined;\n }\n\n // Retry-After is defined in seconds\n const number = new Number(headerValue);\n if (Number.isFinite(number) && number >= 0) {\n return number.valueOf() * 1000;\n }\n\n // Retry-After is defined as a Date\n const retryDate = Date.parse(headerValue);\n if (Number.isNaN(retryDate)) {\n return undefined;\n }\n\n const diff = retryDate - Date.now();\n return diff <= 0 ? undefined : diff;\n}\n\nfunction shouldRetryError(e: unknown): boolean {\n if (isAbortError(e)) {\n return false;\n }\n\n if (isRestError(e)) {\n // Throttle and legacy throttle\n if (e?.statusCode === 429 || e?.statusCode === 403) {\n return true;\n }\n // Network hiccups\n if (\n e?.statusCode === 500 ||\n e?.statusCode === 503 ||\n e?.statusCode === 504 ||\n e?.statusCode === 408\n ) {\n return true;\n }\n }\n\n return false;\n}\n\nfunction calculateFixedDelay(baseDelaySeconds: number, baseJitterSeconds: number): number {\n return (baseDelaySeconds + Math.random() * baseJitterSeconds) * 1000;\n}\n\nfunction calculateExponentialDelay(\n attemptCount: number,\n baseDelaySeconds: number,\n baseJitterSeconds: number\n): number {\n return (Math.pow(2, attemptCount) * baseDelaySeconds + Math.random() * baseJitterSeconds) * 1000;\n}\n"]}
@@ -1,5 +1,6 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
+ import { SDK_VERSION } from "./constants.js";
3
4
  import { createTracingClient } from "@azure/core-tracing";
4
5
  /**
5
6
  * A tracing client to handle spans.
@@ -8,6 +9,6 @@ import { createTracingClient } from "@azure/core-tracing";
8
9
  export const tracingClient = createTracingClient({
9
10
  namespace: "Microsoft.NotificationHubs",
10
11
  packageName: "@azure/notification-hubs",
11
- packageVersion: "1.0.0",
12
+ packageVersion: SDK_VERSION,
12
13
  });
13
14
  //# sourceMappingURL=tracing.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/utils/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,SAAS,EAAE,4BAA4B;IACvC,WAAW,EAAE,0BAA0B;IACvC,cAAc,EAAE,OAAO;CACxB,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createTracingClient } from \"@azure/core-tracing\";\n\n/**\n * A tracing client to handle spans.\n * @internal\n */\nexport const tracingClient = createTracingClient({\n namespace: \"Microsoft.NotificationHubs\",\n packageName: \"@azure/notification-hubs\",\n packageVersion: \"1.0.0\",\n});\n"]}
1
+ {"version":3,"file":"tracing.js","sourceRoot":"","sources":["../../../src/utils/tracing.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,mBAAmB,CAAC;IAC/C,SAAS,EAAE,4BAA4B;IACvC,WAAW,EAAE,0BAA0B;IACvC,cAAc,EAAE,WAAW;CAC5B,CAAC,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { SDK_VERSION } from \"./constants.js\";\nimport { createTracingClient } from \"@azure/core-tracing\";\n\n/**\n * A tracing client to handle spans.\n * @internal\n */\nexport const tracingClient = createTracingClient({\n namespace: \"Microsoft.NotificationHubs\",\n packageName: \"@azure/notification-hubs\",\n packageVersion: SDK_VERSION,\n});\n"]}