Skip to content

Commit

Permalink
Merge branch 'main' into kbnArchiveDashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Mar 7, 2022
2 parents 7f0e9eb + a24b1fc commit 64ae171
Show file tree
Hide file tree
Showing 283 changed files with 5,243 additions and 4,163 deletions.
4 changes: 2 additions & 2 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,8 @@ x-pack/plugins/session_view @elastic/awp-platform
# Security Asset Management
/x-pack/plugins/osquery @elastic/security-asset-management

# Cloud Posture Security
/x-pack/plugins/cloud_security_posture/ @elastic/cloud-posture-security
# Cloud Security Posture
/x-pack/plugins/cloud_security_posture/ @elastic/cloud-security-posture-control-plane

# Design (at the bottom for specificity of SASS files)
**/*.scss @elastic/kibana-design
Expand Down
31 changes: 31 additions & 0 deletions .github/workflows/add-to-imui-project.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Add to Infra Monitoring UI project
on:
issues:
types:
- labeled
jobs:
add_to_project:
runs-on: ubuntu-latest
if: |
contains(github.event.issue.labels.*.name, 'Team:Infra Monitoring UI') ||
contains(github.event.issue.labels.*.name, 'Feature:Stack Monitoring') ||
contains(github.event.issue.labels.*.name, 'Feature:Logs UI') ||
contains(github.event.issue.labels.*.name, 'Feature:Metrics UI')
steps:
- uses: octokit/graphql-action@v2.x
id: add_to_project
with:
headers: '{"GraphQL-Features": "projects_next_graphql"}'
query: |
mutation add_to_project($projectid:ID!,$contentid:ID!) {
addProjectNextItem(input:{projectId:$projectid contentId:$contentid}) {
projectNextItem {
id
}
}
}
projectid: ${{ env.PROJECT_ID }}
contentid: ${{ github.event.issue.node_id }}
env:
PROJECT_ID: "PN_kwDOAGc3Zs1EEA"
GITHUB_TOKEN: ${{ secrets.PROJECT_ASSIGNER_TOKEN }}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Update multiple documents at once
<b>Signature:</b>

```typescript
bulkUpdate<T = unknown>(objects?: SavedObjectsBulkUpdateObject[]): Promise<SavedObjectsBatchResponse<unknown>>;
bulkUpdate<T = unknown>(objects?: SavedObjectsBulkUpdateObject[]): Promise<SavedObjectsBatchResponse<T>>;
```

## Parameters
Expand All @@ -20,7 +20,7 @@ bulkUpdate<T = unknown>(objects?: SavedObjectsBulkUpdateObject[]): Promise<Saved

<b>Returns:</b>

Promise&lt;SavedObjectsBatchResponse&lt;unknown&gt;&gt;
Promise&lt;SavedObjectsBatchResponse&lt;T&gt;&gt;

The result of the update operation containing both failed and updated saved objects.

Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ Client used to query the elasticsearch cluster.
<b>Signature:</b>

```typescript
export declare type ElasticsearchClient = Omit<Client, 'connectionPool' | 'serializer' | 'extend' | 'child' | 'close' | 'diagnostic'>;
export declare type ElasticsearchClient = Omit<Client, 'connectionPool' | 'serializer' | 'extend' | 'close' | 'diagnostic'>;
```
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 @@ -196,6 +196,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
std_dev: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-extendedstats-aggregation.html`,
sum: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-sum-aggregation.html`,
top_hits: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-top-hits-aggregation.html`,
top_metrics: `${ELASTICSEARCH_DOCS}search-aggregations-metrics-top-metrics.html`,
},
runtimeFields: {
overview: `${ELASTICSEARCH_DOCS}runtime.html`,
Expand Down
20 changes: 12 additions & 8 deletions packages/kbn-type-summarizer/src/lib/source_mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,25 @@ import { tryReadFile } from './helpers/fs';
import { parseJson } from './helpers/json';
import { isNodeModule } from './is_node_module';

type SourceMapConsumerEntry = [ts.SourceFile, BasicSourceMapConsumer | undefined];

export class SourceMapper {
static async forSourceFiles(
log: Logger,
dtsDir: string,
repoRelativePackageDir: string,
sourceFiles: readonly ts.SourceFile[]
) {
const consumers = new Map<ts.SourceFile, BasicSourceMapConsumer | undefined>();

await Promise.all(
sourceFiles.map(async (sourceFile) => {
const entries = await Promise.all(
sourceFiles.map(async (sourceFile): Promise<undefined | SourceMapConsumerEntry> => {
if (isNodeModule(dtsDir, sourceFile.fileName)) {
return;
}

const text = sourceFile.getText();
const match = text.match(/^\/\/#\s*sourceMappingURL=(.*)/im);
if (!match) {
consumers.set(sourceFile, undefined);
return;
return [sourceFile, undefined];
}

const relSourceFile = Path.relative(process.cwd(), sourceFile.fileName);
Expand All @@ -50,11 +49,16 @@ export class SourceMapper {
}

const json = parseJson(sourceJson, `source map at [${relSourceMapPath}]`);
consumers.set(sourceFile, await new SourceMapConsumer(json));
log.debug('loaded sourcemap for', relSourceFile);
return [sourceFile, await new SourceMapConsumer(json)];
})
);

const consumers = new Map(entries.filter((e): e is SourceMapConsumerEntry => !!e));
log.debug(
'loaded sourcemaps for',
Array.from(consumers.keys()).map((s) => Path.relative(process.cwd(), s.fileName))
);

return new SourceMapper(consumers, repoRelativePackageDir);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ it('prints basic class correctly', async () => {
}
`);
expect(output.logs).toMatchInlineSnapshot(`
"debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts
"debug loaded sourcemaps for [ 'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts' ]
debug Ignoring 1 global declarations for \\"Record\\"
debug Ignoring 5 global declarations for \\"Promise\\"
"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ it('prints the function declaration, including comments', async () => {
}
`);
expect(result.logs).toMatchInlineSnapshot(`
"debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/bar.d.ts
debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts
"debug loaded sourcemaps for [
'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/bar.d.ts',
'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts'
]
"
`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ it('output type links to named import from node modules', async () => {
}
`);
expect(output.logs).toMatchInlineSnapshot(`
"debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts
"debug loaded sourcemaps for [ 'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts' ]
"
`);
});
Expand Down Expand Up @@ -84,7 +84,7 @@ it('output type links to default import from node modules', async () => {
}
`);
expect(output.logs).toMatchInlineSnapshot(`
"debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts
"debug loaded sourcemaps for [ 'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts' ]
"
`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ it('prints the whole interface, including comments', async () => {
}
`);
expect(result.logs).toMatchInlineSnapshot(`
"debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts
"debug loaded sourcemaps for [ 'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts' ]
debug Ignoring 5 global declarations for \\"Promise\\"
"
`);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ it('collects references from source files which contribute to result', async ()
}
`);
expect(result.logs).toMatchInlineSnapshot(`
"debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/files/foo.d.ts
debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/files/index.d.ts
debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts
"debug loaded sourcemaps for [
'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/files/foo.d.ts',
'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/files/index.d.ts',
'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts'
]
debug Ignoring 5 global declarations for \\"Promise\\"
debug Ignoring 4 global declarations for \\"Symbol\\"
debug Ignoring 2 global declarations for \\"Component\\"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ it('prints basic type alias', async () => {
}
`);
expect(output.logs).toMatchInlineSnapshot(`
"debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts
"debug loaded sourcemaps for [ 'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts' ]
"
`);
});
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ it('prints basic variable exports with sourcemaps', async () => {
}
`);
expect(output.logs).toMatchInlineSnapshot(`
"debug loaded sourcemap for packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts
"debug loaded sourcemaps for [ 'packages/kbn-type-summarizer/tests/__tmp__/dist_dts/index.d.ts' ]
"
`);
});
2 changes: 1 addition & 1 deletion src/core/public/public.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ export class SavedObjectsClient {
}>) => Promise<{
resolved_objects: ResolvedSimpleSavedObject<T>[];
}>;
bulkUpdate<T = unknown>(objects?: SavedObjectsBulkUpdateObject[]): Promise<SavedObjectsBatchResponse<unknown>>;
bulkUpdate<T = unknown>(objects?: SavedObjectsBulkUpdateObject[]): Promise<SavedObjectsBatchResponse<T>>;
create: <T = unknown>(type: string, attributes: T, options?: SavedObjectsCreateOptions) => Promise<SimpleSavedObject<T>>;
// Warning: (ae-forgotten-export) The symbol "SavedObjectsDeleteOptions" needs to be exported by the entry point index.d.ts
// Warning: (ae-forgotten-export) The symbol "SavedObjectsClientContract" needs to be exported by the entry point index.d.ts
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/saved_objects/saved_objects_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ export class SavedObjectsClient {
return renameKeys<
PromiseType<ReturnType<SavedObjectsApi['bulkUpdate']>>,
SavedObjectsBatchResponse
>({ saved_objects: 'savedObjects' }, resp) as SavedObjectsBatchResponse;
>({ saved_objects: 'savedObjects' }, resp) as SavedObjectsBatchResponse<T>;
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/core/server/elasticsearch/client/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import type { Client } from '@elastic/elasticsearch';
*/
export type ElasticsearchClient = Omit<
Client,
'connectionPool' | 'serializer' | 'extend' | 'child' | 'close' | 'diagnostic'
'connectionPool' | 'serializer' | 'extend' | 'close' | 'diagnostic'
>;

/**
Expand Down
2 changes: 1 addition & 1 deletion src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@ export { EcsEventOutcome }
export { EcsEventType }

// @public
export type ElasticsearchClient = Omit<Client, 'connectionPool' | 'serializer' | 'extend' | 'child' | 'close' | 'diagnostic'>;
export type ElasticsearchClient = Omit<Client, 'connectionPool' | 'serializer' | 'extend' | 'close' | 'diagnostic'>;

// @public
export type ElasticsearchClientConfig = Pick<ElasticsearchConfig, 'customHeaders' | 'compression' | 'sniffOnStart' | 'sniffOnConnectionFault' | 'requestHeadersWhitelist' | 'sniffInterval' | 'hosts' | 'username' | 'password' | 'serviceAccountToken'> & {
Expand Down
14 changes: 5 additions & 9 deletions src/core/server/ui_settings/settings/date_formats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export const getDateFormatSettings = (): Record<string, UiSettingsParams> => {
}),
value: 'MMM D, YYYY @ HH:mm:ss.SSS',
description: i18n.translate('core.ui_settings.params.dateFormatText', {
defaultMessage: 'When displaying a pretty formatted date, use this {formatLink}',
defaultMessage: 'The {formatLink} for pretty formatted dates.',
description:
'Part of composite text: core.ui_settings.params.dateFormatText + ' +
'core.ui_settings.params.dateFormat.optionsLinkText',
Expand All @@ -48,15 +48,11 @@ export const getDateFormatSettings = (): Record<string, UiSettingsParams> => {
},
'dateFormat:tz': {
name: i18n.translate('core.ui_settings.params.dateFormat.timezoneTitle', {
defaultMessage: 'Timezone for date formatting',
defaultMessage: 'Time zone',
}),
value: 'Browser',
description: i18n.translate('core.ui_settings.params.dateFormat.timezoneText', {
defaultMessage:
'Which timezone should be used. {defaultOption} will use the timezone detected by your browser.',
values: {
defaultOption: '"Browser"',
},
defaultMessage: 'The default time zone.',
}),
type: 'select',
options: timezones,
Expand Down Expand Up @@ -115,7 +111,7 @@ export const getDateFormatSettings = (): Record<string, UiSettingsParams> => {
}),
value: defaultWeekday,
description: i18n.translate('core.ui_settings.params.dateFormat.dayOfWeekText', {
defaultMessage: 'What day should weeks start on?',
defaultMessage: 'The day that starts the week.',
}),
type: 'select',
options: weekdays,
Expand All @@ -141,7 +137,7 @@ export const getDateFormatSettings = (): Record<string, UiSettingsParams> => {
}),
value: 'MMM D, YYYY @ HH:mm:ss.SSSSSSSSS',
description: i18n.translate('core.ui_settings.params.dateNanosFormatText', {
defaultMessage: 'Used for the {dateNanosLink} datatype of Elasticsearch',
defaultMessage: 'The format for {dateNanosLink} data.',
values: {
dateNanosLink:
'<a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/date_nanos.html" target="_blank" rel="noopener noreferrer">' +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export function DevToolsSettingsModal(props: Props) {
const [fields, setFields] = useState(props.settings.autocomplete.fields);
const [indices, setIndices] = useState(props.settings.autocomplete.indices);
const [templates, setTemplates] = useState(props.settings.autocomplete.templates);
const [dataStreams, setDataStreams] = useState(props.settings.autocomplete.dataStreams);
const [polling, setPolling] = useState(props.settings.polling);
const [pollInterval, setPollInterval] = useState(props.settings.pollInterval);
const [tripleQuotes, setTripleQuotes] = useState(props.settings.tripleQuotes);
Expand Down Expand Up @@ -97,12 +98,20 @@ export function DevToolsSettingsModal(props: Props) {
}),
stateSetter: setTemplates,
},
{
id: 'dataStreams',
label: i18n.translate('console.settingsPage.dataStreamsLabelText', {
defaultMessage: 'Data streams',
}),
stateSetter: setDataStreams,
},
];

const checkboxIdToSelectedMap = {
fields,
indices,
templates,
dataStreams,
};

const onAutocompleteChange = (optionId: AutocompleteOptions) => {
Expand All @@ -120,6 +129,7 @@ export function DevToolsSettingsModal(props: Props) {
fields,
indices,
templates,
dataStreams,
},
polling,
pollInterval,
Expand Down Expand Up @@ -170,6 +180,7 @@ export function DevToolsSettingsModal(props: Props) {
fields,
indices,
templates,
dataStreams,
});
}}
>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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 { getDataStreams } from '../../mappings/mappings';
import { ListComponent } from './list_component';

export class DataStreamAutocompleteComponent extends ListComponent {
constructor(name, parent, multiValued) {
super(name, getDataStreams, parent, multiValued);
}

getContextKey() {
return 'data_stream';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,5 @@ export { IdAutocompleteComponent } from './id_autocomplete_component';
export { UsernameAutocompleteComponent } from './username_autocomplete_component';
export { IndexTemplateAutocompleteComponent } from './index_template_autocomplete_component';
export { ComponentTemplateAutocompleteComponent } from './component_template_autocomplete_component';
export { DataStreamAutocompleteComponent } from './data_stream_autocomplete_component';
export * from './legacy';
4 changes: 4 additions & 0 deletions src/plugins/console/public/lib/kb/kb.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
UsernameAutocompleteComponent,
IndexTemplateAutocompleteComponent,
ComponentTemplateAutocompleteComponent,
DataStreamAutocompleteComponent,
} from '../autocomplete/components';

import $ from 'jquery';
Expand Down Expand Up @@ -94,6 +95,9 @@ const parametrizedComponentFactories = {
component_template: function (name, parent) {
return new ComponentTemplateAutocompleteComponent(name, parent);
},
data_stream: function (name, parent) {
return new DataStreamAutocompleteComponent(name, parent);
},
};

export function getUnmatchedEndpointComponents() {
Expand Down
9 changes: 9 additions & 0 deletions src/plugins/console/public/lib/mappings/mapping.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -266,4 +266,13 @@ describe('Mappings', () => {
expect(mappings.getIndexTemplates()).toEqual(expectedResult);
expect(mappings.getComponentTemplates()).toEqual(expectedResult);
});

test('Data streams', function () {
mappings.loadDataStreams({
data_streams: [{ name: 'test_index1' }, { name: 'test_index2' }, { name: 'test_index3' }],
});

const expectedResult = ['test_index1', 'test_index2', 'test_index3'];
expect(mappings.getDataStreams()).toEqual(expectedResult);
});
});
Loading

0 comments on commit 64ae171

Please sign in to comment.