Skip to content
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

[maps] remove xpack.maps.showMapVisualizationTypes #105979

Merged
merged 9 commits into from
Aug 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions docs/maps/trouble-shooting.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,4 @@ Increase <<settings, `server.maxPayload`>> for large index patterns.
[float]
==== Custom tiles are not displayed
* When using a custom tile service, ensure your tile server has configured https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS[Cross-Origin Resource Sharing (CORS)] so tile requests from your {kib} domain have permission to access your tile server domain.
* Ensure custom vector and tile services have the required coordinate system. Vector data must use EPSG:4326 and tiles must use EPSG:3857.

[float]
==== Coordinate and region map visualizations not available in New Visualization menu

Kibana’s out-of-the-box settings no longer offers coordinate and region maps as a
choice in the New Visualization menu because you can create these maps in the Maps app.
If you want to create new coordinate and region map visualizations, set `xpack.maps.showMapVisualizationTypes` to `true`.
* Ensure custom vector and tile services have the required coordinate system. Vector data must use EPSG:4326 and tiles must use EPSG:3857.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { parsedWorkingCollector } from './parsed_working_collector';
import { parsedCollectorWithDescription } from './parsed_working_collector_with_description';
import { parsedStatsCollector } from './parsed_stats_collector';
import { parsedImportedInterfaceFromExport } from './parsed_imported_interface_from_export';
import { parsedEnumCollector } from './parsed_enum_collector';

export const allExtractedCollectors: ParsedUsageCollection[] = [
...parsedExternallyDefinedCollector,
Expand All @@ -29,4 +30,5 @@ export const allExtractedCollectors: ParsedUsageCollection[] = [
...parsedStatsCollector,
parsedCollectorWithDescription,
parsedWorkingCollector,
parsedEnumCollector,
];
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@
"flat": {
"type": "keyword"
},
"interface_terms": {
"properties": {
"computed_term": {
"properties": {
"total": {
"type": "long"
},
"type": {
"type": "boolean"
}
}
}
}
},
"my_index_signature_prop": {
"properties": {
"avg": {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* 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 { SyntaxKind } from 'typescript';
import { ParsedUsageCollection } from '../ts_parser';

export const parsedEnumCollector: ParsedUsageCollection = [
'src/fixtures/telemetry_collectors/enum_collector.ts',
{
collectorName: 'my_enum_collector',
fetch: {
typeName: 'Usage',
typeDescriptor: {
layerTypes: {
es_docs: {
min: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
max: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
total: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
avg: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
},
es_top_hits: {
min: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
max: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
total: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
avg: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
},
},
},
},
schema: {
value: {
layerTypes: {
es_top_hits: {
min: {
type: 'long',
_meta: {
description: 'min number of es top hits layers per map',
},
},
max: {
type: 'long',
_meta: {
description: 'max number of es top hits layers per map',
},
},
avg: {
type: 'float',
_meta: {
description: 'avg number of es top hits layers per map',
},
},
total: {
type: 'long',
_meta: {
description: 'total number of es top hits layers in cluster',
},
},
},
es_docs: {
min: {
type: 'long',
_meta: {
description: 'min number of es document layers per map',
},
},
max: {
type: 'long',
_meta: {
description: 'max number of es document layers per map',
},
},
avg: {
type: 'float',
_meta: {
description: 'avg number of es document layers per map',
},
},
total: {
type: 'long',
_meta: {
description: 'total number of es document layers in cluster',
},
},
},
},
},
},
},
];
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ export const parsedWorkingCollector: ParsedUsageCollection = [
collectorName: 'my_working_collector',
schema: {
value: {
interface_terms: {
computed_term: {
total: { type: 'long' },
type: { type: 'boolean' },
},
},
flat: {
type: 'keyword',
},
Expand Down Expand Up @@ -100,6 +106,18 @@ export const parsedWorkingCollector: ParsedUsageCollection = [
type: 'StringKeyword',
},
},
interface_terms: {
computed_term: {
total: {
kind: SyntaxKind.NumberKeyword,
type: 'NumberKeyword',
},
type: {
kind: SyntaxKind.BooleanKeyword,
type: 'BooleanKeyword',
},
},
},
},
},
},
Expand Down
18 changes: 15 additions & 3 deletions packages/kbn-telemetry-tools/src/tools/extract_collectors.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,21 @@ describe('extractCollectors', () => {
const configs = await parseTelemetryRC(configRoot);
expect(configs).toHaveLength(1);
const programPaths = await getProgramPaths(configs[0]);

const results = [...extractCollectors(programPaths, tsConfig)];
expect(results).toHaveLength(11);
expect(results).toStrictEqual(allExtractedCollectors);
expect(results).toHaveLength(12);

// loop over results for better error messages on failure:
for (const result of results) {
const [resultPath, resultCollectorDetails] = result;
const matchingCollector = allExtractedCollectors.find(
([, extractorCollectorDetails]) =>
extractorCollectorDetails.collectorName === resultCollectorDetails.collectorName
);
if (!matchingCollector) {
throw new Error(`Unable to find matching collector in ${resultPath}`);
}

expect(result).toStrictEqual(matchingCollector);
}
});
});
58 changes: 50 additions & 8 deletions packages/kbn-telemetry-tools/src/tools/serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function getConstraints(node: ts.Node, program: ts.Program): any {
return getConstraints(node.type, program);
}

// node input ('a' | 'b'). returns ['a', 'b'];
if (ts.isUnionTypeNode(node)) {
const types = node.types.filter(discardNullOrUndefined);
return types.reduce<any>((acc, typeNode) => {
Expand All @@ -95,6 +96,10 @@ export function getConstraints(node: ts.Node, program: ts.Program): any {
return node.literal.text;
}

if (ts.isStringLiteral(node)) {
return node.text;
}

if (ts.isImportSpecifier(node)) {
const source = node.getSourceFile();
const importedModuleName = getModuleSpecifier(node);
Expand All @@ -104,6 +109,24 @@ export function getConstraints(node: ts.Node, program: ts.Program): any {
return getConstraints(declarationNode, program);
}

// node input ( enum { A = 'my_a', B = 'my_b' } ). returns ['my_a', 'my_b'];
if (ts.isEnumDeclaration(node)) {
return node.members.map((member) => getConstraints(member, program));
}

// node input ( 'A = my_a' )
if (ts.isEnumMember(node)) {
const { initializer } = node;
if (!initializer) {
// no initializer ( enum { A } );
const memberName = node.getText();
throw Error(
`EnumMember (${memberName}) must have an initializer. Example: (enum { ${memberName} = '${memberName}' })`
);
}

return getConstraints(initializer, program);
}
throw Error(`Unsupported constraint of kind ${node.kind} [${ts.SyntaxKind[node.kind]}]`);
}

Expand All @@ -113,22 +136,41 @@ export function getDescriptor(node: ts.Node, program: ts.Program): Descriptor |
return getDescriptor(node.type, program);
}
}

/**
* Supported interface keys:
* inteface T { [computed_value]: ANY_VALUE };
* inteface T { hardcoded_string: ANY_VALUE };
*/
if (ts.isTypeLiteralNode(node) || ts.isInterfaceDeclaration(node)) {
return node.members.reduce((acc, m) => {
const key = m.name?.getText();
if (key) {
return { ...acc, [key]: getDescriptor(m, program) };
} else {
return { ...acc, ...getDescriptor(m, program) };
const { name: nameNode } = m;
if (nameNode) {
const nodeText = nameNode.getText();
if (ts.isComputedPropertyName(nameNode)) {
const typeChecker = program.getTypeChecker();
const symbol = typeChecker.getSymbolAtLocation(nameNode);
const key = symbol?.getName();
if (!key) {
throw Error(`Unable to parse computed value of ${nodeText}.`);
}
return { ...acc, [key]: getDescriptor(m, program) };
}

return { ...acc, [nodeText]: getDescriptor(m, program) };
}

return { ...acc, ...getDescriptor(m, program) };
}, {});
}

// If it's defined as signature { [key: string]: OtherInterface }
/**
* Supported signature constraints of `string`:
* { [key in 'prop1' | 'prop2']: value }
* { [key in Enum]: value }
*/
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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,6 @@ kibana_vars=(
xpack.ingestManager.registryUrl
xpack.license_management.enabled
xpack.maps.enabled
xpack.maps.showMapVisualizationTypes
xpack.ml.enabled
xpack.observability.annotations.index
xpack.observability.unsafe.alertingExperience.enabled
Expand Down
Loading