Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function getEventPositionFilter(eventPosition: EventPosition): string {
let result;
// order of preference
if (eventPosition.offset != undefined) {
result = eventPosition.isInclusive
? `${Constants.offsetAnnotation} >= '${eventPosition.offset}'`
: `${Constants.offsetAnnotation} > '${eventPosition.offset}'`;
} else if (eventPosition.sequenceNumber != undefined) {
result = eventPosition.isInclusive
? `${Constants.sequenceNumberAnnotation} >= '${eventPosition.sequenceNumber}'`
: `${Constants.sequenceNumberAnnotation} > '${eventPosition.sequenceNumber}'`;
} else if (eventPosition.enqueuedTime != undefined) {
const time =
eventPosition.enqueuedTime instanceof Date
? eventPosition.enqueuedTime.getTime()
: eventPosition.enqueuedTime;
result = `${Constants.enqueuedTimeAnnotation} > '${time}'`;
}
if (!result) {
throw translate({
condition: ErrorNameConditionMapper.ArgumentError,
description: "No starting position was set in the EventPosition."
});
}
return result;
}
export function getEventPositionFilter(eventPosition: EventPosition): string {
let result;
// order of preference
if (eventPosition.offset != undefined) {
result = eventPosition.isInclusive
? `${Constants.offsetAnnotation} >= '${eventPosition.offset}'`
: `${Constants.offsetAnnotation} > '${eventPosition.offset}'`;
} else if (eventPosition.sequenceNumber != undefined) {
result = eventPosition.isInclusive
? `${Constants.sequenceNumberAnnotation} >= '${eventPosition.sequenceNumber}'`
: `${Constants.sequenceNumberAnnotation} > '${eventPosition.sequenceNumber}'`;
} else if (eventPosition.enqueuedOn != undefined) {
const time =
eventPosition.enqueuedOn instanceof Date
? eventPosition.enqueuedOn.getTime()
: eventPosition.enqueuedOn;
result = `${Constants.enqueuedTimeAnnotation} > '${time}'`;
}
if (!result) {
throw translate({
condition: ErrorNameConditionMapper.ArgumentError,
description: "No starting position was set in the EventPosition."
});
}
return result;