dsl-builder
Version:
OpenSearch Query Builder - Extract from OpenSearch Dashboards
198 lines (197 loc) • 5.54 kB
TypeScript
import { SavedObject } from 'src/type';
import { IFieldType } from './fields';
export type FieldFormatMap = Record<string, any>;
export interface IIndexPattern {
fields: IFieldType[];
title: string;
id?: string;
type?: string;
timeFieldName?: string;
intervalName?: string | null;
getTimeField?(): IFieldType | undefined;
fieldFormatMap?: Record<string, any>;
getFormatterForField?: (field: any | any['spec'] | IFieldType) => any;
}
export interface IndexPatternAttributes {
type: string;
fields: string;
title: string;
typeMeta: string;
timeFieldName?: string;
intervalName?: string;
sourceFilters?: string;
fieldFormatMap?: string;
}
export type OnNotification = (toastInputFields: any) => void;
export type OnError = (error: Error, toastInputFields: any) => void;
export type OnUnsupportedTimePattern = ({ id, title, index, }: {
id: string;
title: string;
index: string;
}) => void;
export interface UiSettingsCommon {
get: (key: string) => Promise<any>;
getAll: () => Promise<Record<string, any>>;
set: (key: string, value: any) => Promise<void>;
remove: (key: string) => Promise<void>;
}
export interface SavedObjectsClientCommonFindArgs {
type: string | string[];
fields?: string[];
perPage?: number;
search?: string;
searchFields?: string[];
}
export interface SavedObjectsClientCommon {
find: <T = unknown>(options: SavedObjectsClientCommonFindArgs) => Promise<Array<SavedObject<T>>>;
get: <T = unknown>(type: string, id: string) => Promise<SavedObject<T>>;
update: <T = unknown>(type: string, id: string, attributes: Record<string, any>, options: Record<string, any>) => Promise<SavedObject<T>>;
create: (type: string, attributes: Record<string, any>, options: Record<string, any>) => Promise<SavedObject>;
delete: (type: string, id: string) => Promise<{}>;
}
export interface GetFieldsOptions {
pattern?: string;
type?: string;
params?: any;
lookBack?: boolean;
metaFields?: string[];
dataSourceId?: string;
}
export interface IIndexPatternsApiClient {
getFieldsForTimePattern: (options: GetFieldsOptions) => Promise<any>;
getFieldsForWildcard: (options: GetFieldsOptions) => Promise<any>;
}
export type AggregationRestrictions = Record<string, {
agg?: string;
interval?: number;
fixed_interval?: string;
calendar_interval?: string;
delay?: string;
time_zone?: string;
}>;
export interface IFieldSubType {
multi?: {
parent: string;
};
nested?: {
path: string;
};
}
export interface TypeMeta {
aggs?: Record<string, AggregationRestrictions>;
[key: string]: any;
}
export type FieldSpecConflictDescriptions = Record<string, string[]>;
export interface FieldSpecExportFmt {
count?: number;
script?: string;
lang?: string;
conflictDescriptions?: FieldSpecConflictDescriptions;
name: string;
type: OSD_FIELD_TYPES;
esTypes?: string[];
scripted: boolean;
searchable: boolean;
aggregatable: boolean;
readFromDocValues?: boolean;
subType?: IFieldSubType;
format?: any;
indexed?: boolean;
}
export interface FieldSpec {
count?: number;
script?: string;
lang?: string;
conflictDescriptions?: Record<string, string[]>;
format?: any;
name: string;
type: string;
esTypes?: string[];
scripted?: boolean;
searchable: boolean;
aggregatable: boolean;
readFromDocValues?: boolean;
subType?: IFieldSubType;
indexed?: boolean;
}
export type IndexPatternFieldMap = Record<string, FieldSpec>;
export interface SavedObjectReference {
name?: string;
id: string;
type: string;
}
export interface IndexPatternSpec {
id?: string;
version?: string;
title?: string;
intervalName?: string;
timeFieldName?: string;
sourceFilters?: SourceFilter[];
fields?: IndexPatternFieldMap;
typeMeta?: TypeMeta;
type?: string;
dataSourceRef?: SavedObjectReference;
fieldsLoading?: boolean;
}
export interface SourceFilter {
value: string;
}
/** @public **/
export interface OsdFieldTypeOptions {
sortable: boolean;
filterable: boolean;
name: string;
esTypes: OPENSEARCH_FIELD_TYPES[];
}
/** @public **/
export declare enum OPENSEARCH_FIELD_TYPES {
_ID = "_id",
_INDEX = "_index",
_SOURCE = "_source",
_TYPE = "_type",
STRING = "string",
TEXT = "text",
MATCH_ONLY_TEXT = "match_only_text",
KEYWORD = "keyword",
WILDCARD = "wildcard",
BOOLEAN = "boolean",
OBJECT = "object",
DATE = "date",
DATE_NANOS = "date_nanos",
GEO_POINT = "geo_point",
GEO_SHAPE = "geo_shape",
FLOAT = "float",
HALF_FLOAT = "half_float",
SCALED_FLOAT = "scaled_float",
DOUBLE = "double",
INTEGER = "integer",
INT = "int",
LONG = "long",
SHORT = "short",
UNSIGNED_LONG = "unsigned_long",
NESTED = "nested",
BYTE = "byte",
IP = "ip",
ATTACHMENT = "attachment",
TOKEN_COUNT = "token_count",
MURMUR3 = "murmur3",
HISTOGRAM = "histogram"
}
/** @public **/
export declare enum OSD_FIELD_TYPES {
_SOURCE = "_source",
ATTACHMENT = "attachment",
BOOLEAN = "boolean",
DATE = "date",
GEO_POINT = "geo_point",
GEO_SHAPE = "geo_shape",
IP = "ip",
MURMUR3 = "murmur3",
NUMBER = "number",
STRING = "string",
UNKNOWN = "unknown",
CONFLICT = "conflict",
OBJECT = "object",
NESTED = "nested",
HISTOGRAM = "histogram"
}