@eagleoutice/flowr
Version:
Static Dataflow Analyzer and Program Slicer for the R Programming Language
57 lines (56 loc) • 3.04 kB
TypeScript
import type { IPipelineStep, StepProcessingFunction } from '../steps/pipeline-step';
import type { TailOfArray } from '../../util/collections/arrays';
/**
* Defines the output format of a step that you are interested in.
*/
export declare const enum StepOutputFormat {
/**
* [Internal]
* This output format is special as it corresponds to whatever the step would normally produce - unchanged - as a typescript object.
* There is no special way to influence this output format, and it is not to be serialized.
*/
Internal = 0,
/**
* A human-readable textual representation of the result. Depending on the step this may be of lesser use as the results
* of the dataflow analysis are not easily readable in text form.
*/
Text = 1,
/**
* This is usually a one-to-one serialization of the internal format, although it is possible that some recursive references are broken.
*/
Json = 2,
/**
* If possible, this will produce a mermaid graph of the result and contain the mermaid code.
* This is only really possible for some of the step (e.g., the dataflow analysis).
*/
Mermaid = 3,
/**
* This is an extension of the {@link Mermaid} format. Instead of returning
* the mermaid code, it will return an url to mermaid live.
*/
MermaidUrl = 4,
/**
* Produce n-quads as the output.
* See {@link serialize2quads}
*/
RdfQuads = 5
}
/**
* Helper function to support the {@link Internal} format, as it is simply returning the input.
*
* @see IPipelineStepPrinter
*/
export declare function internalPrinter<Input>(input: Input): Input;
/**
* A mapping function that maps the result of a step (i.e., the dataflow graph)
* to another representation (linked by {@link StepOutputFormat} in an {@link IPipelineStep}).
*
* For the internal format, refer to {@link InternalStepPrinter} as a shorthand.
*/
export type IPipelineStepPrinter<StepInput extends StepProcessingFunction, Format extends StepOutputFormat, AdditionalInput extends unknown[]> = Format extends StepOutputFormat.Internal ? (input: Awaited<ReturnType<StepInput>>) => Awaited<ReturnType<StepInput>> : (input: Awaited<ReturnType<StepInput>>, ...additional: AdditionalInput) => Promise<string> | string;
export type InternalStepPrinter<StepInput extends StepProcessingFunction> = IPipelineStepPrinter<StepInput, StepOutputFormat.Internal, []>;
/**
* For a `step` of the given name, which returned the given `data`. Convert that data into the given `format`.
* Depending on your step and the format this may require `additional` inputs.
*/
export declare function printStepResult<Step extends IPipelineStep, Processor extends Step['processor'], Format extends Exclude<keyof Step['printer'], StepOutputFormat.Internal> & number, Printer extends Step['printer'][Format], AdditionalInput extends TailOfArray<Parameters<Printer>>>(step: Step, data: Awaited<ReturnType<Processor>>, format: Format, ...additional: AdditionalInput): Promise<string>;