Skip to content

Commit

Permalink
Merge branch 'main' into fleet/165672-serverless-proxies-support
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine committed Feb 5, 2024
2 parents a3a5562 + 6fc6950 commit 2df7a75
Show file tree
Hide file tree
Showing 122 changed files with 3,080 additions and 1,172 deletions.
46 changes: 46 additions & 0 deletions docs/CHANGELOG.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

Review important information about the {kib} 8.x releases.

* <<release-notes-8.12.1>>
* <<release-notes-8.12.0>>
* <<release-notes-8.11.4>>
* <<release-notes-8.11.3>>
Expand Down Expand Up @@ -58,6 +59,51 @@ Review important information about the {kib} 8.x releases.
* <<release-notes-8.0.0-alpha1>>

--
[[release-notes-8.12.1]]
== {kib} 8.12.1

The 8.12.1 release includes the following enhancements and bug fixes.

[float]
[[enhancement-v8.12.1]]
=== Enhancements

Elastic Security::
For the Elastic Security 8.12.1 release information, refer to {security-guide}/release-notes.html[_Elastic Security Solution Release Notes_].
Observability::
* Adds `defer_validation: true` to transforms on creation to stop errors when the destination index doesn't exist yet ({kibana-pull}174463[#174463]).

[float]
[[fixes-v8.12.1]]
=== Bug Fixes
Alerting::
* Fixes context variables not being passed in to the action parameters when an alert- as-data document is available ({kibana-pull}175682[#175682]).
* Fixes the Rules page loosing user selections when navigating back ({kibana-pull}174954[#174954]).
* Fixes the custom threshold rendering in the create rule flyout ({kibana-pull}174982[#174982]).
APM::
* Fixes a transactions error link for mobile ({kibana-pull}174655[#174655]).
* Increases the number of maximum function calls from 3 to 5 ({kibana-pull}175588[#175588]).
Dashboard::
* Fixes a caching issue that caused problems updating dashboard information ({kibana-pull}175635[#175635]).
Elastic Security::
For the Elastic Security 8.12.1 release information, refer to {security-guide}/release-notes.html[_Elastic Security Solution Release Notes_].
Fleet::
* Fixes the display of category label on the Integration overview page ({kibana-pull}176141[#176141]).
* Fixes conflicting dynamic template mappings for intermediate objects ({kibana-pull}175970[#175970]).
* Fixes reserved keys for Elasticsearch output YAML box ({kibana-pull}175901[#175901]).
* Prevent deletion of agent policies with inactive agents from UI ({kibana-pull}175815[#175815]).
* Fixes incorrect count of agents in bulk actions ({kibana-pull}175318[#175318]).
* Fixes a custom integrations not displaying on the Installed integrations page ({kibana-pull}174804[#174804]).
Lens & Visualizations::
* Fixes a validation error for invalid formula and math columns in *Lens* ({kibana-pull}175644[#175644]).
Machine Learning::
* Fixes Allocation rendering for failed deployments ({kibana-pull}174882[#174882]).
* Fixes an issue where a user could create an anomaly rule but couldn't see it or interact with the rule via stack management ({kibana-pull}174791[#174791]).
Security::
* Fixes API Key table sorting ({kibana-pull}175813[#175813]).
* Ensures all API Keys have a defined name ({kibana-pull}175721[#175721]).
* Fixes an issue with `@kbn-handlebars`, where nested inputs were not being escaped properly ({kibana-pull}175490[#175490]).

[[release-notes-8.12.0]]
== {kib} 8.12.0

Expand Down
2 changes: 1 addition & 1 deletion docs/developer/plugin-list.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ Elastic.
|{kib-repo}blob/{branch}/x-pack/plugins/observability_solution/observability_logs_explorer/README.md[observabilityLogsExplorer]
|This plugin provides an app based on the LogExplorer component from the logs_explorer plugin, but adds observability-specific affordances.
|This plugin provides an app based on the LogsExplorer component from the logs_explorer plugin, but adds observability-specific affordances.
|{kib-repo}blob/{branch}/x-pack/plugins/observability_onboarding/README.md[observabilityOnboarding]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export abstract class BaseUiSettingsClient implements IUiSettingsClient {
}

async validate(key: string, value: unknown) {
if (!value) {
if (value == null) {
throw new ValidationBadValueError();
}
const definition = this.defaults[key];
Expand Down
10 changes: 8 additions & 2 deletions packages/kbn-monaco/src/esql/lib/ast/ast_factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,14 @@ export class AstListener implements ESQLParserListener {
exitStatsCommand(ctx: StatsCommandContext) {
const command = createCommand('stats', ctx);
this.ast.push(command);
const [statsExpr, byExpr] = ctx.fields();
command.args.push(...collectAllFieldsStatements(statsExpr), ...visitByOption(ctx, byExpr));
const fields = ctx.fields();
// STATS expression is optional
if (ctx._stats) {
command.args.push(...collectAllFieldsStatements(fields[0]));
}
if (ctx._grouping) {
command.args.push(...visitByOption(ctx, ctx._stats ? fields[1] : fields[0]));
}
}

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/kbn-monaco/src/esql/lib/ast/ast_walker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ function visitOperatorExpression(
if (ctx instanceof ArithmeticUnaryContext) {
const arg = visitOperatorExpression(ctx.operatorExpression());
// this is a number sign thing
const fn = createFunction('multiply', ctx);
const fn = createFunction('*', ctx);
fn.args.push(createFakeMultiplyLiteral(ctx));
if (arg) {
fn.args.push(arg);
Expand Down Expand Up @@ -443,7 +443,7 @@ function collectIsNullExpression(ctx: BooleanExpressionContext) {
return [];
}
const negate = ctx.NOT();
const fnName = `${negate ? 'not_' : ''}is_null`;
const fnName = `is${negate ? ' not ' : ' '}null`;
const fn = createFunction(fnName, ctx);
const arg = visitValueExpression(ctx.valueExpression());
if (arg) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { builtinFunctions } from '../definitions/builtin';
import { statsAggregationFunctionDefinitions } from '../definitions/aggs';
import { chronoLiterals, timeLiterals } from '../definitions/literals';
import { commandDefinitions } from '../definitions/commands';
import { TRIGGER_SUGGESTION_COMMAND } from './factories';

const triggerCharacters = [',', '(', '=', ' '];

Expand Down Expand Up @@ -130,9 +131,12 @@ function getFunctionSignaturesByReturnType(
}
return true;
})
.map(({ type, name, signatures, ...defRest }) =>
type === 'builtin' ? `${name} $0` : `${name}($0)`
);
.map(({ type, name, signatures }) => {
if (type === 'builtin') {
return signatures.some(({ params }) => params.length > 1) ? `${name} $0` : name;
}
return `${name}($0)`;
});
}

function getFieldNamesByType(requestedType: string) {
Expand Down Expand Up @@ -287,30 +291,33 @@ describe('autocomplete', () => {
const sourceCommands = ['row', 'from', 'show'];

describe('New command', () => {
testSuggestions(' ', sourceCommands);
testSuggestions(
' ',
sourceCommands.map((name) => name + ' $0')
);
testSuggestions(
'from a | ',
commandDefinitions
.filter(({ name }) => !sourceCommands.includes(name))
.map(({ name }) => name)
.map(({ name }) => name + ' $0')
);
testSuggestions(
'from a [metadata _id] | ',
commandDefinitions
.filter(({ name }) => !sourceCommands.includes(name))
.map(({ name }) => name)
.map(({ name }) => name + ' $0')
);
testSuggestions(
'from a | eval var0 = a | ',
commandDefinitions
.filter(({ name }) => !sourceCommands.includes(name))
.map(({ name }) => name)
.map(({ name }) => name + ' $0')
);
testSuggestions(
'from a [metadata _id] | eval var0 = a | ',
commandDefinitions
.filter(({ name }) => !sourceCommands.includes(name))
.map(({ name }) => name)
.map(({ name }) => name + ' $0')
);
});

Expand All @@ -319,7 +326,10 @@ describe('autocomplete', () => {
.filter(({ hidden }) => !hidden)
.map(({ name, suggestedAs }) => suggestedAs || name);
// Monaco will filter further down here
testSuggestions('f', sourceCommands);
testSuggestions(
'f',
sourceCommands.map((name) => name + ' $0')
);
testSuggestions('from ', suggestedIndexes);
testSuggestions('from a,', suggestedIndexes);
testSuggestions('from a, b ', ['[metadata $0 ]', '|', ',']);
Expand Down Expand Up @@ -1038,4 +1048,40 @@ describe('autocomplete', () => {
expect(callbackMocks.getFieldsFor).toHaveBeenCalledWith({ query: 'from a' });
});
});

describe('auto triggers', () => {
function getSuggestionsFor(statement: string) {
const callbackMocks = createCustomCallbackMocks(undefined, undefined, undefined);
const triggerOffset = statement.lastIndexOf(' ') + 1; // drop <here>
const context = createSuggestContext(statement, statement[triggerOffset]);
const { model, position } = createModelAndPosition(statement, triggerOffset + 2);
return suggest(
model,
position,
context,
async (text) => (text ? await getAstAndErrors(text) : { ast: [], errors: [] }),
callbackMocks
);
}
it('should trigger further suggestions for functions', async () => {
const suggestions = await getSuggestionsFor('from a | eval ');
// test that all functions will retrigger suggestions
expect(
suggestions
.filter(({ kind }) => kind === 1)
.every(({ command }) => command === TRIGGER_SUGGESTION_COMMAND)
).toBeTruthy();
// now test that non-function won't retrigger
expect(
suggestions.filter(({ kind }) => kind !== 1).every(({ command }) => command == null)
).toBeTruthy();
});
it('should trigger further suggestions for commands', async () => {
const suggestions = await getSuggestionsFor('from a | ');
// test that all commands will retrigger suggestions
expect(
suggestions.every(({ command }) => command === TRIGGER_SUGGESTION_COMMAND)
).toBeTruthy();
});
});
});
51 changes: 43 additions & 8 deletions packages/kbn-monaco/src/esql/lib/ast/autocomplete/autocomplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ export async function suggest(
context.triggerCharacter === ',' ||
(context.triggerKind === 0 && unclosedRoundBrackets === 0) ||
(context.triggerCharacter === ' ' &&
// make this more robust
(isMathFunction(innerText, offset) || isComma(innerText[offset - 2])))
) {
finalText = `${innerText.substring(0, offset)}${EDITOR_MARKER}${innerText.substring(offset)}`;
Expand Down Expand Up @@ -324,6 +323,14 @@ function findNewVariable(variables: Map<string, ESQLVariable[]>) {
return name;
}

function workoutBuiltinOptions(
nodeArg: ESQLAstItem,
references: Pick<ReferenceMaps, 'fields' | 'variables'>
): { skipAssign: boolean } {
// skip assign operator if it's a function or an existing field to avoid promoting shadowing
return { skipAssign: Boolean(!isColumnItem(nodeArg) || getColumnHit(nodeArg.name, references)) };
}

function areCurrentArgsValid(
command: ESQLCommand,
node: ESQLAstItem,
Expand Down Expand Up @@ -617,7 +624,13 @@ async function getExpressionSuggestionsByType(
const nodeArgType = extractFinalTypeFromArg(nodeArg, references);
if (nodeArgType) {
suggestions.push(
...getBuiltinCompatibleFunctionDefinition(command.name, undefined, nodeArgType)
...getBuiltinCompatibleFunctionDefinition(
command.name,
undefined,
nodeArgType,
undefined,
workoutBuiltinOptions(nodeArg, references)
)
);
} else {
suggestions.push(getAssignmentDefinitionCompletitionItem());
Expand Down Expand Up @@ -663,7 +676,13 @@ async function getExpressionSuggestionsByType(
const [rightArg] = nodeArg.args[1] as [ESQLSingleAstItem];
const nodeArgType = extractFinalTypeFromArg(rightArg, references);
suggestions.push(
...getBuiltinCompatibleFunctionDefinition(command.name, undefined, nodeArgType || 'any')
...getBuiltinCompatibleFunctionDefinition(
command.name,
undefined,
nodeArgType || 'any',
undefined,
workoutBuiltinOptions(rightArg, references)
)
);
if (nodeArgType === 'number' && isLiteralItem(rightArg)) {
// ... EVAL var = 1 <suggest>
Expand Down Expand Up @@ -798,7 +817,13 @@ async function getExpressionSuggestionsByType(
} else {
// i.e. ... | <COMMAND> field <suggest>
suggestions.push(
...getBuiltinCompatibleFunctionDefinition(command.name, undefined, nodeArgType)
...getBuiltinCompatibleFunctionDefinition(
command.name,
undefined,
nodeArgType,
undefined,
workoutBuiltinOptions(nodeArg, references)
)
);
}
}
Expand Down Expand Up @@ -874,7 +899,13 @@ async function getBuiltinFunctionNextArgument(
// i.e. ... | <COMMAND> field > 0 <suggest>
// i.e. ... | <COMMAND> field + otherN <suggest>
suggestions.push(
...getBuiltinCompatibleFunctionDefinition(command.name, option?.name, nodeArgType || 'any')
...getBuiltinCompatibleFunctionDefinition(
command.name,
option?.name,
nodeArgType || 'any',
undefined,
workoutBuiltinOptions(nodeArg, references)
)
);
} else {
// i.e. ... | <COMMAND> field >= <suggest>
Expand Down Expand Up @@ -922,9 +953,13 @@ async function getBuiltinFunctionNextArgument(
// suggest something to complete the builtin function
if (nestedType !== argDef.type) {
suggestions.push(
...getBuiltinCompatibleFunctionDefinition(command.name, undefined, nestedType, [
argDef.type,
])
...getBuiltinCompatibleFunctionDefinition(
command.name,
undefined,
nestedType,
[argDef.type],
workoutBuiltinOptions(nodeArg, references)
)
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,18 @@ export const getBuiltinCompatibleFunctionDefinition = (
command: string,
option: string | undefined,
argType: string,
returnTypes?: string[]
returnTypes?: string[],
{ skipAssign }: { skipAssign?: boolean } = {}
): AutocompleteCommandDefinition[] => {
const compatibleFunctions = builtinFunctions.filter(
({ name, supportedCommands, supportedOptions, signatures, ignoreAsSuggestion }) =>
!ignoreAsSuggestion &&
!/not_/.test(name) &&
(!skipAssign || name !== '=') &&
(option ? supportedOptions?.includes(option) : supportedCommands.includes(command)) &&
signatures.some(
({ params }) => !params.length || params.some((pArg) => pArg.type === argType)
({ params }) =>
!params.length || params.some((pArg) => pArg.type === argType || pArg.type === 'any')
)
);
if (!returnTypes) {
Expand All @@ -100,7 +103,7 @@ function buildCharCompleteItem(
return {
label,
insertText: quoted ? `"${label}"` : label,
kind: 1,
kind: 11,
detail,
sortText,
};
Expand Down Expand Up @@ -140,7 +143,7 @@ export const listCompleteItem: AutocompleteCommandDefinition = {
label: '( ... )',
insertText: '( $0 )',
insertTextRules: 4,
kind: 1,
kind: 11,
detail: i18n.translate('monaco.esql.autocomplete.listDoc', {
defaultMessage: 'List of items ( ...)',
}),
Expand Down
Loading

0 comments on commit 2df7a75

Please sign in to comment.