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

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 (96) hide show
  1. package/dist/{index.js → index.cjs} +193 -52
  2. package/dist/index.cjs.map +1 -0
  3. package/dist-esm/src/{utils → auth}/connectionStringUtils.js +37 -1
  4. package/dist-esm/src/auth/connectionStringUtils.js.map +1 -0
  5. package/dist-esm/src/auth/hmacSha256.browser.js +11 -0
  6. package/dist-esm/src/auth/hmacSha256.browser.js.map +1 -0
  7. package/dist-esm/src/auth/hmacSha256.js +8 -0
  8. package/dist-esm/src/auth/hmacSha256.js.map +1 -0
  9. package/dist-esm/src/auth/sasTokenProvider.js +79 -0
  10. package/dist-esm/src/auth/sasTokenProvider.js.map +1 -0
  11. package/dist-esm/src/client/cancelScheduledNotification.js +3 -2
  12. package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
  13. package/dist-esm/src/client/createOrUpdateInstallation.js +3 -2
  14. package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
  15. package/dist-esm/src/client/createOrUpdateRegistration.js +2 -1
  16. package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -1
  17. package/dist-esm/src/client/createRegistration.js +2 -1
  18. package/dist-esm/src/client/createRegistration.js.map +1 -1
  19. package/dist-esm/src/client/createRegistrationId.js +3 -2
  20. package/dist-esm/src/client/createRegistrationId.js.map +1 -1
  21. package/dist-esm/src/client/deleteInstallation.js +3 -2
  22. package/dist-esm/src/client/deleteInstallation.js.map +1 -1
  23. package/dist-esm/src/client/deleteRegistration.js +3 -2
  24. package/dist-esm/src/client/deleteRegistration.js.map +1 -1
  25. package/dist-esm/src/client/getFeedbackContainerUrl.js +3 -2
  26. package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -1
  27. package/dist-esm/src/client/getInstallation.js +3 -2
  28. package/dist-esm/src/client/getInstallation.js.map +1 -1
  29. package/dist-esm/src/client/getNotificationHubJob.js +3 -2
  30. package/dist-esm/src/client/getNotificationHubJob.js.map +1 -1
  31. package/dist-esm/src/client/getNotificationOutcomeDetails.js +3 -2
  32. package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -1
  33. package/dist-esm/src/client/getRegistration.js +3 -2
  34. package/dist-esm/src/client/getRegistration.js.map +1 -1
  35. package/dist-esm/src/client/index.js +7 -3
  36. package/dist-esm/src/client/index.js.map +1 -1
  37. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js +1 -1
  38. package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +1 -1
  39. package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +3 -2
  40. package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +1 -1
  41. package/dist-esm/src/client/internal/_sendNotificationPayload.js +1 -1
  42. package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +1 -1
  43. package/dist-esm/src/client/listNotificationHubJobs.js +3 -2
  44. package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -1
  45. package/dist-esm/src/client/listRegistrations.js +3 -2
  46. package/dist-esm/src/client/listRegistrations.js.map +1 -1
  47. package/dist-esm/src/client/listRegistrationsByTag.js +3 -2
  48. package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -1
  49. package/dist-esm/src/client/submitNotificationHubJob.js +3 -2
  50. package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -1
  51. package/dist-esm/src/client/updateInstallation.js +3 -2
  52. package/dist-esm/src/client/updateInstallation.js.map +1 -1
  53. package/dist-esm/src/client/updateRegistration.js +2 -1
  54. package/dist-esm/src/client/updateRegistration.js.map +1 -1
  55. package/dist-esm/src/utils/constants.js +1 -0
  56. package/dist-esm/src/utils/constants.js.map +1 -1
  57. package/dist-esm/src/utils/retryPolicy.js +2 -2
  58. package/dist-esm/src/utils/retryPolicy.js.map +1 -1
  59. package/dist-esm/src/utils/tracing.js +2 -1
  60. package/dist-esm/src/utils/tracing.js.map +1 -1
  61. package/package.json +15 -10
  62. package/types/src/{utils → auth}/connectionStringUtils.d.ts +7 -1
  63. package/types/src/auth/connectionStringUtils.d.ts.map +1 -0
  64. package/types/src/auth/hmacSha256.browser.d.ts +2 -0
  65. package/types/src/auth/hmacSha256.browser.d.ts.map +1 -0
  66. package/types/src/auth/hmacSha256.d.ts +2 -0
  67. package/types/src/auth/hmacSha256.d.ts.map +1 -0
  68. package/types/src/auth/sasTokenProvider.d.ts +57 -0
  69. package/types/src/auth/sasTokenProvider.d.ts.map +1 -0
  70. package/types/src/client/cancelScheduledNotification.d.ts.map +1 -1
  71. package/types/src/client/createOrUpdateInstallation.d.ts.map +1 -1
  72. package/types/src/client/createOrUpdateRegistration.d.ts.map +1 -1
  73. package/types/src/client/createRegistration.d.ts.map +1 -1
  74. package/types/src/client/createRegistrationId.d.ts.map +1 -1
  75. package/types/src/client/deleteInstallation.d.ts.map +1 -1
  76. package/types/src/client/deleteRegistration.d.ts.map +1 -1
  77. package/types/src/client/getFeedbackContainerUrl.d.ts.map +1 -1
  78. package/types/src/client/getInstallation.d.ts.map +1 -1
  79. package/types/src/client/getNotificationHubJob.d.ts.map +1 -1
  80. package/types/src/client/getNotificationOutcomeDetails.d.ts.map +1 -1
  81. package/types/src/client/getRegistration.d.ts.map +1 -1
  82. package/types/src/client/index.d.ts +2 -2
  83. package/types/src/client/index.d.ts.map +1 -1
  84. package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +1 -1
  85. package/types/src/client/listNotificationHubJobs.d.ts.map +1 -1
  86. package/types/src/client/listRegistrations.d.ts.map +1 -1
  87. package/types/src/client/listRegistrationsByTag.d.ts.map +1 -1
  88. package/types/src/client/submitNotificationHubJob.d.ts.map +1 -1
  89. package/types/src/client/updateInstallation.d.ts.map +1 -1
  90. package/types/src/client/updateRegistration.d.ts.map +1 -1
  91. package/types/src/utils/constants.d.ts +1 -0
  92. package/types/src/utils/constants.d.ts.map +1 -1
  93. package/types/src/utils/tracing.d.ts.map +1 -1
  94. package/dist/index.js.map +0 -1
  95. package/dist-esm/src/utils/connectionStringUtils.js.map +0 -1
  96. package/types/src/utils/connectionStringUtils.d.ts.map +0 -1
@@ -3,6 +3,7 @@
3
3
  import { createRequest, sendRequest } from "./internal/_client.js";
4
4
  import { registrationDescriptionParser } from "../serializers/registrationSerializer.js";
5
5
  import { tracingClient } from "../utils/tracing.js";
6
+ const OPERATION_NAME = "getRegistration";
6
7
  /**
7
8
  * Gets a registration by the given registration ID.
8
9
  * @param context - The Notification Hubs client.
@@ -11,10 +12,10 @@ import { tracingClient } from "../utils/tracing.js";
11
12
  * @returns A RegistrationDescription that has the given registration ID.
12
13
  */
13
14
  export function getRegistration(context, registrationId, options = {}) {
14
- return tracingClient.withSpan("NotificationHubsClientContext-getRegistration", options, async (updatedOptions) => {
15
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options, async (updatedOptions) => {
15
16
  const endpoint = context.requestUrl();
16
17
  endpoint.pathname += `/registrations/${registrationId}`;
17
- const headers = context.createHeaders();
18
+ const headers = await context.createHeaders(OPERATION_NAME);
18
19
  headers.set("Content-Type", "application/xml;type=entry;charset=utf-8");
19
20
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
20
21
  const response = await sendRequest(context, request, 200);
@@ -1 +1 @@
1
- {"version":3,"file":"getRegistration.js","sourceRoot":"","sources":["../../../src/client/getRegistration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAInE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAsC,EACtC,cAAsB,EACtB,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,+CAA+C,EAC/C,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,kBAAkB,cAAc,EAAE,CAAC;QAExD,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,0CAA0C,CAAC,CAAC;QAExE,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,6BAA6B,CAAC,sBAAsB,CAAC,QAAQ,CAAC,UAAW,CAAC,CAAC;IACpF,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { RegistrationDescription } from \"../models/registration.js\";\nimport { registrationDescriptionParser } from \"../serializers/registrationSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Gets a registration by the given registration ID.\n * @param context - The Notification Hubs client.\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 */\nexport function getRegistration(\n context: NotificationHubsClientContext,\n registrationId: string,\n options: OperationOptions = {}\n): Promise<RegistrationDescription> {\n return tracingClient.withSpan(\n \"NotificationHubsClientContext-getRegistration\",\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += `/registrations/${registrationId}`;\n\n const headers = context.createHeaders();\n headers.set(\"Content-Type\", \"application/xml;type=entry;charset=utf-8\");\n\n const request = createRequest(endpoint, \"GET\", headers, updatedOptions);\n const response = await sendRequest(context, request, 200);\n\n return registrationDescriptionParser.parseRegistrationEntry(response.bodyAsText!);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"getRegistration.js","sourceRoot":"","sources":["../../../src/client/getRegistration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAInE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,iBAAiB,CAAC;AAEzC;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAsC,EACtC,cAAsB,EACtB,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,cAAc,EAAE,EACjD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,kBAAkB,cAAc,EAAE,CAAC;QAExD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,0CAA0C,CAAC,CAAC;QAExE,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,6BAA6B,CAAC,sBAAsB,CAAC,QAAQ,CAAC,UAAW,CAAC,CAAC;IACpF,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { RegistrationDescription } from \"../models/registration.js\";\nimport { registrationDescriptionParser } from \"../serializers/registrationSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"getRegistration\";\n\n/**\n * Gets a registration by the given registration ID.\n * @param context - The Notification Hubs client.\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 */\nexport function getRegistration(\n context: NotificationHubsClientContext,\n registrationId: string,\n options: OperationOptions = {}\n): Promise<RegistrationDescription> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext-${OPERATION_NAME}`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += `/registrations/${registrationId}`;\n\n const headers = await context.createHeaders(OPERATION_NAME);\n headers.set(\"Content-Type\", \"application/xml;type=entry;charset=utf-8\");\n\n const request = createRequest(endpoint, \"GET\", headers, updatedOptions);\n const response = await sendRequest(context, request, 200);\n\n return registrationDescriptionParser.parseRegistrationEntry(response.bodyAsText!);\n }\n );\n}\n"]}
@@ -1,7 +1,8 @@
1
1
  // Copyright (c) Microsoft Corporation.
2
2
  // Licensed under the MIT license.
3
+ import * as constants from "../utils/constants.js";
3
4
  import { createHttpHeaders, } from "@azure/core-rest-pipeline";
4
- import { createTokenProviderFromConnection, parseNotificationHubsConnectionString, } from "../utils/connectionStringUtils.js";
5
+ import { createTokenProviderFromConnection, parseNotificationHubsConnectionString, } from "../auth/connectionStringUtils.js";
5
6
  import { parseXML, stringifyXML } from "@azure/core-xml";
6
7
  import { ServiceClient } from "@azure/core-client";
7
8
  const API_VERSION = "2020-06";
@@ -20,17 +21,20 @@ class NotificationHubsServiceClient extends ServiceClient {
20
21
  parseXML,
21
22
  }, serializationOptions: {
22
23
  stringifyXML,
24
+ }, userAgentOptions: {
25
+ userAgentPrefix: `azsdk-js-messaging-notificationhubs/${constants.SDK_VERSION}`,
23
26
  } }, options));
24
27
  this.hubName = hubName;
25
28
  const parsedConnection = parseNotificationHubsConnectionString(connectionString);
26
29
  this.baseUrl = parsedConnection.endpoint;
27
30
  this.sasTokenProvider = createTokenProviderFromConnection(parsedConnection.sharedAccessKey, parsedConnection.sharedAccessKeyName);
28
31
  }
29
- createHeaders() {
30
- const authorization = this.sasTokenProvider.getToken(this.baseUrl);
32
+ async createHeaders(operationName) {
33
+ const authorization = await this.sasTokenProvider.getToken(this.baseUrl);
31
34
  const headers = createHttpHeaders();
32
35
  headers.set("Authorization", authorization.token);
33
36
  headers.set("x-ms-version", API_VERSION);
37
+ headers.set("x-ms-azsdk-telemetry", `class=NotificationHubsServiceClient;method=${operationName}`);
34
38
  return headers;
35
39
  }
36
40
  requestUrl() {
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAIL,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,GAAG,SAAS,CAAC;AAqC9B;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,gBAAwB,EACxB,OAAe,EACf,UAAyC,EAAE;IAE3C,OAAO,IAAI,6BAA6B,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,6BAA8B,SAAQ,aAAa;IAKvD,YACE,gBAAwB,EACxB,OAAe,EACf,UAAyC,EAAE;QAE3C,KAAK,CAAC,gBACJ,sBAAsB,EAAE;gBACtB,QAAQ;aACT,EACD,oBAAoB,EAAE;gBACpB,YAAY;aACb,IACE,OAAO,CACsB,CAAC,CAAC;QAEpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,MAAM,gBAAgB,GAAG,qCAAqC,CAAC,gBAAgB,CAAC,CAAC;QACjF,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC;QACzC,IAAI,CAAC,gBAAgB,GAAG,iCAAiC,CACvD,gBAAgB,CAAC,eAAe,EAChC,gBAAgB,CAAC,mBAAmB,CACrC,CAAC;IACJ,CAAC;IAED,aAAa;QACX,MAAM,aAAa,GAAG,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACnE,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QAEzC,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,UAAU;QACR,mFAAmF;QACnF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/D,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAEjD,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n HttpHeaders,\n PipelineRequest,\n PipelineResponse,\n createHttpHeaders,\n} from \"@azure/core-rest-pipeline\";\nimport {\n createTokenProviderFromConnection,\n parseNotificationHubsConnectionString,\n} from \"../utils/connectionStringUtils.js\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\nimport { InternalClientPipelineOptions } from \"@azure/core-client\";\nimport { NotificationHubsClientOptions } from \"../models/options.js\";\nimport { SasTokenProvider } from \"@azure/core-amqp\";\nimport { ServiceClient } from \"@azure/core-client\";\n\nconst API_VERSION = \"2020-06\";\n\n/**\n * Represents the Notification Hubs SDK client context.\n */\nexport interface NotificationHubsClientContext {\n /**\n * The SAS Token Provider for connecting to Notification Hubs.\n */\n readonly sasTokenProvider: SasTokenProvider;\n\n /**\n * The base URL for the Notification Hub namespace.\n */\n readonly baseUrl: string;\n\n /**\n * The Notification Hub name.\n */\n readonly hubName: string;\n\n /**\n * @internal\n */\n sendRequest(request: PipelineRequest): Promise<PipelineResponse>;\n\n /**\n * @internal\n */\n createHeaders(): HttpHeaders;\n\n /**\n * @internal\n */\n requestUrl(): URL;\n}\n\n/**\n * Creates a NotificationHubClient from the Access Policy connection string and hub name.\n * @param connectionString - The Access Policy connection string for the notification hub.\n * @param hubName - The notification hub name.\n * @returns A NotificationHubsClientContext initialized from the connection string and hub name.\n */\nexport function createClientContext(\n connectionString: string,\n hubName: string,\n options: NotificationHubsClientOptions = {}\n): NotificationHubsClientContext {\n return new NotificationHubsServiceClient(connectionString, hubName, options);\n}\n\nclass NotificationHubsServiceClient extends ServiceClient implements NotificationHubsClientContext {\n sasTokenProvider: SasTokenProvider;\n baseUrl: string;\n hubName: string;\n\n constructor(\n connectionString: string,\n hubName: string,\n options: NotificationHubsClientOptions = {}\n ) {\n super({\n deserializationOptions: {\n parseXML,\n },\n serializationOptions: {\n stringifyXML,\n },\n ...options,\n } as InternalClientPipelineOptions);\n\n this.hubName = hubName;\n\n const parsedConnection = parseNotificationHubsConnectionString(connectionString);\n this.baseUrl = parsedConnection.endpoint;\n this.sasTokenProvider = createTokenProviderFromConnection(\n parsedConnection.sharedAccessKey,\n parsedConnection.sharedAccessKeyName\n );\n }\n\n createHeaders(): HttpHeaders {\n const authorization = this.sasTokenProvider.getToken(this.baseUrl);\n const headers = createHttpHeaders();\n headers.set(\"Authorization\", authorization.token);\n headers.set(\"x-ms-version\", API_VERSION);\n\n return headers;\n }\n\n requestUrl(): URL {\n // Node doesn't allow change in protocol but browsers do, so doing a string replace\n const url = new URL(this.baseUrl.replace(\"sb://\", \"https://\"));\n url.pathname = this.hubName;\n url.searchParams.set(\"api-version\", API_VERSION);\n\n return url;\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/index.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,KAAK,SAAS,MAAM,uBAAuB,CAAC;AACnD,OAAO,EAIL,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EACL,iCAAiC,EACjC,qCAAqC,GACtC,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAIzD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAEnD,MAAM,WAAW,GAAG,SAAS,CAAC;AAqC9B;;;;;GAKG;AACH,MAAM,UAAU,mBAAmB,CACjC,gBAAwB,EACxB,OAAe,EACf,UAAyC,EAAE;IAE3C,OAAO,IAAI,6BAA6B,CAAC,gBAAgB,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;AAC/E,CAAC;AAED,MAAM,6BAA8B,SAAQ,aAAa;IAKvD,YACE,gBAAwB,EACxB,OAAe,EACf,UAAyC,EAAE;QAE3C,KAAK,CAAC,gBACJ,sBAAsB,EAAE;gBACtB,QAAQ;aACT,EACD,oBAAoB,EAAE;gBACpB,YAAY;aACb,EACD,gBAAgB,EAAE;gBAChB,eAAe,EAAE,uCAAuC,SAAS,CAAC,WAAW,EAAE;aAChF,IACE,OAAO,CACsB,CAAC,CAAC;QAEpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QAEvB,MAAM,gBAAgB,GAAG,qCAAqC,CAAC,gBAAgB,CAAC,CAAC;QACjF,IAAI,CAAC,OAAO,GAAG,gBAAgB,CAAC,QAAQ,CAAC;QACzC,IAAI,CAAC,gBAAgB,GAAG,iCAAiC,CACvD,gBAAgB,CAAC,eAAe,EAChC,gBAAgB,CAAC,mBAAmB,CACrC,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,aAAqB;QACvC,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACzE,MAAM,OAAO,GAAG,iBAAiB,EAAE,CAAC;QACpC,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,aAAa,CAAC,KAAK,CAAC,CAAC;QAClD,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;QACzC,OAAO,CAAC,GAAG,CACT,sBAAsB,EACtB,8CAA8C,aAAa,EAAE,CAC9D,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED,UAAU;QACR,mFAAmF;QACnF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;QAC/D,GAAG,CAAC,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC;QAC5B,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,aAAa,EAAE,WAAW,CAAC,CAAC;QAEjD,OAAO,GAAG,CAAC;IACb,CAAC;CACF","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport * as constants from \"../utils/constants.js\";\nimport {\n HttpHeaders,\n PipelineRequest,\n PipelineResponse,\n createHttpHeaders,\n} from \"@azure/core-rest-pipeline\";\nimport {\n createTokenProviderFromConnection,\n parseNotificationHubsConnectionString,\n} from \"../auth/connectionStringUtils.js\";\nimport { parseXML, stringifyXML } from \"@azure/core-xml\";\nimport { InternalClientPipelineOptions } from \"@azure/core-client\";\nimport { NotificationHubsClientOptions } from \"../models/options.js\";\nimport { SasTokenProvider } from \"../auth/sasTokenProvider.js\";\nimport { ServiceClient } from \"@azure/core-client\";\n\nconst API_VERSION = \"2020-06\";\n\n/**\n * Represents the Notification Hubs SDK client context.\n */\nexport interface NotificationHubsClientContext {\n /**\n * The SAS Token Provider for connecting to Notification Hubs.\n */\n readonly sasTokenProvider: SasTokenProvider;\n\n /**\n * The base URL for the Notification Hub namespace.\n */\n readonly baseUrl: string;\n\n /**\n * The Notification Hub name.\n */\n readonly hubName: string;\n\n /**\n * @internal\n */\n sendRequest(request: PipelineRequest): Promise<PipelineResponse>;\n\n /**\n * @internal\n */\n createHeaders(operationName: string): Promise<HttpHeaders>;\n\n /**\n * @internal\n */\n requestUrl(): URL;\n}\n\n/**\n * Creates a NotificationHubClient from the Access Policy connection string and hub name.\n * @param connectionString - The Access Policy connection string for the notification hub.\n * @param hubName - The notification hub name.\n * @returns A NotificationHubsClientContext initialized from the connection string and hub name.\n */\nexport function createClientContext(\n connectionString: string,\n hubName: string,\n options: NotificationHubsClientOptions = {}\n): NotificationHubsClientContext {\n return new NotificationHubsServiceClient(connectionString, hubName, options);\n}\n\nclass NotificationHubsServiceClient extends ServiceClient implements NotificationHubsClientContext {\n sasTokenProvider: SasTokenProvider;\n baseUrl: string;\n hubName: string;\n\n constructor(\n connectionString: string,\n hubName: string,\n options: NotificationHubsClientOptions = {}\n ) {\n super({\n deserializationOptions: {\n parseXML,\n },\n serializationOptions: {\n stringifyXML,\n },\n userAgentOptions: {\n userAgentPrefix: `azsdk-js-messaging-notificationhubs/${constants.SDK_VERSION}`,\n },\n ...options,\n } as InternalClientPipelineOptions);\n\n this.hubName = hubName;\n\n const parsedConnection = parseNotificationHubsConnectionString(connectionString);\n this.baseUrl = parsedConnection.endpoint;\n this.sasTokenProvider = createTokenProviderFromConnection(\n parsedConnection.sharedAccessKey,\n parsedConnection.sharedAccessKeyName\n );\n }\n\n async createHeaders(operationName: string): Promise<HttpHeaders> {\n const authorization = await this.sasTokenProvider.getToken(this.baseUrl);\n const headers = createHttpHeaders();\n headers.set(\"Authorization\", authorization.token);\n headers.set(\"x-ms-version\", API_VERSION);\n headers.set(\n \"x-ms-azsdk-telemetry\",\n `class=NotificationHubsServiceClient;method=${operationName}`\n );\n\n return headers;\n }\n\n requestUrl(): URL {\n // Node doesn't allow change in protocol but browsers do, so doing a string replace\n const url = new URL(this.baseUrl.replace(\"sb://\", \"https://\"));\n url.pathname = this.hubName;\n url.searchParams.set(\"api-version\", API_VERSION);\n\n return url;\n }\n}\n"]}
@@ -18,7 +18,7 @@ export async function createOrUpdateRegistrationDescription(context, registratio
18
18
  // Clear out readonly properties
19
19
  registration.registrationId = undefined;
20
20
  registration.etag = undefined;
21
- const headers = context.createHeaders();
21
+ const headers = await context.createHeaders(`${operationName}Registration`);
22
22
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
23
23
  if (operationName === "update") {
24
24
  headers.set("If-Match", isDefined(etag) ? `"${etag}"` : "*");
@@ -1 +1 @@
1
- {"version":3,"file":"_createOrUpdateRegistrationDescription.js","sourceRoot":"","sources":["../../../../src/client/internal/_createOrUpdateRegistrationDescription.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,GAClC,MAAM,6CAA6C,CAAC;AAKrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,OAAsC,EACtC,YAAqC,EACrC,aAAqD,EACrD,OAAyB;IAEzB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,IAAI,gBAAgB,CAAC;IACtC,IAAI,UAAU,GAAgB,MAAM,CAAC;IAErC,IAAI,aAAa,KAAK,gBAAgB,IAAI,aAAa,KAAK,QAAQ,EAAE;QACpE,QAAQ,CAAC,QAAQ,IAAI,IAAI,YAAY,CAAC,cAAc,EAAE,CAAC;QACvD,UAAU,GAAG,KAAK,CAAC;KACpB;IAED,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;IAE/B,gCAAgC;IAChC,YAAY,CAAC,cAAc,GAAG,SAAS,CAAC;IACxC,YAAY,CAAC,IAAI,GAAG,SAAS,CAAC;IAE9B,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IACxC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,+CAA+C,CAAC,CAAC;IAE7E,IAAI,aAAa,KAAK,QAAQ,EAAE;QAC9B,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KAC9D;IAED,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACtE,OAAO,CAAC,IAAI,GAAG,iCAAiC,CAAC,gCAAgC,CAAC,YAAY,CAAC,CAAC;IAChG,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjE,OAAO,6BAA6B,CAAC,sBAAsB,CAAC,QAAQ,CAAC,UAAW,CAAC,CAAC;AACpF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./_client.js\";\nimport {\n registrationDescriptionParser,\n registrationDescriptionSerializer,\n} from \"../../serializers/registrationSerializer.js\";\nimport { HttpMethods } from \"@azure/core-rest-pipeline\";\nimport { NotificationHubsClientContext } from \"../index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { RegistrationDescription } from \"../../models/registration.js\";\nimport { isDefined } from \"../../utils/utils.js\";\n\n/**\n * @internal\n */\nexport async function createOrUpdateRegistrationDescription(\n context: NotificationHubsClientContext,\n registration: RegistrationDescription,\n operationName: \"create\" | \"createOrUpdate\" | \"update\",\n options: OperationOptions\n): Promise<RegistrationDescription> {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/registrations\";\n let httpMethod: HttpMethods = \"POST\";\n\n if (operationName === \"createOrUpdate\" || operationName === \"update\") {\n endpoint.pathname += `/${registration.registrationId}`;\n httpMethod = \"PUT\";\n }\n\n const etag = registration.etag;\n\n // Clear out readonly properties\n registration.registrationId = undefined;\n registration.etag = undefined;\n\n const headers = context.createHeaders();\n headers.set(\"Content-Type\", \"application/atom+xml;type=entry;charset=utf-8\");\n\n if (operationName === \"update\") {\n headers.set(\"If-Match\", isDefined(etag) ? `\"${etag}\"` : \"*\");\n }\n\n const request = createRequest(endpoint, httpMethod, headers, options);\n request.body = registrationDescriptionSerializer.serializeRegistrationDescription(registration);\n const response = await sendRequest(context, request, [200, 201]);\n\n return registrationDescriptionParser.parseRegistrationEntry(response.bodyAsText!);\n}\n"]}
1
+ {"version":3,"file":"_createOrUpdateRegistrationDescription.js","sourceRoot":"","sources":["../../../../src/client/internal/_createOrUpdateRegistrationDescription.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EACL,6BAA6B,EAC7B,iCAAiC,GAClC,MAAM,6CAA6C,CAAC;AAKrD,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAEjD;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,qCAAqC,CACzD,OAAsC,EACtC,YAAqC,EACrC,aAAqD,EACrD,OAAyB;IAEzB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,IAAI,gBAAgB,CAAC;IACtC,IAAI,UAAU,GAAgB,MAAM,CAAC;IAErC,IAAI,aAAa,KAAK,gBAAgB,IAAI,aAAa,KAAK,QAAQ,EAAE;QACpE,QAAQ,CAAC,QAAQ,IAAI,IAAI,YAAY,CAAC,cAAc,EAAE,CAAC;QACvD,UAAU,GAAG,KAAK,CAAC;KACpB;IAED,MAAM,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;IAE/B,gCAAgC;IAChC,YAAY,CAAC,cAAc,GAAG,SAAS,CAAC;IACxC,YAAY,CAAC,IAAI,GAAG,SAAS,CAAC;IAE9B,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,GAAG,aAAa,cAAc,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,+CAA+C,CAAC,CAAC;IAE7E,IAAI,aAAa,KAAK,QAAQ,EAAE;QAC9B,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;KAC9D;IAED,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACtE,OAAO,CAAC,IAAI,GAAG,iCAAiC,CAAC,gCAAgC,CAAC,YAAY,CAAC,CAAC;IAChG,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC;IAEjE,OAAO,6BAA6B,CAAC,sBAAsB,CAAC,QAAQ,CAAC,UAAW,CAAC,CAAC;AACpF,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./_client.js\";\nimport {\n registrationDescriptionParser,\n registrationDescriptionSerializer,\n} from \"../../serializers/registrationSerializer.js\";\nimport { HttpMethods } from \"@azure/core-rest-pipeline\";\nimport { NotificationHubsClientContext } from \"../index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { RegistrationDescription } from \"../../models/registration.js\";\nimport { isDefined } from \"../../utils/utils.js\";\n\n/**\n * @internal\n */\nexport async function createOrUpdateRegistrationDescription(\n context: NotificationHubsClientContext,\n registration: RegistrationDescription,\n operationName: \"create\" | \"createOrUpdate\" | \"update\",\n options: OperationOptions\n): Promise<RegistrationDescription> {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/registrations\";\n let httpMethod: HttpMethods = \"POST\";\n\n if (operationName === \"createOrUpdate\" || operationName === \"update\") {\n endpoint.pathname += `/${registration.registrationId}`;\n httpMethod = \"PUT\";\n }\n\n const etag = registration.etag;\n\n // Clear out readonly properties\n registration.registrationId = undefined;\n registration.etag = undefined;\n\n const headers = await context.createHeaders(`${operationName}Registration`);\n headers.set(\"Content-Type\", \"application/atom+xml;type=entry;charset=utf-8\");\n\n if (operationName === \"update\") {\n headers.set(\"If-Match\", isDefined(etag) ? `\"${etag}\"` : \"*\");\n }\n\n const request = createRequest(endpoint, httpMethod, headers, options);\n request.body = registrationDescriptionSerializer.serializeRegistrationDescription(registration);\n const response = await sendRequest(context, request, [200, 201]);\n\n return registrationDescriptionParser.parseRegistrationEntry(response.bodyAsText!);\n}\n"]}
@@ -2,14 +2,15 @@
2
2
  // Licensed under the MIT license.
3
3
  import { createRequest, parseNotificationSendResponse, sendRequest } from "./_client.js";
4
4
  import { tracingClient } from "../../utils/tracing.js";
5
+ const OPERATION_NAME = "scheduleNotificationPayload";
5
6
  /**
6
7
  * @internal
7
8
  */
8
9
  export function scheduleNotificationPayload(context, scheduledTime, tags, notification, options = {}) {
9
- return tracingClient.withSpan("NotificationHubsClientContext-$scheduleNotification", options, async (updatedOptions) => {
10
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options, async (updatedOptions) => {
10
11
  const endpoint = context.requestUrl();
11
12
  endpoint.pathname += "/schedulednotifications/";
12
- const headers = context.createHeaders();
13
+ const headers = await context.createHeaders(OPERATION_NAME);
13
14
  if (notification.headers) {
14
15
  for (const headerName of Object.keys(notification.headers)) {
15
16
  headers.set(headerName, notification.headers[headerName]);
@@ -1 +1 @@
1
- {"version":3,"file":"_scheduleNotificationPayload.js","sourceRoot":"","sources":["../../../../src/client/internal/_scheduleNotificationPayload.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKzF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;GAEG;AAEH,MAAM,UAAU,2BAA2B,CACzC,OAAsC,EACtC,aAAmB,EACnB,IAAmC,EACnC,YAA0B,EAC1B,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,qDAAqD,EACrD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,0BAA0B,CAAC;QAEhD,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QACxC,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE;gBAC1D,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;aAC3D;SACF;QAED,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;QAChF,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;QAEpE,IAAI,IAAI,EAAE;YACR,IAAI,aAAa,GAAG,IAAI,CAAC;YACzB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACvB,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACjC;iBAAM;gBACL,aAAa,GAAG,IAAI,CAAC;aACtB;YACD,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,aAAa,CAAC,CAAC;SAC3D;QAED,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;QAEjC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, parseNotificationSendResponse, sendRequest } from \"./_client.js\";\nimport { Notification } from \"../../models/notification.js\";\nimport { NotificationHubsClientContext } from \"../index.js\";\nimport { NotificationHubsMessageResponse } from \"../../models/response.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { tracingClient } from \"../../utils/tracing.js\";\n\n/**\n * @internal\n */\n\nexport function scheduleNotificationPayload(\n context: NotificationHubsClientContext,\n scheduledTime: Date,\n tags: string[] | string | undefined,\n notification: Notification,\n options: OperationOptions = {}\n): Promise<NotificationHubsMessageResponse> {\n return tracingClient.withSpan(\n \"NotificationHubsClientContext-$scheduleNotification\",\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/schedulednotifications/\";\n\n const headers = context.createHeaders();\n if (notification.headers) {\n for (const headerName of Object.keys(notification.headers)) {\n headers.set(headerName, notification.headers[headerName]);\n }\n }\n\n headers.set(\"ServiceBusNotification-ScheduleTime\", scheduledTime.toISOString());\n headers.set(\"Content-Type\", notification.contentType);\n headers.set(\"ServiceBusNotification-Format\", notification.platform);\n\n if (tags) {\n let tagExpression = null;\n if (Array.isArray(tags)) {\n tagExpression = tags.join(\"||\");\n } else {\n tagExpression = tags;\n }\n headers.set(\"ServiceBusNotification-Tags\", tagExpression);\n }\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n request.body = notification.body;\n\n const response = await sendRequest(context, request, 201);\n\n return parseNotificationSendResponse(response);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"_scheduleNotificationPayload.js","sourceRoot":"","sources":["../../../../src/client/internal/_scheduleNotificationPayload.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKzF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAErD;;GAEG;AACH,MAAM,UAAU,2BAA2B,CACzC,OAAsC,EACtC,aAAmB,EACnB,IAAmC,EACnC,YAA0B,EAC1B,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,cAAc,EAAE,EACjD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,0BAA0B,CAAC;QAEhD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAC5D,IAAI,YAAY,CAAC,OAAO,EAAE;YACxB,KAAK,MAAM,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,EAAE;gBAC1D,OAAO,CAAC,GAAG,CAAC,UAAU,EAAE,YAAY,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC;aAC3D;SACF;QAED,OAAO,CAAC,GAAG,CAAC,qCAAqC,EAAE,aAAa,CAAC,WAAW,EAAE,CAAC,CAAC;QAChF,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,YAAY,CAAC,WAAW,CAAC,CAAC;QACtD,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,YAAY,CAAC,QAAQ,CAAC,CAAC;QAEpE,IAAI,IAAI,EAAE;YACR,IAAI,aAAa,GAAG,IAAI,CAAC;YACzB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;gBACvB,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACjC;iBAAM;gBACL,aAAa,GAAG,IAAI,CAAC;aACtB;YACD,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,aAAa,CAAC,CAAC;SAC3D;QAED,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;QAEjC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, parseNotificationSendResponse, sendRequest } from \"./_client.js\";\nimport { Notification } from \"../../models/notification.js\";\nimport { NotificationHubsClientContext } from \"../index.js\";\nimport { NotificationHubsMessageResponse } from \"../../models/response.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { tracingClient } from \"../../utils/tracing.js\";\n\nconst OPERATION_NAME = \"scheduleNotificationPayload\";\n\n/**\n * @internal\n */\nexport function scheduleNotificationPayload(\n context: NotificationHubsClientContext,\n scheduledTime: Date,\n tags: string[] | string | undefined,\n notification: Notification,\n options: OperationOptions = {}\n): Promise<NotificationHubsMessageResponse> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext-${OPERATION_NAME}`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/schedulednotifications/\";\n\n const headers = await context.createHeaders(OPERATION_NAME);\n if (notification.headers) {\n for (const headerName of Object.keys(notification.headers)) {\n headers.set(headerName, notification.headers[headerName]);\n }\n }\n\n headers.set(\"ServiceBusNotification-ScheduleTime\", scheduledTime.toISOString());\n headers.set(\"Content-Type\", notification.contentType);\n headers.set(\"ServiceBusNotification-Format\", notification.platform);\n\n if (tags) {\n let tagExpression = null;\n if (Array.isArray(tags)) {\n tagExpression = tags.join(\"||\");\n } else {\n tagExpression = tags;\n }\n headers.set(\"ServiceBusNotification-Tags\", tagExpression);\n }\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n request.body = notification.body;\n\n const response = await sendRequest(context, request, 201);\n\n return parseNotificationSendResponse(response);\n }\n );\n}\n"]}
@@ -12,7 +12,7 @@ export function sendNotificationPayload(context, notification, method, pushHandl
12
12
  if (options.enableTestSend) {
13
13
  endpoint.searchParams.append("debug", "true");
14
14
  }
15
- const headers = context.createHeaders();
15
+ const headers = await context.createHeaders(method);
16
16
  if (notification.headers) {
17
17
  for (const headerName of Object.keys(notification.headers)) {
18
18
  headers.set(headerName, notification.headers[headerName]);
@@ -1 +1 @@
1
- {"version":3,"file":"_sendNotificationPayload.js","sourceRoot":"","sources":["../../../../src/client/internal/_sendNotificationPayload.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKzF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAsC,EACtC,YAA0B,EAC1B,MAAc,EACd,UAAuB,EACvB,IAAwB,EACxB,UAAgC,EAAE;IAElC,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,MAAM,EAAE,EACzC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ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AC,EAAE;gBACvB,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACjC;iBAAM;gBACL,aAAa,GAAG,IAAI,CAAC;aACtB;YACD,OAAO,CAAC,GAAG,CAAC,6BAA6B,EAAE,aAAa,CAAC,CAAC;SAC3D;QAED,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;QAEjC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { BrowserPushChannel, PushHandle } from \"../../models/installation.js\";\nimport { createRequest, parseNotificationSendResponse, sendRequest } from \"./_client.js\";\nimport { Notification } from \"../../models/notification.js\";\nimport { NotificationHubsClientContext } from \"../index.js\";\nimport { NotificationHubsMessageResponse } from \"../../models/response.js\";\nimport { SendOperationOptions } from \"../../models/options.js\";\nimport { tracingClient } from \"../../utils/tracing.js\";\n\n/**\n * @internal\n */\nexport function sendNotificationPayload(\n context: NotificationHubsClientContext,\n notification: Notification,\n method: string,\n pushHandle?: PushHandle,\n tags?: string | string[],\n options: SendOperationOptions = {}\n): Promise<NotificationHubsMessageResponse> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext-${method}`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/messages/\";\n\n if (options.enableTestSend) {\n endpoint.searchParams.append(\"debug\", \"true\");\n }\n\n const headers = context.createHeaders();\n if (notification.headers) {\n for (const headerName of Object.keys(notification.headers)) {\n headers.set(headerName, notification.headers[headerName]);\n }\n }\n\n if (pushHandle) {\n endpoint.searchParams.append(\"direct\", \"true\");\n\n if (notification.platform === \"browser\") {\n const browserHandle = pushHandle as BrowserPushChannel;\n headers.set(\"ServiceBusNotification-DeviceHandle\", browserHandle.endpoint);\n headers.set(\"Auth\", browserHandle.auth);\n headers.set(\"P256DH\", browserHandle.p256dh);\n } else {\n headers.set(\"ServiceBusNotification-DeviceHandle\", pushHandle as string);\n }\n }\n\n headers.set(\"Content-Type\", notification.contentType);\n headers.set(\"ServiceBusNotification-Format\", notification.platform);\n\n if (tags) {\n let tagExpression = null;\n if (Array.isArray(tags)) {\n tagExpression = tags.join(\"||\");\n } else {\n tagExpression = tags;\n }\n headers.set(\"ServiceBusNotification-Tags\", tagExpression);\n }\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n request.body = notification.body;\n\n const response = await sendRequest(context, request, 201);\n\n return parseNotificationSendResponse(response);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"_sendNotificationPayload.js","sourceRoot":"","sources":["../../../../src/client/internal/_sendNotificationPayload.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAGlC,OAAO,EAAE,aAAa,EAAE,6BAA6B,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAKzF,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAEvD;;GAEG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAsC,EACtC,YAA0B,EAC1B,MAAc,EACd,UAAuB,EACvB,IAAwB,EACxB,UAAgC,EAAE;IAElC,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,MAAM,EAAE,EACzC,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,YAAY,CAAC;QAElC,IAAI,OAAO,CAAC,cAAc,EAAE;YAC1B,QAAQ,CAAC,YAAY,CAAC,MAAM,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;SAC/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;SAC3D;QAED,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;QAEjC,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,6BAA6B,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { BrowserPushChannel, PushHandle } from \"../../models/installation.js\";\nimport { createRequest, parseNotificationSendResponse, sendRequest } from \"./_client.js\";\nimport { Notification } from \"../../models/notification.js\";\nimport { NotificationHubsClientContext } from \"../index.js\";\nimport { NotificationHubsMessageResponse } from \"../../models/response.js\";\nimport { SendOperationOptions } from \"../../models/options.js\";\nimport { tracingClient } from \"../../utils/tracing.js\";\n\n/**\n * @internal\n */\nexport function sendNotificationPayload(\n context: NotificationHubsClientContext,\n notification: Notification,\n method: string,\n pushHandle?: PushHandle,\n tags?: string | string[],\n options: SendOperationOptions = {}\n): Promise<NotificationHubsMessageResponse> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext-${method}`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/messages/\";\n\n if (options.enableTestSend) {\n endpoint.searchParams.append(\"debug\", \"true\");\n }\n\n const headers = await context.createHeaders(method);\n if (notification.headers) {\n for (const headerName of Object.keys(notification.headers)) {\n headers.set(headerName, notification.headers[headerName]);\n }\n }\n\n if (pushHandle) {\n endpoint.searchParams.append(\"direct\", \"true\");\n\n if (notification.platform === \"browser\") {\n const browserHandle = pushHandle as BrowserPushChannel;\n headers.set(\"ServiceBusNotification-DeviceHandle\", browserHandle.endpoint);\n headers.set(\"Auth\", browserHandle.auth);\n headers.set(\"P256DH\", browserHandle.p256dh);\n } else {\n headers.set(\"ServiceBusNotification-DeviceHandle\", pushHandle as string);\n }\n }\n\n headers.set(\"Content-Type\", notification.contentType);\n headers.set(\"ServiceBusNotification-Format\", notification.platform);\n\n if (tags) {\n let tagExpression = null;\n if (Array.isArray(tags)) {\n tagExpression = tags.join(\"||\");\n } else {\n tagExpression = tags;\n }\n headers.set(\"ServiceBusNotification-Tags\", tagExpression);\n }\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n request.body = notification.body;\n\n const response = await sendRequest(context, request, 201);\n\n return parseNotificationSendResponse(response);\n }\n );\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  import { createRequest, sendRequest } from "./internal/_client.js";
4
4
  import { parseNotificationHubJobFeed } from "../serializers/notificationHubJobSerializer.js";
5
5
  import { tracingClient } from "../utils/tracing.js";
6
+ const OPERATION_NAME = "listNotificationHubJobs";
6
7
  /**
7
8
  * Gets all Notification Hub Jobs for this Notification Hub.
8
9
  * @param context - The Notification Hubs client.xs
@@ -10,10 +11,10 @@ import { tracingClient } from "../utils/tracing.js";
10
11
  * @returns An array of all Notification Hub Jobs for this Notification Hub.
11
12
  */
12
13
  export function listNotificationHubJobs(context, options = {}) {
13
- return tracingClient.withSpan("NotificationHubsClientContext-getNotificationHubJobs", options, async (updatedOptions) => {
14
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options, async (updatedOptions) => {
14
15
  const endpoint = context.requestUrl();
15
16
  endpoint.pathname += "/jobs";
16
- const headers = context.createHeaders();
17
+ const headers = await context.createHeaders(OPERATION_NAME);
17
18
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
18
19
  const request = createRequest(endpoint, "GET", headers, updatedOptions);
19
20
  const response = await sendRequest(context, request, 200);
@@ -1 +1 @@
1
- {"version":3,"file":"listNotificationHubJobs.js","sourceRoot":"","sources":["../../../src/client/listNotificationHubJobs.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAInE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAsC,EACtC,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,sDAAsD,EACtD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC;QAE7B,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,+CAA+C,CAAC,CAAC;QAE7E,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,2BAA2B,CAAC,QAAQ,CAAC,UAAW,CAAC,CAAC;IAC3D,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubJob } from \"../models/notificationHubJob.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { parseNotificationHubJobFeed } from \"../serializers/notificationHubJobSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Gets all Notification Hub Jobs for this Notification Hub.\n * @param context - The Notification Hubs client.xs\n * @param options - The operation options.\n * @returns An array of all Notification Hub Jobs for this Notification Hub.\n */\nexport function listNotificationHubJobs(\n context: NotificationHubsClientContext,\n options: OperationOptions = {}\n): Promise<NotificationHubJob[]> {\n return tracingClient.withSpan(\n \"NotificationHubsClientContext-getNotificationHubJobs\",\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/jobs\";\n\n const headers = context.createHeaders();\n headers.set(\"Content-Type\", \"application/atom+xml;type=entry;charset=utf-8\");\n\n const request = createRequest(endpoint, \"GET\", headers, updatedOptions);\n const response = await sendRequest(context, request, 200);\n\n return parseNotificationHubJobFeed(response.bodyAsText!);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"listNotificationHubJobs.js","sourceRoot":"","sources":["../../../src/client/listNotificationHubJobs.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAInE,OAAO,EAAE,2BAA2B,EAAE,MAAM,gDAAgD,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,yBAAyB,CAAC;AAEjD;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,OAAsC,EACtC,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,cAAc,EAAE,EACjD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC;QAE7B,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,+CAA+C,CAAC,CAAC;QAE7E,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACxE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,2BAA2B,CAAC,QAAQ,CAAC,UAAW,CAAC,CAAC;IAC3D,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubJob } from \"../models/notificationHubJob.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { parseNotificationHubJobFeed } from \"../serializers/notificationHubJobSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"listNotificationHubJobs\";\n\n/**\n * Gets all Notification Hub Jobs for this Notification Hub.\n * @param context - The Notification Hubs client.xs\n * @param options - The operation options.\n * @returns An array of all Notification Hub Jobs for this Notification Hub.\n */\nexport function listNotificationHubJobs(\n context: NotificationHubsClientContext,\n options: OperationOptions = {}\n): Promise<NotificationHubJob[]> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext-${OPERATION_NAME}`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/jobs\";\n\n const headers = await context.createHeaders(OPERATION_NAME);\n headers.set(\"Content-Type\", \"application/atom+xml;type=entry;charset=utf-8\");\n\n const request = createRequest(endpoint, \"GET\", headers, updatedOptions);\n const response = await sendRequest(context, request, 200);\n\n return parseNotificationHubJobFeed(response.bodyAsText!);\n }\n );\n}\n"]}
@@ -4,6 +4,7 @@ import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tsli
4
4
  import { createRequest, sendRequest } from "./internal/_client.js";
5
5
  import { registrationDescriptionParser } from "../serializers/registrationSerializer.js";
6
6
  import { tracingClient } from "../utils/tracing.js";
7
+ const OPERATION_NAME = "listRegistrations";
7
8
  /**
8
9
  * Gets all registrations for the notification hub with the given query options.
9
10
  * @param context - The Notification Hubs client.
@@ -11,7 +12,7 @@ import { tracingClient } from "../utils/tracing.js";
11
12
  * @returns A paged async iterable containing all of the registrations for the notification hub.
12
13
  */
13
14
  export function listRegistrations(context, options = {}) {
14
- const { span, updatedOptions } = tracingClient.startSpan("NotificationHubsClientContext-listRegistrations", options);
15
+ const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options);
15
16
  try {
16
17
  const iter = listRegistrationsAll(context, updatedOptions);
17
18
  return {
@@ -76,7 +77,7 @@ async function _listRegistrations(context, options, continuationToken) {
76
77
  if (continuationToken !== undefined) {
77
78
  endpoint.searchParams.set("continuationtoken", continuationToken);
78
79
  }
79
- const headers = context.createHeaders();
80
+ const headers = await context.createHeaders(OPERATION_NAME);
80
81
  const request = createRequest(endpoint, "GET", headers, options);
81
82
  const response = await sendRequest(context, request, 200);
82
83
  const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
@@ -1 +1 @@
1
- {"version":3,"file":"listRegistrations.js","sourceRoot":"","sources":["../../../src/client/listRegistrations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAsC,EACtC,UAAoC,EAAE;IAEtC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,iDAAiD,EACjD,OAAO,CACR,CAAC;IACF,IAAI;QACF,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC3D,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM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;IACtC,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE;QAC7B,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;KACrD;IAED,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE;QAChC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;KACtD;IAED,IAAI,iBAAiB,KAAK,SAAS,EAAE;QACnC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;KACnE;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAExC,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAE1D,MAAM,aAAa,GAAG,MAAM,6BAA6B,CAAC,qBAAqB,CAC7E,QAAQ,CAAC,UAAW,CACrB,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACjE,OAAO;QACL,aAAa;QACb,iBAAiB,EAAE,SAAS;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { RegistrationDescription } from \"../models/registration.js\";\nimport { RegistrationQueryOptions } from \"../models/options.js\";\nimport { RegistrationQueryResponse } from \"../models/response.js\";\nimport { registrationDescriptionParser } from \"../serializers/registrationSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Gets all registrations for the notification hub with the given query options.\n * @param context - The Notification Hubs client.\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 */\nexport function listRegistrations(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions = {}\n): PagedAsyncIterableIterator<RegistrationDescription> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"NotificationHubsClientContext-listRegistrations\",\n options\n );\n try {\n const iter = listRegistrationsAll(context, updatedOptions);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return listRegistrationPagingPage(context, options);\n },\n };\n } catch (e: any) {\n span.setStatus({ status: \"error\", error: e });\n throw e;\n } finally {\n span.end();\n }\n}\n\nasync function* listRegistrationsAll(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions\n): AsyncIterableIterator<RegistrationDescription> {\n for await (const page of listRegistrationPagingPage(context, options)) {\n yield* page;\n }\n}\n\nasync function* listRegistrationPagingPage(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions\n): AsyncIterableIterator<RegistrationDescription[]> {\n let result = await _listRegistrations(context, options);\n yield result.registrations || [];\n let continuationToken = result.continuationToken;\n while (continuationToken) {\n result = await _listRegistrations(context, options, continuationToken);\n continuationToken = result.continuationToken;\n yield result.registrations || [];\n }\n}\n\nasync function _listRegistrations(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions,\n continuationToken?: string\n): Promise<RegistrationQueryResponse> {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/registrations\";\n if (options.top !== undefined) {\n endpoint.searchParams.set(\"$top\", `${options.top}`);\n }\n\n if (options.filter !== undefined) {\n endpoint.searchParams.set(\"$filter\", options.filter);\n }\n\n if (continuationToken !== undefined) {\n endpoint.searchParams.set(\"continuationtoken\", continuationToken);\n }\n\n const headers = context.createHeaders();\n\n const request = createRequest(endpoint, \"GET\", headers, options);\n const response = await sendRequest(context, request, 200);\n\n const registrations = await registrationDescriptionParser.parseRegistrationFeed(\n response.bodyAsText!\n );\n const nextToken = response.headers.get(\"x-ms-continuationtoken\");\n return {\n registrations,\n continuationToken: nextToken,\n };\n}\n"]}
1
+ {"version":3,"file":"listRegistrations.js","sourceRoot":"","sources":["../../../src/client/listRegistrations.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,mBAAmB,CAAC;AAE3C;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAsC,EACtC,UAAoC,EAAE;IAEtC,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,iCAAiC,cAAc,EAAE,EACjD,OAAO,CACR,CAAC;IACF,IAAI;QACF,MAAM,IAAI,GAAG,oBAAoB,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC;QAC3D,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,GAAG,EAAE;gBACX,OAAO,0BAA0B,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YACtD,CAAC;SACF,CAAC;KACH;IAAC,OAAO,CAAM,EAAE;QACf,IAAI,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,CAAC;KACT;YAAS;QACR,IAAI,CAAC,GAAG,EAAE,CAAC;KACZ;AACH,CAAC;AAED,SAAgB,oBAAoB,CAClC,OAAsC,EACtC,OAAiC;;;;YAEjC,KAAyB,IAAA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,EAAE,iBAAiB,CAAC,CAAC;KACnE;IAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAE1D,MAAM,aAAa,GAAG,MAAM,6BAA6B,CAAC,qBAAqB,CAC7E,QAAQ,CAAC,UAAW,CACrB,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACjE,OAAO;QACL,aAAa;QACb,iBAAiB,EAAE,SAAS;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { RegistrationDescription } from \"../models/registration.js\";\nimport { RegistrationQueryOptions } from \"../models/options.js\";\nimport { RegistrationQueryResponse } from \"../models/response.js\";\nimport { registrationDescriptionParser } from \"../serializers/registrationSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"listRegistrations\";\n\n/**\n * Gets all registrations for the notification hub with the given query options.\n * @param context - The Notification Hubs client.\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 */\nexport function listRegistrations(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions = {}\n): PagedAsyncIterableIterator<RegistrationDescription> {\n const { span, updatedOptions } = tracingClient.startSpan(\n `NotificationHubsClientContext-${OPERATION_NAME}`,\n options\n );\n try {\n const iter = listRegistrationsAll(context, updatedOptions);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return listRegistrationPagingPage(context, options);\n },\n };\n } catch (e: any) {\n span.setStatus({ status: \"error\", error: e });\n throw e;\n } finally {\n span.end();\n }\n}\n\nasync function* listRegistrationsAll(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions\n): AsyncIterableIterator<RegistrationDescription> {\n for await (const page of listRegistrationPagingPage(context, options)) {\n yield* page;\n }\n}\n\nasync function* listRegistrationPagingPage(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions\n): AsyncIterableIterator<RegistrationDescription[]> {\n let result = await _listRegistrations(context, options);\n yield result.registrations || [];\n let continuationToken = result.continuationToken;\n while (continuationToken) {\n result = await _listRegistrations(context, options, continuationToken);\n continuationToken = result.continuationToken;\n yield result.registrations || [];\n }\n}\n\nasync function _listRegistrations(\n context: NotificationHubsClientContext,\n options: RegistrationQueryOptions,\n continuationToken?: string\n): Promise<RegistrationQueryResponse> {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/registrations\";\n if (options.top !== undefined) {\n endpoint.searchParams.set(\"$top\", `${options.top}`);\n }\n\n if (options.filter !== undefined) {\n endpoint.searchParams.set(\"$filter\", options.filter);\n }\n\n if (continuationToken !== undefined) {\n endpoint.searchParams.set(\"continuationtoken\", continuationToken);\n }\n\n const headers = await context.createHeaders(OPERATION_NAME);\n const request = createRequest(endpoint, \"GET\", headers, options);\n const response = await sendRequest(context, request, 200);\n\n const registrations = await registrationDescriptionParser.parseRegistrationFeed(\n response.bodyAsText!\n );\n const nextToken = response.headers.get(\"x-ms-continuationtoken\");\n return {\n registrations,\n continuationToken: nextToken,\n };\n}\n"]}
@@ -4,6 +4,7 @@ import { __asyncDelegator, __asyncGenerator, __asyncValues, __await } from "tsli
4
4
  import { createRequest, sendRequest } from "./internal/_client.js";
5
5
  import { registrationDescriptionParser } from "../serializers/registrationSerializer.js";
6
6
  import { tracingClient } from "../utils/tracing.js";
7
+ const OPERATION_NAME = "listRegistrationsByTag";
7
8
  /**
8
9
  * Lists all registrations with the matching tag.
9
10
  * @param context - The Notification Hubs client.
@@ -12,7 +13,7 @@ import { tracingClient } from "../utils/tracing.js";
12
13
  * @returns A paged async iterable containing the matching registrations for the notification hub.
13
14
  */
14
15
  export function listRegistrationsByTag(context, tag, options = {}) {
15
- const { span, updatedOptions } = tracingClient.startSpan("NotificationHubsClientContext-listRegistrationsByTag", options);
16
+ const { span, updatedOptions } = tracingClient.startSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options);
16
17
  try {
17
18
  const iter = listRegistrationsByTagAll(context, tag, updatedOptions);
18
19
  return {
@@ -74,7 +75,7 @@ async function _listRegistrationsByTag(context, tag, options, continuationToken)
74
75
  if (continuationToken !== undefined) {
75
76
  endpoint.searchParams.set("continuationtoken", continuationToken);
76
77
  }
77
- const headers = context.createHeaders();
78
+ const headers = await context.createHeaders(OPERATION_NAME);
78
79
  const request = createRequest(endpoint, "GET", headers, options);
79
80
  const response = await sendRequest(context, request, 200);
80
81
  const registrations = await registrationDescriptionParser.parseRegistrationFeed(response.bodyAsText);
@@ -1 +1 @@
1
- {"version":3,"file":"listRegistrationsByTag.js","sourceRoot":"","sources":["../../../src/client/listRegistrationsByTag.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAsC,EACtC,GAAW,EACX,UAAyC,EAAE;IAE3C,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,sDAAsD,EACtD,OAAO,CACR,CAAC;IACF,IAAI;QACF,MAAM,IAAI,GAAG,yBAAyB,CAAC,OAAO,EAAE,GAAG,EAAE,cA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,oBAAM,MAAM,CAAC,aAAa,IAAI,EAAE,CAAA,CAAC;SAClC;IACH,CAAC;CAAA;AAED,KAAK,UAAU,uBAAuB,CACpC,OAAsC,EACtC,GAAW,EACX,OAAsC,EACtC,iBAA0B;IAE1B,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;IACtC,QAAQ,CAAC,QAAQ,IAAI,SAAS,GAAG,gBAAgB,CAAC;IAClD,IAAI,OAAO,CAAC,GAAG,KAAK,SAAS,EAAE;QAC7B,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;KACrD;IAED,IAAI,iBAAiB,KAAK,SAAS,EAAE;QACnC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;KACnE;IAED,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAExC,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAE1D,MAAM,aAAa,GAAG,MAAM,6BAA6B,CAAC,qBAAqB,CAC7E,QAAQ,CAAC,UAAW,CACrB,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACjE,OAAO;QACL,aAAa;QACb,iBAAiB,EAAE,SAAS;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { RegistrationDescription } from \"../models/registration.js\";\nimport { RegistrationQueryLimitOptions } from \"../models/options.js\";\nimport { RegistrationQueryResponse } from \"../models/response.js\";\nimport { registrationDescriptionParser } from \"../serializers/registrationSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Lists all registrations with the matching tag.\n * @param context - The Notification Hubs client.\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 */\nexport function listRegistrationsByTag(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions = {}\n): PagedAsyncIterableIterator<RegistrationDescription> {\n const { span, updatedOptions } = tracingClient.startSpan(\n \"NotificationHubsClientContext-listRegistrationsByTag\",\n options\n );\n try {\n const iter = listRegistrationsByTagAll(context, tag, updatedOptions);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return listRegistrationsByTagPagingPage(context, tag, options);\n },\n };\n } catch (e: any) {\n span.setStatus({ status: \"error\", error: e });\n throw e;\n } finally {\n span.end();\n }\n}\n\nasync function* listRegistrationsByTagAll(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions\n): AsyncIterableIterator<RegistrationDescription> {\n for await (const page of listRegistrationsByTagPagingPage(context, tag, options)) {\n yield* page;\n }\n}\n\nasync function* listRegistrationsByTagPagingPage(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions\n): AsyncIterableIterator<RegistrationDescription[]> {\n let result = await _listRegistrationsByTag(context, tag, options);\n yield result.registrations || [];\n let continuationToken = result.continuationToken;\n while (continuationToken) {\n result = await _listRegistrationsByTag(context, tag, options, continuationToken);\n continuationToken = result.continuationToken;\n yield result.registrations || [];\n }\n}\n\nasync function _listRegistrationsByTag(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions,\n continuationToken?: string\n): Promise<RegistrationQueryResponse> {\n const endpoint = context.requestUrl();\n endpoint.pathname += `/tags/${tag}/registrations`;\n if (options.top !== undefined) {\n endpoint.searchParams.set(\"$top\", `${options.top}`);\n }\n\n if (continuationToken !== undefined) {\n endpoint.searchParams.set(\"continuationtoken\", continuationToken);\n }\n\n const headers = context.createHeaders();\n\n const request = createRequest(endpoint, \"GET\", headers, options);\n const response = await sendRequest(context, request, 200);\n\n const registrations = await registrationDescriptionParser.parseRegistrationFeed(\n response.bodyAsText!\n );\n const nextToken = response.headers.get(\"x-ms-continuationtoken\");\n return {\n registrations,\n continuationToken: nextToken,\n };\n}\n"]}
1
+ {"version":3,"file":"listRegistrationsByTag.js","sourceRoot":"","sources":["../../../src/client/listRegistrationsByTag.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAMnE,OAAO,EAAE,6BAA6B,EAAE,MAAM,0CAA0C,CAAC;AACzF,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,wBAAwB,CAAC;AAEhD;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAsC,EACtC,GAAW,EACX,UAAyC,EAAE;IAE3C,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,SAAS,CACtD,iCAAiC,cAAc,EAAE,EACjD,OAAO,CACR,CAAC;IACF,IAAI;QACF,MAAM,IAAI,GAAG,yBAAyB,CAAC,OAAO,EAAE,GAAG,EAAE,cAAc,CAAC,CAAC;QACrE,OAAO;YACL,IAAI;gBACF,OAAO,IAAI,CAAC,IAAI,EAAE,CAAC;YACrB,CAAC;YACD,CAAC,MAAM,CAAC,aAAa,CAAC;gBACpB,OAAO,IAAI,CAAC;YACd,CAAC;YACD,MAAM,EAAE,GAAG,EAAE;gBACX,OAAO,gCAAgC,CAAC,OAAO,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;YACjE,CAAC;SACF,CAAC;KACH;IAAC,OAAO,CAAM,EAAE;QACf,IAA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QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;KACrD;IAED,IAAI,iBAAiB,KAAK,SAAS,EAAE;QACnC,QAAQ,CAAC,YAAY,CAAC,GAAG,CAAC,mBAAmB,EAAE,iBAAiB,CAAC,CAAC;KACnE;IAED,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAC5D,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC;IACjE,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;IAE1D,MAAM,aAAa,GAAG,MAAM,6BAA6B,CAAC,qBAAqB,CAC7E,QAAQ,CAAC,UAAW,CACrB,CAAC;IACF,MAAM,SAAS,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC,CAAC;IACjE,OAAO;QACL,aAAa;QACb,iBAAiB,EAAE,SAAS;KAC7B,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { PagedAsyncIterableIterator } from \"@azure/core-paging\";\nimport { RegistrationDescription } from \"../models/registration.js\";\nimport { RegistrationQueryLimitOptions } from \"../models/options.js\";\nimport { RegistrationQueryResponse } from \"../models/response.js\";\nimport { registrationDescriptionParser } from \"../serializers/registrationSerializer.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"listRegistrationsByTag\";\n\n/**\n * Lists all registrations with the matching tag.\n * @param context - The Notification Hubs client.\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 */\nexport function listRegistrationsByTag(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions = {}\n): PagedAsyncIterableIterator<RegistrationDescription> {\n const { span, updatedOptions } = tracingClient.startSpan(\n `NotificationHubsClientContext-${OPERATION_NAME}`,\n options\n );\n try {\n const iter = listRegistrationsByTagAll(context, tag, updatedOptions);\n return {\n next() {\n return iter.next();\n },\n [Symbol.asyncIterator]() {\n return this;\n },\n byPage: () => {\n return listRegistrationsByTagPagingPage(context, tag, options);\n },\n };\n } catch (e: any) {\n span.setStatus({ status: \"error\", error: e });\n throw e;\n } finally {\n span.end();\n }\n}\n\nasync function* listRegistrationsByTagAll(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions\n): AsyncIterableIterator<RegistrationDescription> {\n for await (const page of listRegistrationsByTagPagingPage(context, tag, options)) {\n yield* page;\n }\n}\n\nasync function* listRegistrationsByTagPagingPage(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions\n): AsyncIterableIterator<RegistrationDescription[]> {\n let result = await _listRegistrationsByTag(context, tag, options);\n yield result.registrations || [];\n let continuationToken = result.continuationToken;\n while (continuationToken) {\n result = await _listRegistrationsByTag(context, tag, options, continuationToken);\n continuationToken = result.continuationToken;\n yield result.registrations || [];\n }\n}\n\nasync function _listRegistrationsByTag(\n context: NotificationHubsClientContext,\n tag: string,\n options: RegistrationQueryLimitOptions,\n continuationToken?: string\n): Promise<RegistrationQueryResponse> {\n const endpoint = context.requestUrl();\n endpoint.pathname += `/tags/${tag}/registrations`;\n if (options.top !== undefined) {\n endpoint.searchParams.set(\"$top\", `${options.top}`);\n }\n\n if (continuationToken !== undefined) {\n endpoint.searchParams.set(\"continuationtoken\", continuationToken);\n }\n\n const headers = await context.createHeaders(OPERATION_NAME);\n const request = createRequest(endpoint, \"GET\", headers, options);\n const response = await sendRequest(context, request, 200);\n\n const registrations = await registrationDescriptionParser.parseRegistrationFeed(\n response.bodyAsText!\n );\n const nextToken = response.headers.get(\"x-ms-continuationtoken\");\n return {\n registrations,\n continuationToken: nextToken,\n };\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  import { createRequest, sendRequest } from "./internal/_client.js";
4
4
  import { parseNotificationHubJobEntry, serializeNotificationHubJobEntry, } from "../serializers/notificationHubJobSerializer.js";
5
5
  import { tracingClient } from "../utils/tracing.js";
6
+ const OPERATION_NAME = "submitNotificationHubJob";
6
7
  /**
7
8
  * Submits a Notification Hub Job.
8
9
  * Note: this is available to Standard SKU namespace and above.
@@ -12,10 +13,10 @@ import { tracingClient } from "../utils/tracing.js";
12
13
  * @returns The notification hub job details including job ID and status.
13
14
  */
14
15
  export function submitNotificationHubJob(context, job, options = {}) {
15
- return tracingClient.withSpan("NotificationHubsClientContext-submitNotificationHubJob", options, async (updatedOptions) => {
16
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options, async (updatedOptions) => {
16
17
  const endpoint = context.requestUrl();
17
18
  endpoint.pathname += "/jobs";
18
- const headers = context.createHeaders();
19
+ const headers = await context.createHeaders(OPERATION_NAME);
19
20
  headers.set("Content-Type", "application/atom+xml;type=entry;charset=utf-8");
20
21
  const request = createRequest(endpoint, "POST", headers, updatedOptions);
21
22
  request.body = serializeNotificationHubJobEntry(job);
@@ -1 +1 @@
1
- {"version":3,"file":"submitNotificationHubJob.js","sourceRoot":"","sources":["../../../src/client/submitNotificationHubJob.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,gDAAgD,CAAC;AAIxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAsC,EACtC,GAAuB,EACvB,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,wDAAwD,EACxD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC;QAE7B,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,+CAA+C,CAAC,CAAC;QAE7E,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,GAAG,gCAAgC,CAAC,GAAG,CAAC,CAAC;QAErD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,4BAA4B,CAAC,QAAQ,CAAC,UAAW,CAAC,CAAC;IAC5D,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport {\n parseNotificationHubJobEntry,\n serializeNotificationHubJobEntry,\n} from \"../serializers/notificationHubJobSerializer.js\";\nimport { NotificationHubJob } from \"../models/notificationHubJob.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Submits a Notification Hub Job.\n * Note: this is available to Standard SKU namespace and above.\n * @param context - The Notification Hubs client.\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 */\nexport function submitNotificationHubJob(\n context: NotificationHubsClientContext,\n job: NotificationHubJob,\n options: OperationOptions = {}\n): Promise<NotificationHubJob> {\n return tracingClient.withSpan(\n \"NotificationHubsClientContext-submitNotificationHubJob\",\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/jobs\";\n\n const headers = context.createHeaders();\n headers.set(\"Content-Type\", \"application/atom+xml;type=entry;charset=utf-8\");\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n request.body = serializeNotificationHubJobEntry(job);\n\n const response = await sendRequest(context, request, 201);\n\n return parseNotificationHubJobEntry(response.bodyAsText!);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"submitNotificationHubJob.js","sourceRoot":"","sources":["../../../src/client/submitNotificationHubJob.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EACL,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,gDAAgD,CAAC;AAIxD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,0BAA0B,CAAC;AAElD;;;;;;;GAOG;AACH,MAAM,UAAU,wBAAwB,CACtC,OAAsC,EACtC,GAAuB,EACvB,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,cAAc,EAAE,EACjD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,OAAO,CAAC;QAE7B,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,+CAA+C,CAAC,CAAC;QAE7E,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QACzE,OAAO,CAAC,IAAI,GAAG,gCAAgC,CAAC,GAAG,CAAC,CAAC;QACrD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,4BAA4B,CAAC,QAAQ,CAAC,UAAW,CAAC,CAAC;IAC5D,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, sendRequest } from \"./internal/_client.js\";\nimport {\n parseNotificationHubJobEntry,\n serializeNotificationHubJobEntry,\n} from \"../serializers/notificationHubJobSerializer.js\";\nimport { NotificationHubJob } from \"../models/notificationHubJob.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"submitNotificationHubJob\";\n\n/**\n * Submits a Notification Hub Job.\n * Note: this is available to Standard SKU namespace and above.\n * @param context - The Notification Hubs client.\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 */\nexport function submitNotificationHubJob(\n context: NotificationHubsClientContext,\n job: NotificationHubJob,\n options: OperationOptions = {}\n): Promise<NotificationHubJob> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext-${OPERATION_NAME}`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += \"/jobs\";\n\n const headers = await context.createHeaders(OPERATION_NAME);\n headers.set(\"Content-Type\", \"application/atom+xml;type=entry;charset=utf-8\");\n\n const request = createRequest(endpoint, \"POST\", headers, updatedOptions);\n request.body = serializeNotificationHubJobEntry(job);\n const response = await sendRequest(context, request, 201);\n\n return parseNotificationHubJobEntry(response.bodyAsText!);\n }\n );\n}\n"]}
@@ -2,6 +2,7 @@
2
2
  // Licensed under the MIT license.
3
3
  import { createRequest, parseNotificationResponse, sendRequest } from "./internal/_client.js";
4
4
  import { tracingClient } from "../utils/tracing.js";
5
+ const OPERATION_NAME = "updateInstallation";
5
6
  /**
6
7
  * Updates an installation using the JSON-Patch standard in RFC6902.
7
8
  * @param context - The Notification Hubs client.
@@ -11,10 +12,10 @@ import { tracingClient } from "../utils/tracing.js";
11
12
  * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
12
13
  */
13
14
  export function updateInstallation(context, installationId, installationPatches, options = {}) {
14
- return tracingClient.withSpan("NotificationHubsClientContext-updateInstallation", options, async (updatedOptions) => {
15
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options, async (updatedOptions) => {
15
16
  const endpoint = context.requestUrl();
16
17
  endpoint.pathname += `/installations/${installationId}`;
17
- const headers = context.createHeaders();
18
+ const headers = await context.createHeaders(OPERATION_NAME);
18
19
  headers.set("Content-Type", "application/json");
19
20
  const request = createRequest(endpoint, "PATCH", headers, updatedOptions);
20
21
  request.body = JSON.stringify(installationPatches);
@@ -1 +1 @@
1
- {"version":3,"file":"updateInstallation.js","sourceRoot":"","sources":["../../../src/client/updateInstallation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAK9F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAsC,EACtC,cAAsB,EACtB,mBAAgC,EAChC,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,kDAAkD,EAClD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,kBAAkB,cAAc,EAAE,CAAC;QACxD,MAAM,OAAO,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;QACxC,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAEhD,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QAEnD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,yBAAyB,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, parseNotificationResponse, sendRequest } from \"./internal/_client.js\";\nimport { JsonPatch } from \"../models/installation.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsResponse } from \"../models/response.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Updates an installation using the JSON-Patch standard in RFC6902.\n * @param context - The Notification Hubs client.\n * @param installationId - The ID of the installation to update.\n * @param installationPatches - 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 */\nexport function updateInstallation(\n context: NotificationHubsClientContext,\n installationId: string,\n installationPatches: JsonPatch[],\n options: OperationOptions = {}\n): Promise<NotificationHubsResponse> {\n return tracingClient.withSpan(\n \"NotificationHubsClientContext-updateInstallation\",\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += `/installations/${installationId}`;\n const headers = context.createHeaders();\n headers.set(\"Content-Type\", \"application/json\");\n\n const request = createRequest(endpoint, \"PATCH\", headers, updatedOptions);\n request.body = JSON.stringify(installationPatches);\n\n const response = await sendRequest(context, request, 200);\n\n return parseNotificationResponse(response);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"updateInstallation.js","sourceRoot":"","sources":["../../../src/client/updateInstallation.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,aAAa,EAAE,yBAAyB,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAK9F,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAsC,EACtC,cAAsB,EACtB,mBAAgC,EAChC,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,cAAc,EAAE,EACjD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,MAAM,QAAQ,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC;QACtC,QAAQ,CAAC,QAAQ,IAAI,kBAAkB,cAAc,EAAE,CAAC;QAExD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,cAAc,EAAE,kBAAkB,CAAC,CAAC;QAEhD,MAAM,OAAO,GAAG,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,cAAc,CAAC,CAAC;QAC1E,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,mBAAmB,CAAC,CAAC;QACnD,MAAM,QAAQ,GAAG,MAAM,WAAW,CAAC,OAAO,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;QAE1D,OAAO,yBAAyB,CAAC,QAAQ,CAAC,CAAC;IAC7C,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { createRequest, parseNotificationResponse, sendRequest } from \"./internal/_client.js\";\nimport { JsonPatch } from \"../models/installation.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsResponse } from \"../models/response.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"updateInstallation\";\n\n/**\n * Updates an installation using the JSON-Patch standard in RFC6902.\n * @param context - The Notification Hubs client.\n * @param installationId - The ID of the installation to update.\n * @param installationPatches - 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 */\nexport function updateInstallation(\n context: NotificationHubsClientContext,\n installationId: string,\n installationPatches: JsonPatch[],\n options: OperationOptions = {}\n): Promise<NotificationHubsResponse> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext-${OPERATION_NAME}`,\n options,\n async (updatedOptions) => {\n const endpoint = context.requestUrl();\n endpoint.pathname += `/installations/${installationId}`;\n\n const headers = await context.createHeaders(OPERATION_NAME);\n headers.set(\"Content-Type\", \"application/json\");\n\n const request = createRequest(endpoint, \"PATCH\", headers, updatedOptions);\n request.body = JSON.stringify(installationPatches);\n const response = await sendRequest(context, request, 200);\n\n return parseNotificationResponse(response);\n }\n );\n}\n"]}
@@ -3,6 +3,7 @@
3
3
  import { RestError } from "@azure/core-rest-pipeline";
4
4
  import { createOrUpdateRegistrationDescription } from "./internal/_createOrUpdateRegistrationDescription.js";
5
5
  import { tracingClient } from "../utils/tracing.js";
6
+ const OPERATION_NAME = "updateRegistration";
6
7
  /**
7
8
  * Updates an existing registration.
8
9
  * @param context - The Notification Hubs client.
@@ -11,7 +12,7 @@ import { tracingClient } from "../utils/tracing.js";
11
12
  * @returns The updated registration description.
12
13
  */
13
14
  export function updateRegistration(context, registration, options = {}) {
14
- return tracingClient.withSpan("NotificationHubsClientContext-updateRegistration", options, async (updatedOptions) => {
15
+ return tracingClient.withSpan(`NotificationHubsClientContext-${OPERATION_NAME}`, options, async (updatedOptions) => {
15
16
  if (!registration.etag) {
16
17
  throw new RestError("ETag is required for registration update", { statusCode: 400 });
17
18
  }
@@ -1 +1 @@
1
- {"version":3,"file":"updateRegistration.js","sourceRoot":"","sources":["../../../src/client/updateRegistration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,qCAAqC,EAAE,MAAM,sDAAsD,CAAC;AAC7G,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAsC,EACtC,YAAqC,EACrC,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,kDAAkD,EAClD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;YACtB,MAAM,IAAI,SAAS,CAAC,0CAA0C,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;SACtF;QACD,OAAO,qCAAqC,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IAChG,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { RegistrationDescription } from \"../models/registration.js\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { createOrUpdateRegistrationDescription } from \"./internal/_createOrUpdateRegistrationDescription.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\n/**\n * Updates an existing registration.\n * @param context - The Notification Hubs client.\n * @param registration - The registration to update.\n * @param options - The operation options.\n * @returns The updated registration description.\n */\nexport function updateRegistration(\n context: NotificationHubsClientContext,\n registration: RegistrationDescription,\n options: OperationOptions = {}\n): Promise<RegistrationDescription> {\n return tracingClient.withSpan(\n \"NotificationHubsClientContext-updateRegistration\",\n options,\n async (updatedOptions) => {\n if (!registration.etag) {\n throw new RestError(\"ETag is required for registration update\", { statusCode: 400 });\n }\n return createOrUpdateRegistrationDescription(context, registration, \"update\", updatedOptions);\n }\n );\n}\n"]}
1
+ {"version":3,"file":"updateRegistration.js","sourceRoot":"","sources":["../../../src/client/updateRegistration.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAKlC,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EAAE,qCAAqC,EAAE,MAAM,sDAAsD,CAAC;AAC7G,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,MAAM,cAAc,GAAG,oBAAoB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAsC,EACtC,YAAqC,EACrC,UAA4B,EAAE;IAE9B,OAAO,aAAa,CAAC,QAAQ,CAC3B,iCAAiC,cAAc,EAAE,EACjD,OAAO,EACP,KAAK,EAAE,cAAc,EAAE,EAAE;QACvB,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;YACtB,MAAM,IAAI,SAAS,CAAC,0CAA0C,EAAE,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,CAAC;SACtF;QACD,OAAO,qCAAqC,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;IAChG,CAAC,CACF,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { RegistrationDescription } from \"../models/registration.js\";\nimport { RestError } from \"@azure/core-rest-pipeline\";\nimport { createOrUpdateRegistrationDescription } from \"./internal/_createOrUpdateRegistrationDescription.js\";\nimport { tracingClient } from \"../utils/tracing.js\";\n\nconst OPERATION_NAME = \"updateRegistration\";\n\n/**\n * Updates an existing registration.\n * @param context - The Notification Hubs client.\n * @param registration - The registration to update.\n * @param options - The operation options.\n * @returns The updated registration description.\n */\nexport function updateRegistration(\n context: NotificationHubsClientContext,\n registration: RegistrationDescription,\n options: OperationOptions = {}\n): Promise<RegistrationDescription> {\n return tracingClient.withSpan(\n `NotificationHubsClientContext-${OPERATION_NAME}`,\n options,\n async (updatedOptions) => {\n if (!registration.etag) {\n throw new RestError(\"ETag is required for registration update\", { statusCode: 400 });\n }\n return createOrUpdateRegistrationDescription(context, registration, \"update\", updatedOptions);\n }\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.2";
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.2\";\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;QAE3B,OAAO,CAAC,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,CAAA,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AI,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,KAAK,EAAE,IAAI,EACX,QAAQ,EAAE,IAAI,GAAG,EAAE,IAChB,OAAO,EACV;AACJ,C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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