import { ClientMetadata, DataTypeFieldConfig, xLuceneTypeConfig } from '@terascope/types'; import { GraphQLType, TypeESMapping, DuckDBTypeConfig } from '../interfaces.js'; export interface IBaseType { new (field: string, config: DataTypeFieldConfig): BaseType; } /** Options controlling how a field is rendered into GraphQL. */ export type ToGraphQLOptions = { typeName?: string; isInput?: boolean; includePrivate?: boolean; useSnakeCase?: boolean; }; /** * The abstract base class every field type extends. It captures a single * field's identity (`field` name, its `DataTypeFieldConfig`, and the data-type * `version`) and defines the contract for converting that field into each * supported output format. * * Concrete subclasses implement the three conversion methods; `BaseType` * itself provides the shared validation and GraphQL-formatting helpers they * build on. Subclasses live in `types/v1/` (the versioned field types) plus the * grouping types {@link GroupType} and {@link TupleType} in `types/`. */ export default abstract class BaseType { readonly field: string; readonly config: DataTypeFieldConfig; readonly version: number; constructor(field: string, config: DataTypeFieldConfig, version?: number); /** * Guard used by subclasses before emitting an ES mapping: throws if the * field is configured `indexed: false` but its type is in * `indexedRequiredFieldTypes` (types that cannot be left unindexed). */ protected _validateESMapping(): void; abstract toESMapping(config: ClientMetadata): TypeESMapping; abstract toGraphQL(options?: ToGraphQLOptions): GraphQLType; abstract toXlucene(): xLuceneTypeConfig; abstract toDuckDB(): DuckDBTypeConfig; /** * Build the `{ type, customTypes }` GraphQL result for a field of the given * GraphQL `type`. Honors the field's `description` and `array` config * (wrapping the type as a `[list]`), and carries along any `customType` * SDL definitions (e.g. `scalar`/nested-type declarations) the field needs. */ protected _formatGql(type: string, customType?: string | (string[])): GraphQLType; /** * Build the `{ [field]: type }` DuckDB result, wrapping the type as a DuckDB list * (`TYPE[]`) when the field is an array. The DuckDB counterpart of `_formatGql`. */ protected _formatDuckDB(type: string): DuckDBTypeConfig; /** * Build the generated name for a custom GraphQL type, e.g. * `DTV` (with an `Input` suffix for input types). Used by * the grouping types to name the nested types they emit. */ _formatGQLTypeName(typeName: string, isInput?: boolean, inputSuffix?: string): string; } /** Prefix a GraphQL type/field line with its formatted description, when present. */ export declare function formatGQLType(type: string, desc?: string): string; /** * Quote a DuckDB identifier, always. Used for STRUCT member names, which can be any * DataType field name, including reserved words (`inner`, `order`) and tuple positions (`0`). * * Quoting unconditionally is safe because DuckDB matches quoted identifiers * case-insensitively. * * `@terascope/sql-builder` has the same one-liner; it is duplicated so this package does not * depend on a query builder just for one line. */ export declare function quoteDuckDBIdentifier(name: string): string; //# sourceMappingURL=base-type.d.ts.map