import * as functionless_event_bridge from "../types";
/**
 * These are simplified and better structured interfaces/types to make it easier to work with Event Bridge Patterns.
 * Use the {@link patternToEventBridgePattern} to generate a valid object for event bridge.
 *
 * All patterns are applied to a single field {@link PatternDocument}s provide AND logic on multiple fields.
 */
export declare type Pattern = AggregatePattern | ExactMatchPattern | PrefixMatchPattern | NumericRangePattern | PresentPattern | AnythingButPattern | AnythingButPrefixPattern | EmptyPattern | NumericAggregationPattern | NeverPattern;
/**
 * The base of an event pattern is a object with multiple fields. Additionally some fields like detail can be deep.
 */
export interface PatternDocument {
    doc: {
        [key: string]: PatternDocument | Pattern;
    };
}
export declare const isPatternDocument: (x: Pattern | PatternDocument) => x is PatternDocument;
/**
 * One or more patterns with OR logic between them on a single field.
 */
export interface AggregatePattern {
    patterns: (ExactMatchPattern | PrefixMatchPattern | PresentPattern | AnythingButPattern | AnythingButPrefixPattern | NeverPattern)[];
}
export declare const isAggregatePattern: (x: Pattern) => x is AggregatePattern;
/**
 * One or more {@link NumericRangePattern} with OR/Union logic applied.
 */
export interface NumericAggregationPattern {
    ranges: NumericRangePattern[];
}
export declare const isNumericAggregationPattern: (x: Pattern) => x is NumericAggregationPattern;
/**
 * Equals logic for a string, boolean, or null.
 * Number is handled using {@link NumericRangePattern} and normalized later.
 */
export interface ExactMatchPattern {
    value: string | boolean | null;
}
export declare const isExactMatchPattern: (x: Pattern) => x is ExactMatchPattern;
/**
 * Starts With logic for strings.
 */
export interface PrefixMatchPattern {
    prefix: string;
}
export declare const isPrefixMatchPattern: (x: Pattern) => x is PrefixMatchPattern;
/**
 * The lower or upper end of a numeric range.
 * Use {@link Number.POSITIVE_INFINITY} or {@link Number.NEGATIVE_INFINITY} to represent no LOWER or UPPER value.
 */
export interface NumericRangeLimit {
    value: number;
    inclusive: boolean;
}
/**
 * A range of values from a possible {@link Number.NEGATIVE_INFINITY} to {@link Number.POSITIVE_INFINITY}.
 *
 * Use a Upper and Lower bound of a single value to represent a single value.
 * Exclusive on upper and lower represents a NOT on the value.
 *
 * Generally represents the AND logic of a numeric range.
 */
export interface NumericRangePattern {
    lower: NumericRangeLimit;
    upper: NumericRangeLimit;
}
export declare const isNumericRangePattern: (x: Pattern) => x is NumericRangePattern;
/**
 * Exists or `field in` logic on an object in Event Bridge
 */
export interface PresentPattern {
    isPresent: boolean;
}
export declare const isPresentPattern: (x: Pattern) => x is PresentPattern;
/**
 * NOT logic for string and null.
 *
 * Use {@link NumericRangePattern} to represent NOT logic for numbers.
 */
export declare type AnythingButPattern = {
    anythingBut: (string | null)[];
};
export declare const isAnythingButPattern: (x: any) => x is AnythingButPattern;
/**
 * NOT logic for string and null.
 *
 * Use {@link NumericRangePattern} to represent NOT logic for numbers.
 */
export declare type AnythingButPrefixPattern = {
    anythingButPrefix: string;
};
export declare const isAnythingButPrefixPattern: (x: any) => x is AnythingButPrefixPattern;
/**
 * A Pattern that represents logic that is always true.
 * This pattern will be filtered out by the end of the compilation.
 * If the only pattern remaining is a EmptyPattern, the field will be removed from the pattern.
 */
export interface EmptyPattern {
    empty: true;
}
export declare const isEmptyPattern: (x: Pattern) => x is EmptyPattern;
/**
 * A Pattern that represents logic that is never true.
 * This pattern may be filtered out at the end.
 * It is the opposite of EmptyPattern
 * If it is applied to AND logic, either between or within a field, an error is thrown.
 *
 * When to return NeverPattern and when to Error
 * * NeverPattern - when the logic is impossible, but valid aka, contradictions x !== "a" && x === "a". These MAY later be evaluated to possible using an OR.
 * * Error - When the combination is unsupported by Event Bridge or Functionless.
 *           For example, if we do not know how to represent !x.startsWith("x") && x.startsWith("y"),
 *           then we need to fail compilation as the logic may filter a event if it was supported and not ignored.
 */
export interface NeverPattern {
    never: true;
    reason?: string;
}
export declare const isNeverPattern: (x: Pattern) => x is NeverPattern;
export declare const isPositiveSingleValueRange: (pattern: NumericRangePattern) => boolean;
export declare const isNegativeSingleValueRange: (pattern: NumericRangePattern) => boolean;
/**
 * Transforms the proprietary {@link PatternDocument} into AWS's EventPattern schema.
 * https://docs.aws.amazon.com/eventbridge/latest/userguide/eb-event-patterns.html
 *
 * For each field,
 *  if the field is a nested PatternDocument, recurse.
 *  if the field is a Pattern, output the pattern as a EventPattern.
 *
 * We will not maintain empty patterns or pattern documents.
 */
export declare const patternDocumentToEventPattern: (patternDocument: PatternDocument) => functionless_event_bridge.SubPattern;
/**
 * Transforms the proprietary {@link Pattern} into a EventBridge's {@link functionless_event_bridge.PatternList} schema.
 */
export declare const patternToEventBridgePattern: (pattern: Pattern, aggregate?: boolean) => functionless_event_bridge.PatternList | undefined;
export declare const deploymentOnlyModule = true;
//# sourceMappingURL=pattern.d.ts.map