import { type Formatter } from '@json2csv/formatters'; import type Transform from './types/Transform.js'; export interface FieldValueGetterInfo { label: string; default?: FT; } export interface FieldValueGetterFnWithoutField { (row: RT): FT; } export interface FieldValueGetterFnWithField { (row: RT, field: FieldValueGetterInfo): FT; } export type FieldValueGetter = string | FieldValueGetterFnWithoutField | FieldValueGetterFnWithField; export interface FieldInfo { label?: string | undefined; default?: FT | undefined; value: FieldValueGetter; } export declare enum FormatterTypes { header = "header", undefined = "undefined", boolean = "boolean", number = "number", bigint = "bigint", string = "string", symbol = "symbol", function = "function", object = "object" } export interface FormattersOptions { [FormatterTypes.header]?: Formatter; [FormatterTypes.undefined]?: Formatter; [FormatterTypes.boolean]?: Formatter; [FormatterTypes.number]?: Formatter; [FormatterTypes.bigint]?: Formatter; [FormatterTypes.string]?: Formatter; [FormatterTypes.symbol]?: Formatter; [FormatterTypes.function]?: Formatter; [FormatterTypes.object]?: Formatter; } export interface Json2CSVBaseOptions { fields?: Array>; ndjson?: boolean; defaultValue?: string; delimiter?: string; eol?: string; header?: boolean; includeEmptyRows?: boolean; withBOM?: boolean; formatters?: FormattersOptions; transforms?: [] | [Transform] | [Transform, ...Array>, Transform]; } interface NormalizedFieldInfo { label: string; value: FieldValueGetterFnWithoutField; } export interface NormalizedJson2CSVBaseOptions extends Required> { fields: Array>; formatters: Required; } export default abstract class JSON2CSVBase { protected opts: NormalizedJson2CSVBaseOptions; constructor(opts?: Readonly>); /** * Check passing opts and set defaults. * * @param {Json2CsvOptions} opts Options object containing fields, * delimiter, default value, header, etc. */ protected preprocessOpts(opts?: Json2CSVBaseOptions): NormalizedJson2CSVBaseOptions; /** * Check and normalize the fields configuration. * * @param {(string|object)[]} fields Fields configuration provided by the user * or inferred from the data * @returns {object[]} preprocessed FieldsInfo array */ protected preprocessFieldsInfo(fields: Array>, globalDefaultValue?: string): Array>; /** * Create the title row with all the provided fields as column headings * * @returns {String} titles as a string */ protected getHeader(): string; /** * Preprocess each object according to the given transforms (unwind, flatten, etc.). * @param {Object} row JSON object to be converted in a CSV row */ protected preprocessRow(row: TRaw): Array; /** * Create the content of a specific CSV row * * @param {Object} row JSON object to be converted in a CSV row * @returns {String} CSV string (row) */ protected processRow(row: T): string | undefined; /** * Create the content of a specfic CSV row cell * * @param {Object} row JSON object representing the CSV row that the cell belongs to * @param {FieldInfo} fieldInfo Details of the field to process to be a CSV cell * @returns {String} CSV string (cell) */ protected processCell(row: T, fieldInfo: NormalizedFieldInfo): string; /** * Create the content of a specfic CSV row cell * * @param {T} value Value to be included in a CSV cell * @returns {String} Value stringified and processed */ protected processValue(value: T): string; } export {}; //# sourceMappingURL=BaseParser.d.ts.map