@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.
Files changed (73) hide show
  1. package/dist/commonjs/cloudEventDistrubtedTracingEnricherPolicy.js +62 -55
  2. package/dist/commonjs/cloudEventDistrubtedTracingEnricherPolicy.js.map +7 -1
  3. package/dist/commonjs/consumer.js +76 -73
  4. package/dist/commonjs/consumer.js.map +7 -1
  5. package/dist/commonjs/eventGridReceiverClient.js +136 -105
  6. package/dist/commonjs/eventGridReceiverClient.js.map +7 -1
  7. package/dist/commonjs/eventGridSenderClient.js +94 -81
  8. package/dist/commonjs/eventGridSenderClient.js.map +7 -1
  9. package/dist/commonjs/generated/api/eventGridContext.js +66 -48
  10. package/dist/commonjs/generated/api/eventGridContext.js.map +7 -1
  11. package/dist/commonjs/generated/api/index.js +42 -16
  12. package/dist/commonjs/generated/api/index.js.map +7 -1
  13. package/dist/commonjs/generated/api/operations.js +300 -206
  14. package/dist/commonjs/generated/api/operations.js.map +7 -1
  15. package/dist/commonjs/generated/api/options.js +15 -5
  16. package/dist/commonjs/generated/api/options.js.map +7 -1
  17. package/dist/commonjs/generated/eventGridClient.js +98 -52
  18. package/dist/commonjs/generated/eventGridClient.js.map +7 -1
  19. package/dist/commonjs/generated/index.js +32 -11
  20. package/dist/commonjs/generated/index.js.map +7 -1
  21. package/dist/commonjs/generated/logger.js +28 -8
  22. package/dist/commonjs/generated/logger.js.map +7 -1
  23. package/dist/commonjs/generated/models/index.js +29 -9
  24. package/dist/commonjs/generated/models/index.js.map +7 -1
  25. package/dist/commonjs/generated/models/models.js +156 -124
  26. package/dist/commonjs/generated/models/models.js.map +7 -1
  27. package/dist/commonjs/generated/static-helpers/urlTemplate.js +149 -148
  28. package/dist/commonjs/generated/static-helpers/urlTemplate.js.map +7 -1
  29. package/dist/commonjs/index.js +39 -16
  30. package/dist/commonjs/index.js.map +7 -1
  31. package/dist/commonjs/models.js +36 -16
  32. package/dist/commonjs/models.js.map +7 -1
  33. package/dist/commonjs/util.js +152 -145
  34. package/dist/commonjs/util.js.map +7 -1
  35. package/dist/esm/cloudEventDistrubtedTracingEnricherPolicy.js +35 -52
  36. package/dist/esm/cloudEventDistrubtedTracingEnricherPolicy.js.map +7 -1
  37. package/dist/esm/consumer.js +50 -66
  38. package/dist/esm/consumer.js.map +7 -1
  39. package/dist/esm/eventGridReceiverClient.js +110 -98
  40. package/dist/esm/eventGridReceiverClient.js.map +7 -1
  41. package/dist/esm/eventGridSenderClient.js +67 -73
  42. package/dist/esm/eventGridSenderClient.js.map +7 -1
  43. package/dist/esm/generated/api/eventGridContext.js +44 -44
  44. package/dist/esm/generated/api/eventGridContext.js.map +7 -1
  45. package/dist/esm/generated/api/index.js +22 -5
  46. package/dist/esm/generated/api/index.js.map +7 -1
  47. package/dist/esm/generated/api/operations.js +301 -215
  48. package/dist/esm/generated/api/operations.js.map +7 -1
  49. package/dist/esm/generated/api/options.js +0 -4
  50. package/dist/esm/generated/api/options.js.map +7 -1
  51. package/dist/esm/generated/eventGridClient.js +86 -49
  52. package/dist/esm/generated/eventGridClient.js.map +7 -1
  53. package/dist/esm/generated/index.js +10 -5
  54. package/dist/esm/generated/index.js.map +7 -1
  55. package/dist/esm/generated/logger.js +4 -4
  56. package/dist/esm/generated/logger.js.map +7 -1
  57. package/dist/esm/generated/models/index.js +8 -4
  58. package/dist/esm/generated/models/index.js.map +7 -1
  59. package/dist/esm/generated/models/models.js +131 -120
  60. package/dist/esm/generated/models/models.js.map +7 -1
  61. package/dist/esm/generated/static-helpers/urlTemplate.js +126 -145
  62. package/dist/esm/generated/static-helpers/urlTemplate.js.map +7 -1
  63. package/dist/esm/index.js +14 -8
  64. package/dist/esm/index.js.map +7 -1
  65. package/dist/esm/models.js +13 -13
  66. package/dist/esm/models.js.map +7 -1
  67. package/dist/esm/util.js +129 -142
  68. package/dist/esm/util.js.map +7 -1
  69. package/package.json +4 -21
  70. package/dist/browser/generated/metadata.json +0 -4
  71. package/dist/commonjs/generated/metadata.json +0 -4
  72. package/dist/esm/generated/metadata.json +0 -4
  73. package/dist/react-native/generated/metadata.json +0 -4
@@ -1,57 +1,64 @@
1
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.cloudEventDistributedTracingEnricherPolicyName = exports.ContentTypeHeaderName = exports.TraceStateHeaderName = exports.TraceParentHeaderName = exports.CloudEventBatchContentType = void 0;
6
- exports.cloudEventDistributedTracingEnricherPolicy = cloudEventDistributedTracingEnricherPolicy;
7
- exports.CloudEventBatchContentType = "application/cloudevents-batch+json; charset=utf-8";
8
- exports.TraceParentHeaderName = "traceparent";
9
- exports.TraceStateHeaderName = "tracestate";
10
- exports.ContentTypeHeaderName = "Content-Type";
11
- /**
12
- * The programmatic identifier of the cloudEventDistributedTracingEnricherPolicy.
13
- */
14
- exports.cloudEventDistributedTracingEnricherPolicyName = "cloudEventDistributedTracingEnricherPolicy";
15
- /**
16
- * cloudEventDistributedTracingEnricherPolicy is a policy which adds distributed tracing information
17
- * to a batch of cloud events. It does so by copying the `traceparent` and `tracestate` properties
18
- * from the HTTP request into the individual events as extension properties.
19
- *
20
- * This will only happen in the case where an event does not have a `traceparent` defined already. This
21
- * allows events to explicitly set a traceparent and tracestate which would be respected during "multi-hop
22
- * transmition".
23
- *
24
- * See https://github.com/cloudevents/spec/blob/master/extensions/distributed-tracing.md
25
- * for more information on distributed tracing and cloud events.
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
- return {
29
- name: exports.cloudEventDistributedTracingEnricherPolicyName,
30
- async sendRequest(request, next) {
31
- const traceparent = request.headers.get(exports.TraceParentHeaderName);
32
- const tracestate = request.headers.get(exports.TraceStateHeaderName);
33
- if (request.headers.get(exports.ContentTypeHeaderName) === exports.CloudEventBatchContentType &&
34
- typeof request.body === "string" &&
35
- traceparent) {
36
- // per the cloud event batched content type we know the body is an array encoded in JSON.
37
- const parsedBody = JSON.parse(request.body);
38
- for (const item of parsedBody) {
39
- // When using the distributed tracing extension, the "traceparent" is a required property
40
- // and "tracestate" is optional. This means if an item already has a "traceparent" property
41
- // we should not stomp over it. Well formed events will not have a "tracestate" without
42
- // also having a "traceparent" so there's no need to guard against that case.
43
- if (typeof item !== "object" || item.traceparent) {
44
- continue;
45
- }
46
- item.traceparent = traceparent;
47
- if (tracestate) {
48
- item.tracestate = tracestate;
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
- //# sourceMappingURL=cloudEventDistrubtedTracingEnricherPolicy.js.map
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
- {"version":3,"file":"cloudEventDistrubtedTracingEnricherPolicy.js","sourceRoot":"","sources":["../../src/cloudEventDistrubtedTracingEnricherPolicy.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAgClC,gGAoCC;AA3DY,QAAA,0BAA0B,GAAG,mDAAmD,CAAC;AACjF,QAAA,qBAAqB,GAAG,aAAa,CAAC;AACtC,QAAA,oBAAoB,GAAG,YAAY,CAAC;AACpC,QAAA,qBAAqB,GAAG,cAAc,CAAC;AAEpD;;GAEG;AACU,QAAA,8CAA8C,GACzD,4CAA4C,CAAC;AAE/C;;;;;;;;;;;GAWG;AACH,SAAgB,0CAA0C;IACxD,OAAO;QACL,IAAI,EAAE,sDAA8C;QACpD,KAAK,CAAC,WAAW,CAAC,OAAwB,EAAE,IAAiB;YAC3D,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,6BAAqB,CAAC,CAAC;YAC/D,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,4BAAoB,CAAC,CAAC;YAE7D,IACE,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,6BAAqB,CAAC,KAAK,kCAA0B;gBACzE,OAAO,OAAO,CAAC,IAAI,KAAK,QAAQ;gBAChC,WAAW,EACX,CAAC;gBACD,yFAAyF;gBACzF,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAU,CAAC;gBAErD,KAAK,MAAM,IAAI,IAAI,UAAU,EAAE,CAAC;oBAC9B,yFAAyF;oBACzF,2FAA2F;oBAC3F,uFAAuF;oBACvF,6EAA6E;oBAC7E,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;wBACjD,SAAS;oBACX,CAAC;oBAED,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;oBAC/B,IAAI,UAAU,EAAE,CAAC;wBACf,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;oBAC/B,CAAC;gBACH,CAAC;gBAED,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;YAC5C,CAAC;YAED,OAAO,IAAI,CAAC,OAAO,CAAC,CAAC;QACvB,CAAC;KACF,CAAC;AACJ,CAAC","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"]}
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
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.EventGridDeserializer = void 0;
6
- const core_client_1 = require("@azure/core-client");
7
- const models_js_1 = require("./models.js");
8
- const util_js_1 = require("./util.js");
9
- const serializer = (0, core_client_1.createSerializer)();
10
- /**
11
- * EventGridDeserializer is used to aid in processing events delivered by EventGrid. It can deserialize a JSON encoded payload
12
- * of either a single event or batch of events as well as be used to convert the result of `JSON.parse` into an
13
- * `EventGridEvent` or `CloudEvent` like object.
14
- *
15
- * Unlike normal JSON deseralization, EventGridDeserializer does some additional conversions:
16
- *
17
- * - The consumer parses the event time property into a `Date` object, for ease of use.
18
- * - When deserializing an event in the CloudEvent schema, if the event contains binary data, it is base64 decoded
19
- * and returned as an instance of the `Uint8Array` type.
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
- async deserializeCloudEvents(encodedEvents) {
23
- const decodedArray = (0, util_js_1.parseAndWrap)(encodedEvents);
24
- const events = [];
25
- for (const o of decodedArray) {
26
- (0, util_js_1.validateCloudEventEvent)(o);
27
- // Check that the required fields are present and of the correct type and the optional fields are missing
28
- // or of the correct type.
29
- const deserialized = serializer.deserialize(util_js_1.CloudEvent, o, "");
30
- const modelEvent = {
31
- specversion: deserialized.specversion,
32
- id: deserialized.id,
33
- source: deserialized.source,
34
- type: deserialized.type,
35
- };
36
- if (deserialized.datacontenttype !== undefined) {
37
- modelEvent.datacontenttype = deserialized.datacontenttype;
38
- }
39
- if (deserialized.dataschema !== undefined) {
40
- modelEvent.dataschema = deserialized.dataschema;
41
- }
42
- if (deserialized.subject !== undefined) {
43
- modelEvent.subject = deserialized.subject;
44
- }
45
- if (deserialized.time !== undefined) {
46
- modelEvent.time = deserialized.time;
47
- }
48
- if (deserialized.data !== undefined) {
49
- modelEvent.data = deserialized.data;
50
- }
51
- // 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.
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
- return events;
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
- exports.EventGridDeserializer = EventGridDeserializer;
77
- //# sourceMappingURL=consumer.js.map
77
+ // Annotate the CommonJS export names for ESM import in node:
78
+ 0 && (module.exports = {
79
+ EventGridDeserializer
80
+ });
@@ -1 +1,7 @@
1
- {"version":3,"file":"consumer.js","sourceRoot":"","sources":["../../src/consumer.ts"],"names":[],"mappings":";AAAA,uCAAuC;AACvC,kCAAkC;;;AAElC,oDAAsD;AAEtD,2CAA8D;AAC9D,uCAAkG;AAElG,MAAM,UAAU,GAAG,IAAA,8BAAgB,GAAE,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,MAAa,qBAAqB;IAiBzB,KAAK,CAAC,sBAAsB,CACjC,aAA+C;QAE/C,MAAM,YAAY,GAAG,IAAA,sBAAY,EAAC,aAAa,CAAC,CAAC;QAEjD,MAAM,MAAM,GAA0B,EAAE,CAAC;QAEzC,KAAK,MAAM,CAAC,IAAI,YAAY,EAAE,CAAC;YAC7B,IAAA,iCAAuB,EAAC,CAAC,CAAC,CAAC;YAE3B,yGAAyG;YACzG,0BAA0B;YAE1B,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW,CAAC,oBAAgB,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YACrE,MAAM,UAAU,GAAwB;gBACtC,WAAW,EAAE,YAAY,CAAC,WAAW;gBACrC,EAAE,EAAE,YAAY,CAAC,EAAE;gBACnB,MAAM,EAAE,YAAY,CAAC,MAAM;gBAC3B,IAAI,EAAE,YAAY,CAAC,IAAI;aACxB,CAAC;YAEF,IAAI,YAAY,CAAC,eAAe,KAAK,SAAS,EAAE,CAAC;gBAC/C,UAAU,CAAC,eAAe,GAAG,YAAY,CAAC,eAAe,CAAC;YAC5D,CAAC;YAED,IAAI,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC1C,UAAU,CAAC,UAAU,GAAG,YAAY,CAAC,UAAU,CAAC;YAClD,CAAC;YAED,IAAI,YAAY,CAAC,OAAO,KAAK,SAAS,EAAE,CAAC;gBACvC,UAAU,CAAC,OAAO,GAAG,YAAY,CAAC,OAAO,CAAC;YAC5C,CAAC;YAED,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBACpC,UAAU,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;YACtC,CAAC;YAED,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBACpC,UAAU,CAAC,IAAI,GAAG,YAAY,CAAC,IAAI,CAAC;YACtC,CAAC;YAED,0IAA0I;YAC1I,IAAI,YAAY,CAAC,UAAU,KAAK,SAAS,EAAE,CAAC;gBAC1C,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;oBACpC,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAC;gBAC1E,CAAC;gBAED,IAAI,CAAC,CAAC,YAAY,CAAC,UAAU,YAAY,UAAU,CAAC,EAAE,CAAC;oBACrD,MAAM,IAAI,SAAS,CAAC,6DAA6D,CAAC,CAAC;gBACrF,CAAC;gBAED,UAAU,CAAC,IAAI,GAAG,YAAY,CAAC,UAAU,CAAC;YAC5C,CAAC;YAED,4FAA4F;YAC5F,MAAM,mBAAmB,GAAG,EAAE,GAAG,YAAY,EAAE,CAAC;YAChD,KAAK,MAAM,QAAQ,IAAI,2CAA+B,EAAE,CAAC;gBACvD,OAAO,mBAAmB,CAAC,QAAQ,CAAC,CAAC;YACvC,CAAC;YACD,OAAO,mBAAmB,CAAC,UAAU,CAAC;YAEtC,oDAAoD;YACpD,IAAI,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChD,UAAU,CAAC,mBAAmB,GAAG,mBAAmB,CAAC;YACvD,CAAC;YAED,MAAM,CAAC,IAAI,CAAC,UAAiC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAxFD,sDAwFC","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"]}
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
- "use strict";
2
- // Copyright (c) Microsoft Corporation.
3
- // Licensed under the MIT License.
4
- Object.defineProperty(exports, "__esModule", { value: true });
5
- exports.EventGridReceiverClient = void 0;
6
- const eventGridClient_js_1 = require("./generated/eventGridClient.js");
7
- const cloudEventDistrubtedTracingEnricherPolicy_js_1 = require("./cloudEventDistrubtedTracingEnricherPolicy.js");
8
- const core_rest_pipeline_1 = require("@azure/core-rest-pipeline");
9
- const core_util_1 = require("@azure/core-util");
10
- /**
11
- * Event Grid Namespaces Client
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
- _client;
15
- _topicName;
16
- _subscriptionName;
17
- /** Azure Messaging EventGrid Client */
18
- constructor(endpoint, credential, topicName, subscriptionName, options = {}) {
19
- this._client = new eventGridClient_js_1.EventGridClient(endpoint, credential, options);
20
- this._topicName = topicName;
21
- this._subscriptionName = subscriptionName;
22
- this._client.pipeline.addPolicy((0, cloudEventDistrubtedTracingEnricherPolicy_js_1.cloudEventDistributedTracingEnricherPolicy)(), {
23
- afterPolicies: [core_rest_pipeline_1.tracingPolicyName],
24
- });
25
- }
26
- /**
27
- * Receive Batch of Cloud Events from the Event Subscription.
28
- *
29
- * @param options - Options to receive
30
- *
31
- */
32
- async receiveEvents(options = { requestOptions: {} }) {
33
- const result = await this._client.receiveCloudEvents(this._topicName, this._subscriptionName, options);
34
- const modifiedResult = {
35
- details: result.details.map((receiveDetails) => {
36
- const cloudEvent = {
37
- type: receiveDetails.event.type,
38
- source: receiveDetails.event.source,
39
- id: receiveDetails.event.id,
40
- time: receiveDetails.event.time,
41
- dataSchema: receiveDetails.event.dataschema,
42
- dataContentType: receiveDetails.event.datacontenttype,
43
- subject: receiveDetails.event.subject,
44
- specVersion: receiveDetails.event.specversion,
45
- data: receiveDetails.event.data
46
- ? receiveDetails.event.data
47
- : receiveDetails.event.dataBase64
48
- ? (0, core_util_1.uint8ArrayToString)(receiveDetails.event.dataBase64, "base64")
49
- : undefined,
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 modifiedResult;
58
- }
59
- /**
60
- * Acknowledge batch of Cloud Events. The server responds with an HTTP 200 status code if at least one
61
- * event is successfully acknowledged. The response body will include the set of successfully acknowledged
62
- * lockTokens, along with other failed lockTokens with their corresponding error information. Successfully
63
- * acknowledged events will no longer be available to any consumer.
64
- *
65
- * @param lockTokens - Lock Tokens
66
- * @param options - Options to Acknowledge
67
- *
68
- */
69
- acknowledgeEvents(lockTokens, options = { requestOptions: {} }) {
70
- return this._client.acknowledgeCloudEvents(this._topicName, this._subscriptionName, lockTokens, options);
71
- }
72
- /**
73
- * Release batch of Cloud Events. The server responds with an HTTP 200 status code if at least one event is
74
- * successfully released. The response body will include the set of successfully released lockTokens, along
75
- * with other failed lockTokens with their corresponding error information.
76
- *
77
- * @param lockTokens - Lock Tokens
78
- * @param options - Options to release
79
- *
80
- */
81
- releaseEvents(lockTokens, options = { requestOptions: {} }) {
82
- return this._client.releaseCloudEvents(this._topicName, this._subscriptionName, lockTokens, {
83
- ...options,
84
- releaseDelayInSeconds: options.releaseDelay,
85
- });
86
- }
87
- /**
88
- * Reject batch of Cloud Events.
89
- *
90
- * @param lockTokens - Lock Tokens
91
- * @param options - Options to reject
92
- *
93
- */
94
- rejectEvents(lockTokens, options = { requestOptions: {} }) {
95
- return this._client.rejectCloudEvents(this._topicName, this._subscriptionName, lockTokens, options);
96
- }
97
- /**
98
- * Renew lock for batch of Cloud Events.
99
- *
100
- * @param lockTokens - Lock Tokens
101
- * @param options - Options to renew
102
- */
103
- renewEventLocks(lockTokens, options = { requestOptions: {} }) {
104
- return this._client.renewCloudEventLocks(this._topicName, this._subscriptionName, lockTokens, options);
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
- exports.EventGridReceiverClient = EventGridReceiverClient;
108
- //# sourceMappingURL=eventGridReceiverClient.js.map
136
+ // Annotate the CommonJS export names for ESM import in node:
137
+ 0 && (module.exports = {
138
+ EventGridReceiverClient
139
+ });