import { DataTypeConfig, ESMapping, ReadonlyDataTypeFields, xLuceneTypeConfig } from '@terascope/types'; import * as i from './interfaces.js'; import { DuckDBTypeConfig } from './interfaces.js'; /** * A DataType is used to define the structure of data with version support * and can be converted to the following formats: * * - Elasticsearch Mappings * - GraphQL Schemas * - xLucene * - DuckDB column types * * `toDuckDB` nests deeper than the other conversions. `getGroupedFields` splits on the * first dot only, so `a.b` and `a.b.c` arrive as siblings and `toESMapping`/`toGraphQL` * nest just one level. For DuckDB that would produce a `STRUCT` member named `b.c`, which * is an invalid table definition, so {@link GroupType.toDuckDB} regroups the dotted paths * and recurses. Supporting deeper nesting in the grouping itself would remove this special case. * * It is constructed from a `DataTypeConfig` (a `version` plus a map of field * names to their {@link BaseType} configs); nested `Object` and `Tuple` fields * declared with dot-notation are grouped into {@link GroupType} / * {@link TupleType} instances during construction. * * @example * const dataType = new DataType({ * version: 1, * fields: { * name: { type: 'Keyword' }, * location: { type: 'GeoPoint' }, * }, * }, 'Person'); * * dataType.toESMapping(); // Elasticsearch/OpenSearch mapping * dataType.toGraphQL(); // GraphQL schema string * dataType.toXlucene(); // xLucene type config */ export declare class DataType { readonly name: string; readonly description?: string; readonly fields: ReadonlyDataTypeFields; readonly version: number; /** An object of base fields with their child fields */ readonly groupedFields: i.GroupedFields; private readonly _types; /** * Merge multiple data types into a single GraphQL schema, de-duplicating * shared custom types and scalars. Throws on a missing or duplicate type * name (or duplicate input name when `createInputTypes` is set). Options * control input-type generation, snake_case naming, scalar removal, and * per-type reference/virtual fields. */ static mergeGraphQLDataTypes(types: DataType[], options?: i.MergeGraphQLOptions): string; /** * @param config the data type config; `version` defaults to the latest and * `fields` to `{}`, and the config is validated (throwing on an unknown * version or invalid field config). * @param typeName optional name for the type (required by some conversions, * e.g. GraphQL). * @param description optional description carried into the GraphQL output. */ constructor(config: Partial, typeName?: string, description?: string); /** * Convert the DataType to an elasticsearch mapping. */ toESMapping({ overrides, distribution, majorVersion, minorVersion, version, _meta }?: Partial): ESMapping; /** * Convert the DataType to a formatted GraphQL schema string. Combines the * generated custom types, the base type, an optional input type, and any * `args.customTypes`, then validates and prints the result. Pass * `removeScalars` to strip `scalar` declarations from the output. * * Note: fields that reference an undeclared scalar (e.g. `Any`/`Tuple` → * `JSON`) require that scalar to be supplied for the schema to validate. */ toGraphQL(args?: i.GraphQLOptions, removeScalars?: boolean): string; /** * Build the GraphQL type parts without assembling/validating a full schema: * the `baseType` definition, an optional `inputType`, and the `customTypes` * (scalars and generated nested types) the fields reference. Use this when * composing several data types into one schema (see * {@link DataType.mergeGraphQLDataTypes}); use `toGraphQL` for a single, * ready-to-use schema string. Throws if no type name is available. */ toGraphQLTypes(args?: i.GraphQLOptions): i.GraphQLTypesResult; /** * Convert the DataType to an xLucene type config — a flat map of field name * (including nested dot-notation paths) to its xLucene field type, merged * across every field. */ toXlucene(): xLuceneTypeConfig; /** * Convert the DataType to a map of top-level column name to DuckDB type. * * Dot-notation children are folded into their parent as a STRUCT, so the result is the * column set of a table built from this DataType, not one entry per declared field. */ toDuckDB(): DuckDBTypeConfig; } //# sourceMappingURL=data-type.d.ts.map