UNPKG

dsl-builder

Version:

OpenSearch Query Builder - Extract from OpenSearch Dashboards

32 lines (31 loc) 1.25 kB
/** * This can convert a type into a known Expression string representation of * that type. For example, `TypeToString<Datatable>` will resolve to `'datatable'`. * This allows Expression Functions to continue to specify their type in a * simple string format. */ export type TypeToString<T> = KnownTypeToString<T> | UnmappedTypeStrings; /** * Map the type of the generic to a string-based representation of the type. * * If the provided generic is its own type interface, we use the value of * the `type` key as a string literal type for it. */ export type KnownTypeToString<T> = T extends string ? 'string' : T extends boolean ? 'boolean' : T extends number ? 'number' : T extends null ? 'null' : T extends { type: string; } ? T['type'] : never; /** * Types used in Expressions that don't map to a primitive cleanly: * * `date` is typed as a number or string, and represents a date */ export type UnmappedTypeStrings = 'date' | 'filter'; /** * JSON representation of a field formatter configuration. * Is used to carry information about how to format data in * a data table as part of the column definition. */ export interface SerializedFieldFormat<TParams = Record<string, any>> { id?: string; params?: TParams; }