Skip to content

Commit

Permalink
Merge branch 'main' into april/api_docs
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasneirynck authored May 3, 2022
2 parents c74f55e + 06b958d commit 382d038
Show file tree
Hide file tree
Showing 142 changed files with 7,991 additions and 3,901 deletions.
1 change: 1 addition & 0 deletions .buildkite/scripts/pipelines/pull_request/pipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const SKIPPABLE_PATHS = [
/^\.github\//,
/\.md$/,
/^\.backportrc\.json$/,
/^nav-kibana-dev\.docnav\.json$/,
];

const REQUIRED_PATHS = [
Expand Down
1 change: 1 addition & 0 deletions nav-kibana-dev.docnav.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
{
"label": "Contributors Newsletters",
"items": [
{ "id": "kibApril2022ContributorNewsletter" },
{ "id": "kibMarch2022ContributorNewsletter" },
{ "id": "kibFebruary2022ContributorNewsletter" },
{ "id": "kibJanuary2022ContributorNewsletter" },
Expand Down
7 changes: 6 additions & 1 deletion packages/kbn-ci-stats-reporter/src/ci_stats_reporter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ import { parseConfig, Config, CiStatsMetadata } from '@kbn/ci-stats-core';
import type { CiStatsTestGroupInfo, CiStatsTestRun } from './ci_stats_test_group_types';

const BASE_URL = 'https://ci-stats.kibana.dev';
const SECOND = 1000;
const MINUTE = 60 * SECOND;

function limitMetaStrings(meta: CiStatsMetadata) {
return Object.fromEntries(
Expand Down Expand Up @@ -107,6 +109,7 @@ interface ReqOptions {
body: any;
bodyDesc: string;
query?: AxiosRequestConfig['params'];
timeout?: number;
}

/** Object that helps report data to the ci-stats service */
Expand Down Expand Up @@ -282,6 +285,7 @@ export class CiStatsReporter {
},
bodyDesc: `[${group.name}/${group.type}] Chunk of ${bufferBytes} bytes`,
body: buffer.join('\n'),
timeout: 5 * MINUTE,
});
buffer.length = 0;
bufferBytes = 0;
Expand Down Expand Up @@ -336,7 +340,7 @@ export class CiStatsReporter {
}
}

private async req<T>({ auth, body, bodyDesc, path, query }: ReqOptions) {
private async req<T>({ auth, body, bodyDesc, path, query, timeout = 60 * SECOND }: ReqOptions) {
let attempt = 0;
const maxAttempts = 5;

Expand Down Expand Up @@ -365,6 +369,7 @@ export class CiStatsReporter {
// if it can be serialized into a string, send it
maxBodyLength: Infinity,
maxContentLength: Infinity,
timeout,
});

return resp.data;
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-optimizer/limits.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ pageLoadAssetSize:
visTypeGauge: 24113
unifiedSearch: 71059
data: 454087
expressionXY: 26500
eventAnnotation: 19334
screenshotting: 22870
synthetics: 40958
expressionXY: 29000
11 changes: 8 additions & 3 deletions packages/kbn-pm/dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1580,6 +1580,8 @@ var _ciStatsCore = __webpack_require__("../../node_modules/@kbn/ci-stats-core/ta
*/
// @ts-expect-error not "public", but necessary to prevent Jest shimming from breaking things
const BASE_URL = 'https://ci-stats.kibana.dev';
const SECOND = 1000;
const MINUTE = 60 * SECOND;

function limitMetaStrings(meta) {
return Object.fromEntries(Object.entries(meta).map(([key, value]) => {
Expand Down Expand Up @@ -1782,7 +1784,8 @@ class CiStatsReporter {
groupType: group.type
},
bodyDesc: `[${group.name}/${group.type}] Chunk of ${bufferBytes} bytes`,
body: buffer.join('\n')
body: buffer.join('\n'),
timeout: 5 * MINUTE
});
buffer.length = 0;
bufferBytes = 0;
Expand Down Expand Up @@ -1851,7 +1854,8 @@ class CiStatsReporter {
body,
bodyDesc,
path,
query
query,
timeout = 60 * SECOND
}) {
let attempt = 0;
const maxAttempts = 5;
Expand Down Expand Up @@ -1879,7 +1883,8 @@ class CiStatsReporter {
adapter: _http.default,
// if it can be serialized into a string, send it
maxBodyLength: Infinity,
maxContentLength: Infinity
maxContentLength: Infinity,
timeout
});
return resp.data;
} catch (error) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { Position } from '@elastic/charts';
import type { PaletteOutput } from '@kbn/coloring';
import { Datatable, DatatableRow } from '@kbn/expressions-plugin';
import { LayerTypes } from '../constants';
import { DataLayerConfigResult, LensMultiTable, XYArgs } from '../types';
import { DataLayerConfig, XYProps } from '../types';

export const mockPaletteOutput: PaletteOutput = {
type: 'palette',
Expand Down Expand Up @@ -46,9 +46,9 @@ export const createSampleDatatableWithRows = (rows: DatatableRow[]): Datatable =
rows,
});

export const sampleLayer: DataLayerConfigResult = {
type: 'dataLayer',
export const sampleLayer: DataLayerConfig = {
layerId: 'first',
type: 'dataLayer',
layerType: LayerTypes.DATA,
seriesType: 'line',
xAccessor: 'c',
Expand All @@ -59,9 +59,12 @@ export const sampleLayer: DataLayerConfigResult = {
yScaleType: 'linear',
isHistogram: false,
palette: mockPaletteOutput,
table: createSampleDatatableWithRows([]),
};

export const createArgsWithLayers = (layers: DataLayerConfigResult[] = [sampleLayer]): XYArgs => ({
export const createArgsWithLayers = (
layers: DataLayerConfig | DataLayerConfig[] = sampleLayer
): XYProps => ({
xTitle: '',
yTitle: '',
yRightTitle: '',
Expand Down Expand Up @@ -104,25 +107,17 @@ export const createArgsWithLayers = (layers: DataLayerConfigResult[] = [sampleLa
mode: 'full',
type: 'axisExtentConfig',
},
layers,
layers: Array.isArray(layers) ? layers : [layers],
});

export function sampleArgs() {
const data: LensMultiTable = {
type: 'lens_multitable',
tables: {
first: createSampleDatatableWithRows([
{ a: 1, b: 2, c: 'I', d: 'Foo' },
{ a: 1, b: 5, c: 'J', d: 'Bar' },
]),
},
dateRange: {
fromDate: new Date('2019-01-02T05:00:00.000Z'),
toDate: new Date('2019-01-03T05:00:00.000Z'),
},
};

const args: XYArgs = createArgsWithLayers();
const data = createSampleDatatableWithRows([
{ a: 1, b: 2, c: 'I', d: 'Foo' },
{ a: 1, b: 5, c: 'J', d: 'Bar' },
]);

return { data, args };
return {
data,
args: createArgsWithLayers({ ...sampleLayer, table: data }),
};
}
26 changes: 24 additions & 2 deletions src/plugins/chart_expressions/expression_xy/common/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,21 @@
*/

export const XY_VIS = 'xyVis';
export const LAYERED_XY_VIS = 'layeredXyVis';
export const Y_CONFIG = 'yConfig';
export const EXTENDED_Y_CONFIG = 'extendedYConfig';
export const MULTITABLE = 'lens_multitable';
export const DATA_LAYER = 'dataLayer';
export const EXTENDED_DATA_LAYER = 'extendedDataLayer';
export const LEGEND_CONFIG = 'legendConfig';
export const XY_VIS_RENDERER = 'xyVis';
export const GRID_LINES_CONFIG = 'gridlinesConfig';
export const ANNOTATION_LAYER = 'annotationLayer';
export const EXTENDED_ANNOTATION_LAYER = 'extendedAnnotationLayer';
export const TICK_LABELS_CONFIG = 'tickLabelsConfig';
export const AXIS_EXTENT_CONFIG = 'axisExtentConfig';
export const REFERENCE_LINE_LAYER = 'referenceLineLayer';
export const EXTENDED_REFERENCE_LINE_LAYER = 'extendedReferenceLineLayer';
export const LABELS_ORIENTATION_CONFIG = 'labelsOrientationConfig';
export const AXIS_TITLES_VISIBILITY_CONFIG = 'axisTitlesVisibilityConfig';

Expand Down Expand Up @@ -106,6 +111,23 @@ export const XYCurveTypes = {

export const ValueLabelModes = {
HIDE: 'hide',
INSIDE: 'inside',
OUTSIDE: 'outside',
SHOW: 'show',
} as const;

export const AvailableReferenceLineIcons = {
EMPTY: 'empty',
ASTERISK: 'asterisk',
ALERT: 'alert',
BELL: 'bell',
BOLT: 'bolt',
BUG: 'bug',
CIRCLE: 'circle',
EDITOR_COMMENT: 'editorComment',
FLAG: 'flag',
HEART: 'heart',
MAP_MARKER: 'mapMarker',
PIN_FILLED: 'pinFilled',
STAR_EMPTY: 'starEmpty',
TAG: 'tag',
TRIANGLE: 'triangle',
} as const;
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,40 @@
* Side Public License, v 1.
*/

import type { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import type { Datatable, ExpressionFunctionDefinition } from '@kbn/expressions-plugin/common';
import { LayerTypes, ANNOTATION_LAYER } from '../constants';
import { AnnotationLayerArgs, AnnotationLayerConfigResult } from '../types';
import { strings } from '../i18n';

export function annotationLayerConfigFunction(): ExpressionFunctionDefinition<
export function annotationLayerFunction(): ExpressionFunctionDefinition<
typeof ANNOTATION_LAYER,
null,
Datatable,
AnnotationLayerArgs,
AnnotationLayerConfigResult
> {
return {
name: ANNOTATION_LAYER,
aliases: [],
type: ANNOTATION_LAYER,
inputTypes: ['null'],
help: 'Annotation layer in lens',
inputTypes: ['datatable'],
help: strings.getAnnotationLayerFnHelp(),
args: {
layerId: {
types: ['string'],
help: '',
},
hide: {
types: ['boolean'],
default: false,
help: 'Show details',
help: strings.getAnnotationLayerHideHelp(),
},
annotations: {
types: ['manual_point_event_annotation', 'manual_range_event_annotation'],
help: '',
help: strings.getAnnotationLayerAnnotationsHelp(),
multi: true,
},
},
fn: (input, args) => {
return {
type: ANNOTATION_LAYER,
...args,
annotations: args.annotations ?? [],
layerType: LayerTypes.ANNOTATIONS,
};
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import type { ExpressionFunctionDefinition } from '@kbn/expressions-plugin/commo
import { AxisExtentConfig, AxisExtentConfigResult } from '../types';
import { AxisExtentModes, AXIS_EXTENT_CONFIG } from '../constants';

const errors = {
upperBoundLowerOrEqualToLowerBoundError: () =>
i18n.translate('expressionXY.reusable.function.axisExtentConfig.errors.emptyUpperBound', {
defaultMessage: 'Upper bound should be greater than lower bound, if custom mode is enabled.',
}),
};

export const axisExtentConfigFunction: ExpressionFunctionDefinition<
typeof AXIS_EXTENT_CONFIG,
null,
Expand All @@ -27,10 +34,12 @@ export const axisExtentConfigFunction: ExpressionFunctionDefinition<
args: {
mode: {
types: ['string'],
options: [...Object.values(AxisExtentModes)],
help: i18n.translate('expressionXY.axisExtentConfig.extentMode.help', {
defaultMessage: 'The extent mode',
}),
options: [...Object.values(AxisExtentModes)],
strict: true,
default: AxisExtentModes.FULL,
},
lowerBound: {
types: ['number'],
Expand All @@ -46,6 +55,16 @@ export const axisExtentConfigFunction: ExpressionFunctionDefinition<
},
},
fn(input, args) {
if (args.mode === AxisExtentModes.CUSTOM) {
if (
args.lowerBound !== undefined &&
args.upperBound !== undefined &&
args.lowerBound >= args.upperBound
) {
throw new Error(errors.upperBoundLowerOrEqualToLowerBoundError());
}
}

return {
type: AXIS_EXTENT_CONFIG,
...args,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { SeriesTypes, XScaleTypes, YScaleTypes, Y_CONFIG } from '../constants';
import { strings } from '../i18n';
import { DataLayerFn, ExtendedDataLayerFn } from '../types';

type CommonDataLayerFn = DataLayerFn | ExtendedDataLayerFn;

export const commonDataLayerArgs: CommonDataLayerFn['args'] = {
hide: {
types: ['boolean'],
default: false,
help: strings.getHideHelp(),
},
xAccessor: {
types: ['string'],
help: strings.getXAccessorHelp(),
},
seriesType: {
types: ['string'],
options: [...Object.values(SeriesTypes)],
help: strings.getSeriesTypeHelp(),
required: true,
strict: true,
},
xScaleType: {
options: [...Object.values(XScaleTypes)],
help: strings.getXScaleTypeHelp(),
default: XScaleTypes.ORDINAL,
strict: true,
},
isHistogram: {
types: ['boolean'],
default: false,
help: strings.getIsHistogramHelp(),
},
yScaleType: {
options: [...Object.values(YScaleTypes)],
help: strings.getYScaleTypeHelp(),
default: YScaleTypes.LINEAR,
strict: true,
},
splitAccessor: {
types: ['string'],
help: strings.getSplitAccessorHelp(),
},
accessors: {
types: ['string'],
help: strings.getAccessorsHelp(),
multi: true,
},
yConfig: {
types: [Y_CONFIG],
help: strings.getYConfigHelp(),
multi: true,
},
columnToLabel: {
types: ['string'],
help: strings.getColumnToLabelHelp(),
},
palette: {
types: ['palette', 'system_palette'],
help: strings.getPaletteHelp(),
default: '{palette}',
},
};
Loading

0 comments on commit 382d038

Please sign in to comment.