-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RAM][Maintenance Window] Maintenance window scoped query frontend changes #171949
Merged
JiaweiWu
merged 20 commits into
elastic:main
from
JiaweiWu:issue-164255-mw-filtering-fe-and-api
Dec 4, 2023
Merged
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
08d7210
MW scoped query API and schema changes
JiaweiWu eee5cb8
Merge branch 'main' into mw-scoped-query-api-changes
kibanamachine 61ff8d4
WIP
JiaweiWu 4a97122
WIP packages
JiaweiWu 6f80f82
Merge branch 'main' into issue-164255-mw-filtering-fe-and-api
JiaweiWu a7165db
Fix packages
JiaweiWu c6f17fe
Merge branch 'main' into issue-164255-mw-filtering-fe-and-api
JiaweiWu 0553e5a
MW scoped query FE changes
JiaweiWu 3977779
Merge branch 'main' into issue-164255-mw-filtering-fe-and-api
kibanamachine 164349b
[CI] Auto-commit changed files from 'node scripts/lint_ts_projects --…
kibanamachine 00ebe60
[CI] Auto-commit changed files from 'node scripts/generate codeowners'
kibanamachine d79cd5e
[CI] Auto-commit changed files from 'node scripts/eslint --no-cache -…
kibanamachine ce9f7f7
fix translations
JiaweiWu cf4cfdc
Fix tests
JiaweiWu 2a09c42
Merge branch 'main' into issue-164255-mw-filtering-fe-and-api
JiaweiWu f3ac0d9
merge conflicts
JiaweiWu abcd3a1
Put changes behind flag
JiaweiWu e0c998a
Merge branch 'main' into issue-164255-mw-filtering-fe-and-api
kibanamachine 276927e
Merge branch 'main' into issue-164255-mw-filtering-fe-and-api
JiaweiWu 7afeb0b
Address comments
JiaweiWu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @kbn/actions-types | ||
|
||
Empty package generated by @kbn/generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from './rewrite_request_case_types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../..', | ||
roots: ['<rootDir>/packages/kbn-actions-types'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/actions-types", | ||
"owner": "@elastic/response-ops" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@kbn/actions-types", | ||
"private": true, | ||
"version": "1.0.0", | ||
"license": "SSPL-1.0 OR Elastic License 2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
type RenameActionToConnector<K extends string> = K extends `actionTypeId` | ||
? `connectorTypeId` | ||
: K extends `actionId` | ||
? `connectorId` | ||
: K; | ||
|
||
export type AsApiContract<T> = { | ||
[K in keyof T as CamelToSnake<RenameActionToConnector<Extract<K, string>>>]: K extends 'frequency' | ||
? AsApiContract<T[K]> | ||
: T[K]; | ||
}; | ||
|
||
export type RewriteRequestCase<T> = (requested: AsApiContract<T>) => T; | ||
export type RewriteResponseCase<T> = ( | ||
responded: T | ||
) => T extends Array<infer Item> ? Array<AsApiContract<Item>> : AsApiContract<T>; | ||
|
||
/** | ||
* This type maps Camel Case strings into their Snake Case version. | ||
* This is achieved by checking each character and, if it is an uppercase character, it is mapped to an | ||
* underscore followed by a lowercase one. | ||
* | ||
* The reason there are two ternaries is that, for perfformance reasons, TS limits its | ||
* character parsing to ~15 characters. | ||
* To get around this we use the second turnery to parse 2 characters at a time, which allows us to support | ||
* strings that are 30 characters long. | ||
* | ||
* If you get the TS #2589 error ("Type instantiation is excessively deep and possibly infinite") then most | ||
* likely you have a string that's longer than 30 characters. | ||
* Address this by reducing the length if possible, otherwise, you'll need to add a 3rd ternary which | ||
* parses 3 chars at a time :grimace: | ||
* | ||
* For more details see this PR comment: https://github.com/microsoft/TypeScript/pull/40336#issuecomment-686723087 | ||
*/ | ||
type CamelToSnake<T extends string> = string extends T | ||
? string | ||
: T extends `${infer C0}${infer C1}${infer R}` | ||
? `${C0 extends Uppercase<C0> ? '_' : ''}${Lowercase<C0>}${C1 extends Uppercase<C1> | ||
? '_' | ||
: ''}${Lowercase<C1>}${CamelToSnake<R>}` | ||
: T extends `${infer C0}${infer R}` | ||
? `${C0 extends Uppercase<C0> ? '_' : ''}${Lowercase<C0>}${CamelToSnake<R>}` | ||
: ''; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "target/types", | ||
"types": [ | ||
"jest", | ||
"node", | ||
"react" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
], | ||
"exclude": [ | ||
"target/**/*" | ||
], | ||
"kbn_references": [] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# @kbn/alerting-types | ||
|
||
Empty package generated by @kbn/generate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export interface ActionGroup<ActionGroupIds extends string> { | ||
id: ActionGroupIds; | ||
name: string; | ||
} |
21 changes: 21 additions & 0 deletions
21
packages/kbn-alerting-types/builtin_action_groups_types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/* | ||
* 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 { i18n } from '@kbn/i18n'; | ||
import { ActionGroup } from './action_group_types'; | ||
|
||
export const RecoveredActionGroup: Readonly<ActionGroup<'recovered'>> = Object.freeze({ | ||
id: 'recovered', | ||
name: i18n.translate('alertingTypes.builtinActionGroups.recovered', { | ||
defaultMessage: 'Recovered', | ||
}), | ||
}); | ||
|
||
export type DefaultActionGroupId = 'default'; | ||
|
||
export type RecoveredActionGroupId = typeof RecoveredActionGroup['id']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export * from './builtin_action_groups_types'; | ||
export * from './rule_type'; | ||
export * from './action_group_types'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
module.exports = { | ||
preset: '@kbn/test', | ||
rootDir: '../..', | ||
roots: ['<rootDir>/packages/kbn-alerting-types'], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"type": "shared-common", | ||
"id": "@kbn/alerting-types", | ||
"owner": "@elastic/response-ops" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"name": "@kbn/alerting-types", | ||
"private": true, | ||
"version": "1.0.0", | ||
"license": "SSPL-1.0 OR Elastic License 2.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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 type { LicenseType } from '@kbn/licensing-plugin/common/types'; | ||
import type { RecoveredActionGroupId, DefaultActionGroupId } from './builtin_action_groups_types'; | ||
import { ActionGroup } from './action_group_types'; | ||
|
||
interface ConsumerPrivileges { | ||
read: boolean; | ||
all: boolean; | ||
} | ||
|
||
export interface ActionVariable { | ||
name: string; | ||
description: string; | ||
deprecated?: boolean; | ||
useWithTripleBracesInTemplates?: boolean; | ||
usesPublicBaseUrl?: boolean; | ||
} | ||
|
||
export interface RuleType< | ||
ActionGroupIds extends Exclude<string, RecoveredActionGroupId> = DefaultActionGroupId, | ||
RecoveryActionGroupId extends string = RecoveredActionGroupId | ||
> { | ||
id: string; | ||
name: string; | ||
actionGroups: Array<ActionGroup<ActionGroupIds>>; | ||
recoveryActionGroup: ActionGroup<RecoveryActionGroupId>; | ||
actionVariables: { | ||
context: ActionVariable[]; | ||
state: ActionVariable[]; | ||
params: ActionVariable[]; | ||
}; | ||
defaultActionGroupId: ActionGroupIds; | ||
category: string; | ||
producer: string; | ||
minimumLicenseRequired: LicenseType; | ||
isExportable: boolean; | ||
ruleTaskTimeout?: string; | ||
defaultScheduleInterval?: string; | ||
doesSetRecoveryContext?: boolean; | ||
enabledInLicense: boolean; | ||
authorizedConsumers: Record<string, ConsumerPrivileges>; | ||
} | ||
|
||
export type ActionGroupIdsOf<T> = T extends ActionGroup<infer groups> | ||
? groups | ||
: T extends Readonly<ActionGroup<infer groups>> | ||
? groups | ||
: never; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"extends": "../../tsconfig.base.json", | ||
"compilerOptions": { | ||
"outDir": "target/types", | ||
"types": [ | ||
"jest", | ||
"node", | ||
"react" | ||
] | ||
}, | ||
"include": [ | ||
"**/*.ts", | ||
"**/*.tsx", | ||
], | ||
"exclude": [ | ||
"target/**/*" | ||
], | ||
"kbn_references": [ | ||
"@kbn/i18n", | ||
"@kbn/licensing-plugin", | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/kbn-alerts-ui-shared/src/alerts_search_bar/apis/fetch_aad_fields.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/* | ||
* 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 type { HttpStart } from '@kbn/core/public'; | ||
import type { DataViewField } from '@kbn/data-views-plugin/common'; | ||
import { BASE_RAC_ALERTS_API_PATH, EMPTY_AAD_FIELDS } from '../constants'; | ||
|
||
export async function fetchAadFields({ | ||
http, | ||
ruleTypeId, | ||
}: { | ||
http: HttpStart; | ||
ruleTypeId?: string; | ||
}): Promise<DataViewField[]> { | ||
if (!ruleTypeId) return EMPTY_AAD_FIELDS; | ||
const fields = await http.get<DataViewField[]>(`${BASE_RAC_ALERTS_API_PATH}/aad_fields`, { | ||
query: { ruleTypeId }, | ||
}); | ||
|
||
return fields; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we need to add some explanation for future user?