Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
34fd9f6
Use as code dataView schema and rename dataset to data_source
markov00 Apr 2, 2026
c5d2a29
renamed dataset.ts to data_source.ts
markov00 Apr 2, 2026
8f139e5
Changes from node scripts/regenerate_moon_projects.js --update
kibanamachine Apr 2, 2026
7e85f66
fix examples and test examples
markov00 Apr 2, 2026
c11b7cb
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 2, 2026
bdaf7f4
fix the need to pull data-views-plugin at runtime
markov00 Apr 2, 2026
2968873
renamed mising dataset function names
markov00 Apr 3, 2026
0daba56
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 3, 2026
dc8c289
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 4, 2026
83b0749
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 6, 2026
ee87339
use consts for data view types
markov00 Apr 7, 2026
2ea18cb
add reasons to ts-ignore
markov00 Apr 7, 2026
af9b4c9
fix datasource to data source in docs
markov00 Apr 7, 2026
32c0ceb
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 7, 2026
49817e2
fix ad hoc mock
markov00 Apr 7, 2026
26bb383
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 7, 2026
be83aa6
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 7, 2026
3e8905e
update data view id to ref_id
markov00 Apr 7, 2026
357c753
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 7, 2026
3485b5e
fix test
markov00 Apr 7, 2026
5c4b291
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 7, 2026
464fcc1
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 7, 2026
8160797
fix example
markov00 Apr 7, 2026
a5b9398
Merge branch 'main' into 2026_04_02-use_data_view_schema
markov00 Apr 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,23 @@

import type { Type } from '@kbn/config-schema';
import { schema } from '@kbn/config-schema';
import {
PRIMITIVE_RUNTIME_FIELD_TYPES,
RUNTIME_FIELD_COMPOSITE_TYPE,
import type {
PrimitiveRuntimeFieldTypes,
RuntimeFieldCompositeType,
} from '@kbn/data-views-plugin/common';

const PRIMITIVE_RUNTIME_FIELD_TYPES: PrimitiveRuntimeFieldTypes = [
Comment thread
markov00 marked this conversation as resolved.
'keyword',
'long',
'double',
'date',
'ip',
'boolean',
'geo_point',
];

const RUNTIME_FIELD_COMPOSITE_TYPE: RuntimeFieldCompositeType = 'composite';

const MAX_NAME_LENGTH = 1000;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
"exclude": ["target/**/*"],
"kbn_references": [
"@kbn/config-schema",
"@kbn/data-views-plugin",
"@kbn/data-views-plugin"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* your election, the "Elastic License 2.0", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/
import { AS_CODE_DATA_VIEW_REFERENCE_TYPE } from '@kbn/as-code-data-views-schema';
import { LENS_EMPTY_AS_NULL_DEFAULT_VALUE } from '../../transforms/columns/utils';
import type { DatatableState } from './datatable';
import { datatableStateSchema } from './datatable';
Expand All @@ -16,9 +17,9 @@ type DatatableWithoutDefaultsConfig = Omit<DatatableState, 'sampling' | 'ignore_
describe('Datatable Schema', () => {
const baseDatatableConfig: Omit<DatatableWithoutDefaultsConfig, 'metrics'> = {
type: 'data_table',
dataset: {
type: 'dataView',
id: 'test-data-view',
data_source: {
type: AS_CODE_DATA_VIEW_REFERENCE_TYPE,
ref_id: 'test-data-view',
},
};

Expand Down Expand Up @@ -450,7 +451,7 @@ describe('Datatable Schema', () => {
it('throws when using term buckets operation in an esql configuration', () => {
const input: DatatableWithoutDefaultsConfig = {
type: 'data_table',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand All @@ -473,7 +474,7 @@ describe('Datatable Schema', () => {
it('throws when esql datatable has no metrics and no rows', () => {
const input: Omit<DatatableWithoutDefaultsConfig, 'metrics' | 'rows'> = {
type: 'data_table',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand All @@ -487,7 +488,7 @@ describe('Datatable Schema', () => {
it('throws on empty metrics array for esql', () => {
const input: DatatableWithoutDefaultsConfig = {
type: 'data_table',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand All @@ -505,7 +506,7 @@ describe('Datatable Schema', () => {
it('throws on empty rows array for esql', () => {
const input: DatatableWithoutDefaultsConfig = {
type: 'data_table',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand Down Expand Up @@ -752,7 +753,7 @@ describe('Datatable Schema', () => {
type: 'data_table',
title: 'Datatable',
description: 'ESQL table full configuration',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand Down Expand Up @@ -838,7 +839,7 @@ describe('Datatable Schema', () => {
type: 'data_table',
title: 'Datatable',
description: 'ESQL table without metrics',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { schema } from '@kbn/config-schema';
import { DEFAULT_HEADER_ROW_HEIGHT_LINES, DEFAULT_ROW_HEIGHT_LINES } from '@kbn/lens-common';
import { esqlColumnWithFormatSchema } from '../metric_ops';
import { applyColorToSchema, colorByValueSchema, colorMappingSchema } from '../color';
import { datasetSchema, datasetEsqlTableSchema } from '../dataset';
import { dataSourceSchema, dataSourceEsqlTableSchema } from '../data_source';
import {
collapseBySchema,
dslOnlyPanelInfoSchema,
Expand Down Expand Up @@ -379,7 +379,7 @@ export const datatableStateSchemaNoESQL = schema.object(
...sharedPanelInfoSchema,
...dslOnlyPanelInfoSchema,
...layerSettingsSchema,
...datasetSchema,
...dataSourceSchema,
...datatableStateSharedOptionsSchema,
/**
* Metric columns configuration, must define operation.
Expand Down Expand Up @@ -431,7 +431,7 @@ export const datatableStateSchemaESQL = schema.object(
type: schema.literal('data_table'),
...sharedPanelInfoSchema,
...layerSettingsSchema,
...datasetEsqlTableSchema,
...dataSourceEsqlTableSchema,
...datatableStateSharedOptionsSchema,
/**
* Metric columns configuration, must define operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { AS_CODE_DATA_VIEW_REFERENCE_TYPE } from '@kbn/as-code-data-views-schema';
import { LENS_EMPTY_AS_NULL_DEFAULT_VALUE } from '../../transforms/columns/utils';
import type { ColorByValueType } from '../color';
import type { GaugeState } from './gauge';
Expand All @@ -15,9 +16,9 @@ import { gaugeStateSchema } from './gauge';
describe('Gauge Schema', () => {
const baseGaugeConfig = {
type: 'gauge',
dataset: {
type: 'dataView',
id: 'test-data-view',
data_source: {
type: AS_CODE_DATA_VIEW_REFERENCE_TYPE,
ref_id: 'test-data-view',
},
} satisfies Partial<GaugeState>;

Expand Down Expand Up @@ -140,7 +141,7 @@ describe('Gauge Schema', () => {
it('validates ESQL configuration', () => {
const input = {
type: 'gauge',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand All @@ -157,7 +158,7 @@ describe('Gauge Schema', () => {
it('validates ES|QL full configuration with bullet shape', () => {
const input = {
type: 'gauge',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand Down Expand Up @@ -198,7 +199,7 @@ describe('Gauge Schema', () => {
it('throws on mixed DSL and ES|QL configs', () => {
const input = {
type: 'gauge',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
metricOperationDefinitionSchema,
} from '../metric_ops';
import { colorByValueSchema } from '../color';
import { datasetSchema, datasetEsqlTableSchema } from '../dataset';
import { dataSourceSchema, dataSourceEsqlTableSchema } from '../data_source';
import { dslOnlyPanelInfoSchema, layerSettingsSchema, sharedPanelInfoSchema } from '../shared';
import { mergeAllMetricsWithChartDimensionSchema } from './shared';
import { builderEnums } from '../enums';
Expand Down Expand Up @@ -152,7 +152,7 @@ export const gaugeStateSchemaNoESQL = schema.object(
...sharedPanelInfoSchema,
...dslOnlyPanelInfoSchema,
...layerSettingsSchema,
...datasetSchema,
...dataSourceSchema,
...gaugeStateSharedOptionsSchema,
/**
* Primary value configuration, must define operation.
Expand All @@ -170,7 +170,7 @@ export const gaugeStateSchemaESQL = schema.object(
type: schema.literal('gauge'),
...sharedPanelInfoSchema,
...layerSettingsSchema,
...datasetEsqlTableSchema,
...dataSourceEsqlTableSchema,
...gaugeStateSharedOptionsSchema,
/**
* Primary value configuration, must define operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { omit } from 'lodash';

import { schema, type TypeOf } from '@kbn/config-schema';

import { datasetSchema, datasetEsqlTableSchema } from '../dataset';
import { dataSourceSchema, dataSourceEsqlTableSchema } from '../data_source';
import { colorByValueSchema } from '../color';
import { esqlColumnWithFormatSchema } from '../metric_ops';
import {
Expand Down Expand Up @@ -151,7 +151,7 @@ export const heatmapStateSchemaNoESQL = schema.object(
...heatmapSharedStateSchema,
...heatmapAxesStateSchemaProps,
...dslOnlyPanelInfoSchema,
...datasetSchema,
...dataSourceSchema,
metric: mergeAllMetricsWithChartDimensionSchemaWithRefBasedOps(
heatmapStateMetricOptionsSchemaProps
),
Expand All @@ -163,7 +163,7 @@ export const heatmapStateSchemaESQL = schema.object(
{
...heatmapSharedStateSchema,
...heatmapAxesStateESQLSchemaProps,
...datasetEsqlTableSchema,
...dataSourceEsqlTableSchema,
metric: esqlColumnWithFormatSchema.extends(heatmapStateMetricOptionsSchemaProps),
},
{ meta: { id: 'heatmapESQL', title: 'Heatmap Chart (ES|QL)' } }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { AS_CODE_DATA_VIEW_REFERENCE_TYPE } from '@kbn/as-code-data-views-schema';
import { LENS_EMPTY_AS_NULL_DEFAULT_VALUE } from '../../transforms/columns/utils';
import type { LegacyMetricState } from './legacy_metric';
import { legacyMetricStateSchema } from './legacy_metric';

describe('Legacy Metric Schema', () => {
const baseLegacyMetricConfig = {
type: 'legacy_metric',
dataset: {
type: 'dataView',
id: 'test-data-view',
data_source: {
type: AS_CODE_DATA_VIEW_REFERENCE_TYPE,
ref_id: 'test-data-view',
},
} satisfies Partial<LegacyMetricState>;

Expand Down Expand Up @@ -217,7 +218,7 @@ describe('Legacy Metric Schema', () => {
it('validates esql configuration', () => {
const input = {
type: 'legacy_metric',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import type { TypeOf } from '@kbn/config-schema';
import { schema } from '@kbn/config-schema';
import { esqlColumnWithFormatSchema } from '../metric_ops';
import { datasetSchema, datasetEsqlTableSchema } from '../dataset';
import { dataSourceSchema, dataSourceEsqlTableSchema } from '../data_source';
import { layerSettingsSchema, sharedPanelInfoSchema, dslOnlyPanelInfoSchema } from '../shared';
import {
applyColorToSchema,
Expand Down Expand Up @@ -86,7 +86,7 @@ export const legacyMetricStateSchemaNoESQL = schema.object(
...sharedPanelInfoSchema,
...dslOnlyPanelInfoSchema,
...layerSettingsSchema,
...datasetSchema,
...dataSourceSchema,
/**
* Metric configuration, must define operation.
*/
Expand All @@ -100,7 +100,7 @@ const esqlLegacyMetricState = schema.object(
type: schema.literal('legacy_metric'),
...sharedPanelInfoSchema,
...layerSettingsSchema,
...datasetEsqlTableSchema,
...dataSourceEsqlTableSchema,
/**
* Metric configuration, must define operation.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,17 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { AS_CODE_DATA_VIEW_REFERENCE_TYPE } from '@kbn/as-code-data-views-schema';
import { LENS_EMPTY_AS_NULL_DEFAULT_VALUE } from '../../transforms/columns/utils';
import type { MetricState } from './metric';
import { metricStateSchema } from './metric';

describe('Metric Schema', () => {
const baseMetricConfig = {
type: 'metric',
dataset: {
type: 'dataView',
id: 'test-data-view',
data_source: {
type: AS_CODE_DATA_VIEW_REFERENCE_TYPE,
ref_id: 'test-data-view',
},
} satisfies Partial<MetricState>;

Expand Down Expand Up @@ -577,7 +578,7 @@ describe('Metric Schema', () => {
it('validates esql configuration', () => {
const input = {
type: 'metric',
dataset: {
data_source: {
type: 'esql',
query: 'FROM my-index | LIMIT 100',
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
esqlColumnWithFormatSchema,
} from '../metric_ops';
import { staticColorSchema, applyColorToSchema, colorByValueSchema } from '../color';
import { datasetSchema, datasetEsqlTableSchema } from '../dataset';
import { dataSourceSchema, dataSourceEsqlTableSchema } from '../data_source';
import {
collapseBySchema,
layerSettingsSchema,
Expand Down Expand Up @@ -404,7 +404,7 @@ function validateMetrics(metrics: (PrimaryMetricType | SecondaryMetricType)[]) {
}
}

const primaryMetricSchemaNoESQL = mergeAllMetricsWithChartDimensionSchemaWithRefBasedOps({
export const primaryMetricSchemaNoESQL = mergeAllMetricsWithChartDimensionSchemaWithRefBasedOps({
...metricStatePrimaryMetricOptionsSchema,
...metricStateBackgroundChartSchemaNoESQL,
});
Expand All @@ -418,7 +418,7 @@ export const metricStateSchemaNoESQL = schema.object(
...sharedPanelInfoSchema,
...dslOnlyPanelInfoSchema,
...layerSettingsSchema,
...datasetSchema,
...dataSourceSchema,
styling: schema.maybe(metricStylingSchema),
/**
* Primary value configuration, must define operation.
Expand Down Expand Up @@ -460,7 +460,7 @@ export const esqlMetricState = schema.object(
type: schema.literal('metric'),
...sharedPanelInfoSchema,
...layerSettingsSchema,
...datasetEsqlTableSchema,
...dataSourceEsqlTableSchema,
styling: schema.maybe(metricStylingSchema),
/**
* Primary value configuration, must define operation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@
* License v3.0 only", or the "Server Side Public License, v 1".
*/

import { AS_CODE_DATA_VIEW_REFERENCE_TYPE } from '@kbn/as-code-data-views-schema';
import type { MosaicState, MosaicStateESQL, MosaicStateNoESQL } from './mosaic';
import { mosaicStateSchema } from './mosaic';

describe('Mosaic Schema', () => {
const baseMosaicConfig: Pick<
MosaicStateNoESQL,
'type' | 'dataset' | 'ignore_global_filters' | 'sampling'
'type' | 'data_source' | 'ignore_global_filters' | 'sampling'
> = {
type: 'mosaic',
dataset: {
type: 'dataView',
id: 'test-data-view',
data_source: {
type: AS_CODE_DATA_VIEW_REFERENCE_TYPE,
ref_id: 'test-data-view',
},
ignore_global_filters: false,
sampling: 0,
Expand Down Expand Up @@ -565,10 +566,10 @@ describe('Mosaic Schema', () => {
describe('ES|QL Schema', () => {
const baseESQLMosaicConfig: Pick<
MosaicStateESQL,
'type' | 'dataset' | 'ignore_global_filters' | 'sampling'
'type' | 'data_source' | 'ignore_global_filters' | 'sampling'
> = {
type: 'mosaic',
dataset: {
data_source: {
type: 'esql',
query: 'FROM blah | KEEP foo, bar',
},
Expand Down
Loading
Loading