import type { IResolvable, IResolveContext } from '../../core'; import type { IRuleRef } from '../../interfaces/generated/aws-events-interfaces.generated'; /** * The input to send to the event target */ export declare abstract class RuleTargetInput { /** * Pass text to the event target * * May contain strings returned by `EventField.from()` to substitute in parts of the * matched event. * * The Rule Target input value will be a single string: the string you pass * here. Do not use this method to pass a complex value like a JSON object to * a Rule Target. Use `RuleTargetInput.fromObject()` instead. * * The target `Input` field must be valid JSON, so the text is JSON-encoded * when the template is synthesized. As a result a plain string is wrapped in * double quotes: `fromText('something')` renders as `Input: '"something"'`. * The quotes are part of the required JSON encoding, not an extra value added * by CDK, and cannot be removed. * * Whether those quotes are visible to the recipient depends on the target * service. Some targets deliver the JSON-encoded value as-is, so the recipient * sees the surrounding quotes (for example, an SNS topic delivering to an * email subscriber shows `"something"`). To send a structured payload, use * `RuleTargetInput.fromObject()` instead. */ static fromText(text: string): RuleTargetInput; /** * Pass text to the event target, splitting on newlines. * * This is only useful when passing to a target that does not * take a single argument. * * May contain strings returned by `EventField.from()` to substitute in parts * of the matched event. * * As with `fromText`, each line is JSON-encoded, so every line is wrapped in * double quotes in the synthesized template. Whether those quotes are visible * to the recipient depends on the target service. */ static fromMultilineText(text: string): RuleTargetInput; /** * Pass a JSON object to the event target * * May contain strings returned by `EventField.from()` to substitute in parts of the * matched event. * * @returns RuleTargetInput */ static fromObject(obj: any): RuleTargetInput; /** * Take the event target input from a path in the event JSON */ static fromEventPath(path: string): RuleTargetInput; protected constructor(); /** * Return the input properties for this input object */ abstract bind(rule: IRuleRef): RuleTargetInputProperties; } /** * The input properties for an event target */ export interface RuleTargetInputProperties { /** * Literal input to the target service (must be valid JSON) * * @default - input for the event target. If the input contains a paths map * values wil be extracted from event and inserted into the `inputTemplate`. */ readonly input?: string; /** * JsonPath to take input from the input event * * @default - None. The entire matched event is passed as input */ readonly inputPath?: string; /** * Input template to insert paths map into * * @default - None. */ readonly inputTemplate?: string; /** * Paths map to extract values from event and insert into `inputTemplate` * * @default - No values extracted from event. */ readonly inputPathsMap?: { [key: string]: string; }; } /** * Input object that can contain field replacements * * Evaluation is done in the bind() method because token resolution * requires access to the construct tree. * * Multiple tokens that use the same path will use the same substitution * key. * * One weird exception: if we're in object context, we MUST skip the quotes * around the placeholder. I assume this is so once a trivial string replace is * done later on by EventBridge, numbers are still numbers. * * So in string context: * * "this is a string with a " * * But in object context: * * "{ \"this is the\": }" * * To achieve the latter, we postprocess the JSON string to remove the surrounding * quotes by using a string replace. * * @internal */ export declare class FieldAwareEventInput extends RuleTargetInput { private readonly input; private readonly inputType; constructor(input: any, inputType: InputType); bind(rule: IRuleRef): RuleTargetInputProperties; /** * Removing surrounding quotes from any object placeholders * when key is the lone value. * * Those have been put there by JSON.stringify(), but we need to * remove them. * * Do not remove quotes when the key is part of a larger string. * * Valid: { "data": "Some string with \"quotes\"" } // key will be string * Valid: { "data": } // Key could be number, bool, obj, or string */ private unquoteKeyPlaceholders; } /** * Represents a field in the event pattern */ export declare class EventField implements IResolvable { readonly path: string; /** * Extract the event ID from the event */ static get eventId(): string; /** * Extract the detail type from the event */ static get detailType(): string; /** * Extract the source from the event */ static get source(): string; /** * Extract the account from the event */ static get account(): string; /** * Extract the time from the event */ static get time(): string; /** * Extract the region from the event */ static get region(): string; /** * Extract a custom JSON path from the event */ static fromPath(path: string): string; /** * Human readable display hint about the event pattern */ readonly displayHint: string; readonly creationStack: string[]; /** * * @param path the path to a field in the event pattern */ private constructor(); resolve(_ctx: IResolveContext): any; toString(): string; /** * Convert the path to the field in the event pattern to JSON */ toJSON(): string; } /** * @internal */ export declare enum InputType { Object = 0, Text = 1, Multiline = 2 }