import { FluxTableMetaData, FluxResultObserver, QueryApi, ParameterizedQuery } from '@influxdata/influxdb-client'; import { Table, FromFluxResult } from '@influxdata/giraffe'; /** A type of a function that creates a new giraffe table of a specified length */ type GiraffeTableFactory = (length: number) => Table; /** * AcceptRowFunction allows to accept/reject specific rows or terminate processing. * @param row - CSV result data row * @param tableMeta - CSV table metadata with column descriptors * @returns true to accept row, false to skip row, undefined means stop processing **/ type AcceptRowFunction = (row: string[], tableMeta: FluxTableMetaData) => true | false | undefined; /** * Contains parameters that optimize/drive creation of the query result Table. */ interface TableOptions { /** * Accept allows to accept/reject specific rows or terminate processing. **/ accept?: AcceptRowFunction | AcceptRowFunction[]; /** * Sets maximum table length, QUERY_MAX_TABLE_LENGTH when undefined. */ maxTableLength?: number; /** column keys to collect in the table, undefined means all columns */ columns?: string[]; /** compute also fluxGroupKeyUnion */ computeFluxGroupKeyUnion?: boolean; /** compute also resultColumnNames */ computeResultColumnNames?: boolean; } /** * QUERY_MAX_TABLE_LENGTH is a default max table length, * it can be overriden in TableOptions. */ declare const QUERY_MAX_TABLE_LENGTH = 100000; /** * Creates an accept function that stops processing * if the table reaches the specified max rows. * @param size - maximum processed rows * @returns AcceptRowFunction that enforces that most max rows are processed */ declare function acceptMaxTableLength(max: number): AcceptRowFunction; /** * Creates influxdb-client-js's FluxResultObserver that collects row results to a Table instance * @param resolve - called when the Table is collected * @param reject - called upon error * @param tableOptions - tableOptions allow to filter or even stop the processing of rows, or restrict the columns to collect * @returns FluxResultObserver that collects table data from result rows */ declare function createCollector(resolve: (value: FromFluxResult) => void, reject: (reason?: any) => void, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): FluxResultObserver; /** * Transforms annotated CSV query response to Giraffe's FromFluxResult. * * @param csv - annotated CSV flux query response * @param tableFactory - creates a new Giraffe table * @param tableOptions - tableOptions allows to filter or even stop the processing of rows, specify maximum rows or restrict the columns to collect * @returns a new FromFluxResult instance */ declare function csvToFromFluxResult(csv: string, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): FromFluxResult; /** * Transforms annotated CSV query response to Giraffe's Table. * * @param csv - annotated CSV flux query response * @param tableFactory - creates a new Giraffe table * @param tableOptions - tableOptions allows to filter or even stop the processing of rows, specify maximum rows or restrict the columns to collect. * @returns a new Table instance */ declare function csvToTable(csv: string, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): Table; /** * Executes a flux query and collects results into a Giraffe's Table. * * @param queryApi - InfluxDB client's QueryApi instance * @param query - query to execute * @param tableFactory - creates a new Giraffe table * @param tableOptions - tableOptions allows to filter or even stop the processing of rows, specify maximum rows or restrict the columns to collect. * @returns Promise with query results */ declare function queryToTable(queryApi: QueryApi, query: string | ParameterizedQuery, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): Promise; /** * Executes a flux query and iterrativelly collects results into a Giraffe's FromFluxResult. * * @param queryApi - InfluxDB client's QueryApi instance * @param query - query to execute * @param tableFactory - creates a new Giraffe table * @param tableOptions - tableOptions allows to filter or even stop the processing of rows, specify maximum rows or restrict the columns to collect * @returns a Promise with query results */ declare function queryToFromFluxResult(queryApi: QueryApi, query: string | ParameterizedQuery, tableFactory: GiraffeTableFactory, tableOptions?: TableOptions): Promise; export { type AcceptRowFunction, type GiraffeTableFactory, QUERY_MAX_TABLE_LENGTH, type TableOptions, acceptMaxTableLength, createCollector, csvToFromFluxResult, csvToTable, queryToFromFluxResult, queryToTable };