@azure/event-hubs 5.13.0-beta.1 → 5.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.
@@ -49,7 +49,7 @@ export function isLatestPosition(eventPosition) {
49
49
  * first event in the partition which has not expired due to the retention policy.
50
50
  */
51
51
  export const earliestEventPosition = {
52
- offset: "-1",
52
+ offset: "-1:-1",
53
53
  };
54
54
  /**
55
55
  * Gets the `EventPosition` corresponding to the end of the partition.
@@ -1 +1 @@
1
- {"version":3,"file":"eventPosition.js","sourceRoot":"","sources":["../../src/eventPosition.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAyChE;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,aAA4B;IACjE,IAAI,MAAM,CAAC;IACX,sBAAsB;IACtB,IAAI,SAAS,CAAC,aAAa,CAAC,MAAM,CAAC,EAAE,CAAC;QACpC,MAAM,GAAG,aAAa,CAAC,WAAW;YAChC,CAAC,CAAC,GAAG,SAAS,CAAC,gBAAgB,QAAQ,aAAa,CAAC,MAAM,GAAG;YAC9D,CAAC,CAAC,GAAG,SAAS,CAAC,gBAAgB,OAAO,aAAa,CAAC,MAAM,GAAG,CAAC;IAClE,CAAC;SAAM,IAAI,SAAS,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,CAAC;QACnD,MAAM,GAAG,aAAa,CAAC,WAAW;YAChC,CAAC,CAAC,GAAG,SAAS,CAAC,wBAAwB,QAAQ,aAAa,CAAC,cAAc,GAAG;YAC9E,CAAC,CAAC,GAAG,SAAS,CAAC,wBAAwB,OAAO,aAAa,CAAC,cAAc,GAAG,CAAC;IAClF,CAAC;SAAM,IAAI,SAAS,CAAC,aAAa,CAAC,UAA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,CAAC,CAAC;IAEzD,IACE,CAAC,aAAa,IAAI,qBAAqB,CAAC;QACxC,CAAC,aAAa,IAAI,iBAAiB,CAAC;QACpC,CAAC,iBAAiB,IAAI,qBAAqB,CAAC,EAC5C,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,yGAAyG,CAC1G,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,aAAa,IAAI,CAAC,iBAAiB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACnE,MAAM,IAAI,SAAS,CACjB,2HAA2H,CAC5H,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Constants, ErrorNameConditionMapper, translate } from \"@azure/core-amqp\";\nimport { isDefined, objectHasProperty } from \"@azure/core-util\";\n\n/**\n * Represents the position of an event in an Event Hub partition, typically used when calling the `subscribe()`\n * method on an `EventHubConsumerClient` to specify the position in the partition to begin receiving events from.\n *\n * To get an EventPosition representing the start or end of the stream, use the constants\n * `earliestEventPosition` and `latestEventPosition` respectively.\n *\n */\nexport interface EventPosition {\n /**\n * The offset of the event identified by this position.\n * Expected to be undefined if the position is just created from a sequence number or an enqueued time.\n *\n * The offset is the relative position for an event in the context of the partition.\n * The offset should not be considered a stable value.\n * The same offset may refer to a different event as events reach the age limit for\n * retention and are no longer visible within the partition.\n */\n offset?: string | \"@latest\";\n /**\n * Indicates if the specified offset is inclusive of the event which it identifies.\n * This information is only relevent if the event position was identified by an offset or sequence number.\n * Default value: `false`.\n */\n isInclusive?: boolean;\n /**\n * The enqueued time in UTC of the event identified by this position.\n * When provided as a number this value is the number of milliseconds since the Unix Epoch.\n * Expected to be undefined if the position is just created from a sequence number or an offset.\n */\n enqueuedOn?: Date | number;\n\n /**\n * The sequence number of the event identified by this position.\n * Expected to be undefined if the position is just created from an offset or enqueued time.\n */\n sequenceNumber?: number;\n}\n\n/**\n * @internal\n * Gets the expression to be set as the filter clause when creating the receiver\n * @returns filterExpression\n */\nexport function getEventPositionFilter(eventPosition: EventPosition): string {\n let result;\n // order of preference\n if (isDefined(eventPosition.offset)) {\n result = eventPosition.isInclusive\n ? `${Constants.offsetAnnotation} >= '${eventPosition.offset}'`\n : `${Constants.offsetAnnotation} > '${eventPosition.offset}'`;\n } else if (isDefined(eventPosition.sequenceNumber)) {\n result = eventPosition.isInclusive\n ? `${Constants.sequenceNumberAnnotation} >= '${eventPosition.sequenceNumber}'`\n : `${Constants.sequenceNumberAnnotation} > '${eventPosition.sequenceNumber}'`;\n } else if (isDefined(eventPosition.enqueuedOn)) {\n const time =\n eventPosition.enqueuedOn instanceof Date\n ? eventPosition.enqueuedOn.getTime()\n : eventPosition.enqueuedOn;\n result = `${Constants.enqueuedTimeAnnotation} > '${time}'`;\n }\n\n if (!result) {\n throw translate({\n condition: ErrorNameConditionMapper.ArgumentError,\n description: \"No starting position was set in the EventPosition.\",\n });\n }\n return result;\n}\n\n/**\n * @internal\n */\nexport function isLatestPosition(eventPosition: EventPosition): boolean {\n if (eventPosition.offset === \"@latest\") {\n return true;\n }\n\n return false;\n}\n\n/**\n * Gets the `EventPosition` corresponding to the location of the the first event present in the partition.\n * Pass this position to the `EventHubConsumerClient.subscribe()` method to begin receiving events from the\n * first event in the partition which has not expired due to the retention policy.\n */\nexport const earliestEventPosition: EventPosition = {\n offset: \"-1\",\n};\n\n/**\n * Gets the `EventPosition` corresponding to the end of the partition.\n * Pass this position to the `EventHubConsumerClient.subscribe()` method to begin receiving events from the\n * event that is enqueued right after the method call.\n * @returns EventPosition\n */\nexport const latestEventPosition: EventPosition = {\n offset: \"@latest\",\n};\n\n/**\n * @internal\n */\nexport function validateEventPositions(\n position: EventPosition | { [partitionId: string]: EventPosition },\n): void {\n if (!isDefined(position)) {\n return;\n }\n\n const keys = Object.keys(position);\n\n if (!keys.length) {\n throw new TypeError(\n \"Invalid value for EventPosition found. Pass an object with either of offset, sequenceNumber or enqueuedOn properties set.\",\n );\n }\n\n if (isEventPosition(position)) {\n validateEventPosition(position);\n return;\n }\n\n const positions = position as { [partitionId: string]: EventPosition };\n for (let i = 0; i < keys.length; i++) {\n if (Object.prototype.hasOwnProperty.call(positions, keys[i])) {\n validateEventPosition(positions[keys[i]]);\n }\n }\n}\n\n/**\n * Determines whether a position is an EventPosition.\n * Does not validate that the position is allowed.\n * @internal\n */\nexport function isEventPosition(position: unknown): position is EventPosition {\n if (!position) {\n return false;\n }\n\n if (objectHasProperty(position, \"offset\") && isDefined(position.offset)) {\n return true;\n }\n\n if (objectHasProperty(position, \"sequenceNumber\") && isDefined(position.sequenceNumber)) {\n return true;\n }\n\n if (objectHasProperty(position, \"enqueuedOn\") && isDefined(position.enqueuedOn)) {\n return true;\n }\n\n return false;\n}\n\nfunction validateEventPosition(position: EventPosition): void {\n if (!isDefined(position)) {\n return;\n }\n const offsetPresent = isDefined(position.offset);\n const sequenceNumberPresent = isDefined(position.sequenceNumber);\n const enqueuedOnPresent = isDefined(position.enqueuedOn);\n\n if (\n (offsetPresent && sequenceNumberPresent) ||\n (offsetPresent && enqueuedOnPresent) ||\n (enqueuedOnPresent && sequenceNumberPresent)\n ) {\n throw new TypeError(\n \"Invalid value for EventPosition found. Set only one of offset, sequenceNumber or enqueuedOn properties.\",\n );\n }\n\n if (!offsetPresent && !enqueuedOnPresent && !sequenceNumberPresent) {\n throw new TypeError(\n \"Invalid value for EventPosition found. Pass an object with either of offset, sequenceNumber or enqueuedOn properties set.\",\n );\n }\n}\n"]}
1
+ {"version":3,"file":"eventPosition.js","sourceRoot":"","sources":["../../src/eventPosition.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,kCAAkC;AAElC,OAAO,EAAE,SAAS,EAAE,wBAAwB,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAyChE;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,aAA4B;IACjE,IAAI,MAAM,CAAC;IACX,s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AAgB,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QACxF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,iBAAiB,CAAC,QAAQ,EAAE,YAAY,CAAC,IAAI,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE,CAAC;QAChF,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,qBAAqB,CAAC,QAAuB;IACpD,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;QACzB,OAAO;IACT,CAAC;IACD,MAAM,aAAa,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IACjD,MAAM,qBAAqB,GAAG,SAAS,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAC;IACjE,MAAM,iBAAiB,GAAG,SAAS,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC;IAEzD,IACE,CAAC,aAAa,IAAI,qBAAqB,CAAC;QACxC,CAAC,aAAa,IAAI,iBAAiB,CAAC;QACpC,CAAC,iBAAiB,IAAI,qBAAqB,CAAC,EAC5C,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,yGAAyG,CAC1G,CAAC;IACJ,CAAC;IAED,IAAI,CAAC,aAAa,IAAI,CAAC,iBAAiB,IAAI,CAAC,qBAAqB,EAAE,CAAC;QACnE,MAAM,IAAI,SAAS,CACjB,2HAA2H,CAC5H,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["// Copyright (c) Microsoft Corporation.\n// Licensed under the MIT license.\n\nimport { Constants, ErrorNameConditionMapper, translate } from \"@azure/core-amqp\";\nimport { isDefined, objectHasProperty } from \"@azure/core-util\";\n\n/**\n * Represents the position of an event in an Event Hub partition, typically used when calling the `subscribe()`\n * method on an `EventHubConsumerClient` to specify the position in the partition to begin receiving events from.\n *\n * To get an EventPosition representing the start or end of the stream, use the constants\n * `earliestEventPosition` and `latestEventPosition` respectively.\n *\n */\nexport interface EventPosition {\n /**\n * The offset of the event identified by this position.\n * Expected to be undefined if the position is just created from a sequence number or an enqueued time.\n *\n * The offset is the relative position for an event in the context of the partition.\n * The offset should not be considered a stable value.\n * The same offset may refer to a different event as events reach the age limit for\n * retention and are no longer visible within the partition.\n */\n offset?: string | \"@latest\";\n /**\n * Indicates if the specified offset is inclusive of the event which it identifies.\n * This information is only relevent if the event position was identified by an offset or sequence number.\n * Default value: `false`.\n */\n isInclusive?: boolean;\n /**\n * The enqueued time in UTC of the event identified by this position.\n * When provided as a number this value is the number of milliseconds since the Unix Epoch.\n * Expected to be undefined if the position is just created from a sequence number or an offset.\n */\n enqueuedOn?: Date | number;\n\n /**\n * The sequence number of the event identified by this position.\n * Expected to be undefined if the position is just created from an offset or enqueued time.\n */\n sequenceNumber?: number;\n}\n\n/**\n * @internal\n * Gets the expression to be set as the filter clause when creating the receiver\n * @returns filterExpression\n */\nexport function getEventPositionFilter(eventPosition: EventPosition): string {\n let result;\n // order of preference\n if (isDefined(eventPosition.offset)) {\n result = eventPosition.isInclusive\n ? `${Constants.offsetAnnotation} >= '${eventPosition.offset}'`\n : `${Constants.offsetAnnotation} > '${eventPosition.offset}'`;\n } else if (isDefined(eventPosition.sequenceNumber)) {\n result = eventPosition.isInclusive\n ? `${Constants.sequenceNumberAnnotation} >= '${eventPosition.sequenceNumber}'`\n : `${Constants.sequenceNumberAnnotation} > '${eventPosition.sequenceNumber}'`;\n } else if (isDefined(eventPosition.enqueuedOn)) {\n const time =\n eventPosition.enqueuedOn instanceof Date\n ? eventPosition.enqueuedOn.getTime()\n : eventPosition.enqueuedOn;\n result = `${Constants.enqueuedTimeAnnotation} > '${time}'`;\n }\n\n if (!result) {\n throw translate({\n condition: ErrorNameConditionMapper.ArgumentError,\n description: \"No starting position was set in the EventPosition.\",\n });\n }\n return result;\n}\n\n/**\n * @internal\n */\nexport function isLatestPosition(eventPosition: EventPosition): boolean {\n if (eventPosition.offset === \"@latest\") {\n return true;\n }\n\n return false;\n}\n\n/**\n * Gets the `EventPosition` corresponding to the location of the the first event present in the partition.\n * Pass this position to the `EventHubConsumerClient.subscribe()` method to begin receiving events from the\n * first event in the partition which has not expired due to the retention policy.\n */\nexport const earliestEventPosition: EventPosition = {\n offset: \"-1:-1\",\n};\n\n/**\n * Gets the `EventPosition` corresponding to the end of the partition.\n * Pass this position to the `EventHubConsumerClient.subscribe()` method to begin receiving events from the\n * event that is enqueued right after the method call.\n * @returns EventPosition\n */\nexport const latestEventPosition: EventPosition = {\n offset: \"@latest\",\n};\n\n/**\n * @internal\n */\nexport function validateEventPositions(\n position: EventPosition | { [partitionId: string]: EventPosition },\n): void {\n if (!isDefined(position)) {\n return;\n }\n\n const keys = Object.keys(position);\n\n if (!keys.length) {\n throw new TypeError(\n \"Invalid value for EventPosition found. Pass an object with either of offset, sequenceNumber or enqueuedOn properties set.\",\n );\n }\n\n if (isEventPosition(position)) {\n validateEventPosition(position);\n return;\n }\n\n const positions = position as { [partitionId: string]: EventPosition };\n for (let i = 0; i < keys.length; i++) {\n if (Object.prototype.hasOwnProperty.call(positions, keys[i])) {\n validateEventPosition(positions[keys[i]]);\n }\n }\n}\n\n/**\n * Determines whether a position is an EventPosition.\n * Does not validate that the position is allowed.\n * @internal\n */\nexport function isEventPosition(position: unknown): position is EventPosition {\n if (!position) {\n return false;\n }\n\n if (objectHasProperty(position, \"offset\") && isDefined(position.offset)) {\n return true;\n }\n\n if (objectHasProperty(position, \"sequenceNumber\") && isDefined(position.sequenceNumber)) {\n return true;\n }\n\n if (objectHasProperty(position, \"enqueuedOn\") && isDefined(position.enqueuedOn)) {\n return true;\n }\n\n return false;\n}\n\nfunction validateEventPosition(position: EventPosition): void {\n if (!isDefined(position)) {\n return;\n }\n const offsetPresent = isDefined(position.offset);\n const sequenceNumberPresent = isDefined(position.sequenceNumber);\n const enqueuedOnPresent = isDefined(position.enqueuedOn);\n\n if (\n (offsetPresent && sequenceNumberPresent) ||\n (offsetPresent && enqueuedOnPresent) ||\n (enqueuedOnPresent && sequenceNumberPresent)\n ) {\n throw new TypeError(\n \"Invalid value for EventPosition found. Set only one of offset, sequenceNumber or enqueuedOn properties.\",\n );\n }\n\n if (!offsetPresent && !enqueuedOnPresent && !sequenceNumberPresent) {\n throw new TypeError(\n \"Invalid value for EventPosition found. Pass an object with either of offset, sequenceNumber or enqueuedOn properties set.\",\n );\n }\n}\n"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@azure/event-hubs",
3
3
  "sdk-type": "client",
4
- "version": "5.13.0-beta.1",
4
+ "version": "5.13.0-beta.2",
5
5
  "description": "Azure Event Hubs SDK for JS.",
6
6
  "author": "Microsoft Corporation",
7
7
  "license": "MIT",
@@ -5,7 +5,7 @@
5
5
  "toolPackages": [
6
6
  {
7
7
  "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.46.2"
8
+ "packageVersion": "7.47.0"
9
9
  }
10
10
  ]
11
11
  }