import { DataTypeFieldConfig, FieldType, DataTypeFields, ReadonlyDataTypeFields, ReadonlyDataTypeConfig } from '@terascope/types'; import { Column } from '../column/index.js'; export type { InNumberRangeArg } from '@terascope/core-utils'; export declare enum FunctionDefinitionType { FIELD_TRANSFORM = "FIELD_TRANSFORM", RECORD_TRANSFORM = "RECORD_TRANSFORM", FIELD_VALIDATION = "FIELD_VALIDATION", RECORD_VALIDATION = "RECORD_TRANSFORM" } export declare enum ProcessMode { /** This indicates that it operations on non-nil individual values */ INDIVIDUAL_VALUES = "INDIVIDUAL_VALUES", /** This indicates that it operations on entire values, including nulls and arrays */ FULL_VALUES = "FULL_VALUES", /** This indicates a noop, usually this is for metadata/datatype changes */ NONE = "NONE" } export declare enum FunctionDefinitionCategory { BOOLEAN = "BOOLEAN", GEO = "GEO", JSON = "JSON", NUMERIC = "NUMERIC", OBJECT = "OBJECT", STRING = "STRING", DATE = "DATE", IP = "IP" } export interface FunctionDefinitionExample, O = unknown> { /** * The example arguments passed to the function */ readonly args: T; /** * The example data type config and children */ readonly config: ReadonlyDataTypeConfig; /** * The field to validate against and get the config for. * Only required for field operations; */ readonly field?: string; /** * An example input value that will be pretty printed for documentation. * @note this is only a single value */ readonly input: unknown; /** * The outputted value that will be pretty printed for documentation. * In the case of validators, this should be either * the input or null (which indicates it is invalid) */ readonly output?: O; /** * Serialize the output for documentation or the function adapter. * In the functionTestHarness this won't be called out the result * from the dataFrameAdapter */ readonly serialize_output?: (output: O) => unknown; /** * If this is set to true, the output is not required. If output * is specified it should be the error message */ readonly fails?: boolean; /** * Optionally describe the behavior of this example */ readonly description?: string; /** * Setting this to true will be exclude it from the * documentation */ readonly test_only?: boolean; } export interface FunctionDefinitionConfig> { /** * The name of the function, this should be considered case-insensitive, * since some languages like SQL are case insensitive. */ readonly name: string; /** * Optionally specify other known aliases to this function */ readonly aliases?: readonly string[]; /** Type of operation that will be preformed */ readonly type: FunctionDefinitionType; /** Used to generate documentation */ readonly description: string; /** * The category of operation, for documentation purposes */ readonly category: FunctionDefinitionCategory; /** * Examples that will be used in the documentation and potentially * in the automated tests. * FIXME make this non-optional */ readonly examples?: readonly FunctionDefinitionExample[]; /** * Used for validating and defining the types of the input arguments, * please include description field when creating the schema */ readonly argument_schema?: DataTypeFields; /** * Used to determine what of the possible args are required, as DataType configs does not have * a mechanism to specify what is required */ readonly required_arguments?: readonly string[]; /** * Can be used in strongly typed contexts to throw early, some types * or only compatible with a given operation */ readonly accepts: readonly FieldType[]; /** Used for additional custom validation of args, called after generic arg validation */ readonly validate_arguments?: (args: T) => void; } export interface FunctionContext = Record> { readonly args: T; readonly inputConfig?: DataTypeFieldAndChildren; readonly outputConfig?: DataTypeFieldAndChildren; readonly parent: Column | unknown[]; } export interface DynamicFrameFunctionContext = Record> { readonly args: (index: number) => T; readonly inputConfig?: DataTypeFieldAndChildren; readonly outputConfig?: DataTypeFieldAndChildren; readonly parent: Column; } export interface DynamicFunctionContext = Record> { readonly args: (index: number) => T; readonly inputConfig?: DataTypeFieldAndChildren; readonly outputConfig?: DataTypeFieldAndChildren; readonly parent: unknown[]; } export interface InitialFunctionContext = Record> { readonly args: T | ((index: number) => T); readonly inputConfig?: DataTypeFieldAndChildren; readonly preserveNulls: boolean; readonly preserveEmptyObjects: boolean; readonly field?: string; } export interface FieldValidateConfig = Record> extends FunctionDefinitionConfig { readonly type: FunctionDefinitionType.FIELD_VALIDATION; readonly process_mode: ProcessMode; readonly create: (config: FunctionContext) => (value: unknown, index: number) => boolean; readonly output_type?: (inputConfig: DataTypeFieldAndChildren, args: T) => DataTypeFieldAndChildren; } export interface FieldTransformConfig = Record> extends FunctionDefinitionConfig { readonly type: FunctionDefinitionType.FIELD_TRANSFORM; readonly process_mode: ProcessMode; readonly output_type?: (inputConfig: DataTypeFieldAndChildren, args: T) => DataTypeFieldAndChildren; readonly create: (config: FunctionContext) => (value: unknown, index: number) => unknown; } export interface FieldMetaTransform = Record> extends FunctionDefinitionConfig { readonly type: FunctionDefinitionType.FIELD_TRANSFORM; readonly process_mode: ProcessMode.NONE; readonly create: (config: FunctionContext) => void; readonly output_type?: (inputConfig: DataTypeFieldAndChildren, args: T) => DataTypeFieldAndChildren; } export interface RecordTransformConfig = Record> extends FunctionDefinitionConfig { readonly type: FunctionDefinitionType.RECORD_TRANSFORM; readonly output_type: (inputConfig: ReadonlyDataTypeFields, args?: T) => ReadonlyDataTypeFields; readonly create: (config: FunctionContext) => (value: Record, index: number) => Record; } export interface RecordValidationConfig = Record> extends FunctionDefinitionConfig { readonly type: FunctionDefinitionType.RECORD_VALIDATION; readonly create: (config: FunctionContext) => (value: Record, index: number) => boolean; } export interface OutputType { output_type: (inputConfig: DataTypeFieldAndChildren, args?: T) => DataTypeFieldAndChildren; } export interface DataTypeFieldAndChildren { readonly field_config: Readonly; readonly child_config?: ReadonlyDataTypeFields; } export interface FunctionConfigRepository { readonly [key: string]: FunctionDefinitionConfig>; } export declare function isFieldValidation>(input: FunctionDefinitionConfig): input is FieldValidateConfig; export declare function isFieldTransform>(input: FunctionDefinitionConfig): input is FieldTransformConfig; export declare function isFieldOperation>(input: FunctionDefinitionConfig): input is (FieldValidateConfig | FieldValidateConfig); export declare function isRecordTransform>(input: FunctionDefinitionConfig): input is RecordTransformConfig; export declare function isRecordValidation>(input: FunctionDefinitionConfig): input is RecordValidationConfig; export declare function isTransformOperation>(input: FunctionDefinitionConfig): input is (RecordTransformConfig | FieldTransformConfig); export declare function isNumericType(fieldConfig: Readonly): boolean; //# sourceMappingURL=interfaces.d.ts.map