Skip to content

Commit

Permalink
Merge branch 'main' into security/remove-usage-of-redux-observables-2
Browse files Browse the repository at this point in the history
  • Loading branch information
janmonschke committed Jan 29, 2024
2 parents 6d99e67 + 9629e66 commit 477348a
Show file tree
Hide file tree
Showing 94 changed files with 2,217 additions and 938 deletions.
Binary file removed docs/user/ml/images/ml-data-comparison.png
Binary file not shown.
Binary file added docs/user/ml/images/ml-data-drift.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 5 additions & 5 deletions docs/user/ml/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,19 @@ NOTE: There are limitations in {ml-features} that affect {kib}. For more
information, refer to {ml-docs}/ml-limitations.html[{ml-cap}].

[discrete]
[[data-comparison-view]]
== Data comparison
[[data-drift-view]]
== Data drift

preview::[]

You can find the data comparison view in **{ml-app}** > *{data-viz}* in {kib}.
The data comparison view shows you the differences in each field for two
You can find the data drift view in **{ml-app}** > *{data-viz}* in {kib}.
The data drift view shows you the differences in each field for two
different time ranges in a given {data-source}. The view helps you to visualize
the changes in your data over time and enables you to understand its behavior
better.

[role="screenshot"]
image::user/ml/images/ml-data-comparison.png[Data comparison view for {kib} Sample Data Flights ]
image::user/ml/images/ml-data-drift.png[Data drift view in {kib}]

Select a {data-source} that you want to analyze, then select a time range for
the reference and the comparison data in the appearing histogram chart. You can
Expand Down
2 changes: 0 additions & 2 deletions docs/user/monitoring/monitoring-elastic-agent.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
<titleabbrev>Collect monitoring data with {agent}</titleabbrev>
++++

preview::[]

In 8.5 and later, you can use {agent} to collect data about {kib} and ship it to
the monitoring cluster, rather than <<monitoring-metricbeat,using {metricbeat}>>
or routing data through the production cluster as described in
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
},
"engines": {
"node": "20.10.0",
"yarn": "^1.22.21"
"yarn": "^1.22.19"
},
"resolutions": {
"**/@hello-pangea/dnd": "16.2.0",
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -900,6 +900,7 @@ export const getDocLinks = ({ kibanaBranch, buildFlavor }: GetDocLinkOptions): D
integrationsLogstash: `${SERVERLESS_ELASTICSEARCH_DOCS}ingest-data-through-logstash`,
integrationsBeats: `${SERVERLESS_ELASTICSEARCH_DOCS}ingest-data-through-beats`,
integrationsConnectorClient: `${SERVERLESS_ELASTICSEARCH_DOCS}ingest-data-through-integrations-connector-client`,
integrationsConnectorClientAvailableConnectors: `${SERVERLESS_ELASTICSEARCH_DOCS}ingest-data-through-integrations-connector-client#available-connectors`,
integrationsConnectorClientRunFromSource: `${SERVERLESS_ELASTICSEARCH_DOCS}ingest-data-through-integrations-connector-client#run-from-source`,
integrationsConnectorClientRunWithDocker: `${SERVERLESS_ELASTICSEARCH_DOCS}ingest-data-through-integrations-connector-client#run-with-docker`,
gettingStartedExplore: `${SERVERLESS_ELASTICSEARCH_DOCS}get-started`,
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-doc-links/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -623,6 +623,7 @@ export interface DocLinks {
readonly integrations: string;
readonly integrationsBeats: string;
readonly integrationsConnectorClient: string;
readonly integrationsConnectorClientAvailableConnectors: string;
readonly integrationsConnectorClientRunFromSource: string;
readonly integrationsConnectorClientRunWithDocker: string;
readonly integrationsLogstash: string;
Expand Down
232 changes: 220 additions & 12 deletions packages/kbn-handlebars/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,226 @@ it('Handlebars.create', () => {

describe('Handlebars.compileAST', () => {
describe('compiler options', () => {
it('noEscape', () => {
expectTemplate('{{value}}').withInput({ value: '<foo>' }).toCompileTo('&lt;foo&gt;');

expectTemplate('{{value}}')
.withCompileOptions({ noEscape: false })
.withInput({ value: '<foo>' })
.toCompileTo('&lt;foo&gt;');

expectTemplate('{{value}}')
.withCompileOptions({ noEscape: true })
.withInput({ value: '<foo>' })
.toCompileTo('<foo>');
describe('noEscape', () => {
describe('basic', () => {
it('should escape a non-nested value with default value set for `noEscape`', () => {
expectTemplate('{{value}}').withInput({ value: '<foo>' }).toCompileTo('&lt;foo&gt;');
});

it('should escape a nested value with default value set for `noEscape`', () => {
expectTemplate('{{nested.value}}')
.withInput({ nested: { value: '<foo>' } })
.toCompileTo('&lt;foo&gt;');
});

it('should escape a non-nested value with `noEscape` set to false', () => {
expectTemplate('{{value}}')
.withCompileOptions({ noEscape: false })
.withInput({ value: '<foo>' })
.toCompileTo('&lt;foo&gt;');
});

it('should escape a nested value with `noEscape` set to false', () => {
expectTemplate('{{nested.value}}')
.withCompileOptions({ noEscape: false })
.withInput({ nested: { value: '<foo>' } })
.toCompileTo('&lt;foo&gt;');
});

it('should not escape a non-nested value with `noEscape` set to true', () => {
expectTemplate('{{value}}')
.withCompileOptions({ noEscape: true })
.withInput({ value: '<foo>' })
.toCompileTo('<foo>');
});

it('should not escape a nested value with `noEscape` set to true', () => {
expectTemplate('{{nested.value}}')
.withCompileOptions({ noEscape: true })
.withInput({ nested: { value: '<foo>' } })
.toCompileTo('<foo>');
});
});

describe('known helper', () => {
it('should escape a non-nested value with a known helper and default value set for `noEscape`', () => {
expectTemplate('{{#with foo}}{{value}}{{/with}}')
.withInput({ foo: { value: '<bar>' } })
.toCompileTo('&lt;bar&gt;');
});

it('should escape a nested value with a known helper and default value set for `noEscape`', () => {
expectTemplate('{{#with foo}}{{nested.value}}{{/with}}')
.withInput({ foo: { nested: { value: '<bar>' } } })
.toCompileTo('&lt;bar&gt;');
});

it('should escape a non-nested value with a known helper and false value set for `noEscape`', () => {
expectTemplate('{{#with foo}}{{value}}{{/with}}')
.withCompileOptions({ noEscape: false })
.withInput({ foo: { value: '<bar>' } })
.toCompileTo('&lt;bar&gt;');
});

it('should escape a nested value with a known helper and false value set for `noEscape`', () => {
expectTemplate('{{#with foo}}{{nested.value}}{{/with}}')
.withCompileOptions({ noEscape: false })
.withInput({ foo: { nested: { value: '<bar>' } } })
.toCompileTo('&lt;bar&gt;');
});

it('should not escape a non-nested value with a known helper and true value set for `noEscape`', () => {
expectTemplate('{{#with foo}}{{value}}{{/with}}')
.withCompileOptions({ noEscape: true })
.withInput({ foo: { value: '<bar>' } })
.toCompileTo('<bar>');
});

it('should not escape a nested value with a known helper and true value set for `noEscape`', () => {
expectTemplate('{{#with foo}}{{nested.value}}{{/with}}')
.withCompileOptions({ noEscape: true })
.withInput({ foo: { nested: { value: '<bar>' } } })
.toCompileTo('<bar>');
});
});

describe('unknown helper', () => {
it('should escape a non-nested value with an unknown helper and no value set for `noEscape`', () => {
expectTemplate('{{foo value}}')
.withHelper('foo', (value: string) => {
return value + 'baz';
})
.withInput({ value: '<bar>' })
.toCompileTo('&lt;bar&gt;baz');
});

it('should escape a nested value with an unknown helper and no value set for `noEscape`', () => {
expectTemplate('{{foo nested.value}}')
.withHelper('foo', (value: string) => {
return value + 'baz';
})
.withInput({ nested: { value: '<bar>' } })
.toCompileTo('&lt;bar&gt;baz');
});

it('should escape a non-nested value with an unknown helper and false value set for `noEscape`', () => {
expectTemplate('{{foo value}}')
.withHelper('foo', (value: string) => {
return value + 'baz';
})
.withCompileOptions({ noEscape: false })
.withInput({ value: '<bar>' })
.toCompileTo('&lt;bar&gt;baz');
});

it('should escape a nested value with an unknown helper and false value set for `noEscape`', () => {
expectTemplate('{{foo nested.value}}')
.withHelper('foo', (value: string) => {
return value + 'baz';
})
.withCompileOptions({ noEscape: false })
.withInput({ nested: { value: '<bar>' } })
.toCompileTo('&lt;bar&gt;baz');
});

it('should not escape a non-nested value with an unknown helper and true value set for `noEscape`', () => {
expectTemplate('{{foo value}}')
.withHelper('foo', (value: string) => {
return value + 'baz';
})
.withCompileOptions({ noEscape: true })
.withInput({ value: '<bar>' })
.toCompileTo('<bar>baz');
});

it('should not escape a nested value with an unknown helper and true value set for `noEscape`', () => {
expectTemplate('{{foo nested.value}}')
.withHelper('foo', (value: string) => {
return value + 'baz';
})
.withCompileOptions({ noEscape: true })
.withInput({ nested: { value: '<bar>' } })
.toCompileTo('<bar>baz');
});
});

describe('blocks', () => {
it('should escape a non-nested value with a block input and default value for `noEscape`', () => {
expectTemplate('{{#with foo}}{{#../myFunction}}{{value}}{{/../myFunction}}{{/with}}')
.withInput({
foo: { value: '<bar>' },
myFunction() {
return this;
},
})
.toCompileTo('&lt;bar&gt;');
});

it('should escape a non-nested value with an block input and false value set for `noEscape`', () => {
expectTemplate('{{#with foo}}{{#../myFunction}}{{value}}{{/../myFunction}}{{/with}}')
.withInput({
foo: { value: '<bar>' },
myFunction() {
return this;
},
})
.withCompileOptions({ noEscape: false })
.toCompileTo('&lt;bar&gt;');
});

it('should not escape a non-nested value with an block input and true value set for `noEscape`', () => {
expectTemplate('{{#with foo}}{{#../myFunction}}{{value}}{{/../myFunction}}{{/with}}')
.withInput({
foo: { value: '<bar>' },
myFunction() {
return this;
},
})
.withCompileOptions({ noEscape: true })
.toCompileTo('<bar>');
});

it('should escape a nested value with an block input and default value for `noEscape`', () => {
expectTemplate(
'{{#with foo}}{{#../myFunction}}{{nested.value}}{{/../myFunction}}{{/with}}'
)
.withInput({
foo: { nested: { value: '<bar>' } },
myFunction() {
return this;
},
})
.toCompileTo('&lt;bar&gt;');
});

it('should escape a nested value with an block input and false value for `noEscape`', () => {
expectTemplate(
'{{#with foo}}{{#../myFunction}}{{nested.value}}{{/../myFunction}}{{/with}}'
)
.withInput({
foo: { nested: { value: '<bar>' } },
myFunction() {
return this;
},
})
.withCompileOptions({ noEscape: false })
.toCompileTo('&lt;bar&gt;');
});

it('should escape a nested value with an block input and true value for `noEscape`', () => {
expectTemplate(
'{{#with foo}}{{#../myFunction}}{{nested.value}}{{/../myFunction}}{{/with}}'
)
.withInput({
foo: { nested: { value: '<bar>' } },
myFunction() {
return this;
},
})
.withCompileOptions({ noEscape: true })
.toCompileTo('<bar>');
});
});
});
});

Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-handlebars/src/spec/.upstream_git_hash
Original file line number Diff line number Diff line change
@@ -1 +1 @@
eab1d141cb4a1d93375d7380ed070aa1f576a2c9
7de4b41c344a5d702edca93d1841b59642fa32bd
20 changes: 16 additions & 4 deletions packages/kbn-handlebars/src/visitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,18 @@ export class ElasticHandlebarsVisitor extends Handlebars.Visitor {
return this.resolvePath(data, path);
}

private pushToOutputWithEscapeCheck(result: any, node: ProcessableNodeWithPathParts) {
if (
!(node as hbs.AST.MustacheStatement).escaped ||
this.compileOptions.noEscape === true ||
typeof result !== 'string'
) {
this.output.push(result);
} else {
this.output.push(Handlebars.escapeExpression(result));
}
}

private processSimpleNode(node: ProcessableNodeWithPathParts) {
const path = node.path;
// @ts-expect-error strict is not a valid property on PathExpression, but we used in the same way it's also used in the original handlebars
Expand All @@ -415,7 +427,7 @@ export class ElasticHandlebarsVisitor extends Handlebars.Visitor {
if (isBlock(node)) {
this.blockValue(node, lambdaResult);
} else {
this.output.push(lambdaResult);
this.pushToOutputWithEscapeCheck(lambdaResult, node);
}
}

Expand All @@ -435,7 +447,6 @@ export class ElasticHandlebarsVisitor extends Handlebars.Visitor {
private processHelperNode(node: ProcessableNodeWithPathParts) {
const path = node.path;
const name = path.parts[0];

if (this.compileOptions.knownHelpers && this.compileOptions.knownHelpers[name]) {
this.invokeKnownHelper(node);
} else if (this.compileOptions.knownHelpersOnly) {
Expand All @@ -455,7 +466,8 @@ export class ElasticHandlebarsVisitor extends Handlebars.Visitor {
const helper = this.setupHelper(node, name);
// TypeScript: `helper.fn` might be `undefined` at this point, but to match the upstream behavior we call it without any guards
const result = helper.fn!.call(helper.context, ...helper.params, helper.options);
this.output.push(result);

this.pushToOutputWithEscapeCheck(result, node);
}

// Pops off the helper's parameters, invokes the helper,
Expand All @@ -482,7 +494,7 @@ export class ElasticHandlebarsVisitor extends Handlebars.Visitor {
// TypeScript: `helper.fn` might be `undefined` at this point, but to match the upstream behavior we call it without any guards
const result = helper.fn!.call(helper.context, ...helper.params, helper.options);

this.output.push(result);
this.pushToOutputWithEscapeCheck(result, node);
}

private invokePartial(partial: hbs.AST.PartialStatement | hbs.AST.PartialBlockStatement) {
Expand Down
25 changes: 25 additions & 0 deletions packages/kbn-monaco/src/esql/lib/ast/definitions/aggs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,29 @@ export const statsAggregationFunctionDefinitions: FunctionDefinition[] = [
},
],
},
{
name: 'st_centroid',
description: i18n.translate('monaco.esql.definitions.stCentroidDoc', {
defaultMessage: 'Returns the count of distinct values in a field.',
}),
supportedCommands: ['stats'],
signatures: [
{
params: [{ name: 'column', type: 'cartesian_point', noNestingFunctions: true }],
returnType: 'number',
examples: [
`from index | stats result = st_centroid(cartesian_field)`,
`from index | stats st_centroid(cartesian_field)`,
],
},
{
params: [{ name: 'column', type: 'geo_point', noNestingFunctions: true }],
returnType: 'number',
examples: [
`from index | stats result = st_centroid(geo_field)`,
`from index | stats st_centroid(geo_field)`,
],
},
],
},
]);
Loading

0 comments on commit 477348a

Please sign in to comment.