Skip to content

Commit

Permalink
Merge branch 'master' into move_popularize_field_to_discover
Browse files Browse the repository at this point in the history
  • Loading branch information
mattkime committed Sep 29, 2020
2 parents d6dc17a + 9a9a8b0 commit 212304e
Show file tree
Hide file tree
Showing 160 changed files with 8,440 additions and 1,587 deletions.
10 changes: 0 additions & 10 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -329,16 +329,6 @@ x-pack/plugins/telemetry_collection_xpack/schema/xpack_plugins.json @elastic/kib
# Shared
/x-pack/plugins/enterprise_search/ @elastic/enterprise-search-frontend
/x-pack/test/functional_enterprise_search/ @elastic/enterprise-search-frontend
# App Search
/x-pack/plugins/enterprise_search/public/applications/app_search @elastic/app-search-frontend
/x-pack/plugins/enterprise_search/server/routes/app_search @elastic/app-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/app_search @elastic/app-search-frontend
/x-pack/plugins/enterprise_search/server/saved_objects/app_search @elastic/app-search-frontend
# Workplace Search
/x-pack/plugins/enterprise_search/public/applications/workplace_search @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/server/routes/workplace_search @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/server/collectors/workplace_search @elastic/workplace-search-frontend
/x-pack/plugins/enterprise_search/server/saved_objects/workplace_search @elastic/workplace-search-frontend

# Elasticsearch UI
/src/plugins/dev_tools/ @elastic/es-ui
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export interface ISearchStart<SearchStrategyRequest extends IKibanaSearchRequest
| [aggs](./kibana-plugin-plugins-data-server.isearchstart.aggs.md) | <code>AggsStart</code> | |
| [getSearchStrategy](./kibana-plugin-plugins-data-server.isearchstart.getsearchstrategy.md) | <code>(name: string) =&gt; ISearchStrategy&lt;SearchStrategyRequest, SearchStrategyResponse&gt;</code> | Get other registered search strategies. For example, if a new strategy needs to use the already-registered ES search strategy, it can use this function to accomplish that. |
| [search](./kibana-plugin-plugins-data-server.isearchstart.search.md) | <code>(context: RequestHandlerContext, request: SearchStrategyRequest, options: ISearchOptions) =&gt; Promise&lt;SearchStrategyResponse&gt;</code> | |
| [searchSource](./kibana-plugin-plugins-data-server.isearchstart.searchsource.md) | <code>{</code><br/><code> asScoped: (request: KibanaRequest) =&gt; Promise&lt;ISearchStartSearchSource&gt;;</code><br/><code> }</code> | |

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-plugins-data-server](./kibana-plugin-plugins-data-server.md) &gt; [ISearchStart](./kibana-plugin-plugins-data-server.isearchstart.md) &gt; [searchSource](./kibana-plugin-plugins-data-server.isearchstart.searchsource.md)

## ISearchStart.searchSource property

<b>Signature:</b>

```typescript
searchSource: {
asScoped: (request: KibanaRequest) => Promise<ISearchStartSearchSource>;
};
```
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@

```typescript
start(core: CoreStart): {
search: ISearchStart<import("./search").IEsSearchRequest, import("./search").IEsSearchResponse<any>>;
fieldFormats: {
fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise<import("../common").FieldFormatsRegistry>;
};
indexPatterns: {
indexPatternsServiceFactory: (kibanaRequest: import("../../../core/server").KibanaRequest<unknown, unknown, unknown, any>) => Promise<import("../public").IndexPatternsService>;
};
search: ISearchStart<import("./search").IEsSearchRequest, import("./search").IEsSearchResponse<any>>;
};
```

Expand All @@ -27,12 +27,12 @@ start(core: CoreStart): {
<b>Returns:</b>

`{
search: ISearchStart<import("./search").IEsSearchRequest, import("./search").IEsSearchResponse<any>>;
fieldFormats: {
fieldFormatServiceFactory: (uiSettings: import("../../../core/server").IUiSettingsClient) => Promise<import("../common").FieldFormatsRegistry>;
};
indexPatterns: {
indexPatternsServiceFactory: (kibanaRequest: import("../../../core/server").KibanaRequest<unknown, unknown, unknown, any>) => Promise<import("../public").IndexPatternsService>;
};
search: ISearchStart<import("./search").IEsSearchRequest, import("./search").IEsSearchResponse<any>>;
}`

6 changes: 3 additions & 3 deletions docs/user/security/api-keys/index.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ The response should look something like this:
"api_key" : "FD6P5UA4QCWlZZQhYF3YGw"
}

Now, you can use the API key to request {kib} roles. You will need
to base64-encode the `id` and `api_key` provided in the response
and add it to your request as an authorization header. For example:
Now, you can use the API key to request {kib} roles. You'll need to send a request with a
`Authorization` header with a value having the prefix `ApiKey` followed by the credentials,
where credentials is the base64 encoding of `id` and `api_key` joined by a colon. For example:

[source,js]
curl --location --request GET 'http://localhost:5601/api/security/role' \
Expand Down
2 changes: 2 additions & 0 deletions examples/embeddable_examples/public/book/book_embeddable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ export class BookEmbeddable
} else {
this.updateOutput({
attributes: this.attributes,
defaultTitle: this.attributes.title,
hasMatch: getHasMatch(this.input.search, this.attributes),
});
}
Expand Down Expand Up @@ -125,6 +126,7 @@ export class BookEmbeddable

this.updateOutput({
attributes: this.attributes,
defaultTitle: this.attributes.title,
hasMatch: getHasMatch(this.input.search, this.attributes),
});
}
Expand Down
14 changes: 14 additions & 0 deletions packages/kbn-telemetry-tools/src/tools/serializer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,4 +124,18 @@ describe('getDescriptor', () => {
'@@INDEX@@': { kind: ts.SyntaxKind.NumberKeyword, type: 'NumberKeyword' },
});
});

it('serializes MappedTypes', () => {
const usageInterface = usageInterfaces.get('MappedTypes')!;
const descriptor = getDescriptor(usageInterface, tsProgram);
expect(descriptor).toEqual({
mappedTypeWithExternallyDefinedProps: {
prop1: { kind: ts.SyntaxKind.NumberKeyword, type: 'NumberKeyword' },
prop2: { kind: ts.SyntaxKind.NumberKeyword, type: 'NumberKeyword' },
},
mappedTypeWithOneInlineProp: {
prop3: { kind: ts.SyntaxKind.NumberKeyword, type: 'NumberKeyword' },
},
});
});
});
42 changes: 40 additions & 2 deletions packages/kbn-telemetry-tools/src/tools/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,33 @@ export function kindToDescriptorName(kind: number) {
}
}

export function getConstraints(node: ts.Node, program: ts.Program): any {
if (ts.isTypeReferenceNode(node)) {
const typeChecker = program.getTypeChecker();
const symbol = typeChecker.getSymbolAtLocation(node.typeName);
const declaration = (symbol?.getDeclarations() || [])[0];
if (declaration) {
return getConstraints(declaration, program);
}
return getConstraints(node.typeName, program);
}

if (ts.isTypeAliasDeclaration(node)) {
return getConstraints(node.type, program);
}

if (ts.isUnionTypeNode(node)) {
const types = node.types.filter(discardNullOrUndefined);
return types.map((typeNode) => getConstraints(typeNode, program));
}

if (ts.isLiteralTypeNode(node) && ts.isLiteralExpression(node.literal)) {
return node.literal.text;
}

throw Error(`Unsupported constraint`);
}

export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor | DescriptorValue {
if (ts.isMethodSignature(node) || ts.isPropertySignature(node)) {
if (node.type) {
Expand All @@ -89,8 +116,19 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor |
}

// If it's defined as signature { [key: string]: OtherInterface }
if (ts.isIndexSignatureDeclaration(node) && node.type) {
return { '@@INDEX@@': getDescriptor(node.type, program) };
if ((ts.isIndexSignatureDeclaration(node) || ts.isMappedTypeNode(node)) && node.type) {
const descriptor = getDescriptor(node.type, program);

// If we know the constraints of `string` ({ [key in 'prop1' | 'prop2']: value })
const constraint = (node as ts.MappedTypeNode).typeParameter?.constraint;
if (constraint) {
const constraints = getConstraints(constraint, program);
const constraintsArray = Array.isArray(constraints) ? constraints : [constraints];
if (typeof constraintsArray[0] === 'string') {
return constraintsArray.reduce((acc, c) => ({ ...acc, [c]: descriptor }), {});
}
}
return { '@@INDEX@@': descriptor };
}

if (ts.SyntaxKind.FirstNode === node.kind) {
Expand Down
4 changes: 3 additions & 1 deletion packages/kbn-telemetry-tools/src/tools/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ export function getVariableValue(node: ts.Node, program: ts.Program): string | R
}

throw Error(
`Unsupported Node: cannot get value of node (${node.getText()}) of kind ${node.kind}`
`Unsupported Node: cannot get value of node (${node.getText()}) of kind ${node.kind} [${
ts.SyntaxKind[node.kind]
}]`
);
}

Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions src/core/public/notifications/toasts/global_toast_list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import { EuiGlobalToastList, EuiGlobalToastListToast as EuiToast } from '@elastic/eui';
import React from 'react';
import * as Rx from 'rxjs';
import { i18n } from '@kbn/i18n';

import { MountWrapper } from '../../utils';
import { Toast } from './toasts_api';
Expand Down Expand Up @@ -61,6 +62,9 @@ export class GlobalToastList extends React.Component<Props, State> {
public render() {
return (
<EuiGlobalToastList
aria-label={i18n.translate('core.notifications.globalToast.ariaLabel', {
defaultMessage: 'Notification message list',
})}
data-test-subj="globalToastList"
toasts={this.state.toasts.map(convertToEui)}
dismissToast={({ id }) => this.props.dismissToast(id)}
Expand Down
11 changes: 11 additions & 0 deletions src/fixtures/telemetry_collectors/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,14 @@ export const externallyDefinedSchema: MakeSchemaFrom<{ locale: string }> = {
export type TypeAliasWithUnion = Usage & WithUnion;

export type TypeAliasWithRecord = Usage & Record<string, number>;

export type MappedTypeProps = 'prop1' | 'prop2';

export interface MappedTypes {
mappedTypeWithExternallyDefinedProps: {
[key in MappedTypeProps]: number;
};
mappedTypeWithOneInlineProp: {
[key in 'prop3']: number;
};
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import React, { Component } from 'react';
import { FormattedMessage } from '@kbn/i18n/react';
import { EuiScreenReaderOnly, EuiDelayRender } from '@elastic/eui';
import { i18n } from '@kbn/i18n';
import { FieldSetting } from '../../types';

interface Props {
Expand All @@ -66,19 +67,34 @@ export class AdvancedSettingsVoiceAnnouncement extends Component<Props> {
const filteredOptions = [...filteredSections];
return (
<EuiScreenReaderOnly>
<div role="region" aria-live="polite">
<div
role="region"
aria-live="polite"
aria-label={i18n.translate('advancedSettings.voiceAnnouncement.ariaLabel', {
defaultMessage: 'Advanced Settings results info',
})}
>
<EuiDelayRender>
<FormattedMessage
id="advancedSettings.voiceAnnouncement.searchResultScreenReaderMessage"
defaultMessage="You searched for {query}.
There {optionLenght, plural, one {is # option} other {are # options}}
in {sectionLenght, plural, one {# section} other {# sections}}"
values={{
query: this.props.queryText,
sectionLenght: filteredSections.length,
optionLenght: filteredOptions.length,
}}
/>
{this.props.queryText ? (
<FormattedMessage
id="advancedSettings.voiceAnnouncement.searchResultScreenReaderMessage"
defaultMessage="You searched for {query}. There {optionLenght, plural, one {is # option} other {are # options}} in {sectionLenght, plural, one {# section} other {# sections}}"
values={{
query: this.props.queryText,
sectionLenght: filteredSections.length,
optionLenght: filteredOptions.length,
}}
/>
) : (
<FormattedMessage
id="advancedSettings.voiceAnnouncement.noSearchResultScreenReaderMessage"
defaultMessage="There {optionLenght, plural, one {is # option} other {are # options}} in {sectionLenght, plural, one {# section} other {# sections}}"
values={{
sectionLenght: filteredSections.length,
optionLenght: filteredOptions.length,
}}
/>
)}
</EuiDelayRender>
</div>
</EuiScreenReaderOnly>
Expand Down
Loading

0 comments on commit 212304e

Please sign in to comment.