@azure/event-hubs 5.7.0-alpha.20220103.3 → 5.7.0-alpha.20220128.3

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 CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
6
-
7
5
  var abortController = require('@azure/abort-controller');
8
6
  var logger$1 = require('@azure/logger');
9
7
  var coreAuth = require('@azure/core-auth');
@@ -11,10 +9,33 @@ var coreAmqp = require('@azure/core-amqp');
11
9
  var coreTracing = require('@azure/core-tracing');
12
10
  var rheaPromise = require('rhea-promise');
13
11
  var buffer = require('buffer');
14
- var isBuffer = _interopDefault(require('is-buffer'));
12
+ var isBuffer = require('is-buffer');
15
13
  var uuid = require('uuid');
16
14
  var os = require('os');
17
- var os__default = _interopDefault(os);
15
+
16
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
17
+
18
+ function _interopNamespace(e) {
19
+ if (e && e.__esModule) return e;
20
+ var n = Object.create(null);
21
+ if (e) {
22
+ Object.keys(e).forEach(function (k) {
23
+ if (k !== 'default') {
24
+ var d = Object.getOwnPropertyDescriptor(e, k);
25
+ Object.defineProperty(n, k, d.get ? d : {
26
+ enumerable: true,
27
+ get: function () { return e[k]; }
28
+ });
29
+ }
30
+ });
31
+ }
32
+ n["default"] = e;
33
+ return Object.freeze(n);
34
+ }
35
+
36
+ var isBuffer__default = /*#__PURE__*/_interopDefaultLegacy(isBuffer);
37
+ var os__namespace = /*#__PURE__*/_interopNamespace(os);
38
+ var os__default = /*#__PURE__*/_interopDefaultLegacy(os);
18
39
 
19
40
  // Copyright (c) Microsoft Corporation.
20
41
  /**
@@ -320,6 +341,12 @@ function validateEventPosition(position) {
320
341
  }
321
342
 
322
343
  // Copyright (c) Microsoft Corporation.
344
+ // Licensed under the MIT license.
345
+ /**
346
+ * An enum representing the different reasons for an `EventHubConsumerClient` to stop processing
347
+ * events from a partition in a consumer group of an Event Hub.
348
+ */
349
+ exports.CloseReason = void 0;
323
350
  (function (CloseReason) {
324
351
  /**
325
352
  * Ownership of the partition was lost or transitioned to a new processor instance.
@@ -367,7 +394,7 @@ const defaultDataTransformer = {
367
394
  else if (bodyType === "sequence") {
368
395
  result = rheaPromise.message.sequence_section(body);
369
396
  }
370
- else if (isBuffer(body)) {
397
+ else if (isBuffer__default["default"](body)) {
371
398
  result = rheaPromise.message.data_section(body);
372
399
  }
373
400
  else if (body === null && bodyType === "data") {
@@ -416,7 +443,7 @@ const defaultDataTransformer = {
416
443
  }
417
444
  }
418
445
  else {
419
- if (isBuffer(body)) {
446
+ if (isBuffer__default["default"](body)) {
420
447
  return { body: skipParsingBodyAsJson ? body : tryToJsonDecode(body), bodyType: "data" };
421
448
  }
422
449
  return { body, bodyType: "value" };
@@ -2626,7 +2653,7 @@ const EventHubConnectionConfig = {
2626
2653
  * @internal
2627
2654
  */
2628
2655
  function getRuntimeInfo() {
2629
- return `NODE-VERSION ${process.version}; ${os.type()} ${os.release()}`;
2656
+ return `NODE-VERSION ${process.version}; ${os__namespace.type()} ${os__namespace.release()}`;
2630
2657
  }
2631
2658
 
2632
2659
  // Copyright (c) Microsoft Corporation.
@@ -4728,7 +4755,7 @@ function mapPartitionKeyToId(partitionKey, partitionCount) {
4728
4755
  return Math.abs(hashedParitionKey % partitionCount);
4729
4756
  }
4730
4757
  function readUInt32(data, offset) {
4731
- return os__default.endianness() === "BE" ? data.readUInt32BE(offset) : data.readUInt32LE(offset);
4758
+ return os__default["default"].endianness() === "BE" ? data.readUInt32BE(offset) : data.readUInt32LE(offset);
4732
4759
  }
4733
4760
  function castToInt16(n) {
4734
4761
  return new Int16Array([n])[0];
@@ -5111,21 +5138,49 @@ class EventHubBufferedProducerClient {
5111
5138
  }
5112
5139
  }
5113
5140
 
5141
+ // Copyright (c) Microsoft Corporation.
5142
+ // Licensed under the MIT license.
5143
+ /**
5144
+ * A function that constructs an event data adapter. That adapter can be used
5145
+ * with `@azure/schema-registry-avro` to encode and decode body in event data.
5146
+ *
5147
+ * @param params - parameters to create the event data
5148
+ * @returns An event data adapter that can produce and consume event data
5149
+ */
5150
+ function createEventDataAdapter(params = {}) {
5151
+ return {
5152
+ produceMessage: ({ body, contentType }) => {
5153
+ return Object.assign(Object.assign({}, params), { body,
5154
+ contentType });
5155
+ },
5156
+ consumeMessage: (message) => {
5157
+ const { body, contentType } = message;
5158
+ if (body === undefined || !(body instanceof Uint8Array)) {
5159
+ throw new Error("Expected the body field to be defined and have a Uint8Array");
5160
+ }
5161
+ if (contentType === undefined) {
5162
+ throw new Error("Expected the contentType field to be defined");
5163
+ }
5164
+ return {
5165
+ body,
5166
+ contentType,
5167
+ };
5168
+ },
5169
+ };
5170
+ }
5171
+
5114
5172
  Object.defineProperty(exports, 'MessagingError', {
5115
5173
  enumerable: true,
5116
- get: function () {
5117
- return coreAmqp.MessagingError;
5118
- }
5174
+ get: function () { return coreAmqp.MessagingError; }
5119
5175
  });
5120
5176
  Object.defineProperty(exports, 'RetryMode', {
5121
5177
  enumerable: true,
5122
- get: function () {
5123
- return coreAmqp.RetryMode;
5124
- }
5178
+ get: function () { return coreAmqp.RetryMode; }
5125
5179
  });
5126
5180
  exports.EventHubBufferedProducerClient = EventHubBufferedProducerClient;
5127
5181
  exports.EventHubConsumerClient = EventHubConsumerClient;
5128
5182
  exports.EventHubProducerClient = EventHubProducerClient;
5183
+ exports.createEventDataAdapter = createEventDataAdapter;
5129
5184
  exports.earliestEventPosition = earliestEventPosition;
5130
5185
  exports.latestEventPosition = latestEventPosition;
5131
5186
  exports.logger = logger;