@azure/eventgrid 4.13.0-alpha.20230607.3 → 4.13.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.
- package/dist/index.js +430 -76
- package/dist/index.js.map +1 -1
- package/dist-esm/src/cadl-generated/EventGridClient.js +28 -0
- package/dist-esm/src/cadl-generated/EventGridClient.js.map +1 -0
- package/dist-esm/src/cadl-generated/api/EventGridContext.js +11 -0
- package/dist-esm/src/cadl-generated/api/EventGridContext.js.map +1 -0
- package/dist-esm/src/cadl-generated/api/index.js +5 -0
- package/dist-esm/src/cadl-generated/api/index.js.map +1 -0
- package/dist-esm/src/cadl-generated/api/models.js +2 -0
- package/dist-esm/src/cadl-generated/api/models.js.map +1 -0
- package/dist-esm/src/cadl-generated/api/operations.js +162 -0
- package/dist-esm/src/cadl-generated/api/operations.js.map +1 -0
- package/dist-esm/src/cadl-generated/common/interfaces.js +4 -0
- package/dist-esm/src/cadl-generated/common/interfaces.js.map +1 -0
- package/dist-esm/src/cadl-generated/index.js +4 -0
- package/dist-esm/src/cadl-generated/index.js.map +1 -0
- package/dist-esm/src/cadl-generated/logger.js +5 -0
- package/dist-esm/src/cadl-generated/logger.js.map +1 -0
- package/dist-esm/src/cadl-generated/rest/clientDefinitions.js +4 -0
- package/dist-esm/src/cadl-generated/rest/clientDefinitions.js.map +1 -0
- package/dist-esm/src/cadl-generated/rest/eventGridClient.js +30 -0
- package/dist-esm/src/cadl-generated/rest/eventGridClient.js.map +1 -0
- package/dist-esm/src/cadl-generated/rest/index.js +12 -0
- package/dist-esm/src/cadl-generated/rest/index.js.map +1 -0
- package/dist-esm/src/cadl-generated/rest/isUnexpected.js +74 -0
- package/dist-esm/src/cadl-generated/rest/isUnexpected.js.map +1 -0
- package/dist-esm/src/cadl-generated/rest/models.js +4 -0
- package/dist-esm/src/cadl-generated/rest/models.js.map +1 -0
- package/dist-esm/src/cadl-generated/rest/outputModels.js +4 -0
- package/dist-esm/src/cadl-generated/rest/outputModels.js.map +1 -0
- package/dist-esm/src/cadl-generated/rest/parameters.js +4 -0
- package/dist-esm/src/cadl-generated/rest/parameters.js.map +1 -0
- package/dist-esm/src/cadl-generated/rest/responses.js +4 -0
- package/dist-esm/src/cadl-generated/rest/responses.js.map +1 -0
- package/dist-esm/src/eventGridClientV2.js +128 -0
- package/dist-esm/src/eventGridClientV2.js.map +1 -0
- package/dist-esm/src/generated/generatedClientContext.js +1 -1
- package/dist-esm/src/generated/generatedClientContext.js.map +1 -1
- package/dist-esm/src/generated/models/index.js.map +1 -1
- package/dist-esm/src/generated/models/mappers.js +0 -65
- package/dist-esm/src/generated/models/mappers.js.map +1 -1
- package/dist-esm/src/index.js +1 -0
- package/dist-esm/src/index.js.map +1 -1
- package/dist-esm/src/models.js.map +1 -1
- package/dist-esm/src/predicates.js.map +1 -1
- package/dist-esm/src/tracing.js +1 -1
- package/dist-esm/src/tracing.js.map +1 -1
- package/package.json +6 -5
- package/types/eventgrid.d.ts +216 -37
package/dist/index.js
CHANGED
@@ -9,6 +9,8 @@ var coreTracing = require('@azure/core-tracing');
|
|
9
9
|
var uuid = require('uuid');
|
10
10
|
var coreRestPipeline = require('@azure/core-rest-pipeline');
|
11
11
|
var crypto = require('crypto');
|
12
|
+
var coreClient$1 = require('@azure-rest/core-client');
|
13
|
+
var logger$1 = require('@azure/logger');
|
12
14
|
|
13
15
|
function _interopNamespace(e) {
|
14
16
|
if (e && e.__esModule) return e;
|
@@ -6729,36 +6731,6 @@ const ContainerServiceNewKubernetesVersionAvailableEventData = {
|
|
6729
6731
|
}
|
6730
6732
|
}
|
6731
6733
|
};
|
6732
|
-
const ContainerServiceClusterSupportEventData = {
|
6733
|
-
type: {
|
6734
|
-
name: "Composite",
|
6735
|
-
className: "ContainerServiceClusterSupportEventData",
|
6736
|
-
modelProperties: {
|
6737
|
-
kubernetesVersion: {
|
6738
|
-
serializedName: "kubernetesVersion",
|
6739
|
-
required: true,
|
6740
|
-
type: {
|
6741
|
-
name: "String"
|
6742
|
-
}
|
6743
|
-
}
|
6744
|
-
}
|
6745
|
-
}
|
6746
|
-
};
|
6747
|
-
const ContainerServiceNodePoolRollingEventData = {
|
6748
|
-
type: {
|
6749
|
-
name: "Composite",
|
6750
|
-
className: "ContainerServiceNodePoolRollingEventData",
|
6751
|
-
modelProperties: {
|
6752
|
-
nodePoolName: {
|
6753
|
-
serializedName: "nodePoolName",
|
6754
|
-
required: true,
|
6755
|
-
type: {
|
6756
|
-
name: "String"
|
6757
|
-
}
|
6758
|
-
}
|
6759
|
-
}
|
6760
|
-
}
|
6761
|
-
};
|
6762
6734
|
const ApiManagementUserCreatedEventData = {
|
6763
6735
|
type: {
|
6764
6736
|
name: "Composite",
|
@@ -7887,41 +7859,6 @@ const AcsSmsReceivedEventData = {
|
|
7887
7859
|
} })
|
7888
7860
|
}
|
7889
7861
|
};
|
7890
|
-
const ContainerServiceClusterSupportEndedEventData = {
|
7891
|
-
type: {
|
7892
|
-
name: "Composite",
|
7893
|
-
className: "ContainerServiceClusterSupportEndedEventData",
|
7894
|
-
modelProperties: Object.assign({}, ContainerServiceClusterSupportEventData.type.modelProperties)
|
7895
|
-
}
|
7896
|
-
};
|
7897
|
-
const ContainerServiceClusterSupportEndingEventData = {
|
7898
|
-
type: {
|
7899
|
-
name: "Composite",
|
7900
|
-
className: "ContainerServiceClusterSupportEndingEventData",
|
7901
|
-
modelProperties: Object.assign({}, ContainerServiceClusterSupportEventData.type.modelProperties)
|
7902
|
-
}
|
7903
|
-
};
|
7904
|
-
const ContainerServiceNodePoolRollingStartedEventData = {
|
7905
|
-
type: {
|
7906
|
-
name: "Composite",
|
7907
|
-
className: "ContainerServiceNodePoolRollingStartedEventData",
|
7908
|
-
modelProperties: Object.assign({}, ContainerServiceNodePoolRollingEventData.type.modelProperties)
|
7909
|
-
}
|
7910
|
-
};
|
7911
|
-
const ContainerServiceNodePoolRollingSucceededEventData = {
|
7912
|
-
type: {
|
7913
|
-
name: "Composite",
|
7914
|
-
className: "ContainerServiceNodePoolRollingSucceededEventData",
|
7915
|
-
modelProperties: Object.assign({}, ContainerServiceNodePoolRollingEventData.type.modelProperties)
|
7916
|
-
}
|
7917
|
-
};
|
7918
|
-
const ContainerServiceNodePoolRollingFailedEventData = {
|
7919
|
-
type: {
|
7920
|
-
name: "Composite",
|
7921
|
-
className: "ContainerServiceNodePoolRollingFailedEventData",
|
7922
|
-
modelProperties: Object.assign({}, ContainerServiceNodePoolRollingEventData.type.modelProperties)
|
7923
|
-
}
|
7924
|
-
};
|
7925
7862
|
const AcsChatMessageReceivedEventData = {
|
7926
7863
|
type: {
|
7927
7864
|
name: "Composite",
|
@@ -8384,8 +8321,6 @@ var Mappers = /*#__PURE__*/Object.freeze({
|
|
8384
8321
|
PolicyInsightsPolicyStateChangedEventData: PolicyInsightsPolicyStateChangedEventData,
|
8385
8322
|
PolicyInsightsPolicyStateDeletedEventData: PolicyInsightsPolicyStateDeletedEventData,
|
8386
8323
|
ContainerServiceNewKubernetesVersionAvailableEventData: ContainerServiceNewKubernetesVersionAvailableEventData,
|
8387
|
-
ContainerServiceClusterSupportEventData: ContainerServiceClusterSupportEventData,
|
8388
|
-
ContainerServiceNodePoolRollingEventData: ContainerServiceNodePoolRollingEventData,
|
8389
8324
|
ApiManagementUserCreatedEventData: ApiManagementUserCreatedEventData,
|
8390
8325
|
ApiManagementUserUpdatedEventData: ApiManagementUserUpdatedEventData,
|
8391
8326
|
ApiManagementUserDeletedEventData: ApiManagementUserDeletedEventData,
|
@@ -8451,11 +8386,6 @@ var Mappers = /*#__PURE__*/Object.freeze({
|
|
8451
8386
|
AcsChatParticipantRemovedFromThreadEventData: AcsChatParticipantRemovedFromThreadEventData,
|
8452
8387
|
AcsSmsDeliveryReportReceivedEventData: AcsSmsDeliveryReportReceivedEventData,
|
8453
8388
|
AcsSmsReceivedEventData: AcsSmsReceivedEventData,
|
8454
|
-
ContainerServiceClusterSupportEndedEventData: ContainerServiceClusterSupportEndedEventData,
|
8455
|
-
ContainerServiceClusterSupportEndingEventData: ContainerServiceClusterSupportEndingEventData,
|
8456
|
-
ContainerServiceNodePoolRollingStartedEventData: ContainerServiceNodePoolRollingStartedEventData,
|
8457
|
-
ContainerServiceNodePoolRollingSucceededEventData: ContainerServiceNodePoolRollingSucceededEventData,
|
8458
|
-
ContainerServiceNodePoolRollingFailedEventData: ContainerServiceNodePoolRollingFailedEventData,
|
8459
8389
|
AcsChatMessageReceivedEventData: AcsChatMessageReceivedEventData,
|
8460
8390
|
AcsChatMessageEditedEventData: AcsChatMessageEditedEventData,
|
8461
8391
|
AcsChatMessageDeletedEventData: AcsChatMessageDeletedEventData,
|
@@ -8494,7 +8424,7 @@ class GeneratedClientContext extends coreClient__namespace.ServiceClient {
|
|
8494
8424
|
const defaults = {
|
8495
8425
|
requestContentType: "application/json; charset=utf-8"
|
8496
8426
|
};
|
8497
|
-
const packageDetails = `azsdk-js-eventgrid/4.13.0`;
|
8427
|
+
const packageDetails = `azsdk-js-eventgrid/4.13.0-beta.2`;
|
8498
8428
|
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
8499
8429
|
? `${options.userAgentOptions.userAgentPrefix} ${packageDetails}`
|
8500
8430
|
: `${packageDetails}`;
|
@@ -8648,7 +8578,7 @@ function cloudEventDistributedTracingEnricherPolicy() {
|
|
8648
8578
|
const tracingClient = coreTracing.createTracingClient({
|
8649
8579
|
namespace: "Microsoft.Messaging.EventGrid",
|
8650
8580
|
packageName: "@azure/event-grid",
|
8651
|
-
packageVersion: "4.13.0",
|
8581
|
+
packageVersion: "4.13.0-beta.2",
|
8652
8582
|
});
|
8653
8583
|
|
8654
8584
|
// Copyright (c) Microsoft Corporation.
|
@@ -8708,7 +8638,7 @@ class EventGridPublisherClient {
|
|
8708
8638
|
if (channelName) {
|
8709
8639
|
sendOptions.aegChannelName = channelName;
|
8710
8640
|
}
|
8711
|
-
return this.client.publishCloudEventEvents(this.endpointUrl, events.map(convertCloudEventToModelType), sendOptions);
|
8641
|
+
return this.client.publishCloudEventEvents(this.endpointUrl, events.map(convertCloudEventToModelType$1), sendOptions);
|
8712
8642
|
}
|
8713
8643
|
case "Custom": {
|
8714
8644
|
return this.client.publishCustomEventEvents(this.endpointUrl, events, updatedOptions);
|
@@ -8738,7 +8668,7 @@ function convertEventGridEventToModelType(event) {
|
|
8738
8668
|
/**
|
8739
8669
|
* @internal
|
8740
8670
|
*/
|
8741
|
-
function convertCloudEventToModelType(event) {
|
8671
|
+
function convertCloudEventToModelType$1(event) {
|
8742
8672
|
var _a, _b, _c, _d;
|
8743
8673
|
if (event.extensionAttributes) {
|
8744
8674
|
for (const propName in event.extensionAttributes) {
|
@@ -8888,6 +8818,429 @@ function isSystemEvent(eventType, event) {
|
|
8888
8818
|
}
|
8889
8819
|
}
|
8890
8820
|
|
8821
|
+
// Copyright (c) Microsoft Corporation.
|
8822
|
+
const logger = logger$1.createClientLogger("event-grid-modular");
|
8823
|
+
|
8824
|
+
// Copyright (c) Microsoft Corporation.
|
8825
|
+
/**
|
8826
|
+
* Initialize a new instance of `EventGridContext`
|
8827
|
+
* @param endpoint - The host name of the namespace, e.g. namespaceName1.westus-1.eventgrid.azure.net
|
8828
|
+
* @param credentials - Uniquely identify client credential
|
8829
|
+
* @param options - optional parameters
|
8830
|
+
*/
|
8831
|
+
function createClient(endpoint, credentials, options = {}) {
|
8832
|
+
var _a, _b, _c, _d;
|
8833
|
+
const baseUrl = (_a = options.baseUrl) !== null && _a !== void 0 ? _a : `${endpoint}`;
|
8834
|
+
options.apiVersion = (_b = options.apiVersion) !== null && _b !== void 0 ? _b : "2023-06-01-preview";
|
8835
|
+
options = Object.assign(Object.assign({}, options), { credentials: {
|
8836
|
+
apiKeyHeaderName: "Authorization",
|
8837
|
+
} });
|
8838
|
+
const userAgentInfo = `azsdk-js-event-grid-modular-rest/1.0.0-beta.1`;
|
8839
|
+
const userAgentPrefix = options.userAgentOptions && options.userAgentOptions.userAgentPrefix
|
8840
|
+
? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}`
|
8841
|
+
: `${userAgentInfo}`;
|
8842
|
+
options = Object.assign(Object.assign({}, options), { userAgentOptions: {
|
8843
|
+
userAgentPrefix,
|
8844
|
+
}, loggingOptions: {
|
8845
|
+
logger: (_d = (_c = options.loggingOptions) === null || _c === void 0 ? void 0 : _c.logger) !== null && _d !== void 0 ? _d : logger.info,
|
8846
|
+
} });
|
8847
|
+
const client = coreClient$1.getClient(baseUrl, credentials, options);
|
8848
|
+
return client;
|
8849
|
+
}
|
8850
|
+
|
8851
|
+
// Copyright (c) Microsoft Corporation.
|
8852
|
+
// Licensed under the MIT license.
|
8853
|
+
const responseMap = {
|
8854
|
+
"POST /topics/{topicName}:publish": ["200"],
|
8855
|
+
"POST /topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:receive": ["200"],
|
8856
|
+
"POST /topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge": ["200"],
|
8857
|
+
"POST /topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:release": ["200"],
|
8858
|
+
"POST /topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:reject": ["200"],
|
8859
|
+
};
|
8860
|
+
function isUnexpected(response) {
|
8861
|
+
const lroOriginal = response.headers["x-ms-original-url"];
|
8862
|
+
const url = new URL(lroOriginal !== null && lroOriginal !== void 0 ? lroOriginal : response.request.url);
|
8863
|
+
const method = response.request.method;
|
8864
|
+
let pathDetails = responseMap[`${method} ${url.pathname}`];
|
8865
|
+
if (!pathDetails) {
|
8866
|
+
pathDetails = getParametrizedPathSuccess(method, url.pathname);
|
8867
|
+
}
|
8868
|
+
return !pathDetails.includes(response.status);
|
8869
|
+
}
|
8870
|
+
function getParametrizedPathSuccess(method, path) {
|
8871
|
+
var _a, _b, _c, _d;
|
8872
|
+
const pathParts = path.split("/");
|
8873
|
+
// Traverse list to match the longest candidate
|
8874
|
+
// matchedLen: the length of candidate path
|
8875
|
+
// matchedValue: the matched status code array
|
8876
|
+
let matchedLen = -1, matchedValue = [];
|
8877
|
+
// Iterate the responseMap to find a match
|
8878
|
+
for (const [key, value] of Object.entries(responseMap)) {
|
8879
|
+
// Extracting the path from the map key which is in format
|
8880
|
+
// GET /path/foo
|
8881
|
+
if (!key.startsWith(method)) {
|
8882
|
+
continue;
|
8883
|
+
}
|
8884
|
+
const candidatePath = getPathFromMapKey(key);
|
8885
|
+
// Get each part of the url path
|
8886
|
+
const candidateParts = candidatePath.split("/");
|
8887
|
+
// track if we have found a match to return the values found.
|
8888
|
+
let found = true;
|
8889
|
+
for (let i = candidateParts.length - 1, j = pathParts.length - 1; i >= 1 && j >= 1; i--, j--) {
|
8890
|
+
if (((_a = candidateParts[i]) === null || _a === void 0 ? void 0 : _a.startsWith("{")) && ((_b = candidateParts[i]) === null || _b === void 0 ? void 0 : _b.indexOf("}")) !== -1) {
|
8891
|
+
const start = candidateParts[i].indexOf("}") + 1, end = (_c = candidateParts[i]) === null || _c === void 0 ? void 0 : _c.length;
|
8892
|
+
// If the current part of the candidate is a "template" part
|
8893
|
+
// Try to use the suffix of pattern to match the path
|
8894
|
+
// {guid} ==> $
|
8895
|
+
// {guid}:export ==> :export$
|
8896
|
+
const isMatched = new RegExp(`${(_d = candidateParts[i]) === null || _d === void 0 ? void 0 : _d.slice(start, end)}`).test(pathParts[j] || "");
|
8897
|
+
if (!isMatched) {
|
8898
|
+
found = false;
|
8899
|
+
break;
|
8900
|
+
}
|
8901
|
+
continue;
|
8902
|
+
}
|
8903
|
+
// If the candidate part is not a template and
|
8904
|
+
// the parts don't match mark the candidate as not found
|
8905
|
+
// to move on with the next candidate path.
|
8906
|
+
if (candidateParts[i] !== pathParts[j]) {
|
8907
|
+
found = false;
|
8908
|
+
break;
|
8909
|
+
}
|
8910
|
+
}
|
8911
|
+
// We finished evaluating the current candidate parts
|
8912
|
+
// Update the matched value if and only if we found the longer pattern
|
8913
|
+
if (found && candidatePath.length > matchedLen) {
|
8914
|
+
matchedLen = candidatePath.length;
|
8915
|
+
matchedValue = value;
|
8916
|
+
}
|
8917
|
+
}
|
8918
|
+
return matchedValue;
|
8919
|
+
}
|
8920
|
+
function getPathFromMapKey(mapKey) {
|
8921
|
+
const pathStart = mapKey.indexOf("/");
|
8922
|
+
return mapKey.slice(pathStart);
|
8923
|
+
}
|
8924
|
+
|
8925
|
+
// Copyright (c) Microsoft Corporation.
|
8926
|
+
/** Azure Messaging EventGrid Client */
|
8927
|
+
function createEventGrid(endpoint, credential, options = {}) {
|
8928
|
+
const baseUrl = endpoint;
|
8929
|
+
options.credentials = Object.assign(Object.assign({}, options.credentials), { apiKeyHeaderName: "Authorization" });
|
8930
|
+
const clientContext = createClient(baseUrl, credential, options);
|
8931
|
+
return clientContext;
|
8932
|
+
}
|
8933
|
+
|
8934
|
+
// Copyright (c) Microsoft Corporation.
|
8935
|
+
/** Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. */
|
8936
|
+
async function publishCloudEvent(context, event, topicName, options = { requestOptions: {} }) {
|
8937
|
+
var _a, _b, _c, _d, _e;
|
8938
|
+
const result = await context.path("/topics/{topicName}:publish", topicName).post({
|
8939
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
8940
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
8941
|
+
contentType: (_c = options.contentType) !== null && _c !== void 0 ? _c : "application/cloudevents+json; charset=utf-8",
|
8942
|
+
headers: Object.assign({}, (_d = options.requestOptions) === null || _d === void 0 ? void 0 : _d.headers),
|
8943
|
+
body: Object.assign({}, event),
|
8944
|
+
});
|
8945
|
+
if (typeof ((_e = options.requestOptions) === null || _e === void 0 ? void 0 : _e.onResponse) === "function") {
|
8946
|
+
options.requestOptions.onResponse(result);
|
8947
|
+
}
|
8948
|
+
if (isUnexpected(result)) {
|
8949
|
+
throw result.body;
|
8950
|
+
}
|
8951
|
+
return result.body;
|
8952
|
+
}
|
8953
|
+
/** Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200 status code with an empty JSON object in response. Otherwise, the server can return various error codes. For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for internal server error. */
|
8954
|
+
async function publishCloudEvents(context, events, topicName, options = { requestOptions: {} }) {
|
8955
|
+
var _a, _b, _c, _d, _e;
|
8956
|
+
const result = await context.path("/topics/{topicName}:publish", topicName).post({
|
8957
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
8958
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
8959
|
+
contentType: (_c = options.contentType) !== null && _c !== void 0 ? _c : "application/cloudevents-batch+json; charset=utf-8",
|
8960
|
+
headers: Object.assign({}, (_d = options.requestOptions) === null || _d === void 0 ? void 0 : _d.headers),
|
8961
|
+
body: events,
|
8962
|
+
});
|
8963
|
+
if (typeof ((_e = options.requestOptions) === null || _e === void 0 ? void 0 : _e.onResponse) === "function") {
|
8964
|
+
options.requestOptions.onResponse(result);
|
8965
|
+
}
|
8966
|
+
if (isUnexpected(result)) {
|
8967
|
+
throw result.body;
|
8968
|
+
}
|
8969
|
+
return result.body;
|
8970
|
+
}
|
8971
|
+
/** Receive Batch of Cloud Events from the Event Subscription. */
|
8972
|
+
async function receiveCloudEvents(context, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
8973
|
+
var _a, _b, _c, _d, _e;
|
8974
|
+
const result = await context
|
8975
|
+
.path("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:receive", topicName, eventSubscriptionName)
|
8976
|
+
.post({
|
8977
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
8978
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
8979
|
+
headers: Object.assign({}, (_c = options.requestOptions) === null || _c === void 0 ? void 0 : _c.headers),
|
8980
|
+
queryParameters: Object.assign(Object.assign({}, (options.maxEvents && { maxEvents: options.maxEvents })), (options.maxWaitTime && { maxWaitTime: options.maxWaitTime })),
|
8981
|
+
});
|
8982
|
+
if (typeof ((_d = options.requestOptions) === null || _d === void 0 ? void 0 : _d.onResponse) === "function") {
|
8983
|
+
options.requestOptions.onResponse(result);
|
8984
|
+
}
|
8985
|
+
if (isUnexpected(result)) {
|
8986
|
+
throw result.body;
|
8987
|
+
}
|
8988
|
+
return {
|
8989
|
+
value: ((_e = result.body["value"]) !== null && _e !== void 0 ? _e : []).map((p) => {
|
8990
|
+
var _a;
|
8991
|
+
return ({
|
8992
|
+
brokerProperties: {
|
8993
|
+
lockToken: p.brokerProperties["lockToken"],
|
8994
|
+
deliveryCount: p.brokerProperties["deliveryCount"],
|
8995
|
+
},
|
8996
|
+
event: {
|
8997
|
+
id: p.event["id"],
|
8998
|
+
source: p.event["source"],
|
8999
|
+
data: p.event["data"],
|
9000
|
+
dataBase64: p.event["data_base64"],
|
9001
|
+
type: p.event["type"],
|
9002
|
+
time: new Date((_a = p.event["time"]) !== null && _a !== void 0 ? _a : ""),
|
9003
|
+
specversion: p.event["specversion"],
|
9004
|
+
dataschema: p.event["dataschema"],
|
9005
|
+
datacontenttype: p.event["datacontenttype"],
|
9006
|
+
subject: p.event["subject"],
|
9007
|
+
},
|
9008
|
+
});
|
9009
|
+
}),
|
9010
|
+
};
|
9011
|
+
}
|
9012
|
+
/** Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully acknowledged. The response body will include the set of successfully acknowledged lockTokens, along with other failed lockTokens with their corresponding error information. Successfully acknowledged events will no longer be available to any consumer. */
|
9013
|
+
async function acknowledgeCloudEvents(context, lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9014
|
+
var _a, _b, _c, _d, _e, _f;
|
9015
|
+
const result = await context
|
9016
|
+
.path("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:acknowledge", topicName, eventSubscriptionName)
|
9017
|
+
.post({
|
9018
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
9019
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
9020
|
+
contentType: (_c = options.contentType) !== null && _c !== void 0 ? _c : "application/json; charset=utf-8",
|
9021
|
+
headers: Object.assign({}, (_d = options.requestOptions) === null || _d === void 0 ? void 0 : _d.headers),
|
9022
|
+
body: { lockTokens: lockTokens },
|
9023
|
+
});
|
9024
|
+
if (typeof ((_e = options.requestOptions) === null || _e === void 0 ? void 0 : _e.onResponse) === "function") {
|
9025
|
+
options.requestOptions.onResponse(result);
|
9026
|
+
}
|
9027
|
+
if (isUnexpected(result)) {
|
9028
|
+
throw result.body;
|
9029
|
+
}
|
9030
|
+
return {
|
9031
|
+
failedLockTokens: ((_f = result.body["failedLockTokens"]) !== null && _f !== void 0 ? _f : []).map((p) => ({
|
9032
|
+
lockToken: p["lockToken"],
|
9033
|
+
errorCode: p["errorCode"],
|
9034
|
+
errorDescription: p["errorDescription"],
|
9035
|
+
})),
|
9036
|
+
succeededLockTokens: result.body["succeededLockTokens"],
|
9037
|
+
};
|
9038
|
+
}
|
9039
|
+
/** Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is successfully released. The response body will include the set of successfully released lockTokens, along with other failed lockTokens with their corresponding error information. */
|
9040
|
+
async function releaseCloudEvents(context, lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9041
|
+
var _a, _b, _c, _d, _e, _f;
|
9042
|
+
const result = await context
|
9043
|
+
.path("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:release", topicName, eventSubscriptionName)
|
9044
|
+
.post({
|
9045
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
9046
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
9047
|
+
contentType: (_c = options.contentType) !== null && _c !== void 0 ? _c : "application/json; charset=utf-8",
|
9048
|
+
headers: Object.assign({}, (_d = options.requestOptions) === null || _d === void 0 ? void 0 : _d.headers),
|
9049
|
+
body: { lockTokens: lockTokens },
|
9050
|
+
});
|
9051
|
+
if (typeof ((_e = options.requestOptions) === null || _e === void 0 ? void 0 : _e.onResponse) === "function") {
|
9052
|
+
options.requestOptions.onResponse(result);
|
9053
|
+
}
|
9054
|
+
if (isUnexpected(result)) {
|
9055
|
+
throw result.body;
|
9056
|
+
}
|
9057
|
+
return {
|
9058
|
+
failedLockTokens: ((_f = result.body["failedLockTokens"]) !== null && _f !== void 0 ? _f : []).map((p) => ({
|
9059
|
+
lockToken: p["lockToken"],
|
9060
|
+
errorCode: p["errorCode"],
|
9061
|
+
errorDescription: p["errorDescription"],
|
9062
|
+
})),
|
9063
|
+
succeededLockTokens: result.body["succeededLockTokens"],
|
9064
|
+
};
|
9065
|
+
}
|
9066
|
+
/** Reject batch of Cloud Events. */
|
9067
|
+
async function rejectCloudEvents(context, lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9068
|
+
var _a, _b, _c, _d, _e, _f;
|
9069
|
+
const result = await context
|
9070
|
+
.path("/topics/{topicName}/eventsubscriptions/{eventSubscriptionName}:reject", topicName, eventSubscriptionName)
|
9071
|
+
.post({
|
9072
|
+
allowInsecureConnection: (_a = options.requestOptions) === null || _a === void 0 ? void 0 : _a.allowInsecureConnection,
|
9073
|
+
skipUrlEncoding: (_b = options.requestOptions) === null || _b === void 0 ? void 0 : _b.skipUrlEncoding,
|
9074
|
+
contentType: (_c = options.contentType) !== null && _c !== void 0 ? _c : "application/json; charset=utf-8",
|
9075
|
+
headers: Object.assign({}, (_d = options.requestOptions) === null || _d === void 0 ? void 0 : _d.headers),
|
9076
|
+
body: { lockTokens: lockTokens },
|
9077
|
+
});
|
9078
|
+
if (typeof ((_e = options.requestOptions) === null || _e === void 0 ? void 0 : _e.onResponse) === "function") {
|
9079
|
+
options.requestOptions.onResponse(result);
|
9080
|
+
}
|
9081
|
+
if (isUnexpected(result)) {
|
9082
|
+
throw result.body;
|
9083
|
+
}
|
9084
|
+
return {
|
9085
|
+
failedLockTokens: ((_f = result.body["failedLockTokens"]) !== null && _f !== void 0 ? _f : []).map((p) => ({
|
9086
|
+
lockToken: p["lockToken"],
|
9087
|
+
errorCode: p["errorCode"],
|
9088
|
+
errorDescription: p["errorDescription"],
|
9089
|
+
})),
|
9090
|
+
succeededLockTokens: result.body["succeededLockTokens"],
|
9091
|
+
};
|
9092
|
+
}
|
9093
|
+
|
9094
|
+
// Copyright (c) Microsoft Corporation.
|
9095
|
+
class EventGridClient$1 {
|
9096
|
+
/** Azure Messaging EventGrid Client */
|
9097
|
+
constructor(endpoint, credential, options = {}) {
|
9098
|
+
this._client = createEventGrid(endpoint, credential, options);
|
9099
|
+
}
|
9100
|
+
publishCloudEvent(event, topicName, options = { requestOptions: {} }) {
|
9101
|
+
return publishCloudEvent(this._client, event, topicName, options);
|
9102
|
+
}
|
9103
|
+
publishCloudEvents(events, topicName, options = { requestOptions: {} }) {
|
9104
|
+
return publishCloudEvents(this._client, events, topicName, options);
|
9105
|
+
}
|
9106
|
+
receiveCloudEvents(topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9107
|
+
return receiveCloudEvents(this._client, topicName, eventSubscriptionName, options);
|
9108
|
+
}
|
9109
|
+
acknowledgeCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9110
|
+
return acknowledgeCloudEvents(this._client, lockTokens, topicName, eventSubscriptionName, options);
|
9111
|
+
}
|
9112
|
+
releaseCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9113
|
+
return releaseCloudEvents(this._client, lockTokens, topicName, eventSubscriptionName, options);
|
9114
|
+
}
|
9115
|
+
rejectCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9116
|
+
return rejectCloudEvents(this._client, lockTokens, topicName, eventSubscriptionName, options);
|
9117
|
+
}
|
9118
|
+
}
|
9119
|
+
|
9120
|
+
// Copyright (c) Microsoft Corporation.
|
9121
|
+
/**
|
9122
|
+
* Event Grid Client
|
9123
|
+
*/
|
9124
|
+
class EventGridClient {
|
9125
|
+
/** Azure Messaging EventGrid Client */
|
9126
|
+
constructor(endpoint, credential, options = {}) {
|
9127
|
+
credential.update(`SharedAccessKey ${credential.key}`);
|
9128
|
+
this._client = new EventGridClient$1(endpoint, credential, options);
|
9129
|
+
}
|
9130
|
+
/**
|
9131
|
+
* Publish Single Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200
|
9132
|
+
* status code with an empty JSON object in response. Otherwise, the server can return various error codes.
|
9133
|
+
* For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message
|
9134
|
+
* is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for
|
9135
|
+
* internal server error.
|
9136
|
+
*
|
9137
|
+
* @param event - Event to publish
|
9138
|
+
* @param topicName - Topic to publish the event
|
9139
|
+
* @param options - Options to publish
|
9140
|
+
*
|
9141
|
+
*/
|
9142
|
+
publishCloudEvent(event, topicName, options = { requestOptions: {} }) {
|
9143
|
+
return this._client.publishCloudEvent(convertCloudEventToModelType(event), topicName, options);
|
9144
|
+
}
|
9145
|
+
/**
|
9146
|
+
* Publish Batch Cloud Event to namespace topic. In case of success, the server responds with an HTTP 200
|
9147
|
+
* status code with an empty JSON object in response. Otherwise, the server can return various error codes.
|
9148
|
+
* For example, 401: which indicates authorization failure, 403: which indicates quota exceeded or message
|
9149
|
+
* is too large, 410: which indicates that specific topic is not found, 400: for bad request, and 500: for
|
9150
|
+
* internal server error.
|
9151
|
+
*
|
9152
|
+
* @param events - Events to publish
|
9153
|
+
* @param topicName - Topic to publish the event
|
9154
|
+
* @param options - Options to publish
|
9155
|
+
*
|
9156
|
+
*/
|
9157
|
+
publishCloudEvents(events, topicName, options = { requestOptions: {} }) {
|
9158
|
+
const eventsWireModel = [];
|
9159
|
+
for (const individualevent of events) {
|
9160
|
+
eventsWireModel.push(convertCloudEventToModelType(individualevent));
|
9161
|
+
}
|
9162
|
+
return this._client.publishCloudEvents(eventsWireModel, topicName, options);
|
9163
|
+
}
|
9164
|
+
/**
|
9165
|
+
* Receive Batch of Cloud Events from the Event Subscription.
|
9166
|
+
*
|
9167
|
+
* @param topicName - Topic to receive
|
9168
|
+
* @param eventSubscriptionName - Name of the Event Subscription
|
9169
|
+
* @param options - Options to receive
|
9170
|
+
*
|
9171
|
+
*/
|
9172
|
+
receiveCloudEvents(topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9173
|
+
return this._client.receiveCloudEvents(topicName, eventSubscriptionName, options);
|
9174
|
+
}
|
9175
|
+
/**
|
9176
|
+
* Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one
|
9177
|
+
* event is successfully acknowledged. The response body will include the set of successfully acknowledged
|
9178
|
+
* lockTokens, along with other failed lockTokens with their corresponding error information. Successfully
|
9179
|
+
* acknowledged events will no longer be available to any consumer.
|
9180
|
+
*
|
9181
|
+
* @param lockTokens - Lock Tokens
|
9182
|
+
* @param topicName - Topic Name
|
9183
|
+
* @param eventSubscriptionName - Name of the Event Subscription
|
9184
|
+
* @param options - Options to Acknowledge
|
9185
|
+
*
|
9186
|
+
*/
|
9187
|
+
acknowledgeCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9188
|
+
return this._client.acknowledgeCloudEvents(lockTokens, topicName, eventSubscriptionName, options);
|
9189
|
+
}
|
9190
|
+
/**
|
9191
|
+
* Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is
|
9192
|
+
* successfully released. The response body will include the set of successfully released lockTokens, along
|
9193
|
+
* with other failed lockTokens with their corresponding error information.
|
9194
|
+
*
|
9195
|
+
* @param lockTokens - Lock Tokens
|
9196
|
+
* @param topicName - Topic Name
|
9197
|
+
* @param eventSubscriptionName - Name of the Event Subscription
|
9198
|
+
* @param options - Options to release
|
9199
|
+
*
|
9200
|
+
*/
|
9201
|
+
releaseCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9202
|
+
return this._client.releaseCloudEvents(lockTokens, topicName, eventSubscriptionName, options);
|
9203
|
+
}
|
9204
|
+
/**
|
9205
|
+
* Reject batch of Cloud Events.
|
9206
|
+
*
|
9207
|
+
* @param lockTokens - Lock Tokens
|
9208
|
+
* @param topicName - Topic Name
|
9209
|
+
* @param eventSubscriptionName - Name of the Event Subscription
|
9210
|
+
* @param options - Options to reject
|
9211
|
+
*
|
9212
|
+
*/
|
9213
|
+
rejectCloudEvents(lockTokens, topicName, eventSubscriptionName, options = { requestOptions: {} }) {
|
9214
|
+
return this._client.rejectCloudEvents(lockTokens, topicName, eventSubscriptionName, options);
|
9215
|
+
}
|
9216
|
+
}
|
9217
|
+
function convertCloudEventToModelType(event) {
|
9218
|
+
var _a, _b, _c, _d, _e;
|
9219
|
+
if (event.extensionAttributes) {
|
9220
|
+
for (const propName in event.extensionAttributes) {
|
9221
|
+
// Per the cloud events spec: "CloudEvents attribute names MUST consist of lower-case letters ('a' to 'z') or digits ('0' to '9') from the ASCII character set"
|
9222
|
+
// they also can not match an existing defined property name.
|
9223
|
+
if (!/^[a-z0-9]*$/.test(propName) ||
|
9224
|
+
cloudEventReservedPropertyNames.indexOf(propName) !== -1) {
|
9225
|
+
throw new Error(`invalid extension attribute name: ${propName}`);
|
9226
|
+
}
|
9227
|
+
}
|
9228
|
+
}
|
9229
|
+
const converted = Object.assign({ specversion: (_a = event.specversion) !== null && _a !== void 0 ? _a : "1.0", type: event.type, source: event.source, id: (_b = event.id) !== null && _b !== void 0 ? _b : uuid.v4(), time: (_c = event.time) !== null && _c !== void 0 ? _c : new Date(), subject: event.subject, dataschema: event.dataschema }, ((_d = event.extensionAttributes) !== null && _d !== void 0 ? _d : []));
|
9230
|
+
if (event.data instanceof Uint8Array) {
|
9231
|
+
if (!event.datacontenttype) {
|
9232
|
+
throw new Error("a data content type must be provided when sending an event with binary data");
|
9233
|
+
}
|
9234
|
+
converted.datacontenttype = event.datacontenttype;
|
9235
|
+
converted.data_base64 = event.data;
|
9236
|
+
}
|
9237
|
+
else {
|
9238
|
+
converted.datacontenttype = (_e = event.datacontenttype) !== null && _e !== void 0 ? _e : "application/json";
|
9239
|
+
converted.data = event.data;
|
9240
|
+
}
|
9241
|
+
return converted;
|
9242
|
+
}
|
9243
|
+
|
8891
9244
|
Object.defineProperty(exports, 'AzureKeyCredential', {
|
8892
9245
|
enumerable: true,
|
8893
9246
|
get: function () { return coreAuth.AzureKeyCredential; }
|
@@ -8896,6 +9249,7 @@ Object.defineProperty(exports, 'AzureSASCredential', {
|
|
8896
9249
|
enumerable: true,
|
8897
9250
|
get: function () { return coreAuth.AzureSASCredential; }
|
8898
9251
|
});
|
9252
|
+
exports.EventGridClient = EventGridClient;
|
8899
9253
|
exports.EventGridDeserializer = EventGridDeserializer;
|
8900
9254
|
exports.EventGridPublisherClient = EventGridPublisherClient;
|
8901
9255
|
exports.generateSharedAccessSignature = generateSharedAccessSignature;
|