@azure/eventgrid-namespaces 1.0.2-alpha.20260302.1 → 1.0.2-alpha.20260304.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/commonjs/cloudEventDistrubtedTracingEnricherPolicy.js +62 -55
- package/dist/commonjs/cloudEventDistrubtedTracingEnricherPolicy.js.map +7 -1
- package/dist/commonjs/consumer.js +76 -73
- package/dist/commonjs/consumer.js.map +7 -1
- package/dist/commonjs/eventGridReceiverClient.js +136 -105
- package/dist/commonjs/eventGridReceiverClient.js.map +7 -1
- package/dist/commonjs/eventGridSenderClient.js +94 -81
- package/dist/commonjs/eventGridSenderClient.js.map +7 -1
- package/dist/commonjs/generated/api/eventGridContext.js +66 -48
- package/dist/commonjs/generated/api/eventGridContext.js.map +7 -1
- package/dist/commonjs/generated/api/index.js +42 -16
- package/dist/commonjs/generated/api/index.js.map +7 -1
- package/dist/commonjs/generated/api/operations.js +300 -206
- package/dist/commonjs/generated/api/operations.js.map +7 -1
- package/dist/commonjs/generated/api/options.js +15 -5
- package/dist/commonjs/generated/api/options.js.map +7 -1
- package/dist/commonjs/generated/eventGridClient.js +98 -52
- package/dist/commonjs/generated/eventGridClient.js.map +7 -1
- package/dist/commonjs/generated/index.js +32 -11
- package/dist/commonjs/generated/index.js.map +7 -1
- package/dist/commonjs/generated/logger.js +28 -8
- package/dist/commonjs/generated/logger.js.map +7 -1
- package/dist/commonjs/generated/models/index.js +29 -9
- package/dist/commonjs/generated/models/index.js.map +7 -1
- package/dist/commonjs/generated/models/models.js +156 -124
- package/dist/commonjs/generated/models/models.js.map +7 -1
- package/dist/commonjs/generated/static-helpers/urlTemplate.js +149 -148
- package/dist/commonjs/generated/static-helpers/urlTemplate.js.map +7 -1
- package/dist/commonjs/index.js +39 -16
- package/dist/commonjs/index.js.map +7 -1
- package/dist/commonjs/models.js +36 -16
- package/dist/commonjs/models.js.map +7 -1
- package/dist/commonjs/util.js +152 -145
- package/dist/commonjs/util.js.map +7 -1
- package/dist/esm/cloudEventDistrubtedTracingEnricherPolicy.js +35 -52
- package/dist/esm/cloudEventDistrubtedTracingEnricherPolicy.js.map +7 -1
- package/dist/esm/consumer.js +50 -66
- package/dist/esm/consumer.js.map +7 -1
- package/dist/esm/eventGridReceiverClient.js +110 -98
- package/dist/esm/eventGridReceiverClient.js.map +7 -1
- package/dist/esm/eventGridSenderClient.js +67 -73
- package/dist/esm/eventGridSenderClient.js.map +7 -1
- package/dist/esm/generated/api/eventGridContext.js +44 -44
- package/dist/esm/generated/api/eventGridContext.js.map +7 -1
- package/dist/esm/generated/api/index.js +22 -5
- package/dist/esm/generated/api/index.js.map +7 -1
- package/dist/esm/generated/api/operations.js +301 -215
- package/dist/esm/generated/api/operations.js.map +7 -1
- package/dist/esm/generated/api/options.js +0 -4
- package/dist/esm/generated/api/options.js.map +7 -1
- package/dist/esm/generated/eventGridClient.js +86 -49
- package/dist/esm/generated/eventGridClient.js.map +7 -1
- package/dist/esm/generated/index.js +10 -5
- package/dist/esm/generated/index.js.map +7 -1
- package/dist/esm/generated/logger.js +4 -4
- package/dist/esm/generated/logger.js.map +7 -1
- package/dist/esm/generated/models/index.js +8 -4
- package/dist/esm/generated/models/index.js.map +7 -1
- package/dist/esm/generated/models/models.js +131 -120
- package/dist/esm/generated/models/models.js.map +7 -1
- package/dist/esm/generated/static-helpers/urlTemplate.js +126 -145
- package/dist/esm/generated/static-helpers/urlTemplate.js.map +7 -1
- package/dist/esm/index.js +14 -8
- package/dist/esm/index.js.map +7 -1
- package/dist/esm/models.js +13 -13
- package/dist/esm/models.js.map +7 -1
- package/dist/esm/util.js +129 -142
- package/dist/esm/util.js.map +7 -1
- package/package.json +4 -21
- package/dist/browser/generated/metadata.json +0 -4
- package/dist/commonjs/generated/metadata.json +0 -4
- package/dist/esm/generated/metadata.json +0 -4
- package/dist/react-native/generated/metadata.json +0 -4
|
@@ -1,57 +1,64 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var cloudEventDistrubtedTracingEnricherPolicy_exports = {};
|
|
19
|
+
__export(cloudEventDistrubtedTracingEnricherPolicy_exports, {
|
|
20
|
+
CloudEventBatchContentType: () => CloudEventBatchContentType,
|
|
21
|
+
ContentTypeHeaderName: () => ContentTypeHeaderName,
|
|
22
|
+
TraceParentHeaderName: () => TraceParentHeaderName,
|
|
23
|
+
TraceStateHeaderName: () => TraceStateHeaderName,
|
|
24
|
+
cloudEventDistributedTracingEnricherPolicy: () => cloudEventDistributedTracingEnricherPolicy,
|
|
25
|
+
cloudEventDistributedTracingEnricherPolicyName: () => cloudEventDistributedTracingEnricherPolicyName
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(cloudEventDistrubtedTracingEnricherPolicy_exports);
|
|
28
|
+
const CloudEventBatchContentType = "application/cloudevents-batch+json; charset=utf-8";
|
|
29
|
+
const TraceParentHeaderName = "traceparent";
|
|
30
|
+
const TraceStateHeaderName = "tracestate";
|
|
31
|
+
const ContentTypeHeaderName = "Content-Type";
|
|
32
|
+
const cloudEventDistributedTracingEnricherPolicyName = "cloudEventDistributedTracingEnricherPolicy";
|
|
27
33
|
function cloudEventDistributedTracingEnricherPolicy() {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
request.body = JSON.stringify(parsedBody);
|
|
52
|
-
}
|
|
53
|
-
return next(request);
|
|
54
|
-
},
|
|
55
|
-
};
|
|
34
|
+
return {
|
|
35
|
+
name: cloudEventDistributedTracingEnricherPolicyName,
|
|
36
|
+
async sendRequest(request, next) {
|
|
37
|
+
const traceparent = request.headers.get(TraceParentHeaderName);
|
|
38
|
+
const tracestate = request.headers.get(TraceStateHeaderName);
|
|
39
|
+
if (request.headers.get(ContentTypeHeaderName) === CloudEventBatchContentType && typeof request.body === "string" && traceparent) {
|
|
40
|
+
const parsedBody = JSON.parse(request.body);
|
|
41
|
+
for (const item of parsedBody) {
|
|
42
|
+
if (typeof item !== "object" || item.traceparent) {
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
item.traceparent = traceparent;
|
|
46
|
+
if (tracestate) {
|
|
47
|
+
item.tracestate = tracestate;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
request.body = JSON.stringify(parsedBody);
|
|
51
|
+
}
|
|
52
|
+
return next(request);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
56
55
|
}
|
|
57
|
-
|
|
56
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
57
|
+
0 && (module.exports = {
|
|
58
|
+
CloudEventBatchContentType,
|
|
59
|
+
ContentTypeHeaderName,
|
|
60
|
+
TraceParentHeaderName,
|
|
61
|
+
TraceStateHeaderName,
|
|
62
|
+
cloudEventDistributedTracingEnricherPolicy,
|
|
63
|
+
cloudEventDistributedTracingEnricherPolicyName
|
|
64
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/eventgrid/eventgrid-namespaces/src/cloudEventDistrubtedTracingEnricherPolicy.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport type {\n PipelineResponse,\n PipelineRequest,\n SendRequest,\n PipelinePolicy,\n} from \"@azure/core-rest-pipeline\";\n\nexport const CloudEventBatchContentType = \"application/cloudevents-batch+json; charset=utf-8\";\nexport const TraceParentHeaderName = \"traceparent\";\nexport const TraceStateHeaderName = \"tracestate\";\nexport const ContentTypeHeaderName = \"Content-Type\";\n\n/**\n * The programmatic identifier of the cloudEventDistributedTracingEnricherPolicy.\n */\nexport const cloudEventDistributedTracingEnricherPolicyName =\n \"cloudEventDistributedTracingEnricherPolicy\";\n\n/**\n * cloudEventDistributedTracingEnricherPolicy is a policy which adds distributed tracing information\n * to a batch of cloud events. It does so by copying the `traceparent` and `tracestate` properties\n * from the HTTP request into the individual events as extension properties.\n *\n * This will only happen in the case where an event does not have a `traceparent` defined already. This\n * allows events to explicitly set a traceparent and tracestate which would be respected during \"multi-hop\n * transmition\".\n *\n * See https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md\n * for more information on distributed tracing and cloud events.\n */\nexport function cloudEventDistributedTracingEnricherPolicy(): PipelinePolicy {\n return {\n name: cloudEventDistributedTracingEnricherPolicyName,\n async sendRequest(request: PipelineRequest, next: SendRequest): Promise<PipelineResponse> {\n const traceparent = request.headers.get(TraceParentHeaderName);\n const tracestate = request.headers.get(TraceStateHeaderName);\n\n if (\n request.headers.get(ContentTypeHeaderName) === CloudEventBatchContentType &&\n typeof request.body === \"string\" &&\n traceparent\n ) {\n // per the cloud event batched content type we know the body is an array encoded in JSON.\n const parsedBody = JSON.parse(request.body) as any[];\n\n for (const item of parsedBody) {\n // When using the distributed tracing extension, the \"traceparent\" is a required property\n // and \"tracestate\" is optional. This means if an item already has a \"traceparent\" property\n // we should not stomp over it. Well formed events will not have a \"tracestate\" without\n // also having a \"traceparent\" so there's no need to guard against that case.\n if (typeof item !== \"object\" || item.traceparent) {\n continue;\n }\n\n item.traceparent = traceparent;\n if (tracestate) {\n item.tracestate = tracestate;\n }\n }\n\n request.body = JSON.stringify(parsedBody);\n }\n\n return next(request);\n },\n };\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUO,MAAM,6BAA6B;AACnC,MAAM,wBAAwB;AAC9B,MAAM,uBAAuB;AAC7B,MAAM,wBAAwB;AAK9B,MAAM,iDACX;AAcK,SAAS,6CAA6D;AAC3E,SAAO;AAAA,IACL,MAAM;AAAA,IACN,MAAM,YAAY,SAA0B,MAA8C;AACxF,YAAM,cAAc,QAAQ,QAAQ,IAAI,qBAAqB;AAC7D,YAAM,aAAa,QAAQ,QAAQ,IAAI,oBAAoB;AAE3D,UACE,QAAQ,QAAQ,IAAI,qBAAqB,MAAM,8BAC/C,OAAO,QAAQ,SAAS,YACxB,aACA;AAEA,cAAM,aAAa,KAAK,MAAM,QAAQ,IAAI;AAE1C,mBAAW,QAAQ,YAAY;AAK7B,cAAI,OAAO,SAAS,YAAY,KAAK,aAAa;AAChD;AAAA,UACF;AAEA,eAAK,cAAc;AACnB,cAAI,YAAY;AACd,iBAAK,aAAa;AAAA,UACpB;AAAA,QACF;AAEA,gBAAQ,OAAO,KAAK,UAAU,UAAU;AAAA,MAC1C;AAEA,aAAO,KAAK,OAAO;AAAA,IACrB;AAAA,EACF;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -1,77 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var consumer_exports = {};
|
|
19
|
+
__export(consumer_exports, {
|
|
20
|
+
EventGridDeserializer: () => EventGridDeserializer
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(consumer_exports);
|
|
23
|
+
var import_core_client = require("@azure/core-client");
|
|
24
|
+
var import_models = require("./models.js");
|
|
25
|
+
var import_util = require("./util.js");
|
|
26
|
+
const serializer = (0, import_core_client.createSerializer)();
|
|
21
27
|
class EventGridDeserializer {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
if (deserialized.dataBase64 !== undefined) {
|
|
53
|
-
if (deserialized.data !== undefined) {
|
|
54
|
-
throw new TypeError("event contains both a data and data_base64 field");
|
|
55
|
-
}
|
|
56
|
-
if (!(deserialized.dataBase64 instanceof Uint8Array)) {
|
|
57
|
-
throw new TypeError("event data_base64 property is not an instance of Uint8Array");
|
|
58
|
-
}
|
|
59
|
-
modelEvent.data = deserialized.dataBase64;
|
|
60
|
-
}
|
|
61
|
-
// Build the "extensionsAttributes" property bag by removing all known top level properties.
|
|
62
|
-
const extensionAttributes = { ...deserialized };
|
|
63
|
-
for (const propName of models_js_1.cloudEventReservedPropertyNames) {
|
|
64
|
-
delete extensionAttributes[propName];
|
|
65
|
-
}
|
|
66
|
-
delete extensionAttributes.dataBase64;
|
|
67
|
-
// If any properties remain, copy them to the model.
|
|
68
|
-
if (Object.keys(extensionAttributes).length > 0) {
|
|
69
|
-
modelEvent.extensionAttributes = extensionAttributes;
|
|
70
|
-
}
|
|
71
|
-
events.push(modelEvent);
|
|
28
|
+
async deserializeCloudEvents(encodedEvents) {
|
|
29
|
+
const decodedArray = (0, import_util.parseAndWrap)(encodedEvents);
|
|
30
|
+
const events = [];
|
|
31
|
+
for (const o of decodedArray) {
|
|
32
|
+
(0, import_util.validateCloudEventEvent)(o);
|
|
33
|
+
const deserialized = serializer.deserialize(import_util.CloudEvent, o, "");
|
|
34
|
+
const modelEvent = {
|
|
35
|
+
specversion: deserialized.specversion,
|
|
36
|
+
id: deserialized.id,
|
|
37
|
+
source: deserialized.source,
|
|
38
|
+
type: deserialized.type
|
|
39
|
+
};
|
|
40
|
+
if (deserialized.datacontenttype !== void 0) {
|
|
41
|
+
modelEvent.datacontenttype = deserialized.datacontenttype;
|
|
42
|
+
}
|
|
43
|
+
if (deserialized.dataschema !== void 0) {
|
|
44
|
+
modelEvent.dataschema = deserialized.dataschema;
|
|
45
|
+
}
|
|
46
|
+
if (deserialized.subject !== void 0) {
|
|
47
|
+
modelEvent.subject = deserialized.subject;
|
|
48
|
+
}
|
|
49
|
+
if (deserialized.time !== void 0) {
|
|
50
|
+
modelEvent.time = deserialized.time;
|
|
51
|
+
}
|
|
52
|
+
if (deserialized.data !== void 0) {
|
|
53
|
+
modelEvent.data = deserialized.data;
|
|
54
|
+
}
|
|
55
|
+
if (deserialized.dataBase64 !== void 0) {
|
|
56
|
+
if (deserialized.data !== void 0) {
|
|
57
|
+
throw new TypeError("event contains both a data and data_base64 field");
|
|
72
58
|
}
|
|
73
|
-
|
|
59
|
+
if (!(deserialized.dataBase64 instanceof Uint8Array)) {
|
|
60
|
+
throw new TypeError("event data_base64 property is not an instance of Uint8Array");
|
|
61
|
+
}
|
|
62
|
+
modelEvent.data = deserialized.dataBase64;
|
|
63
|
+
}
|
|
64
|
+
const extensionAttributes = { ...deserialized };
|
|
65
|
+
for (const propName of import_models.cloudEventReservedPropertyNames) {
|
|
66
|
+
delete extensionAttributes[propName];
|
|
67
|
+
}
|
|
68
|
+
delete extensionAttributes.dataBase64;
|
|
69
|
+
if (Object.keys(extensionAttributes).length > 0) {
|
|
70
|
+
modelEvent.extensionAttributes = extensionAttributes;
|
|
71
|
+
}
|
|
72
|
+
events.push(modelEvent);
|
|
74
73
|
}
|
|
74
|
+
return events;
|
|
75
|
+
}
|
|
75
76
|
}
|
|
76
|
-
|
|
77
|
-
|
|
77
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
78
|
+
0 && (module.exports = {
|
|
79
|
+
EventGridDeserializer
|
|
80
|
+
});
|
|
@@ -1 +1,7 @@
|
|
|
1
|
-
{
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["/mnt/vss/_work/1/s/sdk/eventgrid/eventgrid-namespaces/src/consumer.ts"],
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT License.\n\nimport { createSerializer } from \"@azure/core-client\";\nimport type { CloudEvent } from \"./models.js\";\nimport { cloudEventReservedPropertyNames } from \"./models.js\";\nimport { CloudEvent as CloudEventMapper, parseAndWrap, validateCloudEventEvent } from \"./util.js\";\n\nconst serializer = createSerializer();\n\n/**\n * EventGridDeserializer is used to aid in processing events delivered by EventGrid. It can deserialize a JSON encoded payload\n * of either a single event or batch of events as well as be used to convert the result of `JSON.parse` into an\n * `EventGridEvent` or `CloudEvent` like object.\n *\n * Unlike normal JSON deseralization, EventGridDeserializer does some additional conversions:\n *\n * - The consumer parses the event time property into a `Date` object, for ease of use.\n * - When deserializing an event in the CloudEvent schema, if the event contains binary data, it is base64 decoded\n * and returned as an instance of the `Uint8Array` type.\n */\nexport class EventGridDeserializer {\n /**\n * Deserializes events encoded in the Cloud Events 1.0 schema.\n *\n * @param encodedEvents - the JSON encoded representation of either a single event or an array of\n * events, encoded in the Cloud Events 1.0 Schema.\n */\n public async deserializeCloudEvents(encodedEvents: string): Promise<CloudEvent<unknown>[]>;\n\n /**\n * Deserializes events encoded in the Cloud Events 1.0 schema.\n *\n * @param encodedEvents - an object representing a single event, encoded in the Cloud Events 1.0 schema.\n */\n public async deserializeCloudEvents(\n encodedEvents: Record<string, unknown>,\n ): Promise<CloudEvent<unknown>[]>;\n public async deserializeCloudEvents(\n encodedEvents: string | Record<string, unknown>,\n ): Promise<CloudEvent<unknown>[]> {\n const decodedArray = parseAndWrap(encodedEvents);\n\n const events: CloudEvent<unknown>[] = [];\n\n for (const o of decodedArray) {\n validateCloudEventEvent(o);\n\n // Check that the required fields are present and of the correct type and the optional fields are missing\n // or of the correct type.\n\n const deserialized = serializer.deserialize(CloudEventMapper, o, \"\");\n const modelEvent: Record<string, any> = {\n specversion: deserialized.specversion,\n id: deserialized.id,\n source: deserialized.source,\n type: deserialized.type,\n };\n\n if (deserialized.datacontenttype !== undefined) {\n modelEvent.datacontenttype = deserialized.datacontenttype;\n }\n\n if (deserialized.dataschema !== undefined) {\n modelEvent.dataschema = deserialized.dataschema;\n }\n\n if (deserialized.subject !== undefined) {\n modelEvent.subject = deserialized.subject;\n }\n\n if (deserialized.time !== undefined) {\n modelEvent.time = deserialized.time;\n }\n\n if (deserialized.data !== undefined) {\n modelEvent.data = deserialized.data;\n }\n\n // If the data the event represents binary, it is encoded as base64 text in a different property on the event and we need to transform it.\n if (deserialized.dataBase64 !== undefined) {\n if (deserialized.data !== undefined) {\n throw new TypeError(\"event contains both a data and data_base64 field\");\n }\n\n if (!(deserialized.dataBase64 instanceof Uint8Array)) {\n throw new TypeError(\"event data_base64 property is not an instance of Uint8Array\");\n }\n\n modelEvent.data = deserialized.dataBase64;\n }\n\n // Build the \"extensionsAttributes\" property bag by removing all known top level properties.\n const extensionAttributes = { ...deserialized };\n for (const propName of cloudEventReservedPropertyNames) {\n delete extensionAttributes[propName];\n }\n delete extensionAttributes.dataBase64;\n\n // If any properties remain, copy them to the model.\n if (Object.keys(extensionAttributes).length > 0) {\n modelEvent.extensionAttributes = extensionAttributes;\n }\n\n events.push(modelEvent as CloudEvent<unknown>);\n }\n\n return events;\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,yBAAiC;AAEjC,oBAAgD;AAChD,kBAAsF;AAEtF,MAAM,iBAAa,qCAAiB;AAa7B,MAAM,sBAAsB;AAAA,EAiBjC,MAAa,uBACX,eACgC;AAChC,UAAM,mBAAe,0BAAa,aAAa;AAE/C,UAAM,SAAgC,CAAC;AAEvC,eAAW,KAAK,cAAc;AAC5B,+CAAwB,CAAC;AAKzB,YAAM,eAAe,WAAW,YAAY,YAAAA,YAAkB,GAAG,EAAE;AACnE,YAAM,aAAkC;AAAA,QACtC,aAAa,aAAa;AAAA,QAC1B,IAAI,aAAa;AAAA,QACjB,QAAQ,aAAa;AAAA,QACrB,MAAM,aAAa;AAAA,MACrB;AAEA,UAAI,aAAa,oBAAoB,QAAW;AAC9C,mBAAW,kBAAkB,aAAa;AAAA,MAC5C;AAEA,UAAI,aAAa,eAAe,QAAW;AACzC,mBAAW,aAAa,aAAa;AAAA,MACvC;AAEA,UAAI,aAAa,YAAY,QAAW;AACtC,mBAAW,UAAU,aAAa;AAAA,MACpC;AAEA,UAAI,aAAa,SAAS,QAAW;AACnC,mBAAW,OAAO,aAAa;AAAA,MACjC;AAEA,UAAI,aAAa,SAAS,QAAW;AACnC,mBAAW,OAAO,aAAa;AAAA,MACjC;AAGA,UAAI,aAAa,eAAe,QAAW;AACzC,YAAI,aAAa,SAAS,QAAW;AACnC,gBAAM,IAAI,UAAU,kDAAkD;AAAA,QACxE;AAEA,YAAI,EAAE,aAAa,sBAAsB,aAAa;AACpD,gBAAM,IAAI,UAAU,6DAA6D;AAAA,QACnF;AAEA,mBAAW,OAAO,aAAa;AAAA,MACjC;AAGA,YAAM,sBAAsB,EAAE,GAAG,aAAa;AAC9C,iBAAW,YAAY,+CAAiC;AACtD,eAAO,oBAAoB,QAAQ;AAAA,MACrC;AACA,aAAO,oBAAoB;AAG3B,UAAI,OAAO,KAAK,mBAAmB,EAAE,SAAS,GAAG;AAC/C,mBAAW,sBAAsB;AAAA,MACnC;AAEA,aAAO,KAAK,UAAiC;AAAA,IAC/C;AAEA,WAAO;AAAA,EACT;AACF;",
|
|
6
|
+
"names": ["CloudEventMapper"]
|
|
7
|
+
}
|
|
@@ -1,108 +1,139 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var eventGridReceiverClient_exports = {};
|
|
19
|
+
__export(eventGridReceiverClient_exports, {
|
|
20
|
+
EventGridReceiverClient: () => EventGridReceiverClient
|
|
21
|
+
});
|
|
22
|
+
module.exports = __toCommonJS(eventGridReceiverClient_exports);
|
|
23
|
+
var import_eventGridClient = require("./generated/eventGridClient.js");
|
|
24
|
+
var import_cloudEventDistrubtedTracingEnricherPolicy = require("./cloudEventDistrubtedTracingEnricherPolicy.js");
|
|
25
|
+
var import_core_rest_pipeline = require("@azure/core-rest-pipeline");
|
|
26
|
+
var import_core_util = require("@azure/core-util");
|
|
13
27
|
class EventGridReceiverClient {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
};
|
|
51
|
-
return {
|
|
52
|
-
brokerProperties: receiveDetails.brokerProperties,
|
|
53
|
-
event: cloudEvent,
|
|
54
|
-
};
|
|
55
|
-
}),
|
|
28
|
+
_client;
|
|
29
|
+
_topicName;
|
|
30
|
+
_subscriptionName;
|
|
31
|
+
/** Azure Messaging EventGrid Client */
|
|
32
|
+
constructor(endpoint, credential, topicName, subscriptionName, options = {}) {
|
|
33
|
+
this._client = new import_eventGridClient.EventGridClient(endpoint, credential, options);
|
|
34
|
+
this._topicName = topicName;
|
|
35
|
+
this._subscriptionName = subscriptionName;
|
|
36
|
+
this._client.pipeline.addPolicy((0, import_cloudEventDistrubtedTracingEnricherPolicy.cloudEventDistributedTracingEnricherPolicy)(), {
|
|
37
|
+
afterPolicies: [import_core_rest_pipeline.tracingPolicyName]
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Receive Batch of Cloud Events from the Event Subscription.
|
|
42
|
+
*
|
|
43
|
+
* @param options - Options to receive
|
|
44
|
+
*
|
|
45
|
+
*/
|
|
46
|
+
async receiveEvents(options = { requestOptions: {} }) {
|
|
47
|
+
const result = await this._client.receiveCloudEvents(
|
|
48
|
+
this._topicName,
|
|
49
|
+
this._subscriptionName,
|
|
50
|
+
options
|
|
51
|
+
);
|
|
52
|
+
const modifiedResult = {
|
|
53
|
+
details: result.details.map((receiveDetails) => {
|
|
54
|
+
const cloudEvent = {
|
|
55
|
+
type: receiveDetails.event.type,
|
|
56
|
+
source: receiveDetails.event.source,
|
|
57
|
+
id: receiveDetails.event.id,
|
|
58
|
+
time: receiveDetails.event.time,
|
|
59
|
+
dataSchema: receiveDetails.event.dataschema,
|
|
60
|
+
dataContentType: receiveDetails.event.datacontenttype,
|
|
61
|
+
subject: receiveDetails.event.subject,
|
|
62
|
+
specVersion: receiveDetails.event.specversion,
|
|
63
|
+
data: receiveDetails.event.data ? receiveDetails.event.data : receiveDetails.event.dataBase64 ? (0, import_core_util.uint8ArrayToString)(receiveDetails.event.dataBase64, "base64") : void 0
|
|
56
64
|
};
|
|
57
|
-
return
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
65
|
+
return {
|
|
66
|
+
brokerProperties: receiveDetails.brokerProperties,
|
|
67
|
+
event: cloudEvent
|
|
68
|
+
};
|
|
69
|
+
})
|
|
70
|
+
};
|
|
71
|
+
return modifiedResult;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one
|
|
75
|
+
* event is successfully acknowledged. The response body will include the set of successfully acknowledged
|
|
76
|
+
* lockTokens, along with other failed lockTokens with their corresponding error information. Successfully
|
|
77
|
+
* acknowledged events will no longer be available to any consumer.
|
|
78
|
+
*
|
|
79
|
+
* @param lockTokens - Lock Tokens
|
|
80
|
+
* @param options - Options to Acknowledge
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
acknowledgeEvents(lockTokens, options = { requestOptions: {} }) {
|
|
84
|
+
return this._client.acknowledgeCloudEvents(
|
|
85
|
+
this._topicName,
|
|
86
|
+
this._subscriptionName,
|
|
87
|
+
lockTokens,
|
|
88
|
+
options
|
|
89
|
+
);
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is
|
|
93
|
+
* successfully released. The response body will include the set of successfully released lockTokens, along
|
|
94
|
+
* with other failed lockTokens with their corresponding error information.
|
|
95
|
+
*
|
|
96
|
+
* @param lockTokens - Lock Tokens
|
|
97
|
+
* @param options - Options to release
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
releaseEvents(lockTokens, options = { requestOptions: {} }) {
|
|
101
|
+
return this._client.releaseCloudEvents(this._topicName, this._subscriptionName, lockTokens, {
|
|
102
|
+
...options,
|
|
103
|
+
releaseDelayInSeconds: options.releaseDelay
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Reject batch of Cloud Events.
|
|
108
|
+
*
|
|
109
|
+
* @param lockTokens - Lock Tokens
|
|
110
|
+
* @param options - Options to reject
|
|
111
|
+
*
|
|
112
|
+
*/
|
|
113
|
+
rejectEvents(lockTokens, options = { requestOptions: {} }) {
|
|
114
|
+
return this._client.rejectCloudEvents(
|
|
115
|
+
this._topicName,
|
|
116
|
+
this._subscriptionName,
|
|
117
|
+
lockTokens,
|
|
118
|
+
options
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Renew lock for batch of Cloud Events.
|
|
123
|
+
*
|
|
124
|
+
* @param lockTokens - Lock Tokens
|
|
125
|
+
* @param options - Options to renew
|
|
126
|
+
*/
|
|
127
|
+
renewEventLocks(lockTokens, options = { requestOptions: {} }) {
|
|
128
|
+
return this._client.renewCloudEventLocks(
|
|
129
|
+
this._topicName,
|
|
130
|
+
this._subscriptionName,
|
|
131
|
+
lockTokens,
|
|
132
|
+
options
|
|
133
|
+
);
|
|
134
|
+
}
|
|
106
135
|
}
|
|
107
|
-
|
|
108
|
-
|
|
136
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
137
|
+
0 && (module.exports = {
|
|
138
|
+
EventGridReceiverClient
|
|
139
|
+
});
|