import { Failure, Result } from '@cdklabs/tskb';
import { JsonLensPatcher, PatchReport } from '../patching';
import { BoundProblemReport } from '../report';
export interface LoadSourceOptions {
readonly validate?: boolean;
readonly debug?: boolean;
}
export interface LoaderOptions {
/**
* Fail if we detect schema validations with the data source
*
* @default true
*/
readonly mustValidate?: boolean;
/**
* Patches to apply to the data before it is validated
*/
readonly patcher?: JsonLensPatcher;
/**
* If present, make filenames in errors relative to this directory
*/
readonly errorRootDirectory?: string;
/**
* Where to send problem reports
*/
readonly report?: BoundProblemReport;
}
export declare class Loader {
private readonly validator;
private readonly options;
static fromSchemaFile(fileName: string, options: LoaderOptions): Promise>;
private constructor();
/**
* Validate the given object
*
* - Returns success if validation is NONE or WARNING.
* - Adds warnings to the Loader object if validation is WARNING.
*/
load(obj: unknown): Promise>>;
/**
* Validate the given file
*
* - Returns success if validation is NONE or WARNING.
* - Adds warnings to the Loader object if validation is WARNING.
*/
loadFile(fileName: string): Promise>>;
/**
* Validate the given files
*
* Returns only successfully parsed objects.
*/
loadFiles(fileNames: string[]): Promise>;
loadFiles(fileNames: string[], combiner: (x: Result>[]) => B): Promise;
private annotateWithFilename;
}
/**
* Sequential map for async functions
*
* (In case we're concerned about the performance implications of `Promise.all()`.)
*/
export declare function seqMap(xs: A[], fn: (x: A) => Promise): Promise;
export interface LoadResult {
/**
* The value that was loaded
*/
readonly value: A;
/**
* Schema errors reported by the schema checker
*/
readonly warnings: Failure[];
/**
* Patches that were applied by the patcher (if any)
*/
readonly patchesApplied: PatchReport[];
}
export declare function combineLoadResults(xs: Result>[]): LoadResult;
export declare function mapLoadResult(x: LoadResult, fn: (x: A) => B): LoadResult;