Make data.search.aggs available on the server. (#74472)
This commit is contained in:
parent
c34e30ed0b
commit
fe017f52dd
|
@ -7,5 +7,5 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
baseFormattersPublic: (import("../../common").FieldFormatInstanceType | typeof DateNanosFormat | typeof DateFormat)[]
|
||||
baseFormattersPublic: (import("../../common").FieldFormatInstanceType | typeof DateFormat | typeof DateNanosFormat)[]
|
||||
```
|
||||
|
|
|
@ -14,7 +14,7 @@ search: {
|
|||
intervalOptions: ({
|
||||
display: string;
|
||||
val: string;
|
||||
enabled(agg: import("./search/aggs/buckets/bucket_agg_type").IBucketAggConfig): boolean | "" | undefined;
|
||||
enabled(agg: import("../common").IBucketAggConfig): boolean | "" | undefined;
|
||||
} | {
|
||||
display: string;
|
||||
val: string;
|
||||
|
@ -23,9 +23,9 @@ search: {
|
|||
InvalidEsIntervalFormatError: typeof InvalidEsIntervalFormatError;
|
||||
Ipv4Address: typeof Ipv4Address;
|
||||
isDateHistogramBucketAggConfig: typeof isDateHistogramBucketAggConfig;
|
||||
isNumberType: (agg: import("./search").AggConfig) => boolean;
|
||||
isStringType: (agg: import("./search").AggConfig) => boolean;
|
||||
isType: (...types: string[]) => (agg: import("./search").AggConfig) => boolean;
|
||||
isNumberType: (agg: import("../common").AggConfig) => boolean;
|
||||
isStringType: (agg: import("../common").AggConfig) => boolean;
|
||||
isType: (...types: string[]) => (agg: import("../common").AggConfig) => boolean;
|
||||
isValidEsInterval: typeof isValidEsInterval;
|
||||
isValidInterval: typeof isValidInterval;
|
||||
parentPipelineType: string;
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggConfigOptions](./kibana-plugin-plugins-data-server.aggconfigoptions.md)
|
||||
|
||||
## AggConfigOptions type
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type AggConfigOptions = Assign<AggConfigSerialized, {
|
||||
type: IAggType;
|
||||
}>;
|
||||
```
|
|
@ -0,0 +1,15 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggGroupLabels](./kibana-plugin-plugins-data-server.agggrouplabels.md)
|
||||
|
||||
## AggGroupLabels variable
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
AggGroupLabels: {
|
||||
buckets: string;
|
||||
metrics: string;
|
||||
none: string;
|
||||
}
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggGroupName](./kibana-plugin-plugins-data-server.agggroupname.md)
|
||||
|
||||
## AggGroupName type
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type AggGroupName = $Values<typeof AggGroupNames>;
|
||||
```
|
|
@ -0,0 +1,15 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggGroupNames](./kibana-plugin-plugins-data-server.agggroupnames.md)
|
||||
|
||||
## AggGroupNames variable
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
AggGroupNames: Readonly<{
|
||||
Buckets: "buckets";
|
||||
Metrics: "metrics";
|
||||
None: "none";
|
||||
}>
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggParam](./kibana-plugin-plugins-data-server.aggparam.md)
|
||||
|
||||
## AggParam type
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type AggParam = BaseParamType;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggParamOption](./kibana-plugin-plugins-data-server.aggparamoption.md) > [display](./kibana-plugin-plugins-data-server.aggparamoption.display.md)
|
||||
|
||||
## AggParamOption.display property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
display: string;
|
||||
```
|
|
@ -0,0 +1,22 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggParamOption](./kibana-plugin-plugins-data-server.aggparamoption.md) > [enabled](./kibana-plugin-plugins-data-server.aggparamoption.enabled.md)
|
||||
|
||||
## AggParamOption.enabled() method
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
enabled?(agg: AggConfig): boolean;
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| agg | <code>AggConfig</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`boolean`
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggParamOption](./kibana-plugin-plugins-data-server.aggparamoption.md)
|
||||
|
||||
## AggParamOption interface
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface AggParamOption
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [display](./kibana-plugin-plugins-data-server.aggparamoption.display.md) | <code>string</code> | |
|
||||
| [val](./kibana-plugin-plugins-data-server.aggparamoption.val.md) | <code>string</code> | |
|
||||
|
||||
## Methods
|
||||
|
||||
| Method | Description |
|
||||
| --- | --- |
|
||||
| [enabled(agg)](./kibana-plugin-plugins-data-server.aggparamoption.enabled.md) | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggParamOption](./kibana-plugin-plugins-data-server.aggparamoption.md) > [val](./kibana-plugin-plugins-data-server.aggparamoption.val.md)
|
||||
|
||||
## AggParamOption.val property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
val: string;
|
||||
```
|
|
@ -0,0 +1,20 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggParamType](./kibana-plugin-plugins-data-server.aggparamtype.md) > [(constructor)](./kibana-plugin-plugins-data-server.aggparamtype._constructor_.md)
|
||||
|
||||
## AggParamType.(constructor)
|
||||
|
||||
Constructs a new instance of the `AggParamType` class
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(config: Record<string, any>);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| config | <code>Record<string, any></code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggParamType](./kibana-plugin-plugins-data-server.aggparamtype.md) > [allowedAggs](./kibana-plugin-plugins-data-server.aggparamtype.allowedaggs.md)
|
||||
|
||||
## AggParamType.allowedAggs property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
allowedAggs: string[];
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggParamType](./kibana-plugin-plugins-data-server.aggparamtype.md) > [makeAgg](./kibana-plugin-plugins-data-server.aggparamtype.makeagg.md)
|
||||
|
||||
## AggParamType.makeAgg property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
makeAgg: (agg: TAggConfig, state?: AggConfigSerialized) => TAggConfig;
|
||||
```
|
|
@ -0,0 +1,25 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [AggParamType](./kibana-plugin-plugins-data-server.aggparamtype.md)
|
||||
|
||||
## AggParamType class
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class AggParamType<TAggConfig extends IAggConfig = IAggConfig> extends BaseParamType<TAggConfig>
|
||||
```
|
||||
|
||||
## Constructors
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [(constructor)(config)](./kibana-plugin-plugins-data-server.aggparamtype._constructor_.md) | | Constructs a new instance of the <code>AggParamType</code> class |
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| [allowedAggs](./kibana-plugin-plugins-data-server.aggparamtype.allowedaggs.md) | | <code>string[]</code> | |
|
||||
| [makeAgg](./kibana-plugin-plugins-data-server.aggparamtype.makeagg.md) | | <code>(agg: TAggConfig, state?: AggConfigSerialized) => TAggConfig</code> | |
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [BUCKET\_TYPES](./kibana-plugin-plugins-data-server.bucket_types.md)
|
||||
|
||||
## BUCKET\_TYPES enum
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare enum BUCKET_TYPES
|
||||
```
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
| Member | Value | Description |
|
||||
| --- | --- | --- |
|
||||
| DATE\_HISTOGRAM | <code>"date_histogram"</code> | |
|
||||
| DATE\_RANGE | <code>"date_range"</code> | |
|
||||
| FILTER | <code>"filter"</code> | |
|
||||
| FILTERS | <code>"filters"</code> | |
|
||||
| GEOHASH\_GRID | <code>"geohash_grid"</code> | |
|
||||
| GEOTILE\_GRID | <code>"geotile_grid"</code> | |
|
||||
| HISTOGRAM | <code>"histogram"</code> | |
|
||||
| IP\_RANGE | <code>"ip_range"</code> | |
|
||||
| RANGE | <code>"range"</code> | |
|
||||
| SIGNIFICANT\_TERMS | <code>"significant_terms"</code> | |
|
||||
| TERMS | <code>"terms"</code> | |
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IAggConfig](./kibana-plugin-plugins-data-server.iaggconfig.md)
|
||||
|
||||
## IAggConfig type
|
||||
|
||||
AggConfig
|
||||
|
||||
This class represents an aggregation, which is displayed in the left-hand nav of the Visualize app.
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type IAggConfig = AggConfig;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IAggType](./kibana-plugin-plugins-data-server.iaggtype.md)
|
||||
|
||||
## IAggType type
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type IAggType = AggType;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IFieldParamType](./kibana-plugin-plugins-data-server.ifieldparamtype.md)
|
||||
|
||||
## IFieldParamType type
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type IFieldParamType = FieldParamType;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [IMetricAggType](./kibana-plugin-plugins-data-server.imetricaggtype.md)
|
||||
|
||||
## IMetricAggType type
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type IMetricAggType = MetricAggType;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [ISearchSetup](./kibana-plugin-plugins-data-server.isearchsetup.md) > [aggs](./kibana-plugin-plugins-data-server.isearchsetup.aggs.md)
|
||||
|
||||
## ISearchSetup.aggs property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
aggs: AggsSetup;
|
||||
```
|
|
@ -14,6 +14,7 @@ export interface ISearchSetup
|
|||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [aggs](./kibana-plugin-plugins-data-server.isearchsetup.aggs.md) | <code>AggsSetup</code> | |
|
||||
| [registerSearchStrategy](./kibana-plugin-plugins-data-server.isearchsetup.registersearchstrategy.md) | <code>(name: string, strategy: ISearchStrategy) => void</code> | Extension point exposed for other plugins to register their own search strategies. |
|
||||
| [usage](./kibana-plugin-plugins-data-server.isearchsetup.usage.md) | <code>SearchUsage</code> | Used internally for telemetry |
|
||||
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [ISearchStart](./kibana-plugin-plugins-data-server.isearchstart.md) > [aggs](./kibana-plugin-plugins-data-server.isearchstart.aggs.md)
|
||||
|
||||
## ISearchStart.aggs property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
aggs: AggsStart;
|
||||
```
|
|
@ -14,6 +14,7 @@ export interface ISearchStart
|
|||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [aggs](./kibana-plugin-plugins-data-server.isearchstart.aggs.md) | <code>AggsStart</code> | |
|
||||
| [getSearchStrategy](./kibana-plugin-plugins-data-server.isearchstart.getsearchstrategy.md) | <code>(name: string) => ISearchStrategy</code> | Get other registered search strategies. For example, if a new strategy needs to use the already-registered ES search strategy, it can use this function to accomplish that. |
|
||||
| [search](./kibana-plugin-plugins-data-server.isearchstart.search.md) | <code>(context: RequestHandlerContext, request: IKibanaSearchRequest, options: ISearchOptions) => Promise<IKibanaSearchResponse></code> | |
|
||||
|
||||
|
|
|
@ -8,15 +8,19 @@
|
|||
|
||||
| Class | Description |
|
||||
| --- | --- |
|
||||
| [AggParamType](./kibana-plugin-plugins-data-server.aggparamtype.md) | |
|
||||
| [IndexPatternsFetcher](./kibana-plugin-plugins-data-server.indexpatternsfetcher.md) | |
|
||||
| [OptionedParamType](./kibana-plugin-plugins-data-server.optionedparamtype.md) | |
|
||||
| [Plugin](./kibana-plugin-plugins-data-server.plugin.md) | |
|
||||
|
||||
## Enumerations
|
||||
|
||||
| Enumeration | Description |
|
||||
| --- | --- |
|
||||
| [BUCKET\_TYPES](./kibana-plugin-plugins-data-server.bucket_types.md) | |
|
||||
| [ES\_FIELD\_TYPES](./kibana-plugin-plugins-data-server.es_field_types.md) | \* |
|
||||
| [KBN\_FIELD\_TYPES](./kibana-plugin-plugins-data-server.kbn_field_types.md) | \* |
|
||||
| [METRIC\_TYPES](./kibana-plugin-plugins-data-server.metric_types.md) | |
|
||||
|
||||
## Functions
|
||||
|
||||
|
@ -33,6 +37,7 @@
|
|||
|
||||
| Interface | Description |
|
||||
| --- | --- |
|
||||
| [AggParamOption](./kibana-plugin-plugins-data-server.aggparamoption.md) | |
|
||||
| [EsQueryConfig](./kibana-plugin-plugins-data-server.esqueryconfig.md) | |
|
||||
| [FieldFormatConfig](./kibana-plugin-plugins-data-server.fieldformatconfig.md) | |
|
||||
| [Filter](./kibana-plugin-plugins-data-server.filter.md) | |
|
||||
|
@ -48,17 +53,22 @@
|
|||
| [ISearchStart](./kibana-plugin-plugins-data-server.isearchstart.md) | |
|
||||
| [ISearchStrategy](./kibana-plugin-plugins-data-server.isearchstrategy.md) | Search strategy interface contains a search method that takes in a request and returns a promise that resolves to a response. |
|
||||
| [KueryNode](./kibana-plugin-plugins-data-server.kuerynode.md) | |
|
||||
| [OptionedValueProp](./kibana-plugin-plugins-data-server.optionedvalueprop.md) | |
|
||||
| [PluginSetup](./kibana-plugin-plugins-data-server.pluginsetup.md) | |
|
||||
| [PluginStart](./kibana-plugin-plugins-data-server.pluginstart.md) | |
|
||||
| [Query](./kibana-plugin-plugins-data-server.query.md) | |
|
||||
| [RefreshInterval](./kibana-plugin-plugins-data-server.refreshinterval.md) | |
|
||||
| [SearchUsage](./kibana-plugin-plugins-data-server.searchusage.md) | |
|
||||
| [TabbedAggColumn](./kibana-plugin-plugins-data-server.tabbedaggcolumn.md) | \* |
|
||||
| [TabbedTable](./kibana-plugin-plugins-data-server.tabbedtable.md) | \* |
|
||||
| [TimeRange](./kibana-plugin-plugins-data-server.timerange.md) | |
|
||||
|
||||
## Variables
|
||||
|
||||
| Variable | Description |
|
||||
| --- | --- |
|
||||
| [AggGroupLabels](./kibana-plugin-plugins-data-server.agggrouplabels.md) | |
|
||||
| [AggGroupNames](./kibana-plugin-plugins-data-server.agggroupnames.md) | |
|
||||
| [castEsToKbnFieldTypeName](./kibana-plugin-plugins-data-server.castestokbnfieldtypename.md) | Get the KbnFieldType name for an esType string |
|
||||
| [config](./kibana-plugin-plugins-data-server.config.md) | |
|
||||
| [esFilters](./kibana-plugin-plugins-data-server.esfilters.md) | |
|
||||
|
@ -73,8 +83,16 @@
|
|||
|
||||
| Type Alias | Description |
|
||||
| --- | --- |
|
||||
| [AggConfigOptions](./kibana-plugin-plugins-data-server.aggconfigoptions.md) | |
|
||||
| [AggGroupName](./kibana-plugin-plugins-data-server.agggroupname.md) | |
|
||||
| [AggParam](./kibana-plugin-plugins-data-server.aggparam.md) | |
|
||||
| [EsaggsExpressionFunctionDefinition](./kibana-plugin-plugins-data-server.esaggsexpressionfunctiondefinition.md) | |
|
||||
| [FieldFormatsGetConfigFn](./kibana-plugin-plugins-data-server.fieldformatsgetconfigfn.md) | |
|
||||
| [IAggConfig](./kibana-plugin-plugins-data-server.iaggconfig.md) | AggConfig This class represents an aggregation, which is displayed in the left-hand nav of the Visualize app. |
|
||||
| [IAggType](./kibana-plugin-plugins-data-server.iaggtype.md) | |
|
||||
| [IFieldFormatsRegistry](./kibana-plugin-plugins-data-server.ifieldformatsregistry.md) | |
|
||||
| [IFieldParamType](./kibana-plugin-plugins-data-server.ifieldparamtype.md) | |
|
||||
| [IMetricAggType](./kibana-plugin-plugins-data-server.imetricaggtype.md) | |
|
||||
| [ParsedInterval](./kibana-plugin-plugins-data-server.parsedinterval.md) | |
|
||||
| [TabbedAggRow](./kibana-plugin-plugins-data-server.tabbedaggrow.md) | \* |
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [METRIC\_TYPES](./kibana-plugin-plugins-data-server.metric_types.md)
|
||||
|
||||
## METRIC\_TYPES enum
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare enum METRIC_TYPES
|
||||
```
|
||||
|
||||
## Enumeration Members
|
||||
|
||||
| Member | Value | Description |
|
||||
| --- | --- | --- |
|
||||
| AVG | <code>"avg"</code> | |
|
||||
| AVG\_BUCKET | <code>"avg_bucket"</code> | |
|
||||
| CARDINALITY | <code>"cardinality"</code> | |
|
||||
| COUNT | <code>"count"</code> | |
|
||||
| CUMULATIVE\_SUM | <code>"cumulative_sum"</code> | |
|
||||
| DERIVATIVE | <code>"derivative"</code> | |
|
||||
| GEO\_BOUNDS | <code>"geo_bounds"</code> | |
|
||||
| GEO\_CENTROID | <code>"geo_centroid"</code> | |
|
||||
| MAX | <code>"max"</code> | |
|
||||
| MAX\_BUCKET | <code>"max_bucket"</code> | |
|
||||
| MEDIAN | <code>"median"</code> | |
|
||||
| MIN | <code>"min"</code> | |
|
||||
| MIN\_BUCKET | <code>"min_bucket"</code> | |
|
||||
| MOVING\_FN | <code>"moving_avg"</code> | |
|
||||
| PERCENTILE\_RANKS | <code>"percentile_ranks"</code> | |
|
||||
| PERCENTILES | <code>"percentiles"</code> | |
|
||||
| SERIAL\_DIFF | <code>"serial_diff"</code> | |
|
||||
| STD\_DEV | <code>"std_dev"</code> | |
|
||||
| SUM | <code>"sum"</code> | |
|
||||
| SUM\_BUCKET | <code>"sum_bucket"</code> | |
|
||||
| TOP\_HITS | <code>"top_hits"</code> | |
|
||||
|
|
@ -0,0 +1,20 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [OptionedParamType](./kibana-plugin-plugins-data-server.optionedparamtype.md) > [(constructor)](./kibana-plugin-plugins-data-server.optionedparamtype._constructor_.md)
|
||||
|
||||
## OptionedParamType.(constructor)
|
||||
|
||||
Constructs a new instance of the `OptionedParamType` class
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
constructor(config: Record<string, any>);
|
||||
```
|
||||
|
||||
## Parameters
|
||||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| config | <code>Record<string, any></code> | |
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [OptionedParamType](./kibana-plugin-plugins-data-server.optionedparamtype.md)
|
||||
|
||||
## OptionedParamType class
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare class OptionedParamType extends BaseParamType
|
||||
```
|
||||
|
||||
## Constructors
|
||||
|
||||
| Constructor | Modifiers | Description |
|
||||
| --- | --- | --- |
|
||||
| [(constructor)(config)](./kibana-plugin-plugins-data-server.optionedparamtype._constructor_.md) | | Constructs a new instance of the <code>OptionedParamType</code> class |
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Modifiers | Type | Description |
|
||||
| --- | --- | --- | --- |
|
||||
| [options](./kibana-plugin-plugins-data-server.optionedparamtype.options.md) | | <code>OptionedValueProp[]</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [OptionedParamType](./kibana-plugin-plugins-data-server.optionedparamtype.md) > [options](./kibana-plugin-plugins-data-server.optionedparamtype.options.md)
|
||||
|
||||
## OptionedParamType.options property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
options: OptionedValueProp[];
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [OptionedValueProp](./kibana-plugin-plugins-data-server.optionedvalueprop.md) > [disabled](./kibana-plugin-plugins-data-server.optionedvalueprop.disabled.md)
|
||||
|
||||
## OptionedValueProp.disabled property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
disabled?: boolean;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [OptionedValueProp](./kibana-plugin-plugins-data-server.optionedvalueprop.md) > [isCompatible](./kibana-plugin-plugins-data-server.optionedvalueprop.iscompatible.md)
|
||||
|
||||
## OptionedValueProp.isCompatible property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
isCompatible: (agg: IAggConfig) => boolean;
|
||||
```
|
|
@ -0,0 +1,21 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [OptionedValueProp](./kibana-plugin-plugins-data-server.optionedvalueprop.md)
|
||||
|
||||
## OptionedValueProp interface
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface OptionedValueProp
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [disabled](./kibana-plugin-plugins-data-server.optionedvalueprop.disabled.md) | <code>boolean</code> | |
|
||||
| [isCompatible](./kibana-plugin-plugins-data-server.optionedvalueprop.iscompatible.md) | <code>(agg: IAggConfig) => boolean</code> | |
|
||||
| [text](./kibana-plugin-plugins-data-server.optionedvalueprop.text.md) | <code>string</code> | |
|
||||
| [value](./kibana-plugin-plugins-data-server.optionedvalueprop.value.md) | <code>string</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [OptionedValueProp](./kibana-plugin-plugins-data-server.optionedvalueprop.md) > [text](./kibana-plugin-plugins-data-server.optionedvalueprop.text.md)
|
||||
|
||||
## OptionedValueProp.text property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
text: string;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [OptionedValueProp](./kibana-plugin-plugins-data-server.optionedvalueprop.md) > [value](./kibana-plugin-plugins-data-server.optionedvalueprop.value.md)
|
||||
|
||||
## OptionedValueProp.value property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
value: string;
|
||||
```
|
|
@ -7,10 +7,10 @@
|
|||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
setup(core: CoreSetup<object, DataPluginStart>, { usageCollection }: DataPluginSetupDependencies): {
|
||||
setup(core: CoreSetup<DataPluginStartDependencies, DataPluginStart>, { expressions, usageCollection }: DataPluginSetupDependencies): {
|
||||
search: ISearchSetup;
|
||||
fieldFormats: {
|
||||
register: (customFieldFormat: import("../common").FieldFormatInstanceType) => number;
|
||||
register: (customFieldFormat: import("../public").FieldFormatInstanceType) => number;
|
||||
};
|
||||
};
|
||||
```
|
||||
|
@ -19,15 +19,15 @@ setup(core: CoreSetup<object, DataPluginStart>, { usageCollection }: DataPluginS
|
|||
|
||||
| Parameter | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| core | <code>CoreSetup<object, DataPluginStart></code> | |
|
||||
| { usageCollection } | <code>DataPluginSetupDependencies</code> | |
|
||||
| core | <code>CoreSetup<DataPluginStartDependencies, DataPluginStart></code> | |
|
||||
| { expressions, usageCollection } | <code>DataPluginSetupDependencies</code> | |
|
||||
|
||||
<b>Returns:</b>
|
||||
|
||||
`{
|
||||
search: ISearchSetup;
|
||||
fieldFormats: {
|
||||
register: (customFieldFormat: import("../common").FieldFormatInstanceType) => number;
|
||||
register: (customFieldFormat: import("../public").FieldFormatInstanceType) => number;
|
||||
};
|
||||
}`
|
||||
|
||||
|
|
|
@ -9,15 +9,35 @@
|
|||
```typescript
|
||||
search: {
|
||||
aggs: {
|
||||
CidrMask: typeof CidrMask;
|
||||
dateHistogramInterval: typeof dateHistogramInterval;
|
||||
intervalOptions: ({
|
||||
display: string;
|
||||
val: string;
|
||||
enabled(agg: import("../common").IBucketAggConfig): boolean | "" | undefined;
|
||||
} | {
|
||||
display: string;
|
||||
val: string;
|
||||
})[];
|
||||
InvalidEsCalendarIntervalError: typeof InvalidEsCalendarIntervalError;
|
||||
InvalidEsIntervalFormatError: typeof InvalidEsIntervalFormatError;
|
||||
Ipv4Address: typeof Ipv4Address;
|
||||
isNumberType: (agg: import("../common").AggConfig) => boolean;
|
||||
isStringType: (agg: import("../common").AggConfig) => boolean;
|
||||
isType: (...types: string[]) => (agg: import("../common").AggConfig) => boolean;
|
||||
isValidEsInterval: typeof isValidEsInterval;
|
||||
isValidInterval: typeof isValidInterval;
|
||||
parentPipelineType: string;
|
||||
parseEsInterval: typeof parseEsInterval;
|
||||
parseInterval: typeof parseInterval;
|
||||
propFilter: typeof propFilter;
|
||||
siblingPipelineType: string;
|
||||
termsAggFilter: string[];
|
||||
toAbsoluteDates: typeof toAbsoluteDates;
|
||||
};
|
||||
getRequestInspectorStats: typeof getRequestInspectorStats;
|
||||
getResponseInspectorStats: typeof getResponseInspectorStats;
|
||||
tabifyAggResponse: typeof tabifyAggResponse;
|
||||
tabifyGetColumns: typeof tabifyGetColumns;
|
||||
}
|
||||
```
|
||||
|
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [TabbedAggColumn](./kibana-plugin-plugins-data-server.tabbedaggcolumn.md) > [aggConfig](./kibana-plugin-plugins-data-server.tabbedaggcolumn.aggconfig.md)
|
||||
|
||||
## TabbedAggColumn.aggConfig property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
aggConfig: IAggConfig;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [TabbedAggColumn](./kibana-plugin-plugins-data-server.tabbedaggcolumn.md) > [id](./kibana-plugin-plugins-data-server.tabbedaggcolumn.id.md)
|
||||
|
||||
## TabbedAggColumn.id property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
id: string;
|
||||
```
|
|
@ -0,0 +1,22 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [TabbedAggColumn](./kibana-plugin-plugins-data-server.tabbedaggcolumn.md)
|
||||
|
||||
## TabbedAggColumn interface
|
||||
|
||||
\*
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface TabbedAggColumn
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [aggConfig](./kibana-plugin-plugins-data-server.tabbedaggcolumn.aggconfig.md) | <code>IAggConfig</code> | |
|
||||
| [id](./kibana-plugin-plugins-data-server.tabbedaggcolumn.id.md) | <code>string</code> | |
|
||||
| [name](./kibana-plugin-plugins-data-server.tabbedaggcolumn.name.md) | <code>string</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [TabbedAggColumn](./kibana-plugin-plugins-data-server.tabbedaggcolumn.md) > [name](./kibana-plugin-plugins-data-server.tabbedaggcolumn.name.md)
|
||||
|
||||
## TabbedAggColumn.name property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
name: string;
|
||||
```
|
|
@ -0,0 +1,13 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [TabbedAggRow](./kibana-plugin-plugins-data-server.tabbedaggrow.md)
|
||||
|
||||
## TabbedAggRow type
|
||||
|
||||
\*
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export declare type TabbedAggRow = Record<TabbedAggColumn['id'], string | number>;
|
||||
```
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [TabbedTable](./kibana-plugin-plugins-data-server.tabbedtable.md) > [columns](./kibana-plugin-plugins-data-server.tabbedtable.columns.md)
|
||||
|
||||
## TabbedTable.columns property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
columns: TabbedAggColumn[];
|
||||
```
|
|
@ -0,0 +1,21 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [TabbedTable](./kibana-plugin-plugins-data-server.tabbedtable.md)
|
||||
|
||||
## TabbedTable interface
|
||||
|
||||
\*
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
export interface TabbedTable
|
||||
```
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description |
|
||||
| --- | --- | --- |
|
||||
| [columns](./kibana-plugin-plugins-data-server.tabbedtable.columns.md) | <code>TabbedAggColumn[]</code> | |
|
||||
| [rows](./kibana-plugin-plugins-data-server.tabbedtable.rows.md) | <code>TabbedAggRow[]</code> | |
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
||||
|
||||
[Home](./index.md) > [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) > [TabbedTable](./kibana-plugin-plugins-data-server.tabbedtable.md) > [rows](./kibana-plugin-plugins-data-server.tabbedtable.rows.md)
|
||||
|
||||
## TabbedTable.rows property
|
||||
|
||||
<b>Signature:</b>
|
||||
|
||||
```typescript
|
||||
rows: TabbedAggRow[];
|
||||
```
|
|
@ -26,7 +26,7 @@ import {
|
|||
getAggTypes,
|
||||
AggConfigs,
|
||||
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
|
||||
} from '../../../../../src/plugins/data/public/search/aggs';
|
||||
} from '../../../../../src/plugins/data/common/search/aggs';
|
||||
import { ComponentRegistry } from '../../../../../src/plugins/advanced_settings/public/';
|
||||
import { UI_SETTINGS } from '../../../../../src/plugins/data/public/';
|
||||
import {
|
||||
|
@ -184,12 +184,13 @@ const mockAggTypesRegistry = () => {
|
|||
const registry = new AggTypesRegistry();
|
||||
const registrySetup = registry.setup();
|
||||
const aggTypes = getAggTypes({
|
||||
uiSettings: mockCoreSetup.uiSettings,
|
||||
query: querySetup,
|
||||
getInternalStartServices: () => ({
|
||||
fieldFormats: getFieldFormatsRegistry(mockCoreStart),
|
||||
notifications: mockCoreStart.notifications,
|
||||
calculateBounds: sinon.fake(),
|
||||
getConfig: sinon.fake(),
|
||||
getFieldFormatsStart: () => ({
|
||||
deserialize: sinon.fake(),
|
||||
getDefaultInstance: sinon.fake(),
|
||||
}),
|
||||
isDefaultTimezone: () => true,
|
||||
});
|
||||
aggTypes.buckets.forEach((type) => registrySetup.registerBucket(type));
|
||||
aggTypes.metrics.forEach((type) => registrySetup.registerMetric(type));
|
||||
|
@ -240,7 +241,6 @@ export const npSetup = {
|
|||
query: querySetup,
|
||||
search: {
|
||||
aggs: {
|
||||
calculateAutoTimeExpression: sinon.fake(),
|
||||
types: aggTypesRegistry.setup(),
|
||||
},
|
||||
__LEGACY: {
|
||||
|
|
|
@ -22,7 +22,7 @@ import { shortenDottedString } from '../../utils';
|
|||
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
|
||||
import { FieldFormat } from '../field_format';
|
||||
import { TextContextTypeConvert, HtmlContextTypeConvert, FIELD_FORMAT_IDS } from '../types';
|
||||
import { UI_SETTINGS } from '../../';
|
||||
import { UI_SETTINGS } from '../../constants';
|
||||
|
||||
/**
|
||||
* Remove all of the whitespace between html tags
|
||||
|
|
|
@ -33,7 +33,7 @@ import { baseFormatters } from './constants/base_formatters';
|
|||
import { FieldFormat } from './field_format';
|
||||
import { SerializedFieldFormat } from '../../../expressions/common/types';
|
||||
import { ES_FIELD_TYPES, KBN_FIELD_TYPES } from '../types';
|
||||
import { UI_SETTINGS } from '../';
|
||||
import { UI_SETTINGS } from '../constants';
|
||||
|
||||
export class FieldFormatsRegistry {
|
||||
protected fieldFormats: Map<FieldFormatId, FieldFormatInstanceType> = new Map();
|
||||
|
|
|
@ -24,6 +24,7 @@ export const fieldFormatsMock: IFieldFormatsRegistry = {
|
|||
getByFieldType: jest.fn(),
|
||||
getDefaultConfig: jest.fn(),
|
||||
getDefaultInstance: jest.fn().mockImplementation(() => ({
|
||||
convert: jest.fn().mockImplementation((t: string) => t),
|
||||
getConverterFor: jest.fn().mockImplementation(() => (t: string) => t),
|
||||
})) as any,
|
||||
getDefaultInstanceCacheResolver: jest.fn(),
|
||||
|
|
|
@ -25,7 +25,5 @@ export * from './index_patterns';
|
|||
export * from './kbn_field_types';
|
||||
export * from './query';
|
||||
export * from './search';
|
||||
export * from './search/aggs';
|
||||
export * from './search/expressions';
|
||||
export * from './types';
|
||||
export * from './utils';
|
||||
|
|
|
@ -18,10 +18,11 @@
|
|||
*/
|
||||
|
||||
import { findIndex } from 'lodash';
|
||||
import { IFieldType, shortenDottedString } from '../../../common';
|
||||
import { IFieldType } from './types';
|
||||
import { IndexPatternField } from './index_pattern_field';
|
||||
import { OnNotification, FieldSpec } from '../types';
|
||||
import { IndexPattern } from '../index_patterns';
|
||||
import { shortenDottedString } from '../../utils';
|
||||
|
||||
type FieldMap = Map<IndexPatternField['name'], IndexPatternField>;
|
||||
|
||||
|
|
|
@ -18,13 +18,10 @@
|
|||
*/
|
||||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import {
|
||||
IFieldType,
|
||||
KbnFieldType,
|
||||
getKbnFieldType,
|
||||
KBN_FIELD_TYPES,
|
||||
FieldFormat,
|
||||
} from '../../../common';
|
||||
import { KbnFieldType, getKbnFieldType } from '../../kbn_field_types';
|
||||
import { KBN_FIELD_TYPES } from '../../kbn_field_types/types';
|
||||
import { FieldFormat } from '../../field_formats';
|
||||
import { IFieldType } from './types';
|
||||
import { OnNotification, FieldSpec } from '../types';
|
||||
|
||||
import { IndexPattern } from '../index_patterns';
|
||||
|
|
|
@ -25,7 +25,8 @@ import { AggType } from './agg_type';
|
|||
import { AggTypesRegistryStart } from './agg_types_registry';
|
||||
import { mockAggTypesRegistry } from './test_helpers';
|
||||
import { MetricAggType } from './metrics/metric_agg_type';
|
||||
import { IndexPattern, IIndexPatternFieldList } from '../../index_patterns';
|
||||
import { IndexPattern } from '../../index_patterns/index_patterns/index_pattern';
|
||||
import { IIndexPatternFieldList } from '../../index_patterns/fields';
|
||||
|
||||
describe('AggConfig', () => {
|
||||
let indexPattern: IndexPattern;
|
||||
|
@ -622,7 +623,7 @@ describe('AggConfig', () => {
|
|||
|
||||
it('creates a subexpression for param types other than "agg" which have specified toExpressionAst', () => {
|
||||
// Overwrite the `ranges` param in the `range` agg with a mock toExpressionAst function
|
||||
const range: MetricAggType = typesRegistry.get('range');
|
||||
const range = typesRegistry.get('range') as MetricAggType;
|
||||
range.expressionName = 'aggRange';
|
||||
const rangesParam = range.params.find((p) => p.name === 'ranges');
|
||||
rangesParam!.toExpressionAst = (val: any) => ({
|
|
@ -20,16 +20,17 @@
|
|||
import _ from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { Assign, Ensure } from '@kbn/utility-types';
|
||||
|
||||
import { FetchOptions, ISearchSource } from 'src/plugins/data/public';
|
||||
import {
|
||||
ExpressionAstFunction,
|
||||
ExpressionAstArgument,
|
||||
SerializedFieldFormat,
|
||||
} from 'src/plugins/expressions/common';
|
||||
|
||||
import { IAggType } from './agg_type';
|
||||
import { writeParams } from './agg_params';
|
||||
import { IAggConfigs } from './agg_configs';
|
||||
import { FetchOptions } from '../fetch';
|
||||
import { ISearchSource } from '../search_source';
|
||||
|
||||
type State = string | number | boolean | null | undefined | SerializableState;
|
||||
|
|
@ -22,8 +22,9 @@ import { AggConfig } from './agg_config';
|
|||
import { AggConfigs } from './agg_configs';
|
||||
import { AggTypesRegistryStart } from './agg_types_registry';
|
||||
import { mockAggTypesRegistry } from './test_helpers';
|
||||
import { IndexPatternField, IndexPattern } from '../../index_patterns';
|
||||
import { stubIndexPattern, stubIndexPatternWithFields } from '../../../public/stubs';
|
||||
import type { IndexPatternField } from '../../index_patterns';
|
||||
import { IndexPattern } from '../../index_patterns/index_patterns/index_pattern';
|
||||
import { stubIndexPattern, stubIndexPatternWithFields } from '../../../common/stubs';
|
||||
|
||||
describe('AggConfigs', () => {
|
||||
let indexPattern: IndexPattern;
|
|
@ -20,13 +20,12 @@
|
|||
import _ from 'lodash';
|
||||
import { Assign } from '@kbn/utility-types';
|
||||
|
||||
import { FetchOptions, ISearchSource } from 'src/plugins/data/public';
|
||||
import { AggConfig, AggConfigSerialized, IAggConfig } from './agg_config';
|
||||
import { IAggType } from './agg_type';
|
||||
import { AggTypesRegistryStart } from './agg_types_registry';
|
||||
import { AggGroupNames } from './agg_groups';
|
||||
import { IndexPattern } from '../../index_patterns';
|
||||
import { ISearchSource } from '../search_source';
|
||||
import { FetchOptions } from '../fetch';
|
||||
import { IndexPattern } from '../../index_patterns/index_patterns/index_pattern';
|
||||
import { TimeRange } from '../../../common';
|
||||
|
||||
function removeParentAggs(obj: any) {
|
|
@ -20,6 +20,7 @@
|
|||
import { constant, noop, identity } from 'lodash';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
import { ISearchSource } from 'src/plugins/data/public';
|
||||
import { SerializedFieldFormat } from 'src/plugins/expressions/common';
|
||||
import type { RequestAdapter } from 'src/plugins/inspector/common';
|
||||
|
||||
|
@ -28,7 +29,6 @@ import { AggConfig } from './agg_config';
|
|||
import { IAggConfigs } from './agg_configs';
|
||||
import { BaseParamType } from './param_types/base';
|
||||
import { AggParamType } from './param_types/agg';
|
||||
import { ISearchSource } from '../search_source';
|
||||
|
||||
export interface AggTypeConfig<
|
||||
TAggConfig extends AggConfig = AggConfig,
|
|
@ -17,9 +17,9 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { IUiSettingsClient } from 'src/core/public';
|
||||
import { TimeRange, TimeRangeBounds } from '../../../common';
|
||||
import { GetInternalStartServicesFn } from '../../types';
|
||||
import { FieldFormatsStartCommon } from '../../field_formats';
|
||||
import { BUCKET_TYPES } from './buckets';
|
||||
import { METRIC_TYPES } from './metrics';
|
||||
|
||||
import { getCountMetricAgg } from './metrics/count';
|
||||
import { getAvgMetricAgg } from './metrics/avg';
|
||||
|
@ -39,7 +39,7 @@ import { getCumulativeSumMetricAgg } from './metrics/cumulative_sum';
|
|||
import { getMovingAvgMetricAgg } from './metrics/moving_avg';
|
||||
import { getSerialDiffMetricAgg } from './metrics/serial_diff';
|
||||
|
||||
import { getDateHistogramBucketAgg } from './buckets/date_histogram';
|
||||
import { getDateHistogramBucketAgg, CalculateBoundsFn } from './buckets/date_histogram';
|
||||
import { getHistogramBucketAgg } from './buckets/histogram';
|
||||
import { getRangeBucketAgg } from './buckets/range';
|
||||
import { getDateRangeBucketAgg } from './buckets/date_range';
|
||||
|
@ -55,52 +55,50 @@ import { getBucketAvgMetricAgg } from './metrics/bucket_avg';
|
|||
import { getBucketMinMetricAgg } from './metrics/bucket_min';
|
||||
import { getBucketMaxMetricAgg } from './metrics/bucket_max';
|
||||
|
||||
/** @internal */
|
||||
export interface AggTypesDependencies {
|
||||
calculateBounds: (timeRange: TimeRange) => TimeRangeBounds;
|
||||
getInternalStartServices: GetInternalStartServicesFn;
|
||||
uiSettings: IUiSettingsClient;
|
||||
calculateBounds: CalculateBoundsFn;
|
||||
getConfig: <T = any>(key: string) => T;
|
||||
getFieldFormatsStart: () => Pick<FieldFormatsStartCommon, 'deserialize' | 'getDefaultInstance'>;
|
||||
isDefaultTimezone: () => boolean;
|
||||
}
|
||||
|
||||
export const getAggTypes = ({
|
||||
calculateBounds,
|
||||
getInternalStartServices,
|
||||
uiSettings,
|
||||
}: AggTypesDependencies) => ({
|
||||
export const getAggTypes = () => ({
|
||||
metrics: [
|
||||
getCountMetricAgg(),
|
||||
getAvgMetricAgg(),
|
||||
getSumMetricAgg(),
|
||||
getMedianMetricAgg(),
|
||||
getMinMetricAgg(),
|
||||
getMaxMetricAgg(),
|
||||
getStdDeviationMetricAgg(),
|
||||
getCardinalityMetricAgg(),
|
||||
getPercentilesMetricAgg(),
|
||||
getPercentileRanksMetricAgg({ getInternalStartServices }),
|
||||
getTopHitMetricAgg(),
|
||||
getDerivativeMetricAgg(),
|
||||
getCumulativeSumMetricAgg(),
|
||||
getMovingAvgMetricAgg(),
|
||||
getSerialDiffMetricAgg(),
|
||||
getBucketAvgMetricAgg(),
|
||||
getBucketSumMetricAgg(),
|
||||
getBucketMinMetricAgg(),
|
||||
getBucketMaxMetricAgg(),
|
||||
getGeoBoundsMetricAgg(),
|
||||
getGeoCentroidMetricAgg(),
|
||||
{ name: METRIC_TYPES.COUNT, fn: getCountMetricAgg },
|
||||
{ name: METRIC_TYPES.AVG, fn: getAvgMetricAgg },
|
||||
{ name: METRIC_TYPES.SUM, fn: getSumMetricAgg },
|
||||
{ name: METRIC_TYPES.MEDIAN, fn: getMedianMetricAgg },
|
||||
{ name: METRIC_TYPES.MIN, fn: getMinMetricAgg },
|
||||
{ name: METRIC_TYPES.MAX, fn: getMaxMetricAgg },
|
||||
{ name: METRIC_TYPES.STD_DEV, fn: getStdDeviationMetricAgg },
|
||||
{ name: METRIC_TYPES.CARDINALITY, fn: getCardinalityMetricAgg },
|
||||
{ name: METRIC_TYPES.PERCENTILES, fn: getPercentilesMetricAgg },
|
||||
{ name: METRIC_TYPES.PERCENTILE_RANKS, fn: getPercentileRanksMetricAgg },
|
||||
{ name: METRIC_TYPES.TOP_HITS, fn: getTopHitMetricAgg },
|
||||
{ name: METRIC_TYPES.DERIVATIVE, fn: getDerivativeMetricAgg },
|
||||
{ name: METRIC_TYPES.CUMULATIVE_SUM, fn: getCumulativeSumMetricAgg },
|
||||
{ name: METRIC_TYPES.MOVING_FN, fn: getMovingAvgMetricAgg },
|
||||
{ name: METRIC_TYPES.SERIAL_DIFF, fn: getSerialDiffMetricAgg },
|
||||
{ name: METRIC_TYPES.AVG_BUCKET, fn: getBucketAvgMetricAgg },
|
||||
{ name: METRIC_TYPES.SUM_BUCKET, fn: getBucketSumMetricAgg },
|
||||
{ name: METRIC_TYPES.MIN_BUCKET, fn: getBucketMinMetricAgg },
|
||||
{ name: METRIC_TYPES.MAX_BUCKET, fn: getBucketMaxMetricAgg },
|
||||
{ name: METRIC_TYPES.GEO_BOUNDS, fn: getGeoBoundsMetricAgg },
|
||||
{ name: METRIC_TYPES.GEO_CENTROID, fn: getGeoCentroidMetricAgg },
|
||||
],
|
||||
buckets: [
|
||||
getDateHistogramBucketAgg({ calculateBounds, uiSettings }),
|
||||
getHistogramBucketAgg({ uiSettings, getInternalStartServices }),
|
||||
getRangeBucketAgg({ getInternalStartServices }),
|
||||
getDateRangeBucketAgg({ uiSettings }),
|
||||
getIpRangeBucketAgg(),
|
||||
getTermsBucketAgg(),
|
||||
getFilterBucketAgg(),
|
||||
getFiltersBucketAgg({ uiSettings }),
|
||||
getSignificantTermsBucketAgg(),
|
||||
getGeoHashBucketAgg(),
|
||||
getGeoTitleBucketAgg(),
|
||||
{ name: BUCKET_TYPES.DATE_HISTOGRAM, fn: getDateHistogramBucketAgg },
|
||||
{ name: BUCKET_TYPES.HISTOGRAM, fn: getHistogramBucketAgg },
|
||||
{ name: BUCKET_TYPES.RANGE, fn: getRangeBucketAgg },
|
||||
{ name: BUCKET_TYPES.DATE_RANGE, fn: getDateRangeBucketAgg },
|
||||
{ name: BUCKET_TYPES.IP_RANGE, fn: getIpRangeBucketAgg },
|
||||
{ name: BUCKET_TYPES.TERMS, fn: getTermsBucketAgg },
|
||||
{ name: BUCKET_TYPES.FILTER, fn: getFilterBucketAgg },
|
||||
{ name: BUCKET_TYPES.FILTERS, fn: getFiltersBucketAgg },
|
||||
{ name: BUCKET_TYPES.SIGNIFICANT_TERMS, fn: getSignificantTermsBucketAgg },
|
||||
{ name: BUCKET_TYPES.GEOHASH_GRID, fn: getGeoHashBucketAgg },
|
||||
{ name: BUCKET_TYPES.GEOTILE_GRID, fn: getGeoTitleBucketAgg },
|
||||
],
|
||||
});
|
||||
|
|
@ -17,21 +17,17 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
AggTypesRegistry,
|
||||
AggTypesRegistrySetup,
|
||||
AggTypesRegistryStart,
|
||||
} from './agg_types_registry';
|
||||
import { AggTypesRegistry, AggTypesRegistrySetup } from './agg_types_registry';
|
||||
import { BucketAggType } from './buckets/bucket_agg_type';
|
||||
import { MetricAggType } from './metrics/metric_agg_type';
|
||||
|
||||
const bucketType = { name: 'terms', type: 'bucket' } as BucketAggType<any>;
|
||||
const metricType = { name: 'count', type: 'metric' } as MetricAggType<any>;
|
||||
const bucketType = () => ({ name: 'terms', type: 'buckets' } as BucketAggType<any>);
|
||||
const metricType = () => ({ name: 'count', type: 'metrics' } as MetricAggType<any>);
|
||||
|
||||
describe('AggTypesRegistry', () => {
|
||||
let registry: AggTypesRegistry;
|
||||
let setup: AggTypesRegistrySetup;
|
||||
let start: AggTypesRegistryStart;
|
||||
let start: ReturnType<AggTypesRegistry['start']>;
|
||||
|
||||
beforeEach(() => {
|
||||
registry = new AggTypesRegistry();
|
||||
|
@ -40,49 +36,53 @@ describe('AggTypesRegistry', () => {
|
|||
});
|
||||
|
||||
it('registerBucket adds new buckets', () => {
|
||||
setup.registerBucket(bucketType);
|
||||
expect(start.getBuckets()).toEqual([bucketType]);
|
||||
setup.registerBucket('terms', bucketType);
|
||||
expect(start.getAll().buckets).toEqual([bucketType]);
|
||||
});
|
||||
|
||||
it('registerBucket throws error when registering duplicate bucket', () => {
|
||||
expect(() => {
|
||||
setup.registerBucket(bucketType);
|
||||
setup.registerBucket(bucketType);
|
||||
setup.registerBucket('terms', bucketType);
|
||||
setup.registerBucket('terms', bucketType);
|
||||
}).toThrow(/already been registered with name: terms/);
|
||||
|
||||
const fooBucket = () => ({ name: 'foo', type: 'buckets' } as BucketAggType<any>);
|
||||
const fooMetric = () => ({ name: 'foo', type: 'metrics' } as MetricAggType<any>);
|
||||
expect(() => {
|
||||
setup.registerBucket('foo', fooBucket);
|
||||
setup.registerMetric('foo', fooMetric);
|
||||
}).toThrow(/already been registered with name: foo/);
|
||||
});
|
||||
|
||||
it('registerMetric adds new metrics', () => {
|
||||
setup.registerMetric(metricType);
|
||||
expect(start.getMetrics()).toEqual([metricType]);
|
||||
setup.registerMetric('count', metricType);
|
||||
expect(start.getAll().metrics).toEqual([metricType]);
|
||||
});
|
||||
|
||||
it('registerMetric throws error when registering duplicate metric', () => {
|
||||
expect(() => {
|
||||
setup.registerMetric(metricType);
|
||||
setup.registerMetric(metricType);
|
||||
setup.registerMetric('count', metricType);
|
||||
setup.registerMetric('count', metricType);
|
||||
}).toThrow(/already been registered with name: count/);
|
||||
|
||||
const fooBucket = () => ({ name: 'foo', type: 'buckets' } as BucketAggType<any>);
|
||||
const fooMetric = () => ({ name: 'foo', type: 'metrics' } as MetricAggType<any>);
|
||||
expect(() => {
|
||||
setup.registerMetric('foo', fooMetric);
|
||||
setup.registerBucket('foo', fooBucket);
|
||||
}).toThrow(/already been registered with name: foo/);
|
||||
});
|
||||
|
||||
it('gets either buckets or metrics by id', () => {
|
||||
setup.registerBucket(bucketType);
|
||||
setup.registerMetric(metricType);
|
||||
setup.registerBucket('terms', bucketType);
|
||||
setup.registerMetric('count', metricType);
|
||||
expect(start.get('terms')).toEqual(bucketType);
|
||||
expect(start.get('count')).toEqual(metricType);
|
||||
});
|
||||
|
||||
it('getBuckets retrieves only buckets', () => {
|
||||
setup.registerBucket(bucketType);
|
||||
expect(start.getBuckets()).toEqual([bucketType]);
|
||||
});
|
||||
|
||||
it('getMetrics retrieves only metrics', () => {
|
||||
setup.registerMetric(metricType);
|
||||
expect(start.getMetrics()).toEqual([metricType]);
|
||||
});
|
||||
|
||||
it('getAll returns all buckets and metrics', () => {
|
||||
setup.registerBucket(bucketType);
|
||||
setup.registerMetric(metricType);
|
||||
setup.registerBucket('terms', bucketType);
|
||||
setup.registerMetric('count', metricType);
|
||||
expect(start.getAll()).toEqual({
|
||||
buckets: [bucketType],
|
||||
metrics: [metricType],
|
|
@ -19,9 +19,21 @@
|
|||
|
||||
import { BucketAggType } from './buckets/bucket_agg_type';
|
||||
import { MetricAggType } from './metrics/metric_agg_type';
|
||||
import { AggTypesDependencies } from './agg_types';
|
||||
|
||||
export type AggTypesRegistrySetup = ReturnType<AggTypesRegistry['setup']>;
|
||||
export type AggTypesRegistryStart = ReturnType<AggTypesRegistry['start']>;
|
||||
/**
|
||||
* AggsCommonStart returns the _unitialized_ agg type providers, but in our
|
||||
* real start contract we will need to return the initialized versions.
|
||||
* So we need to provide the correct typings so they can be overwritten
|
||||
* on client/server.
|
||||
*
|
||||
* @internal
|
||||
*/
|
||||
export interface AggTypesRegistryStart {
|
||||
get: (id: string) => BucketAggType<any> | MetricAggType<any>;
|
||||
getAll: () => { buckets: Array<BucketAggType<any>>; metrics: Array<MetricAggType<any>> };
|
||||
}
|
||||
|
||||
export class AggTypesRegistry {
|
||||
private readonly bucketAggs = new Map();
|
||||
|
@ -29,17 +41,27 @@ export class AggTypesRegistry {
|
|||
|
||||
setup = () => {
|
||||
return {
|
||||
registerBucket: <T extends BucketAggType<any>>(type: T): void => {
|
||||
const { name } = type;
|
||||
if (this.bucketAggs.get(name)) {
|
||||
throw new Error(`Bucket agg has already been registered with name: ${name}`);
|
||||
registerBucket: <
|
||||
N extends string,
|
||||
T extends (deps: AggTypesDependencies) => BucketAggType<any>
|
||||
>(
|
||||
name: N,
|
||||
type: T
|
||||
): void => {
|
||||
if (this.bucketAggs.get(name) || this.metricAggs.get(name)) {
|
||||
throw new Error(`Agg has already been registered with name: ${name}`);
|
||||
}
|
||||
this.bucketAggs.set(name, type);
|
||||
},
|
||||
registerMetric: <T extends MetricAggType<any>>(type: T): void => {
|
||||
const { name } = type;
|
||||
if (this.metricAggs.get(name)) {
|
||||
throw new Error(`Metric agg has already been registered with name: ${name}`);
|
||||
registerMetric: <
|
||||
N extends string,
|
||||
T extends (deps: AggTypesDependencies) => MetricAggType<any>
|
||||
>(
|
||||
name: N,
|
||||
type: T
|
||||
): void => {
|
||||
if (this.bucketAggs.get(name) || this.metricAggs.get(name)) {
|
||||
throw new Error(`Agg has already been registered with name: ${name}`);
|
||||
}
|
||||
this.metricAggs.set(name, type);
|
||||
},
|
||||
|
@ -51,12 +73,6 @@ export class AggTypesRegistry {
|
|||
get: (name: string) => {
|
||||
return this.bucketAggs.get(name) || this.metricAggs.get(name);
|
||||
},
|
||||
getBuckets: () => {
|
||||
return Array.from(this.bucketAggs.values());
|
||||
},
|
||||
getMetrics: () => {
|
||||
return Array.from(this.metricAggs.values());
|
||||
},
|
||||
getAll: () => {
|
||||
return {
|
||||
buckets: Array.from(this.bucketAggs.values()),
|
217
src/plugins/data/common/search/aggs/aggs_service.test.ts
Normal file
217
src/plugins/data/common/search/aggs/aggs_service.test.ts
Normal file
|
@ -0,0 +1,217 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import {
|
||||
AggsCommonService,
|
||||
AggsCommonSetupDependencies,
|
||||
AggsCommonStartDependencies,
|
||||
} from './aggs_service';
|
||||
import { AggTypesDependencies, getAggTypes } from './agg_types';
|
||||
import { BucketAggType } from './buckets/bucket_agg_type';
|
||||
import { MetricAggType } from './metrics/metric_agg_type';
|
||||
|
||||
describe('Aggs service', () => {
|
||||
let service: AggsCommonService;
|
||||
let setupDeps: AggsCommonSetupDependencies;
|
||||
let startDeps: AggsCommonStartDependencies;
|
||||
const aggTypesDependencies: AggTypesDependencies = {
|
||||
calculateBounds: jest.fn(),
|
||||
getFieldFormatsStart: jest.fn(),
|
||||
getConfig: jest.fn(),
|
||||
isDefaultTimezone: () => true,
|
||||
};
|
||||
|
||||
beforeEach(() => {
|
||||
service = new AggsCommonService();
|
||||
setupDeps = {
|
||||
registerFunction: jest.fn(),
|
||||
};
|
||||
startDeps = {
|
||||
getConfig: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe('setup()', () => {
|
||||
test('exposes proper contract', () => {
|
||||
const setup = service.setup(setupDeps);
|
||||
expect(Object.keys(setup).length).toBe(1);
|
||||
expect(setup).toHaveProperty('types');
|
||||
});
|
||||
|
||||
test('instantiates a new registry', () => {
|
||||
const a = new AggsCommonService();
|
||||
const b = new AggsCommonService();
|
||||
const bSetupDeps = {
|
||||
registerFunction: jest.fn(),
|
||||
};
|
||||
|
||||
const aSetup = a.setup(setupDeps);
|
||||
aSetup.types.registerBucket(
|
||||
'foo',
|
||||
() => ({ name: 'foo', type: 'buckets' } as BucketAggType<any>)
|
||||
);
|
||||
const aStart = a.start(startDeps);
|
||||
expect(aStart.types.getAll().buckets.map((t) => t(aggTypesDependencies).name))
|
||||
.toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"date_histogram",
|
||||
"histogram",
|
||||
"range",
|
||||
"date_range",
|
||||
"ip_range",
|
||||
"terms",
|
||||
"filter",
|
||||
"filters",
|
||||
"significant_terms",
|
||||
"geohash_grid",
|
||||
"geotile_grid",
|
||||
"foo",
|
||||
]
|
||||
`);
|
||||
expect(aStart.types.getAll().metrics.map((t) => t(aggTypesDependencies).name))
|
||||
.toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"count",
|
||||
"avg",
|
||||
"sum",
|
||||
"median",
|
||||
"min",
|
||||
"max",
|
||||
"std_dev",
|
||||
"cardinality",
|
||||
"percentiles",
|
||||
"percentile_ranks",
|
||||
"top_hits",
|
||||
"derivative",
|
||||
"cumulative_sum",
|
||||
"moving_avg",
|
||||
"serial_diff",
|
||||
"avg_bucket",
|
||||
"sum_bucket",
|
||||
"min_bucket",
|
||||
"max_bucket",
|
||||
"geo_bounds",
|
||||
"geo_centroid",
|
||||
]
|
||||
`);
|
||||
|
||||
b.setup(bSetupDeps);
|
||||
const bStart = b.start(startDeps);
|
||||
expect(bStart.types.getAll().buckets.map((t) => t(aggTypesDependencies).name))
|
||||
.toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"date_histogram",
|
||||
"histogram",
|
||||
"range",
|
||||
"date_range",
|
||||
"ip_range",
|
||||
"terms",
|
||||
"filter",
|
||||
"filters",
|
||||
"significant_terms",
|
||||
"geohash_grid",
|
||||
"geotile_grid",
|
||||
]
|
||||
`);
|
||||
expect(bStart.types.getAll().metrics.map((t) => t(aggTypesDependencies).name))
|
||||
.toMatchInlineSnapshot(`
|
||||
Array [
|
||||
"count",
|
||||
"avg",
|
||||
"sum",
|
||||
"median",
|
||||
"min",
|
||||
"max",
|
||||
"std_dev",
|
||||
"cardinality",
|
||||
"percentiles",
|
||||
"percentile_ranks",
|
||||
"top_hits",
|
||||
"derivative",
|
||||
"cumulative_sum",
|
||||
"moving_avg",
|
||||
"serial_diff",
|
||||
"avg_bucket",
|
||||
"sum_bucket",
|
||||
"min_bucket",
|
||||
"max_bucket",
|
||||
"geo_bounds",
|
||||
"geo_centroid",
|
||||
]
|
||||
`);
|
||||
});
|
||||
|
||||
test('registers default agg types', () => {
|
||||
service.setup(setupDeps);
|
||||
const start = service.start(startDeps);
|
||||
|
||||
const aggTypes = getAggTypes();
|
||||
expect(start.types.getAll().buckets.length).toBe(aggTypes.buckets.length);
|
||||
expect(start.types.getAll().metrics.length).toBe(aggTypes.metrics.length);
|
||||
});
|
||||
|
||||
test('merges default agg types with types registered during setup', () => {
|
||||
const setup = service.setup(setupDeps);
|
||||
setup.types.registerBucket(
|
||||
'foo',
|
||||
() => ({ name: 'foo', type: 'buckets' } as BucketAggType<any>)
|
||||
);
|
||||
setup.types.registerMetric(
|
||||
'bar',
|
||||
() => ({ name: 'bar', type: 'metrics' } as MetricAggType<any>)
|
||||
);
|
||||
const start = service.start(startDeps);
|
||||
|
||||
const aggTypes = getAggTypes();
|
||||
expect(start.types.getAll().buckets.length).toBe(aggTypes.buckets.length + 1);
|
||||
expect(start.types.getAll().buckets.some((t) => t(aggTypesDependencies).name === 'foo')).toBe(
|
||||
true
|
||||
);
|
||||
expect(start.types.getAll().metrics.length).toBe(aggTypes.metrics.length + 1);
|
||||
expect(start.types.getAll().metrics.some((t) => t(aggTypesDependencies).name === 'bar')).toBe(
|
||||
true
|
||||
);
|
||||
});
|
||||
|
||||
test('registers all agg type expression functions', () => {
|
||||
service.setup(setupDeps);
|
||||
const aggTypes = getAggTypes();
|
||||
expect(setupDeps.registerFunction).toHaveBeenCalledTimes(
|
||||
aggTypes.buckets.length + aggTypes.metrics.length
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('start()', () => {
|
||||
test('exposes proper contract', () => {
|
||||
const start = service.start(startDeps);
|
||||
expect(Object.keys(start).length).toBe(3);
|
||||
expect(start).toHaveProperty('calculateAutoTimeExpression');
|
||||
expect(start).toHaveProperty('createAggConfigs');
|
||||
expect(start).toHaveProperty('types');
|
||||
});
|
||||
|
||||
test('types registry returns uninitialized type providers', () => {
|
||||
service.setup(setupDeps);
|
||||
const start = service.start(startDeps);
|
||||
expect(typeof start.types.get('terms')).toBe('function');
|
||||
expect(start.types.get('terms')(aggTypesDependencies).name).toBe('terms');
|
||||
});
|
||||
});
|
||||
});
|
92
src/plugins/data/common/search/aggs/aggs_service.ts
Normal file
92
src/plugins/data/common/search/aggs/aggs_service.ts
Normal file
|
@ -0,0 +1,92 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import { ExpressionsServiceSetup } from 'src/plugins/expressions/common';
|
||||
import { UI_SETTINGS } from '../../../common';
|
||||
import {
|
||||
AggConfigs,
|
||||
AggTypesRegistry,
|
||||
getAggTypes,
|
||||
getAggTypesFunctions,
|
||||
getCalculateAutoTimeExpression,
|
||||
} from './';
|
||||
import { AggsCommonSetup, AggsCommonStart } from './types';
|
||||
|
||||
/** @internal */
|
||||
export const aggsRequiredUiSettings = [
|
||||
'dateFormat',
|
||||
'dateFormat:scaled',
|
||||
'dateFormat:tz',
|
||||
UI_SETTINGS.HISTOGRAM_BAR_TARGET,
|
||||
UI_SETTINGS.HISTOGRAM_MAX_BARS,
|
||||
UI_SETTINGS.SEARCH_QUERY_LANGUAGE,
|
||||
UI_SETTINGS.QUERY_ALLOW_LEADING_WILDCARDS,
|
||||
UI_SETTINGS.QUERY_STRING_OPTIONS,
|
||||
UI_SETTINGS.COURIER_IGNORE_FILTER_IF_FIELD_NOT_IN_INDEX,
|
||||
];
|
||||
|
||||
/** @internal */
|
||||
export interface AggsCommonSetupDependencies {
|
||||
registerFunction: ExpressionsServiceSetup['registerFunction'];
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export interface AggsCommonStartDependencies {
|
||||
getConfig: <T = any>(key: string) => T;
|
||||
}
|
||||
|
||||
/**
|
||||
* The aggs service provides a means of modeling and manipulating the various
|
||||
* Elasticsearch aggregations supported by Kibana, providing the ability to
|
||||
* output the correct DSL when you are ready to send your request to ES.
|
||||
*/
|
||||
export class AggsCommonService {
|
||||
private readonly aggTypesRegistry = new AggTypesRegistry();
|
||||
|
||||
public setup({ registerFunction }: AggsCommonSetupDependencies): AggsCommonSetup {
|
||||
const aggTypesSetup = this.aggTypesRegistry.setup();
|
||||
|
||||
// register each agg type
|
||||
const aggTypes = getAggTypes();
|
||||
aggTypes.buckets.forEach(({ name, fn }) => aggTypesSetup.registerBucket(name, fn));
|
||||
aggTypes.metrics.forEach(({ name, fn }) => aggTypesSetup.registerMetric(name, fn));
|
||||
|
||||
// register expression functions for each agg type
|
||||
const aggFunctions = getAggTypesFunctions();
|
||||
aggFunctions.forEach((fn) => registerFunction(fn));
|
||||
|
||||
return {
|
||||
types: aggTypesSetup,
|
||||
};
|
||||
}
|
||||
|
||||
public start({ getConfig }: AggsCommonStartDependencies): AggsCommonStart {
|
||||
const aggTypesStart = this.aggTypesRegistry.start();
|
||||
|
||||
return {
|
||||
calculateAutoTimeExpression: getCalculateAutoTimeExpression(getConfig),
|
||||
createAggConfigs: (indexPattern, configStates = [], schemas) => {
|
||||
return new AggConfigs(indexPattern, configStates, {
|
||||
typesRegistry: aggTypesStart,
|
||||
});
|
||||
},
|
||||
types: aggTypesStart,
|
||||
};
|
||||
}
|
||||
}
|
|
@ -22,32 +22,17 @@ import { createFilterDateHistogram } from './date_histogram';
|
|||
import { intervalOptions } from '../_interval_options';
|
||||
import { AggConfigs } from '../../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../../test_helpers';
|
||||
import {
|
||||
getDateHistogramBucketAgg,
|
||||
DateHistogramBucketAggDependencies,
|
||||
IBucketDateHistogramAggConfig,
|
||||
} from '../date_histogram';
|
||||
import { IBucketDateHistogramAggConfig } from '../date_histogram';
|
||||
import { BUCKET_TYPES } from '../bucket_agg_types';
|
||||
import { RangeFilter } from '../../../../../common';
|
||||
import { coreMock } from '../../../../../../../core/public/mocks';
|
||||
|
||||
describe('AggConfig Filters', () => {
|
||||
describe('date_histogram', () => {
|
||||
let aggTypesDependencies: DateHistogramBucketAggDependencies;
|
||||
let agg: IBucketDateHistogramAggConfig;
|
||||
let filter: RangeFilter;
|
||||
let bucketStart: any;
|
||||
let field: any;
|
||||
|
||||
beforeEach(() => {
|
||||
const { uiSettings } = coreMock.createSetup();
|
||||
|
||||
aggTypesDependencies = {
|
||||
calculateBounds: jest.fn(),
|
||||
uiSettings,
|
||||
};
|
||||
});
|
||||
|
||||
const init = (interval: string = 'auto', duration: any = moment.duration(15, 'minutes')) => {
|
||||
field = {
|
||||
name: 'date',
|
||||
|
@ -71,7 +56,7 @@ describe('AggConfig Filters', () => {
|
|||
},
|
||||
],
|
||||
{
|
||||
typesRegistry: mockAggTypesRegistry([getDateHistogramBucketAgg(aggTypesDependencies)]),
|
||||
typesRegistry: mockAggTypesRegistry(),
|
||||
}
|
||||
);
|
||||
const bucketKey = 1422579600000;
|
|
@ -18,31 +18,18 @@
|
|||
*/
|
||||
|
||||
import moment from 'moment';
|
||||
import { getDateRangeBucketAgg, DateRangeBucketAggDependencies } from '../date_range';
|
||||
import { createFilterDateRange } from './date_range';
|
||||
import { FieldFormatsGetConfigFn } from '../../../../../common';
|
||||
import { DateFormat } from '../../../../field_formats';
|
||||
import { AggConfigs } from '../../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../../test_helpers';
|
||||
import { BUCKET_TYPES } from '../bucket_agg_types';
|
||||
import { IBucketAggConfig } from '../bucket_agg_type';
|
||||
import { coreMock } from '../../../../../../../core/public/mocks';
|
||||
|
||||
describe('AggConfig Filters', () => {
|
||||
describe('Date range', () => {
|
||||
let aggTypesDependencies: DateRangeBucketAggDependencies;
|
||||
|
||||
beforeEach(() => {
|
||||
const { uiSettings } = coreMock.createSetup();
|
||||
|
||||
aggTypesDependencies = { uiSettings };
|
||||
});
|
||||
|
||||
const getConfig = (() => {}) as FieldFormatsGetConfigFn;
|
||||
const getAggConfigs = () => {
|
||||
const field = {
|
||||
name: '@timestamp',
|
||||
format: new DateFormat({}, getConfig),
|
||||
format: {},
|
||||
};
|
||||
|
||||
const indexPattern = {
|
||||
|
@ -66,7 +53,7 @@ describe('AggConfig Filters', () => {
|
|||
},
|
||||
],
|
||||
{
|
||||
typesRegistry: mockAggTypesRegistry([getDateRangeBucketAgg(aggTypesDependencies)]),
|
||||
typesRegistry: mockAggTypesRegistry(),
|
||||
}
|
||||
);
|
||||
};
|
|
@ -17,23 +17,13 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { getFiltersBucketAgg, FiltersBucketAggDependencies } from '../filters';
|
||||
import { createFilterFilters } from './filters';
|
||||
import { AggConfigs } from '../../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../../test_helpers';
|
||||
import { IBucketAggConfig } from '../bucket_agg_type';
|
||||
import { coreMock } from '../../../../../../../core/public/mocks';
|
||||
|
||||
describe('AggConfig Filters', () => {
|
||||
describe('filters', () => {
|
||||
let aggTypesDependencies: FiltersBucketAggDependencies;
|
||||
|
||||
beforeEach(() => {
|
||||
const { uiSettings } = coreMock.createSetup();
|
||||
|
||||
aggTypesDependencies = { uiSettings };
|
||||
});
|
||||
|
||||
const getAggConfigs = () => {
|
||||
const field = {
|
||||
name: 'bytes',
|
||||
|
@ -63,7 +53,7 @@ describe('AggConfig Filters', () => {
|
|||
},
|
||||
],
|
||||
{
|
||||
typesRegistry: mockAggTypesRegistry([getFiltersBucketAgg(aggTypesDependencies)]),
|
||||
typesRegistry: mockAggTypesRegistry(),
|
||||
}
|
||||
);
|
||||
};
|
|
@ -17,25 +17,14 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { createFilterHistogram } from './histogram';
|
||||
import { BytesFormat, FieldFormatsGetConfigFn } from '../../../../../common/field_formats';
|
||||
import { AggConfigs } from '../../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../../test_helpers';
|
||||
import { mockAggTypesRegistry, mockGetFieldFormatsStart } from '../../test_helpers';
|
||||
import { BUCKET_TYPES } from '../bucket_agg_types';
|
||||
import { IBucketAggConfig } from '../bucket_agg_type';
|
||||
import { BytesFormat, FieldFormatsGetConfigFn } from '../../../../../common';
|
||||
import { GetInternalStartServicesFn, InternalStartServices } from '../../../../types';
|
||||
import { FieldFormatsStart } from '../../../../field_formats';
|
||||
import { fieldFormatsServiceMock } from '../../../../field_formats/mocks';
|
||||
import { createFilterHistogram } from './histogram';
|
||||
|
||||
describe('AggConfig Filters', () => {
|
||||
let getInternalStartServices: GetInternalStartServicesFn;
|
||||
let fieldFormats: FieldFormatsStart;
|
||||
|
||||
beforeEach(() => {
|
||||
fieldFormats = fieldFormatsServiceMock.createStartContract();
|
||||
getInternalStartServices = () => (({ fieldFormats } as unknown) as InternalStartServices);
|
||||
});
|
||||
|
||||
describe('histogram', () => {
|
||||
const getConfig = (() => {}) as FieldFormatsGetConfigFn;
|
||||
const getAggConfigs = () => {
|
||||
|
@ -72,12 +61,12 @@ describe('AggConfig Filters', () => {
|
|||
|
||||
test('should return an range filter for histogram', () => {
|
||||
const aggConfigs = getAggConfigs();
|
||||
const filter = createFilterHistogram(getInternalStartServices)(
|
||||
const filter = createFilterHistogram(mockGetFieldFormatsStart)(
|
||||
aggConfigs.aggs[0] as IBucketAggConfig,
|
||||
'2048'
|
||||
);
|
||||
|
||||
expect(fieldFormats.deserialize).toHaveBeenCalledTimes(1);
|
||||
expect(mockGetFieldFormatsStart().deserialize).toHaveBeenCalledTimes(1);
|
||||
expect(filter).toHaveProperty('meta');
|
||||
expect(filter.meta).toHaveProperty('index', '1234');
|
||||
expect(filter).toHaveProperty('range');
|
|
@ -17,14 +17,16 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { IBucketAggConfig } from '../bucket_agg_type';
|
||||
import { buildRangeFilter, RangeFilterParams } from '../../../../../common';
|
||||
import { GetInternalStartServicesFn } from '../../../../types';
|
||||
import { AggTypesDependencies } from '../../agg_types';
|
||||
import { IBucketAggConfig } from '../bucket_agg_type';
|
||||
|
||||
/** @internal */
|
||||
export const createFilterHistogram = (getInternalStartServices: GetInternalStartServicesFn) => {
|
||||
export const createFilterHistogram = (
|
||||
getFieldFormatsStart: AggTypesDependencies['getFieldFormatsStart']
|
||||
) => {
|
||||
return (aggConfig: IBucketAggConfig, key: string) => {
|
||||
const { fieldFormats } = getInternalStartServices();
|
||||
const { deserialize } = getFieldFormatsStart();
|
||||
const value = parseInt(key, 10);
|
||||
const params: RangeFilterParams = { gte: value, lt: value + aggConfig.params.interval };
|
||||
|
||||
|
@ -32,7 +34,7 @@ export const createFilterHistogram = (getInternalStartServices: GetInternalStart
|
|||
aggConfig.params.field,
|
||||
params,
|
||||
aggConfig.getIndexPattern(),
|
||||
fieldFormats.deserialize(aggConfig.toSerializedFieldFormat()).convert(key)
|
||||
deserialize(aggConfig.toSerializedFieldFormat()).convert(key)
|
||||
);
|
||||
};
|
||||
};
|
|
@ -17,7 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { getIpRangeBucketAgg } from '../ip_range';
|
||||
import { createFilterIpRange } from './ip_range';
|
||||
import { AggConfigs, CreateAggConfigParams } from '../../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../../test_helpers';
|
||||
|
@ -27,7 +26,7 @@ import { IBucketAggConfig } from '../bucket_agg_type';
|
|||
|
||||
describe('AggConfig Filters', () => {
|
||||
describe('IP range', () => {
|
||||
const typesRegistry = mockAggTypesRegistry([getIpRangeBucketAgg()]);
|
||||
const typesRegistry = mockAggTypesRegistry();
|
||||
const getAggConfigs = (aggs: CreateAggConfigParams[]) => {
|
||||
const field = {
|
||||
name: 'ip',
|
|
@ -17,31 +17,15 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { getRangeBucketAgg } from '../range';
|
||||
import { createFilterRange } from './range';
|
||||
import { BytesFormat, FieldFormatsGetConfigFn } from '../../../../../common';
|
||||
import { BytesFormat, FieldFormatsGetConfigFn } from '../../../../../common/field_formats';
|
||||
import { AggConfigs } from '../../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../../test_helpers';
|
||||
import { BUCKET_TYPES } from '../bucket_agg_types';
|
||||
import { mockAggTypesRegistry, mockGetFieldFormatsStart } from '../../test_helpers';
|
||||
import { IBucketAggConfig } from '../bucket_agg_type';
|
||||
import { FieldFormatsStart } from '../../../../field_formats';
|
||||
import { fieldFormatsServiceMock } from '../../../../field_formats/mocks';
|
||||
import { GetInternalStartServicesFn, InternalStartServices } from '../../../../types';
|
||||
import { BUCKET_TYPES } from '../bucket_agg_types';
|
||||
import { createFilterRange } from './range';
|
||||
|
||||
describe('AggConfig Filters', () => {
|
||||
describe('range', () => {
|
||||
let getInternalStartServices: GetInternalStartServicesFn;
|
||||
let fieldFormats: FieldFormatsStart;
|
||||
|
||||
beforeEach(() => {
|
||||
fieldFormats = fieldFormatsServiceMock.createStartContract();
|
||||
|
||||
getInternalStartServices = () =>
|
||||
(({
|
||||
fieldFormats,
|
||||
} as unknown) as InternalStartServices);
|
||||
});
|
||||
|
||||
const getConfig = (() => {}) as FieldFormatsGetConfigFn;
|
||||
const getAggConfigs = () => {
|
||||
const field = {
|
||||
|
@ -72,14 +56,14 @@ describe('AggConfig Filters', () => {
|
|||
},
|
||||
],
|
||||
{
|
||||
typesRegistry: mockAggTypesRegistry([getRangeBucketAgg({ getInternalStartServices })]),
|
||||
typesRegistry: mockAggTypesRegistry(),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
test('should return a range filter for range agg', () => {
|
||||
const aggConfigs = getAggConfigs();
|
||||
const filter = createFilterRange(getInternalStartServices)(
|
||||
const filter = createFilterRange(mockGetFieldFormatsStart)(
|
||||
aggConfigs.aggs[0] as IBucketAggConfig,
|
||||
{
|
||||
gte: 1024,
|
||||
|
@ -87,7 +71,7 @@ describe('AggConfig Filters', () => {
|
|||
}
|
||||
);
|
||||
|
||||
expect(fieldFormats.deserialize).toHaveBeenCalledTimes(1);
|
||||
expect(mockGetFieldFormatsStart().deserialize).toHaveBeenCalledTimes(1);
|
||||
expect(filter).toHaveProperty('range');
|
||||
expect(filter).toHaveProperty('meta');
|
||||
expect(filter.meta).toHaveProperty('index', '1234');
|
|
@ -17,19 +17,21 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { IBucketAggConfig } from '../bucket_agg_type';
|
||||
import { buildRangeFilter } from '../../../../../common';
|
||||
import { GetInternalStartServicesFn } from '../../../../types';
|
||||
import { AggTypesDependencies } from '../../agg_types';
|
||||
import { IBucketAggConfig } from '../bucket_agg_type';
|
||||
|
||||
/** @internal */
|
||||
export const createFilterRange = (getInternalStartServices: GetInternalStartServicesFn) => {
|
||||
export const createFilterRange = (
|
||||
getFieldFormatsStart: AggTypesDependencies['getFieldFormatsStart']
|
||||
) => {
|
||||
return (aggConfig: IBucketAggConfig, params: any) => {
|
||||
const { fieldFormats } = getInternalStartServices();
|
||||
const { deserialize } = getFieldFormatsStart();
|
||||
return buildRangeFilter(
|
||||
aggConfig.params.field,
|
||||
params,
|
||||
aggConfig.getIndexPattern(),
|
||||
fieldFormats.deserialize(aggConfig.toSerializedFieldFormat()).convert(params)
|
||||
deserialize(aggConfig.toSerializedFieldFormat()).convert(params)
|
||||
);
|
||||
};
|
||||
};
|
|
@ -17,7 +17,6 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { getTermsBucketAgg } from '../terms';
|
||||
import { createFilterTerms } from './terms';
|
||||
import { AggConfigs, CreateAggConfigParams } from '../../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../../test_helpers';
|
||||
|
@ -43,7 +42,7 @@ describe('AggConfig Filters', () => {
|
|||
};
|
||||
|
||||
return new AggConfigs(indexPattern, aggs, {
|
||||
typesRegistry: mockAggTypesRegistry([getTermsBucketAgg()]),
|
||||
typesRegistry: mockAggTypesRegistry(),
|
||||
});
|
||||
};
|
||||
|
|
@ -20,27 +20,23 @@
|
|||
import { get, noop, find, every } from 'lodash';
|
||||
import moment from 'moment-timezone';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { IUiSettingsClient } from 'src/core/public';
|
||||
|
||||
import { TimeBuckets } from './lib/time_buckets';
|
||||
import { KBN_FIELD_TYPES, TimeRange, TimeRangeBounds, UI_SETTINGS } from '../../../../common';
|
||||
|
||||
import { intervalOptions } from './_interval_options';
|
||||
import { createFilterDateHistogram } from './create_filter/date_histogram';
|
||||
import { BucketAggType, IBucketAggConfig } from './bucket_agg_type';
|
||||
import { BUCKET_TYPES } from './bucket_agg_types';
|
||||
import { createFilterDateHistogram } from './create_filter/date_histogram';
|
||||
import { intervalOptions } from './_interval_options';
|
||||
import { ExtendedBounds } from './lib/extended_bounds';
|
||||
import { TimeBuckets } from './lib/time_buckets';
|
||||
|
||||
import { writeParams } from '../agg_params';
|
||||
import { isMetricAggType } from '../metrics/metric_agg_type';
|
||||
|
||||
import {
|
||||
dateHistogramInterval,
|
||||
KBN_FIELD_TYPES,
|
||||
TimeRange,
|
||||
TimeRangeBounds,
|
||||
UI_SETTINGS,
|
||||
} from '../../../../common';
|
||||
import { BaseAggParams } from '../types';
|
||||
import { ExtendedBounds } from './lib/extended_bounds';
|
||||
import { dateHistogramInterval } from '../utils';
|
||||
|
||||
type CalculateBoundsFn = (timeRange: TimeRange) => TimeRangeBounds;
|
||||
/** @internal */
|
||||
export type CalculateBoundsFn = (timeRange: TimeRange) => TimeRangeBounds;
|
||||
|
||||
const updateTimeBuckets = (
|
||||
agg: IBucketDateHistogramAggConfig,
|
||||
|
@ -58,7 +54,8 @@ const updateTimeBuckets = (
|
|||
|
||||
export interface DateHistogramBucketAggDependencies {
|
||||
calculateBounds: CalculateBoundsFn;
|
||||
uiSettings: IUiSettingsClient;
|
||||
isDefaultTimezone: () => boolean;
|
||||
getConfig: <T = any>(key: string) => T;
|
||||
}
|
||||
|
||||
export interface IBucketDateHistogramAggConfig extends IBucketAggConfig {
|
||||
|
@ -84,7 +81,8 @@ export interface AggParamsDateHistogram extends BaseAggParams {
|
|||
|
||||
export const getDateHistogramBucketAgg = ({
|
||||
calculateBounds,
|
||||
uiSettings,
|
||||
isDefaultTimezone,
|
||||
getConfig,
|
||||
}: DateHistogramBucketAggDependencies) =>
|
||||
new BucketAggType<IBucketDateHistogramAggConfig>({
|
||||
name: BUCKET_TYPES.DATE_HISTOGRAM,
|
||||
|
@ -122,10 +120,10 @@ export const getDateHistogramBucketAgg = ({
|
|||
if (buckets) return buckets;
|
||||
|
||||
buckets = new TimeBuckets({
|
||||
'histogram:maxBars': uiSettings.get(UI_SETTINGS.HISTOGRAM_MAX_BARS),
|
||||
'histogram:barTarget': uiSettings.get(UI_SETTINGS.HISTOGRAM_BAR_TARGET),
|
||||
dateFormat: uiSettings.get('dateFormat'),
|
||||
'dateFormat:scaled': uiSettings.get('dateFormat:scaled'),
|
||||
'histogram:maxBars': getConfig(UI_SETTINGS.HISTOGRAM_MAX_BARS),
|
||||
'histogram:barTarget': getConfig(UI_SETTINGS.HISTOGRAM_BAR_TARGET),
|
||||
dateFormat: getConfig('dateFormat'),
|
||||
'dateFormat:scaled': getConfig('dateFormat:scaled'),
|
||||
});
|
||||
updateTimeBuckets(this, calculateBounds, buckets);
|
||||
|
||||
|
@ -252,10 +250,9 @@ export const getDateHistogramBucketAgg = ({
|
|||
}
|
||||
if (!tz) {
|
||||
// If the index pattern typeMeta data, didn't had a time zone assigned for the selected field use the configured tz
|
||||
const isDefaultTimezone = uiSettings.isDefault('dateFormat:tz');
|
||||
const detectedTimezone = moment.tz.guess();
|
||||
const tzOffset = moment().format('Z');
|
||||
tz = isDefaultTimezone ? detectedTimezone || tzOffset : uiSettings.get('dateFormat:tz');
|
||||
tz = isDefaultTimezone() ? detectedTimezone || tzOffset : getConfig('dateFormat:tz');
|
||||
}
|
||||
output.params.time_zone = tz;
|
||||
},
|
|
@ -17,19 +17,20 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { coreMock } from '../../../../../../../src/core/public/mocks';
|
||||
import { getDateRangeBucketAgg, DateRangeBucketAggDependencies } from './date_range';
|
||||
import { AggConfigs } from '../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../test_helpers';
|
||||
import { AggTypesDependencies } from '../agg_types';
|
||||
import { mockAggTypesRegistry, mockAggTypesDependencies } from '../test_helpers';
|
||||
import { BUCKET_TYPES } from './bucket_agg_types';
|
||||
|
||||
describe('date_range params', () => {
|
||||
let aggTypesDependencies: DateRangeBucketAggDependencies;
|
||||
let aggTypesDependencies: AggTypesDependencies;
|
||||
|
||||
beforeEach(() => {
|
||||
const { uiSettings } = coreMock.createSetup();
|
||||
|
||||
aggTypesDependencies = { uiSettings };
|
||||
aggTypesDependencies = {
|
||||
...mockAggTypesDependencies,
|
||||
getConfig: jest.fn(),
|
||||
isDefaultTimezone: jest.fn().mockReturnValue(false),
|
||||
};
|
||||
});
|
||||
|
||||
const getAggConfigs = (params: Record<string, any> = {}, hasIncludeTypeMeta: boolean = true) => {
|
||||
|
@ -68,7 +69,7 @@ describe('date_range params', () => {
|
|||
},
|
||||
],
|
||||
{
|
||||
typesRegistry: mockAggTypesRegistry([getDateRangeBucketAgg(aggTypesDependencies)]),
|
||||
typesRegistry: mockAggTypesRegistry(aggTypesDependencies),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -108,10 +109,7 @@ describe('date_range params', () => {
|
|||
test('should use the Kibana time_zone if no parameter specified', () => {
|
||||
aggTypesDependencies = {
|
||||
...aggTypesDependencies,
|
||||
uiSettings: {
|
||||
...aggTypesDependencies.uiSettings,
|
||||
get: () => 'kibanaTimeZone' as any,
|
||||
},
|
||||
getConfig: () => 'kibanaTimeZone' as any,
|
||||
};
|
||||
|
||||
const aggConfigs = getAggConfigs(
|
|
@ -20,14 +20,13 @@
|
|||
import { get } from 'lodash';
|
||||
import moment from 'moment-timezone';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { IUiSettingsClient } from 'src/core/public';
|
||||
|
||||
import { BUCKET_TYPES } from './bucket_agg_types';
|
||||
import { BucketAggType, IBucketAggConfig } from './bucket_agg_type';
|
||||
import { createFilterDateRange } from './create_filter/date_range';
|
||||
import { DateRangeKey } from './lib/date_range';
|
||||
|
||||
import { KBN_FIELD_TYPES } from '../../../../common';
|
||||
import { KBN_FIELD_TYPES } from '../../../../common/kbn_field_types/types';
|
||||
import { BaseAggParams } from '../types';
|
||||
|
||||
const dateRangeTitle = i18n.translate('data.search.aggs.buckets.dateRangeTitle', {
|
||||
|
@ -35,7 +34,8 @@ const dateRangeTitle = i18n.translate('data.search.aggs.buckets.dateRangeTitle',
|
|||
});
|
||||
|
||||
export interface DateRangeBucketAggDependencies {
|
||||
uiSettings: IUiSettingsClient;
|
||||
isDefaultTimezone: () => boolean;
|
||||
getConfig: <T = any>(key: string) => T;
|
||||
}
|
||||
|
||||
export interface AggParamsDateRange extends BaseAggParams {
|
||||
|
@ -44,7 +44,10 @@ export interface AggParamsDateRange extends BaseAggParams {
|
|||
time_zone?: string;
|
||||
}
|
||||
|
||||
export const getDateRangeBucketAgg = ({ uiSettings }: DateRangeBucketAggDependencies) =>
|
||||
export const getDateRangeBucketAgg = ({
|
||||
isDefaultTimezone,
|
||||
getConfig,
|
||||
}: DateRangeBucketAggDependencies) =>
|
||||
new BucketAggType({
|
||||
name: BUCKET_TYPES.DATE_RANGE,
|
||||
title: dateRangeTitle,
|
||||
|
@ -100,9 +103,8 @@ export const getDateRangeBucketAgg = ({ uiSettings }: DateRangeBucketAggDependen
|
|||
if (!tz) {
|
||||
const detectedTimezone = moment.tz.guess();
|
||||
const tzOffset = moment().format('Z');
|
||||
const isDefaultTimezone = uiSettings.isDefault('dateFormat:tz');
|
||||
|
||||
tz = isDefaultTimezone ? detectedTimezone || tzOffset : uiSettings.get('dateFormat:tz');
|
||||
tz = isDefaultTimezone() ? detectedTimezone || tzOffset : getConfig('dateFormat:tz');
|
||||
}
|
||||
output.params.time_zone = tz;
|
||||
},
|
|
@ -18,20 +18,20 @@
|
|||
*/
|
||||
|
||||
import { Query } from '../../../../common';
|
||||
import { coreMock } from '../../../../../../../src/core/public/mocks';
|
||||
import { AggConfigs } from '../agg_configs';
|
||||
import { mockAggTypesRegistry } from '../test_helpers';
|
||||
import { AggTypesDependencies } from '../agg_types';
|
||||
import { mockAggTypesRegistry, mockAggTypesDependencies } from '../test_helpers';
|
||||
import { BUCKET_TYPES } from './bucket_agg_types';
|
||||
import { getFiltersBucketAgg, FiltersBucketAggDependencies } from './filters';
|
||||
|
||||
describe('Filters Agg', () => {
|
||||
let aggTypesDependencies: FiltersBucketAggDependencies;
|
||||
let aggTypesDependencies: AggTypesDependencies;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetAllMocks();
|
||||
const { uiSettings } = coreMock.createSetup();
|
||||
|
||||
aggTypesDependencies = { uiSettings };
|
||||
aggTypesDependencies = {
|
||||
...mockAggTypesDependencies,
|
||||
getConfig: jest.fn(),
|
||||
};
|
||||
});
|
||||
|
||||
describe('order agg editor UI', () => {
|
||||
|
@ -61,7 +61,7 @@ describe('Filters Agg', () => {
|
|||
},
|
||||
],
|
||||
{
|
||||
typesRegistry: mockAggTypesRegistry([getFiltersBucketAgg(aggTypesDependencies)]),
|
||||
typesRegistry: mockAggTypesRegistry(aggTypesDependencies),
|
||||
}
|
||||
);
|
||||
};
|
||||
|
@ -218,7 +218,7 @@ describe('Filters Agg', () => {
|
|||
});
|
||||
|
||||
test('works with leading wildcards if allowed', () => {
|
||||
aggTypesDependencies.uiSettings.get = (s: any) =>
|
||||
aggTypesDependencies.getConfig = (s: any) =>
|
||||
s === 'query:allowLeadingWildcards' ? true : s;
|
||||
|
||||
const aggConfigs = getAggConfigs({
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
import { i18n } from '@kbn/i18n';
|
||||
import { size, transform, cloneDeep } from 'lodash';
|
||||
import { IUiSettingsClient } from 'src/core/public';
|
||||
|
||||
import { createFilterFilters } from './create_filter/filters';
|
||||
import { toAngularJSON } from '../utils';
|
||||
|
@ -41,7 +40,7 @@ interface FilterValue {
|
|||
}
|
||||
|
||||
export interface FiltersBucketAggDependencies {
|
||||
uiSettings: IUiSettingsClient;
|
||||
getConfig: <T = any>(key: string) => any;
|
||||
}
|
||||
|
||||
export interface AggParamsFilters extends Omit<BaseAggParams, 'customLabel'> {
|
||||
|
@ -51,7 +50,7 @@ export interface AggParamsFilters extends Omit<BaseAggParams, 'customLabel'> {
|
|||
}>;
|
||||
}
|
||||
|
||||
export const getFiltersBucketAgg = ({ uiSettings }: FiltersBucketAggDependencies) =>
|
||||
export const getFiltersBucketAgg = ({ getConfig }: FiltersBucketAggDependencies) =>
|
||||
new BucketAggType({
|
||||
name: BUCKET_TYPES.FILTERS,
|
||||
title: filtersTitle,
|
||||
|
@ -60,9 +59,9 @@ export const getFiltersBucketAgg = ({ uiSettings }: FiltersBucketAggDependencies
|
|||
params: [
|
||||
{
|
||||
name: 'filters',
|
||||
default: [
|
||||
default: () => [
|
||||
{
|
||||
input: { query: '', language: uiSettings.get(UI_SETTINGS.SEARCH_QUERY_LANGUAGE) },
|
||||
input: { query: '', language: getConfig(UI_SETTINGS.SEARCH_QUERY_LANGUAGE) },
|
||||
label: '',
|
||||
},
|
||||
],
|
||||
|
@ -80,7 +79,7 @@ export const getFiltersBucketAgg = ({ uiSettings }: FiltersBucketAggDependencies
|
|||
return;
|
||||
}
|
||||
|
||||
const esQueryConfigs = getEsQueryConfig(uiSettings);
|
||||
const esQueryConfigs = getEsQueryConfig({ get: getConfig });
|
||||
const query = buildEsQuery(aggConfig.getIndexPattern(), [input], [], esQueryConfigs);
|
||||
|
||||
if (!query) {
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue