import { Stream } from "../data/Stream"; import { BlobType, BooleanType, EastFunction, EastType, IntegerType, StringType, Variable } from "../east"; import { Builder, ModulePath, Template } from '../template'; import { Assertion } from '../task'; import { ModuleBuilder } from '../template/ModuleBuilder'; /** * Create a `SinkBuilder` to build a data {@link Sink}. * * Methods on the `SinkBuilder` enable you to emit stream data to external systems. If the {@link Stream} is a {@link BlobType}, * specialised operations can be applied to perform an ftp put of the {@link Stream}. * * Quality of data can be observed using `assert` and `warn` by providing expression based conditions * and messages to the whole {@link Stream}. * * A corresponding {@link Template} can be created using `.toTemplate()`. * * @param name the name of the {@link Sink} to create * * @remarks See [Transform Data](https://learn.elaraai.com/courses/development-essentials/03_transform_data/) for a related learning module. * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined uri stream * const uri = Stream("uri", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "uri", stream: uri }) * .assert({ * predicate: uri => NotEqual(uri, ''), * message: "Uri is empty" * }) * .ftp({ * uri: (inputs) => inputs.uri, * }) * .toTemplate(); * ``` **/ export declare class SinkBuilder { private name; private module; /** * Create a `SinkBuilder` to build a data {@link Sink}. * * Methods on the `SinkBuilder` enable you to emit stream data to external systems. If the {@link Stream} is a {@link BlobType}, * specialised operations can be applied to perform an ftp put of the {@link Stream}. * * Quality of data can be observed using `assert` and `warn` by providing expression based conditions * and messages to the whole {@link Stream}. * * A corresponding {@link Template} can be created using `.toTemplate()`. * * @param name the name of the {@link Sink} to create * * @remarks See [Transform Data](https://learn.elaraai.com/courses/development-essentials/03_transform_data/) for a related learning module. * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined uri stream * const uri = Stream("uri", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "uri", stream: uri }) * .assert({ * predicate: uri => NotEqual(uri, ''), * message: "Uri is empty" * }) * .ftp({ * uri: (inputs) => inputs.uri, * }) * .toTemplate(); * ``` **/ constructor(name: string, module?: ModuleBuilder | ModulePath); /** * Define the {@link Stream} to construct the {@link Sink} from. * * @param stream the input {@link Stream} for the {@link Sink} * @returns a new {@link SinkBuilder} * * @category Sink * * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * * const sink = new SinkBuilder("Ftp") * .from(file) * .toTemplate(); * ``` **/ from(stream: Stream): BlobSinkBuilder; } /** * {@inheritDoc SinkBuilder} * * @category Sink * */ export declare class BlobSinkBuilder> { private name; private module; private inputs; private input_streams; private input_assertions; /** @internal */ constructor(name: string, module: ModulePath, inputs?: Inputs, input_streams?: Record, input_assertions?: Assertion[]); /** * Add a stream as input to the `BlobSinkBuilder`, which can be used in * expressions to configure how the {@link Sink} will access the data (such as a URL or password), * the output data, or any data assertions (preconditions and postconditions). * * @param config the configuration for the `input` * @returns a new {@link BlobSinkBuilder} * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined uri stream * const uri = Stream("uri", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "uri", stream: uri }) * .assert({ * predicate: uri => NotEqual(uri, ''), * message: "Uri is empty" * }) * .ftp({ * uri: (inputs) => inputs.uri, * }) * .toTemplate(); * ``` */ input(config: { /** the name to give the input {@link Variable} */ name: Name & Name extends (keyof Inputs | "input") ? never : Name; /** the input stream (the stream and associated preconditions) */ stream: Stream; }): BlobSinkBuilder; }>; /** * Check the sink inputs for validity and identify any errors. When the `if` predicate returns `true` * the sink will be terminated with an error message and sink output will not be produced. * * @param config the error message and predicate * @returns a new {@link BlobSinkBuilder} * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined uri stream * const uri = Stream("uri", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "uri", stream: uri }) * .error({ * if: uri => Equal(uri, ''), * message: "Uri is empty" * }) * .ftp({ * uri: (inputs) => inputs.uri, * }) * .toTemplate(); * ``` */ error(config: { /** If true an error will be created */ if: (inputs: Inputs) => EastFunction; /** The message in the case that an error is created */ message: ((inputs: Inputs) => EastFunction) | string; }): BlobSinkBuilder; /** * Check the sink inputs for validity and raise warnings as necessary. When the `if` predicate returns `true` * the sink will register a warning with a message, but will proceed to proceed to output data. * * @param config the warning message and predicate * @returns a new {@link BlobSinkBuilder} * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined uri stream * const uri = Stream("uri", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "uri", stream: uri }) * .warn({ * if: uri => Equal(uri, ''), * message: "Uri is empty" * }) * .ftp({ * uri: (inputs) => inputs.uri, * }) * .toTemplate(); * ``` */ warn(config: { /** If true a warning will be produced */ if: (inputs: Inputs) => EastFunction; /** The message in the case that a warning is created */ message: ((inputs: Inputs) => EastFunction) | string; }): BlobSinkBuilder; /** * Produce log messages based on the sink inputs. When the `if` predicate returns `true` * the sink will register a log message and proceed to proceed to output data. * * @param config the log message and optional predicate * @returns a new {@link BlobSinkBuilder} * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined uri stream * const uri = Stream("uri", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "uri", stream: uri }) * .warn({ * if: uri => Equal(uri, ''), * message: "Uri is empty" * }) * .ftp({ * uri: (inputs) => inputs.uri, * }) * .toTemplate(); * ``` */ log(config: { /** If true a log message will be produced (optional) */ if?: (inputs: Inputs) => EastFunction; /** The log message */ message: ((inputs: Inputs) => EastFunction) | string; }): BlobSinkBuilder; /** * Build a sink to put a blob into an ftp file uri. * * @param config the configuration of the ftp put * @returns a new {@link BlobSinkBuilder} * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined uri stream * const uri = Stream("uri", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "uri", stream: uri }) * .warn({ * predicate: uri => NotEqual(uri, ''), * message: "Uri is empty" * }) * .ftp({ * uri: (inputs) => inputs.uri, * }) * .toTemplate(); * ``` */ ftp EastFunction, P extends (inputs: Inputs) => EastFunction>(config: { /** An {@link EastFunction} for the ftp uri */ uri: U; /** An {@link EastFunction} for the ftp username */ username?: U; /** An {@link EastFunction} for the ftp password */ password?: U; /** An {@link EastFunction} for the ftp private key */ key?: U; /** An {@link EastFunction} for the ftp port */ port?: P; }): FtpSinkBuilder; /** * Build a sink to put a blob into an s3 path. * * @param config the configuration of the s3 blob * @returns a new {@link BlobSinkBuilder} * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined path stream * const key = Stream("key", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "key", stream: key }) * .warn({ * predicate: key => NotEqual(key, ''), * message: "Key is empty" * }) * .s3({ * region: (inputs) => Const("__REGION__"), * bucket: (inputs) => Const("__BUCKET__"), * key: (inputs) => inputs.key, * access_key_id: (inputs) => Const("__ACCESS_KEY_ID__"), * secret_access_key: (inputs) => Const("__SECRET_KEY__") * }) * .toTemplate(); * ``` */ s3 EastFunction>(config: { /** An {@link EastFunction} with the aws region */ region: U; /** An {@link EastFunction} with a bucket name containing the object */ bucket: U; /** An {@link EastFunction} with the key of the object to get. */ key: U; /** An {@link EastFunction} with the AWS access key ID */ access_key_id: U; /** An {@link EastFunction} with the AWS secret access key */ secret_access_key: U; }): S3SinkBuilder; } /** * {@inheritDoc SinkBuilder} * * @category Sink * */ export declare class FtpSinkBuilder> extends Builder { protected type: B; protected inputs: Inputs; protected input_streams: Record; protected input_assertions: Assertion[]; protected ftp_uri: EastFunction; protected ftp_username?: EastFunction | undefined; protected ftp_password?: EastFunction | undefined; protected ftp_key?: EastFunction | undefined; protected ftp_port?: EastFunction | undefined; /** @internal */ constructor(name: string, module: ModulePath, type: B, inputs: Inputs, input_streams: Record, input_assertions: Assertion[], ftp_uri: EastFunction, ftp_username?: EastFunction | undefined, ftp_password?: EastFunction | undefined, ftp_key?: EastFunction | undefined, ftp_port?: EastFunction | undefined); /** * Return a {@link Template} fragment containing the {@link Stream}s and {@link TaskDescription}s built by this builder. * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined uri stream * const uri = Stream("uri", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "uri", stream: uri }) * .warn({ * predicate: uri => NotEqual(uri, ''), * message: "Uri is empty" * }) * .ftp({ * uri: (inputs) => inputs.uri, * }) * .toTemplate(); * ``` */ toTemplate(): Template; } /** * {@inheritDoc SinkBuilder} * * @category Sink * */ export declare class S3SinkBuilder> extends Builder { protected type: B; protected inputs: Inputs; protected input_streams: Record; protected input_assertions: Assertion[]; protected s3_region: EastFunction; protected s3_bucket: EastFunction; protected s3_key: EastFunction; protected s3_access_key_id: EastFunction; protected s3_secret_access_key: EastFunction; /** @internal */ constructor(name: string, module: ModulePath, type: B, inputs: Inputs, input_streams: Record, input_assertions: Assertion[], s3_region: EastFunction, s3_bucket: EastFunction, s3_key: EastFunction, s3_access_key_id: EastFunction, s3_secret_access_key: EastFunction); /** * Return a {@link Template} fragment containing the {@link Stream}s and {@link TaskDescription}s built by this builder. * * @category Sink * * @example * ```typescript * // get a predefined blob stream * const file = Stream("File", BlobType); * // get a predefined path stream * const key = Stream("key", StringType) * // put the contents of the file at the uri * const sink = new SinkBuilder("Ftp") * .from(file) * .input({ name: "key", stream: key }) * .warn({ * predicate: key => NotEqual(key, ''), * message: "Key is empty" * }) * .s3({ * region: (inputs) => Const("__REGION__"), * bucket: (inputs) => Const("__BUCKET__"), * key: (inputs) => inputs.key, * access_key_id: (inputs) => Const("__ACCESS_KEY_ID__"), * secret_access_key: (inputs) => Const("__SECRET_KEY__") * }) * .toTemplate(); * ``` */ toTemplate(): Template; }