@azure/notification-hubs 1.0.0-beta.1 → 1.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -20
- package/dist/{index.js → index.cjs} +245 -146
- package/dist/index.cjs.map +1 -0
- package/dist-esm/src/{utils → auth}/connectionStringUtils.js +37 -1
- package/dist-esm/src/auth/connectionStringUtils.js.map +1 -0
- package/dist-esm/src/auth/hmacSha256.browser.js +12 -0
- package/dist-esm/src/auth/hmacSha256.browser.js.map +1 -0
- package/dist-esm/src/auth/hmacSha256.js +8 -0
- package/dist-esm/src/auth/hmacSha256.js.map +1 -0
- package/dist-esm/src/auth/sasTokenProvider.js +58 -0
- package/dist-esm/src/auth/sasTokenProvider.js.map +1 -0
- package/dist-esm/src/client/cancelScheduledNotification.js +3 -2
- package/dist-esm/src/client/cancelScheduledNotification.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateInstallation.js +3 -2
- package/dist-esm/src/client/createOrUpdateInstallation.js.map +1 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js +2 -1
- package/dist-esm/src/client/createOrUpdateRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistration.js +2 -1
- package/dist-esm/src/client/createRegistration.js.map +1 -1
- package/dist-esm/src/client/createRegistrationId.js +3 -2
- package/dist-esm/src/client/createRegistrationId.js.map +1 -1
- package/dist-esm/src/client/deleteInstallation.js +3 -2
- package/dist-esm/src/client/deleteInstallation.js.map +1 -1
- package/dist-esm/src/client/deleteRegistration.js +3 -2
- package/dist-esm/src/client/deleteRegistration.js.map +1 -1
- package/dist-esm/src/client/getFeedbackContainerUrl.js +3 -2
- package/dist-esm/src/client/getFeedbackContainerUrl.js.map +1 -1
- package/dist-esm/src/client/getInstallation.js +3 -2
- package/dist-esm/src/client/getInstallation.js.map +1 -1
- package/dist-esm/src/client/getNotificationHubJob.js +3 -2
- package/dist-esm/src/client/getNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/getNotificationOutcomeDetails.js +3 -2
- package/dist-esm/src/client/getNotificationOutcomeDetails.js.map +1 -1
- package/dist-esm/src/client/getRegistration.js +3 -2
- package/dist-esm/src/client/getRegistration.js.map +1 -1
- package/dist-esm/src/client/index.js +7 -3
- package/dist-esm/src/client/index.js.map +1 -1
- package/dist-esm/src/client/internal/_client.js +23 -7
- package/dist-esm/src/client/internal/_client.js.map +1 -1
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js +1 -1
- package/dist-esm/src/client/internal/_createOrUpdateRegistrationDescription.js.map +1 -1
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js +3 -2
- package/dist-esm/src/client/internal/_scheduleNotificationPayload.js.map +1 -1
- package/dist-esm/src/client/internal/_sendNotificationPayload.js +2 -2
- package/dist-esm/src/client/internal/_sendNotificationPayload.js.map +1 -1
- package/dist-esm/src/client/listNotificationHubJobs.js +3 -2
- package/dist-esm/src/client/listNotificationHubJobs.js.map +1 -1
- package/dist-esm/src/client/listRegistrations.js +3 -2
- package/dist-esm/src/client/listRegistrations.js.map +1 -1
- package/dist-esm/src/client/listRegistrationsByTag.js +3 -2
- package/dist-esm/src/client/listRegistrationsByTag.js.map +1 -1
- package/dist-esm/src/client/scheduleBroadcastNotification.js.map +1 -1
- package/dist-esm/src/client/scheduleNotification.js.map +1 -1
- package/dist-esm/src/client/sendBroadcastNotification.js.map +1 -1
- package/dist-esm/src/client/sendDirectNotification.js +1 -2
- package/dist-esm/src/client/sendDirectNotification.js.map +1 -1
- package/dist-esm/src/client/sendNotification.js.map +1 -1
- package/dist-esm/src/client/submitNotificationHubJob.js +3 -2
- package/dist-esm/src/client/submitNotificationHubJob.js.map +1 -1
- package/dist-esm/src/client/updateInstallation.js +3 -2
- package/dist-esm/src/client/updateInstallation.js.map +1 -1
- package/dist-esm/src/client/updateRegistration.js +2 -1
- package/dist-esm/src/client/updateRegistration.js.map +1 -1
- package/dist-esm/src/models/installation.js +1 -1
- package/dist-esm/src/models/installation.js.map +1 -1
- package/dist-esm/src/models/notification.js +1 -1
- package/dist-esm/src/models/notification.js.map +1 -1
- package/dist-esm/src/models/notificationBuilder.js +6 -6
- package/dist-esm/src/models/notificationBuilder.js.map +1 -1
- package/dist-esm/src/models/notificationDetails.js.map +1 -1
- package/dist-esm/src/models/registration.js +3 -39
- package/dist-esm/src/models/registration.js.map +1 -1
- package/dist-esm/src/models/response.js.map +1 -1
- package/dist-esm/src/notificationHubsClient.js +1 -2
- package/dist-esm/src/notificationHubsClient.js.map +1 -1
- package/dist-esm/src/serializers/notificationHubJobSerializer.js +3 -0
- package/dist-esm/src/serializers/notificationHubJobSerializer.js.map +1 -1
- package/dist-esm/src/serializers/notificationOutcomeSerializer.js +31 -0
- package/dist-esm/src/serializers/notificationOutcomeSerializer.js.map +1 -0
- package/dist-esm/src/serializers/registrationSerializer.js +3 -28
- package/dist-esm/src/serializers/registrationSerializer.js.map +1 -1
- package/dist-esm/src/utils/constants.js +1 -0
- package/dist-esm/src/utils/constants.js.map +1 -1
- package/dist-esm/src/utils/retryPolicy.js +2 -2
- package/dist-esm/src/utils/retryPolicy.js.map +1 -1
- package/dist-esm/src/utils/tracing.js +2 -1
- package/dist-esm/src/utils/tracing.js.map +1 -1
- package/package.json +18 -13
- package/types/3.1/notification-hubs.d.ts +60 -77
- package/types/latest/notification-hubs.d.ts +61 -83
- package/types/latest/tsdoc-metadata.json +1 -1
- package/types/src/{utils → auth}/connectionStringUtils.d.ts +7 -1
- package/types/src/auth/connectionStringUtils.d.ts.map +1 -0
- package/types/src/auth/hmacSha256.browser.d.ts +3 -0
- package/types/src/auth/hmacSha256.browser.d.ts.map +1 -0
- package/types/src/auth/hmacSha256.d.ts +2 -0
- package/types/src/auth/hmacSha256.d.ts.map +1 -0
- package/types/src/auth/sasTokenProvider.d.ts +77 -0
- package/types/src/auth/sasTokenProvider.d.ts.map +1 -0
- package/types/src/client/cancelScheduledNotification.d.ts +1 -1
- package/types/src/client/cancelScheduledNotification.d.ts.map +1 -1
- package/types/src/client/createOrUpdateInstallation.d.ts +1 -1
- package/types/src/client/createOrUpdateInstallation.d.ts.map +1 -1
- package/types/src/client/createOrUpdateRegistration.d.ts.map +1 -1
- package/types/src/client/createRegistration.d.ts.map +1 -1
- package/types/src/client/createRegistrationId.d.ts.map +1 -1
- package/types/src/client/deleteInstallation.d.ts +1 -1
- package/types/src/client/deleteInstallation.d.ts.map +1 -1
- package/types/src/client/deleteRegistration.d.ts +1 -1
- package/types/src/client/deleteRegistration.d.ts.map +1 -1
- package/types/src/client/getFeedbackContainerUrl.d.ts.map +1 -1
- package/types/src/client/getInstallation.d.ts.map +1 -1
- package/types/src/client/getNotificationHubJob.d.ts.map +1 -1
- package/types/src/client/getNotificationOutcomeDetails.d.ts.map +1 -1
- package/types/src/client/getRegistration.d.ts.map +1 -1
- package/types/src/client/index.d.ts +2 -3
- package/types/src/client/index.d.ts.map +1 -1
- package/types/src/client/internal/_client.d.ts +8 -8
- package/types/src/client/internal/_client.d.ts.map +1 -1
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts +1 -1
- package/types/src/client/internal/_scheduleNotificationPayload.d.ts.map +1 -1
- package/types/src/client/internal/_sendNotificationPayload.d.ts +1 -1
- package/types/src/client/internal/_sendNotificationPayload.d.ts.map +1 -1
- package/types/src/client/listNotificationHubJobs.d.ts.map +1 -1
- package/types/src/client/listRegistrations.d.ts.map +1 -1
- package/types/src/client/listRegistrationsByTag.d.ts.map +1 -1
- package/types/src/client/scheduleBroadcastNotification.d.ts +1 -1
- package/types/src/client/scheduleBroadcastNotification.d.ts.map +1 -1
- package/types/src/client/scheduleNotification.d.ts +1 -1
- package/types/src/client/scheduleNotification.d.ts.map +1 -1
- package/types/src/client/sendBroadcastNotification.d.ts +1 -1
- package/types/src/client/sendBroadcastNotification.d.ts.map +1 -1
- package/types/src/client/sendDirectNotification.d.ts +4 -5
- package/types/src/client/sendDirectNotification.d.ts.map +1 -1
- package/types/src/client/sendNotification.d.ts +1 -1
- package/types/src/client/sendNotification.d.ts.map +1 -1
- package/types/src/client/submitNotificationHubJob.d.ts.map +1 -1
- package/types/src/client/updateInstallation.d.ts +1 -1
- package/types/src/client/updateInstallation.d.ts.map +1 -1
- package/types/src/client/updateRegistration.d.ts.map +1 -1
- package/types/src/models/installation.d.ts +3 -3
- package/types/src/models/installation.d.ts.map +1 -1
- package/types/src/models/notification.d.ts +3 -3
- package/types/src/models/notification.d.ts.map +1 -1
- package/types/src/models/notificationBuilder.d.ts +4 -4
- package/types/src/models/notificationBuilder.d.ts.map +1 -1
- package/types/src/models/notificationDetails.d.ts +63 -0
- package/types/src/models/notificationDetails.d.ts.map +1 -1
- package/types/src/models/registration.d.ts +6 -59
- package/types/src/models/registration.d.ts.map +1 -1
- package/types/src/models/response.d.ts +0 -26
- package/types/src/models/response.d.ts.map +1 -1
- package/types/src/notificationHubsClient.d.ts +3 -5
- package/types/src/notificationHubsClient.d.ts.map +1 -1
- package/types/src/serializers/notificationHubJobSerializer.d.ts.map +1 -1
- package/types/src/serializers/notificationOutcomeSerializer.d.ts +3 -0
- package/types/src/serializers/notificationOutcomeSerializer.d.ts.map +1 -0
- package/types/src/serializers/registrationSerializer.d.ts +1 -21
- package/types/src/serializers/registrationSerializer.d.ts.map +1 -1
- package/types/src/utils/constants.d.ts +1 -0
- package/types/src/utils/constants.d.ts.map +1 -1
- package/types/src/utils/tracing.d.ts.map +1 -1
- package/dist/index.js.map +0 -1
- package/dist-esm/src/utils/connectionStringUtils.js.map +0 -1
- package/types/src/utils/connectionStringUtils.d.ts.map +0 -1
|
@@ -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
|
|
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 "../
|
|
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,
|
|
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,GAC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AC,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"]}
|
|
@@ -2,16 +2,16 @@
|
|
|
2
2
|
// Licensed under the MIT license.
|
|
3
3
|
import { RestError, createPipelineRequest, } from "@azure/core-rest-pipeline";
|
|
4
4
|
import { isDefined } from "../../utils/utils.js";
|
|
5
|
+
import { parseNotificationOutcome } from "../../serializers/notificationOutcomeSerializer.js";
|
|
5
6
|
import { parseXMLError } from "../../utils/xmlUtils.js";
|
|
6
|
-
/**
|
|
7
|
-
* @internal
|
|
8
|
-
*/
|
|
9
7
|
export function createRequest(endpoint, method, headers, options) {
|
|
10
8
|
return createPipelineRequest(Object.assign(Object.assign(Object.assign({}, options.tracingOptions), options.requestOptions), { url: endpoint.toString(), abortSignal: options.abortSignal, method,
|
|
11
9
|
headers }));
|
|
12
10
|
}
|
|
13
11
|
/**
|
|
14
|
-
*
|
|
12
|
+
* Parses the HTTP response and creates a NotificationHubsResponse with header information from the operation.
|
|
13
|
+
* @param response - The HTTP response used to populate the result.
|
|
14
|
+
* @returns A NotificationHubsResponse with header information from the operation.
|
|
15
15
|
*/
|
|
16
16
|
export function parseNotificationResponse(response) {
|
|
17
17
|
const correlationId = response.headers.get("x-ms-correlation-request-id");
|
|
@@ -24,16 +24,32 @@ export function parseNotificationResponse(response) {
|
|
|
24
24
|
};
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
|
-
*
|
|
27
|
+
* Parses the HTTP response and creates a NotificationHubsMessageResponse with results from the notification.
|
|
28
|
+
* @param response - The HTTP response used to populate the result.
|
|
29
|
+
* @returns A NotificationHubsMessageResponse with results from the notification.
|
|
28
30
|
*/
|
|
29
|
-
export function parseNotificationSendResponse(response) {
|
|
31
|
+
export async function parseNotificationSendResponse(response) {
|
|
30
32
|
const result = parseNotificationResponse(response);
|
|
31
33
|
let notificationId;
|
|
32
34
|
if (result.location) {
|
|
33
35
|
const locationUrl = new URL(result.location);
|
|
34
36
|
notificationId = locationUrl.pathname.split("/")[3];
|
|
35
37
|
}
|
|
36
|
-
|
|
38
|
+
const requestUrl = new URL(response.request.url);
|
|
39
|
+
const isTestSend = requestUrl.searchParams.has("test");
|
|
40
|
+
const isDirectSend = requestUrl.searchParams.has("direct");
|
|
41
|
+
// Only broadcast/tag based sends are supported for test send
|
|
42
|
+
const responseBody = response.bodyAsText;
|
|
43
|
+
if (isTestSend && !isDirectSend && isDefined(responseBody)) {
|
|
44
|
+
const outcome = await parseNotificationOutcome(responseBody);
|
|
45
|
+
return Object.assign(Object.assign(Object.assign({}, result), outcome), { notificationId });
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return createDefaultResponse(result, notificationId);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
function createDefaultResponse(response, notificationId) {
|
|
52
|
+
return Object.assign(Object.assign({}, response), { notificationId, success: 0, failure: 0, results: [], state: "Enqueued" });
|
|
37
53
|
}
|
|
38
54
|
/**
|
|
39
55
|
* Sends a request through the client context.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"_client.js","sourceRoot":"","sources":["../../../../src/client/internal/_client.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAKL,SAAS,EACT,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"_client.js","sourceRoot":"","sources":["../../../../src/client/internal/_client.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAKL,SAAS,EACT,qBAAqB,GACtB,MAAM,2BAA2B,CAAC;AAOnC,OAAO,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,EAAE,wBAAwB,EAAE,MAAM,oDAAoD,CAAC;AAC9F,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAExD,MAAM,UAAU,aAAa,CAC3B,QAAa,EACb,MAAmB,EACnB,OAAoB,EACpB,OAAyB;IAEzB,OAAO,qBAAqB,+CACvB,OAAO,CAAC,cAAc,GACtB,OAAO,CAAC,cAAc,KACzB,GAAG,EAAE,QAAQ,CAAC,QAAQ,EAAE,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U,EAAE,QAAQ,CAAC,MAAM;YAC3B,QAAQ;SACT,CAAC,CAAC;KACJ;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport {\n HttpHeaders,\n HttpMethods,\n PipelineRequest,\n PipelineResponse,\n RestError,\n createPipelineRequest,\n} from \"@azure/core-rest-pipeline\";\nimport {\n NotificationHubsMessageResponse,\n NotificationHubsResponse,\n} from \"../../models/notificationDetails.js\";\nimport { NotificationHubsClientContext } from \"../index.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { isDefined } from \"../../utils/utils.js\";\nimport { parseNotificationOutcome } from \"../../serializers/notificationOutcomeSerializer.js\";\nimport { parseXMLError } from \"../../utils/xmlUtils.js\";\n\nexport function createRequest(\n endpoint: URL,\n method: HttpMethods,\n headers: HttpHeaders,\n options: OperationOptions\n): PipelineRequest {\n return createPipelineRequest({\n ...options.tracingOptions,\n ...options.requestOptions,\n url: endpoint.toString(),\n abortSignal: options.abortSignal,\n method,\n headers,\n });\n}\n\n/**\n * Parses the HTTP response and creates a NotificationHubsResponse with header information from the operation.\n * @param response - The HTTP response used to populate the result.\n * @returns A NotificationHubsResponse with header information from the operation.\n */\nexport function parseNotificationResponse(response: PipelineResponse): NotificationHubsResponse {\n const correlationId = response.headers.get(\"x-ms-correlation-request-id\");\n const trackingId = response.headers.get(\"TrackingId\");\n const location = response.headers.get(\"Location\");\n\n return {\n correlationId,\n trackingId,\n location,\n };\n}\n\n/**\n * Parses the HTTP response and creates a NotificationHubsMessageResponse with results from the notification.\n * @param response - The HTTP response used to populate the result.\n * @returns A NotificationHubsMessageResponse with results from the notification.\n */\nexport async function parseNotificationSendResponse(\n response: PipelineResponse\n): Promise<NotificationHubsMessageResponse> {\n const result = parseNotificationResponse(response);\n let notificationId: string | undefined;\n if (result.location) {\n const locationUrl = new URL(result.location);\n notificationId = locationUrl.pathname.split(\"/\")[3];\n }\n\n const requestUrl = new URL(response.request.url);\n const isTestSend = requestUrl.searchParams.has(\"test\");\n const isDirectSend = requestUrl.searchParams.has(\"direct\");\n\n // Only broadcast/tag based sends are supported for test send\n const responseBody = response.bodyAsText;\n if (isTestSend && !isDirectSend && isDefined(responseBody)) {\n const outcome = await parseNotificationOutcome(responseBody);\n return {\n ...result,\n ...outcome,\n notificationId,\n };\n } else {\n return createDefaultResponse(result, notificationId);\n }\n}\n\nfunction createDefaultResponse(\n response: NotificationHubsResponse,\n notificationId?: string\n): NotificationHubsMessageResponse {\n return {\n ...response,\n notificationId,\n success: 0,\n failure: 0,\n results: [],\n state: \"Enqueued\",\n };\n}\n\n/**\n * Sends a request through the client context.\n * @param context - The client context to use.\n * @param request - The HTTP request to send.\n * @param successStatusCode - A status code or list of status codes to check for success.\n * @returns The HTTP Response.\n */\nexport async function sendRequest(\n context: NotificationHubsClientContext,\n request: PipelineRequest,\n successStatusCode: number | number[]\n): Promise<PipelineResponse> {\n const statuses: number[] = Array.isArray(successStatusCode)\n ? successStatusCode\n : [successStatusCode];\n\n const response = await context.sendRequest(request);\n\n if (!statuses.some((statusCode) => statusCode === response.status)) {\n const responseBody = response.bodyAsText;\n let details: string | undefined;\n if (isDefined(responseBody)) {\n try {\n details = await parseXMLError(responseBody);\n } catch (err) {\n // eslint-disable no-empty\n }\n }\n\n let errorMessage: string | undefined;\n if (isDefined(details)) {\n errorMessage = `operations failed with: ${details}`;\n } else {\n errorMessage = `operation failed with status ${response.status}`;\n }\n\n throw new RestError(errorMessage, {\n statusCode: response.status,\n response,\n });\n }\n\n return response;\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,
|
|
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,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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(
|
|
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;
|
|
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,EAC1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C,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/notificationDetails.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"]}
|
|
@@ -10,9 +10,9 @@ export function sendNotificationPayload(context, notification, method, pushHandl
|
|
|
10
10
|
const endpoint = context.requestUrl();
|
|
11
11
|
endpoint.pathname += "/messages/";
|
|
12
12
|
if (options.enableTestSend) {
|
|
13
|
-
endpoint.searchParams.append("
|
|
13
|
+
endpoint.searchParams.append("test", "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,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,
|
|
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,w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B,CAAC,CAAC;aAC1E;SACF;QAED,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 { 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/notificationDetails.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(\"test\", \"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(
|
|
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,
|
|
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(
|
|
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,
|
|
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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,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,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(
|
|
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,
|
|
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,CAA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,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,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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduleBroadcastNotification.js","sourceRoot":"","sources":["../../../src/client/scheduleBroadcastNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF;;;;;;;;;GASG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAAsC,EACtC,aAAmB,EACnB,YAA0B,EAC1B,UAA4B,EAAE;IAE9B,OAAO,2BAA2B,CAAC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;AAC/F,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/
|
|
1
|
+
{"version":3,"file":"scheduleBroadcastNotification.js","sourceRoot":"","sources":["../../../src/client/scheduleBroadcastNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF;;;;;;;;;GASG;AACH,MAAM,UAAU,6BAA6B,CAC3C,OAAsC,EACtC,aAAmB,EACnB,YAA0B,EAC1B,UAA4B,EAAE;IAE9B,OAAO,2BAA2B,CAAC,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;AAC/F,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { scheduleNotificationPayload } from \"./internal/_scheduleNotificationPayload.js\";\n\n/**\n * Schedules a push notification to all devices registered on the Notification Hub.\n * NOTE: This is only available in Standard SKU Azure Notification Hubs.\n * @param context - The Notification Hubs client.\n * @param scheduledTime - The Date to send the push notification.\n * @param notification - The notification to send to the matching devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function scheduleBroadcastNotification(\n context: NotificationHubsClientContext,\n scheduledTime: Date,\n notification: Notification,\n options: OperationOptions = {}\n): Promise<NotificationHubsMessageResponse> {\n return scheduleNotificationPayload(context, scheduledTime, undefined, notification, options);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scheduleNotification.js","sourceRoot":"","sources":["../../../src/client/scheduleNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAsC,EACtC,aAAmB,EACnB,IAAuB,EACvB,YAA0B,EAC1B,UAA4B,EAAE;IAE9B,OAAO,2BAA2B,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/
|
|
1
|
+
{"version":3,"file":"scheduleNotification.js","sourceRoot":"","sources":["../../../src/client/scheduleNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAEzF;;;;;;;;;;GAUG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAsC,EACtC,aAAmB,EACnB,IAAuB,EACvB,YAA0B,EAC1B,UAA4B,EAAE;IAE9B,OAAO,2BAA2B,CAAC,OAAO,EAAE,aAAa,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,CAAC;AAC1F,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { scheduleNotificationPayload } from \"./internal/_scheduleNotificationPayload.js\";\n\n/**\n * Schedules a push notification to devices that match the given tags or tag expression at the specified time.\n * NOTE: This is only available in Standard SKU Azure Notification Hubs.\n * @param context - The Notification Hubs client.\n * @param scheduledTime - The Date to send the push notification.\n * @param tags - The tags used to target the device for push notifications in either an array or tag expression.\n * @param notification - The notification to send to the matching devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function scheduleNotification(\n context: NotificationHubsClientContext,\n scheduledTime: Date,\n tags: string[] | string,\n notification: Notification,\n options: OperationOptions = {}\n): Promise<NotificationHubsMessageResponse> {\n return scheduleNotificationPayload(context, scheduledTime, tags, notification, options);\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendBroadcastNotification.js","sourceRoot":"","sources":["../../../src/client/sendBroadcastNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAsC,EACtC,YAA0B,EAC1B,UAAgC,EAAE;IAElC,OAAO,uBAAuB,CAC5B,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/
|
|
1
|
+
{"version":3,"file":"sendBroadcastNotification.js","sourceRoot":"","sources":["../../../src/client/sendBroadcastNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,UAAU,yBAAyB,CACvC,OAAsC,EACtC,YAA0B,EAC1B,UAAgC,EAAE;IAElC,OAAO,uBAAuB,CAC5B,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,SAAS,EACT,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { SendOperationOptions } from \"../models/options.js\";\nimport { sendNotificationPayload } from \"./internal/_sendNotificationPayload.js\";\n\n/**\n * Sends push notifications to all devices on the Notification Hub.\n * @param context - The Notification Hubs client.\n * @param notification - The notification to send to all devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function sendBroadcastNotification(\n context: NotificationHubsClientContext,\n notification: Notification,\n options: SendOperationOptions = {}\n): Promise<NotificationHubsMessageResponse> {\n return sendNotificationPayload(\n context,\n notification,\n \"sendNotification\",\n undefined,\n undefined,\n options\n );\n}\n"]}
|
|
@@ -6,8 +6,7 @@ import { sendNotificationPayload } from "./internal/_sendNotificationPayload.js"
|
|
|
6
6
|
* @param context - The Notification Hubs client.
|
|
7
7
|
* @param pushHandle - The push handle which is the unique identifier for the device.
|
|
8
8
|
* @param notification - The notification to send to the device.
|
|
9
|
-
* @param options -
|
|
10
|
-
* which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.
|
|
9
|
+
* @param options - The options for sending a direct notification.
|
|
11
10
|
* @returns A NotificationHubResponse with the tracking ID, correlation ID and location.
|
|
12
11
|
*/
|
|
13
12
|
export function sendDirectNotification(context, pushHandle, notification, options = {}) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendDirectNotification.js","sourceRoot":"","sources":["../../../src/client/sendDirectNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF
|
|
1
|
+
{"version":3,"file":"sendDirectNotification.js","sourceRoot":"","sources":["../../../src/client/sendDirectNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAOlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CACpC,OAAsC,EACtC,UAAsB,EACtB,YAA0B,EAC1B,UAA4B,EAAE;IAE9B,OAAO,uBAAuB,CAC5B,OAAO,EACP,YAAY,EACZ,wBAAwB,EACxB,UAAU,EACV,SAAS,EACT,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { OperationOptions } from \"@azure/core-client\";\nimport { PushHandle } from \"../models/installation.js\";\nimport { sendNotificationPayload } from \"./internal/_sendNotificationPayload.js\";\n\n/**\n * Sends a direct push notification to a device with the given push handle.\n * @param context - The Notification Hubs client.\n * @param pushHandle - The push handle which is the unique identifier for the device.\n * @param notification - The notification to send to the device.\n * @param options - The options for sending a direct notification.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function sendDirectNotification(\n context: NotificationHubsClientContext,\n pushHandle: PushHandle,\n notification: Notification,\n options: OperationOptions = {}\n): Promise<NotificationHubsMessageResponse> {\n return sendNotificationPayload(\n context,\n notification,\n \"sendDirectNotification\",\n pushHandle,\n undefined,\n options\n );\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sendNotification.js","sourceRoot":"","sources":["../../../src/client/sendNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAsC,EACtC,IAAuB,EACvB,YAA0B,EAC1B,UAAgC,EAAE;IAElC,OAAO,uBAAuB,CAC5B,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/
|
|
1
|
+
{"version":3,"file":"sendNotification.js","sourceRoot":"","sources":["../../../src/client/sendNotification.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAMlC,OAAO,EAAE,uBAAuB,EAAE,MAAM,wCAAwC,CAAC;AAEjF;;;;;;;;GAQG;AACH,MAAM,UAAU,gBAAgB,CAC9B,OAAsC,EACtC,IAAuB,EACvB,YAA0B,EAC1B,UAAgC,EAAE;IAElC,OAAO,uBAAuB,CAC5B,OAAO,EACP,YAAY,EACZ,kBAAkB,EAClB,SAAS,EACT,IAAI,EACJ,OAAO,CACR,CAAC;AACJ,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Notification } from \"../models/notification.js\";\nimport { NotificationHubsClientContext } from \"./index.js\";\nimport { NotificationHubsMessageResponse } from \"../models/notificationDetails.js\";\nimport { SendOperationOptions } from \"../models/options.js\";\nimport { sendNotificationPayload } from \"./internal/_sendNotificationPayload.js\";\n\n/**\n * Sends push notifications to devices that match the given tags or tag expression.\n * @param context - The Notification Hubs client.\n * @param tags - The tags used to target the device for push notifications in either an array or tag expression.\n * @param notification - The notification to send to the matching devices.\n * @param options - Configuration options for the direct send operation which can contain custom headers\n * which may include APNs specific such as apns-topic or for WNS, X-WNS-TYPE.\n * @returns A NotificationHubResponse with the tracking ID, correlation ID and location.\n */\nexport function sendNotification(\n context: NotificationHubsClientContext,\n tags: string[] | string,\n notification: Notification,\n options: SendOperationOptions = {}\n): Promise<NotificationHubsMessageResponse> {\n return sendNotificationPayload(\n context,\n notification,\n \"sendNotification\",\n undefined,\n tags,\n options\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(
|
|
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,
|
|
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(
|
|
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);
|