import { KeyField, KeyFieldProps } from "./core/fields/core/key/key-field"; import { ChacaUtils } from "./core/utils"; import { SchemaInput } from "./core/schema/interfaces/schema"; import { DatasetSchema } from "./core/dataset-resolver/interfaces/dataset-schema"; import { DumpConfig, FileConfig } from "./core/export/interfaces/export"; import { PickField, PickFieldProps } from "./core/fields/core/pick/pick-field"; import { DatatypeModule } from "./modules/datatype"; import { DumpFile } from "./core/export/generators/generator/generator"; import { EnumField, ProbabilityField, RefField, SequenceField, SequentialField } from "./core/fields/core"; import { ProbabilityOption } from "./core/fields/core/probability/probability-field"; import { Dataset } from "./core/dataset/dataset"; import { SequenceFieldProps } from "./core/fields/core/sequence/sequence-field"; import { SequentialFieldConfig } from "./core/fields/core/sequential/sequential-field"; import { FieldToRef, RefFieldConfig } from "./core/fields/core/ref/ref-field"; import { Schema } from "./core/schema/schema"; export declare class Chaca { private readonly datatypeModule; readonly utils: ChacaUtils; constructor(datatypeModule: DatatypeModule, utils: ChacaUtils); /** * @param input The object with the keys and type of each field * * @example * chaca.schema({ * id: chaca.key(() => modules.id.uuid()), * image: () => modules.image.film(), * name: () => modules.person.firstName() * }) */ schema(input: SchemaInput): Schema; /** * Create a reference field for a selected schema * @param field Configuration of the reference field. the field location must be separated points * @param config.unique The value to be referenced will only be taken once by this schema. Default `false` * @param config.where Function that filters the fields to reference * @param config.nullOnEmpty When there are no more documents to reference, the generated value will be null. Default `false` * * @example * chaca.ref('schema.field') */ ref(field: FieldToRef, config?: RefFieldConfig): RefField; /** * Sequential field * * @param values Array of the secuential values * @param config.loop Boolean indicating whether the values should be generated cyclically. Default `false` * @example * chaca.schema({ * number: chaca.sequential([1, 2, 3]) * }) * * // array result * [ * { number: 1 }, * { number: 2 }, * { number: 3 } * ] */ sequential(values: K[], config?: SequentialFieldConfig): SequentialField; /** * Sequence field * @param config.starsWith Init value for the field. Default `1` * @param config.step Step between field values in schema documents. Default `1` * * @example * chaca.sequence() * chaca.sequence({ startsWith: 10 }) * chaca.sequence({ step: 0.5 }) */ sequence(config?: SequenceFieldProps): SequenceField; /** * Key field * @param field field that will return the value. Could be (`RefField` | `SequenceField` | `CustomField` ) * * @example * chaca.key(chaca.sequence()) * chaca.key(() => modules.id.uuid()) */ key(field: KeyFieldProps): KeyField; /** * Enum field * @param values Array of posible values * * @example * chaca.enum(["category1", "category2", "category3"]) */ enum(values: ReadonlyArray): EnumField; /** * Export the data to a selected code format * @param data Data you want to export * @param config.filename file name * @param config.location location of the file * @param config.format file extension (`'java'` | `'csv'` | `'typescript'` | `'json'` | `'javascript'` | `'yaml'` | `'postgresql'` | `'python'`) * * @example * const data = [ * { id: 1, name: 'Alberto', age: 20 }, * { id: 2, name: 'Carolina', age: 28 } * ] * const config = { filename: 'users', format: 'json', location: '../../data' } * * await chaca.export(data, config) * * @returns * Promise */ export(data: any, config: FileConfig): Promise; /** * Generate data from realtional schemas * @param schemas Array with the schemas config */ dataset(schemas: DatasetSchema[]): Dataset; /** * Probability field * @param options Array of options to choose from. Where each one has the 'chance' parameter to indicate the probability of being chosen. * * @example * chaca.probability([ * { chance: 0.9, value: 10 }, * { chance: 0.5, value: 5 }, * { chance: 0.1, value: 1 }, * ]) */ probability(options: ProbabilityOption[]): ProbabilityField; /** * Select a number of elements in an array so that all selected values are not repeated * * @param props.values array of values * @param props.count number of items to select * * @example * chaca.pick({ * values: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10], * count: 3 * }) * * // [2, 6, 10] or [4, 5, 1] or [1, 9, 8] or ... */ pick(props: PickFieldProps): PickField; /** * Serializes `data` as a specific file format * * @param data Data to transform * @param props.filename name for the file * @param props.format file extension (`'java'` | `'csv'` | `'typescript'` | `'json'` | `'javascript'` | `'yaml'` | `'postgresql'` | `'python'`) */ transform(data: any, props: DumpConfig): DumpFile[]; }