Migrate App services plugins to TS projects (#87294)

* migrate expressions to ts project refs

* bfetch to ts project

* ui_actions to ts project

* move fitures to data plugins

* add data ts project

* remove outdated ts-expect-error

* add data to x-pack tsconfigs

* navigation to ts project

* cleanup licensing tsconfig

* saved_objects to ts project

* embeddable to ts project

* ui_actions_enhanced to ts project

* embeddable_enhanced to ts project

* features to ts project

* data_enhanced to ts project refs

* fix i18n check

* fix find_plugins_ready_to_migrate_to_ts_refs script

* add a comment for bug ignoring json for composite projects

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
Mikhail Shustov 2021-01-07 09:30:30 +01:00 committed by GitHub
parent 1d49166203
commit 69e2c38bd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 1187 additions and 29 deletions

View file

@ -19,6 +19,7 @@
import Path from 'path';
import Fs from 'fs';
import JSON5 from 'json5';
import { get } from 'lodash';
import { run, KibanaPlatformPlugin } from '@kbn/dev-utils';
import { getPluginDeps, findPlugins } from './plugin_discovery';
@ -46,7 +47,8 @@ run(
id: pluginId,
});
if (deps.size === 0 && errors.size === 0) {
const allDepsMigrated = [...deps].every((p) => isMigratedToTsProjectRefs(p.directory));
if (allDepsMigrated && errors.size === 0) {
readyToMigrate.add(pluginMap.get(pluginId)!);
}
}
@ -82,7 +84,7 @@ function isMigratedToTsProjectRefs(dir: string): boolean {
try {
const path = Path.join(dir, 'tsconfig.json');
const content = Fs.readFileSync(path, { encoding: 'utf8' });
return get(JSON.parse(content), 'compilerOptions.composite', false);
return get(JSON5.parse(content), 'compilerOptions.composite', false);
} catch (e) {
return false;
}

View file

@ -0,0 +1,15 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": ["common/**/*", "public/**/*", "server/**/*", "index.ts"],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
]
}

View file

@ -0,0 +1,85 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { shouldReadFieldFromDocValues, castEsToKbnFieldTypeName } from '../../../../server';
function stubbedLogstashFields() {
return [
// |aggregatable
// | |searchable
// name esType | | |metadata | subType
['bytes', 'long', true, true, { count: 10 }],
['ssl', 'boolean', true, true, { count: 20 }],
['@timestamp', 'date', true, true, { count: 30 }],
['time', 'date', true, true, { count: 30 }],
['@tags', 'keyword', true, true],
['utc_time', 'date', true, true],
['phpmemory', 'integer', true, true],
['ip', 'ip', true, true],
['request_body', 'attachment', true, true],
['point', 'geo_point', true, true],
['area', 'geo_shape', true, true],
['hashed', 'murmur3', false, true],
['geo.coordinates', 'geo_point', true, true],
['extension', 'text', true, true],
['extension.keyword', 'keyword', true, true, {}, { multi: { parent: 'extension' } }],
['machine.os', 'text', true, true],
['machine.os.raw', 'keyword', true, true, {}, { multi: { parent: 'machine.os' } }],
['geo.src', 'keyword', true, true],
['_id', '_id', true, true],
['_type', '_type', true, true],
['_source', '_source', true, true],
['non-filterable', 'text', true, false],
['non-sortable', 'text', false, false],
['custom_user_field', 'conflict', true, true],
['script string', 'text', true, false, { script: "'i am a string'" }],
['script number', 'long', true, false, { script: '1234' }],
['script date', 'date', true, false, { script: '1234', lang: 'painless' }],
['script murmur3', 'murmur3', true, false, { script: '1234' }],
].map(function (row) {
const [name, esType, aggregatable, searchable, metadata = {}, subType = undefined] = row;
const {
count = 0,
script,
lang = script ? 'expression' : undefined,
scripted = !!script,
} = metadata;
// the conflict type is actually a kbnFieldType, we
// don't have any other way to represent it here
const type = esType === 'conflict' ? esType : castEsToKbnFieldTypeName(esType);
return {
name,
type,
esTypes: [esType],
readFromDocValues: shouldReadFieldFromDocValues(aggregatable, esType),
aggregatable,
searchable,
count,
script,
lang,
scripted,
subType,
};
});
}
export default stubbedLogstashFields;

View file

@ -0,0 +1,37 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
// @ts-expect-error
import stubbedLogstashFields from './logstash_fields';
const mockLogstashFields = stubbedLogstashFields();
export function stubbedSavedObjectIndexPattern(id: string | null = null) {
return {
id,
type: 'index-pattern',
attributes: {
timeFieldName: 'timestamp',
customFormats: {},
fields: mockLogstashFields,
title: 'title',
},
version: '2',
};
}

View file

@ -23,8 +23,8 @@ import { IndexPattern } from './index_pattern';
import { DuplicateField } from '../../../../kibana_utils/common';
// @ts-expect-error
import mockLogStashFields from '../../../../../fixtures/logstash_fields';
import { stubbedSavedObjectIndexPattern } from '../../../../../fixtures/stubbed_saved_object_index_pattern';
import mockLogStashFields from './fixtures/logstash_fields';
import { stubbedSavedObjectIndexPattern } from './fixtures/stubbed_saved_object_index_pattern';
import { IndexPatternField } from '../fields';
import { fieldFormatsMock } from '../../field_formats/mocks';

View file

@ -20,7 +20,7 @@
import { defaults } from 'lodash';
import { IndexPatternsService, IndexPattern } from '.';
import { fieldFormatsMock } from '../../field_formats/mocks';
import { stubbedSavedObjectIndexPattern } from '../../../../../fixtures/stubbed_saved_object_index_pattern';
import { stubbedSavedObjectIndexPattern } from './fixtures/stubbed_saved_object_index_pattern';
import { UiSettingsCommon, SavedObjectsClientCommon, SavedObject } from '../types';
const createFieldsFetcher = jest.fn().mockImplementation(() => ({

View file

@ -0,0 +1,632 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export const metricOnly = {
hits: { total: 1000, hits: [], max_score: 0 },
aggregations: {
agg_1: { value: 412032 },
},
};
export const threeTermBuckets = {
hits: { total: 1000, hits: [], max_score: 0 },
aggregations: {
agg_2: {
buckets: [
{
key: 'png',
doc_count: 50,
agg_1: { value: 412032 },
agg_3: {
buckets: [
{
key: 'IT',
doc_count: 10,
agg_1: { value: 9299 },
agg_4: {
buckets: [
{ key: 'win', doc_count: 4, agg_1: { value: 0 } },
{ key: 'mac', doc_count: 6, agg_1: { value: 9299 } },
],
},
},
{
key: 'US',
doc_count: 20,
agg_1: { value: 8293 },
agg_4: {
buckets: [
{ key: 'linux', doc_count: 12, agg_1: { value: 3992 } },
{ key: 'mac', doc_count: 8, agg_1: { value: 3029 } },
],
},
},
],
},
},
{
key: 'css',
doc_count: 20,
agg_1: { value: 412032 },
agg_3: {
buckets: [
{
key: 'MX',
doc_count: 7,
agg_1: { value: 9299 },
agg_4: {
buckets: [
{ key: 'win', doc_count: 3, agg_1: { value: 4992 } },
{ key: 'mac', doc_count: 4, agg_1: { value: 5892 } },
],
},
},
{
key: 'US',
doc_count: 13,
agg_1: { value: 8293 },
agg_4: {
buckets: [
{ key: 'linux', doc_count: 12, agg_1: { value: 3992 } },
{ key: 'mac', doc_count: 1, agg_1: { value: 3029 } },
],
},
},
],
},
},
{
key: 'html',
doc_count: 90,
agg_1: { value: 412032 },
agg_3: {
buckets: [
{
key: 'CN',
doc_count: 85,
agg_1: { value: 9299 },
agg_4: {
buckets: [
{ key: 'win', doc_count: 46, agg_1: { value: 4992 } },
{ key: 'mac', doc_count: 39, agg_1: { value: 5892 } },
],
},
},
{
key: 'FR',
doc_count: 15,
agg_1: { value: 8293 },
agg_4: {
buckets: [
{ key: 'win', doc_count: 3, agg_1: { value: 3992 } },
{ key: 'mac', doc_count: 12, agg_1: { value: 3029 } },
],
},
},
],
},
},
],
},
},
};
export const oneTermOneHistogramBucketWithTwoMetricsOneTopHitOneDerivative = {
hits: { total: 1000, hits: [], max_score: 0 },
aggregations: {
agg_3: {
buckets: [
{
key: 'png',
doc_count: 50,
agg_4: {
buckets: [
{
key_as_string: '2014-09-28T00:00:00.000Z',
key: 1411862400000,
doc_count: 1,
agg_1: { value: 9283 },
agg_2: { value: 1411862400000 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 23,
},
},
],
},
},
},
{
key_as_string: '2014-09-29T00:00:00.000Z',
key: 1411948800000,
doc_count: 2,
agg_1: { value: 28349 },
agg_2: { value: 1411948800000 },
agg_5: { value: 203 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 39,
},
},
],
},
},
},
{
key_as_string: '2014-09-30T00:00:00.000Z',
key: 1412035200000,
doc_count: 3,
agg_1: { value: 84330 },
agg_2: { value: 1412035200000 },
agg_5: { value: 200 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 329,
},
},
],
},
},
},
{
key_as_string: '2014-10-01T00:00:00.000Z',
key: 1412121600000,
doc_count: 4,
agg_1: { value: 34992 },
agg_2: { value: 1412121600000 },
agg_5: { value: 103 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 22,
},
},
],
},
},
},
{
key_as_string: '2014-10-02T00:00:00.000Z',
key: 1412208000000,
doc_count: 5,
agg_1: { value: 145432 },
agg_2: { value: 1412208000000 },
agg_5: { value: 153 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 93,
},
},
],
},
},
},
{
key_as_string: '2014-10-03T00:00:00.000Z',
key: 1412294400000,
doc_count: 35,
agg_1: { value: 220943 },
agg_2: { value: 1412294400000 },
agg_5: { value: 239 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 72,
},
},
],
},
},
},
],
},
},
{
key: 'css',
doc_count: 20,
agg_4: {
buckets: [
{
key_as_string: '2014-09-28T00:00:00.000Z',
key: 1411862400000,
doc_count: 1,
agg_1: { value: 9283 },
agg_2: { value: 1411862400000 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 75,
},
},
],
},
},
},
{
key_as_string: '2014-09-29T00:00:00.000Z',
key: 1411948800000,
doc_count: 2,
agg_1: { value: 28349 },
agg_2: { value: 1411948800000 },
agg_5: { value: 10 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 11,
},
},
],
},
},
},
{
key_as_string: '2014-09-30T00:00:00.000Z',
key: 1412035200000,
doc_count: 3,
agg_1: { value: 84330 },
agg_2: { value: 1412035200000 },
agg_5: { value: 24 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 238,
},
},
],
},
},
},
{
key_as_string: '2014-10-01T00:00:00.000Z',
key: 1412121600000,
doc_count: 4,
agg_1: { value: 34992 },
agg_2: { value: 1412121600000 },
agg_5: { value: 49 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 343,
},
},
],
},
},
},
{
key_as_string: '2014-10-02T00:00:00.000Z',
key: 1412208000000,
doc_count: 5,
agg_1: { value: 145432 },
agg_2: { value: 1412208000000 },
agg_5: { value: 100 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 837,
},
},
],
},
},
},
{
key_as_string: '2014-10-03T00:00:00.000Z',
key: 1412294400000,
doc_count: 5,
agg_1: { value: 220943 },
agg_2: { value: 1412294400000 },
agg_5: { value: 23 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 302,
},
},
],
},
},
},
],
},
},
{
key: 'html',
doc_count: 90,
agg_4: {
buckets: [
{
key_as_string: '2014-09-28T00:00:00.000Z',
key: 1411862400000,
doc_count: 10,
agg_1: { value: 9283 },
agg_2: { value: 1411862400000 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 30,
},
},
],
},
},
},
{
key_as_string: '2014-09-29T00:00:00.000Z',
key: 1411948800000,
doc_count: 20,
agg_1: { value: 28349 },
agg_2: { value: 1411948800000 },
agg_5: { value: 1 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 43,
},
},
],
},
},
},
{
key_as_string: '2014-09-30T00:00:00.000Z',
key: 1412035200000,
doc_count: 30,
agg_1: { value: 84330 },
agg_2: { value: 1412035200000 },
agg_5: { value: 5 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 88,
},
},
],
},
},
},
{
key_as_string: '2014-10-01T00:00:00.000Z',
key: 1412121600000,
doc_count: 11,
agg_1: { value: 34992 },
agg_2: { value: 1412121600000 },
agg_5: { value: 10 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 91,
},
},
],
},
},
},
{
key_as_string: '2014-10-02T00:00:00.000Z',
key: 1412208000000,
doc_count: 12,
agg_1: { value: 145432 },
agg_2: { value: 1412208000000 },
agg_5: { value: 43 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 534,
},
},
],
},
},
},
{
key_as_string: '2014-10-03T00:00:00.000Z',
key: 1412294400000,
doc_count: 7,
agg_1: { value: 220943 },
agg_2: { value: 1412294400000 },
agg_5: { value: 1 },
agg_6: {
hits: {
total: 2,
hits: [
{
fields: {
bytes: 553,
},
},
],
},
},
},
],
},
},
],
},
},
};
export const oneRangeBucket = {
took: 35,
timed_out: false,
_shards: {
total: 1,
successful: 1,
failed: 0,
},
hits: {
total: 6039,
max_score: 0,
hits: [],
},
aggregations: {
agg_2: {
buckets: {
'0.0-1000.0': {
from: 0,
from_as_string: '0.0',
to: 1000,
to_as_string: '1000.0',
doc_count: 606,
},
'1000.0-2000.0': {
from: 1000,
from_as_string: '1000.0',
to: 2000,
to_as_string: '2000.0',
doc_count: 298,
},
},
},
},
};
export const oneFilterBucket = {
took: 11,
timed_out: false,
_shards: {
total: 1,
successful: 1,
failed: 0,
},
hits: {
total: 6005,
max_score: 0,
hits: [],
},
aggregations: {
agg_2: {
buckets: {
'type:apache': {
doc_count: 4844,
},
'type:nginx': {
doc_count: 1161,
},
},
},
},
};
export const oneHistogramBucket = {
took: 37,
timed_out: false,
_shards: {
total: 6,
successful: 6,
failed: 0,
},
hits: {
total: 49208,
max_score: 0,
hits: [],
},
aggregations: {
agg_2: {
buckets: [
{
key_as_string: '2014-09-28T00:00:00.000Z',
key: 1411862400000,
doc_count: 8247,
},
{
key_as_string: '2014-09-29T00:00:00.000Z',
key: 1411948800000,
doc_count: 8184,
},
{
key_as_string: '2014-09-30T00:00:00.000Z',
key: 1412035200000,
doc_count: 8269,
},
{
key_as_string: '2014-10-01T00:00:00.000Z',
key: 1412121600000,
doc_count: 8141,
},
{
key_as_string: '2014-10-02T00:00:00.000Z',
key: 1412208000000,
doc_count: 8148,
},
{
key_as_string: '2014-10-03T00:00:00.000Z',
key: 1412294400000,
doc_count: 8219,
},
],
},
},
};

View file

@ -21,7 +21,7 @@ import { tabifyAggResponse } from './tabify';
import { IndexPattern } from '../../index_patterns/index_patterns/index_pattern';
import { AggConfigs, IAggConfig, IAggConfigs } from '../aggs';
import { mockAggTypesRegistry } from '../aggs/test_helpers';
import { metricOnly, threeTermBuckets } from 'fixtures/fake_hierarchical_data';
import { metricOnly, threeTermBuckets } from './fixtures/fake_hierarchical_data';
describe('tabifyAggResponse Integration', () => {
const typesRegistry = mockAggTypesRegistry();

View file

@ -0,0 +1,21 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": ["common/**/*", "public/**/*", "server/**/*", "config.ts"],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../bfetch/tsconfig.json" },
{ "path": "../ui_actions/tsconfig.json" },
{ "path": "../share/tsconfig.json" },
{ "path": "../inspector/tsconfig.json" },
{ "path": "../usage_collection/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
]
}

View file

@ -24,7 +24,7 @@ import {
HelloWorldEmbeddable,
HelloWorldEmbeddableFactoryDefinition,
HELLO_WORLD_EMBEDDABLE,
} from '../../../../../../examples/embeddable_examples/public/hello_world';
} from '../../tests/fixtures';
import { EmbeddableRenderer } from './embeddable_renderer';
import { embeddablePluginMock } from '../../mocks';

View file

@ -17,7 +17,7 @@
* under the License.
*/
import React from 'react';
import { HelloWorldEmbeddable } from '../../../../../../examples/embeddable_examples/public';
import { HelloWorldEmbeddable } from '../../tests/fixtures';
import { EmbeddableRoot } from './embeddable_root';
import { mount } from 'enzyme';
import { findTestSubject } from '@elastic/eui/lib/test';

View file

@ -20,7 +20,7 @@ import { coreMock } from '../../../core/public/mocks';
import { testPlugin } from './tests/test_plugin';
import { EmbeddableFactoryProvider } from './types';
import { defaultEmbeddableFactoryProvider } from './lib';
import { HelloWorldEmbeddable } from '../../../../examples/embeddable_examples/public';
import { HelloWorldEmbeddable } from './tests/fixtures';
test('can set custom embeddable factory provider', async () => {
const coreSetup = coreMock.createSetup();

View file

@ -36,10 +36,7 @@ import { ERROR_EMBEDDABLE_TYPE } from '../lib/embeddables/error_embeddable';
import { FilterableEmbeddableFactory } from '../lib/test_samples/embeddables/filterable_embeddable_factory';
import { CONTACT_CARD_EMBEDDABLE } from '../lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory';
import { SlowContactCardEmbeddableFactory } from '../lib/test_samples/embeddables/contact_card/slow_contact_card_embeddable_factory';
import {
HELLO_WORLD_EMBEDDABLE,
HelloWorldEmbeddableFactoryDefinition,
} from '../../../../../examples/embeddable_examples/public';
import { HELLO_WORLD_EMBEDDABLE, HelloWorldEmbeddableFactoryDefinition } from './fixtures';
import { HelloWorldContainer } from '../lib/test_samples/embeddables/hello_world_container';
import {
ContactCardEmbeddableInput,

View file

@ -27,10 +27,7 @@ import {
import { FilterableEmbeddableFactory } from '../lib/test_samples/embeddables/filterable_embeddable_factory';
import { CONTACT_CARD_EMBEDDABLE } from '../lib/test_samples/embeddables/contact_card/contact_card_embeddable_factory';
import { SlowContactCardEmbeddableFactory } from '../lib/test_samples/embeddables/contact_card/slow_contact_card_embeddable_factory';
import {
HELLO_WORLD_EMBEDDABLE,
HelloWorldEmbeddableFactoryDefinition,
} from '../../../../../examples/embeddable_examples/public';
import { HELLO_WORLD_EMBEDDABLE, HelloWorldEmbeddableFactoryDefinition } from './fixtures';
import { FilterableContainer } from '../lib/test_samples/embeddables/filterable_container';
import { isErrorEmbeddable } from '../lib';
import { HelloWorldContainer } from '../lib/test_samples/embeddables/hello_world_container';

View file

@ -0,0 +1,54 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { Embeddable, EmbeddableInput, IContainer } from '../../';
export const HELLO_WORLD_EMBEDDABLE = 'HELLO_WORLD_EMBEDDABLE';
export class HelloWorldEmbeddable extends Embeddable {
// The type of this embeddable. This will be used to find the appropriate factory
// to instantiate this kind of embeddable.
public readonly type = HELLO_WORLD_EMBEDDABLE;
constructor(initialInput: EmbeddableInput, parent?: IContainer) {
super(
// Input state is irrelevant to this embeddable, just pass it along.
initialInput,
// Initial output state - this embeddable does not do anything with output, so just
// pass along an empty object.
{},
// Optional parent component, this embeddable can optionally be rendered inside a container.
parent
);
}
/**
* Render yourself at the dom node using whatever framework you like, angular, react, or just plain
* vanilla js.
* @param node
*/
public render(node: HTMLElement) {
node.innerHTML = '<div data-test-subj="helloWorldEmbeddable">HELLO WORLD!</div>';
}
/**
* This is mostly relevant for time based embeddables which need to update data
* even if EmbeddableInput has not changed at all.
*/
public reload() {}
}

View file

@ -0,0 +1,46 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
import { i18n } from '@kbn/i18n';
import { IContainer, EmbeddableInput, EmbeddableFactoryDefinition, EmbeddableFactory } from '../..';
import { HelloWorldEmbeddable, HELLO_WORLD_EMBEDDABLE } from './hello_world_embeddable';
export type HelloWorldEmbeddableFactory = EmbeddableFactory;
export class HelloWorldEmbeddableFactoryDefinition implements EmbeddableFactoryDefinition {
public readonly type = HELLO_WORLD_EMBEDDABLE;
/**
* In our simple example, we let everyone have permissions to edit this. Most
* embeddables should check the UI Capabilities service to be sure of
* the right permissions.
*/
public async isEditable() {
return true;
}
public async create(initialInput: EmbeddableInput, parent?: IContainer) {
return new HelloWorldEmbeddable(initialInput, parent);
}
public getDisplayName() {
return i18n.translate('embeddableApi.helloworld.displayName', {
defaultMessage: 'hello world',
});
}
}

View file

@ -0,0 +1,21 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
export * from './hello_world_embeddable';
export * from './hello_world_embeddable_factory';

View file

@ -0,0 +1,23 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*"
],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../inspector/tsconfig.json" },
{ "path": "../saved_objects/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
{ "path": "../ui_actions/tsconfig.json" },
]
}

View file

@ -0,0 +1,16 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": ["common/**/*", "public/**/*", "server/**/*", "./index.ts"],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
{ "path": "../inspector/tsconfig.json" },
]
}

View file

@ -0,0 +1,16 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": ["public/**/*"],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
{ "path": "../data/tsconfig.json" },
]
}

View file

@ -0,0 +1,17 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": ["common/**/*", "public/**/*", "server/**/*"],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../data/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
]
}

View file

@ -19,7 +19,7 @@
import { i18n } from '@kbn/i18n';
import { Trigger } from '.';
import { Datatable } from '../../../expressions';
import type { Datatable } from '../../../expressions';
export const ROW_CLICK_TRIGGER = 'ROW_CLICK_TRIGGER';

View file

@ -0,0 +1,17 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": ["public/**/*"],
"references": [
{ "path": "../../core/tsconfig.json" },
{ "path": "../expressions/tsconfig.json" },
{ "path": "../kibana_utils/tsconfig.json" },
{ "path": "../kibana_react/tsconfig.json" },
]
}

View file

@ -8,13 +8,19 @@
"exclude": ["plugin_functional/plugins/**/*", "interpreter_functional/plugins/**/*"],
"references": [
{ "path": "../src/core/tsconfig.json" },
{ "path": "../src/plugins/bfetch/tsconfig.json" },
{ "path": "../src/plugins/embeddable/tsconfig.json" },
{ "path": "../src/plugins/expressions/tsconfig.json" },
{ "path": "../src/plugins/inspector/tsconfig.json" },
{ "path": "../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../src/plugins/navigation/tsconfig.json" },
{ "path": "../src/plugins/newsfeed/tsconfig.json" },
{ "path": "../src/plugins/saved_objects/tsconfig.json" },
{ "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" },
{ "path": "../src/plugins/telemetry/tsconfig.json" },
{ "path": "../src/plugins/usage_collection/tsconfig.json" }
{ "path": "../src/plugins/ui_actions/tsconfig.json" },
{ "path": "../src/plugins/usage_collection/tsconfig.json" },
]
}

View file

@ -7,17 +7,24 @@
"exclude": [
"src/**/__fixtures__/**/*",
"src/core/**/*",
"src/plugins/bfetch/**/*",
"src/plugins/data/**/*",
"src/plugins/dev_tools/**/*",
"src/plugins/embeddable/**/*",
"src/plugins/expressions/**/*",
"src/plugins/inspector/**/*",
"src/plugins/kibana_legacy/**/*",
"src/plugins/kibana_react/**/*",
"src/plugins/kibana_usage_collection/**/*",
"src/plugins/kibana_utils/**/*",
"src/plugins/navigation/**/*",
"src/plugins/newsfeed/**/*",
"src/plugins/saved_objects/**/*",
"src/plugins/security_oss/**/*",
"src/plugins/share/**/*",
"src/plugins/telemetry/**/*",
"src/plugins/telemetry_collection_manager/**/*",
"src/plugins/ui_actions/**/*",
"src/plugins/url_forwarding/**/*",
"src/plugins/usage_collection/**/*",
// In the build we actually exclude **/public/**/* from this config so that
@ -28,17 +35,24 @@
],
"references": [
{ "path": "./src/core/tsconfig.json" },
{ "path": "./src/plugins/bfetch/tsconfig.json" },
{ "path": "./src/plugins/data/tsconfig.json" },
{ "path": "./src/plugins/dev_tools/tsconfig.json" },
{ "path": "./src/plugins/embeddable/tsconfig.json" },
{ "path": "./src/plugins/expressions/tsconfig.json" },
{ "path": "./src/plugins/inspector/tsconfig.json" },
{ "path": "./src/plugins/kibana_legacy/tsconfig.json" },
{ "path": "./src/plugins/kibana_react/tsconfig.json" },
{ "path": "./src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "./src/plugins/kibana_utils/tsconfig.json" },
{ "path": "./src/plugins/navigation/tsconfig.json" },
{ "path": "./src/plugins/newsfeed/tsconfig.json" },
{ "path": "./src/plugins/saved_objects/tsconfig.json" },
{ "path": "./src/plugins/security_oss/tsconfig.json" },
{ "path": "./src/plugins/share/tsconfig.json" },
{ "path": "./src/plugins/telemetry/tsconfig.json" },
{ "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" },
{ "path": "./src/plugins/ui_actions/tsconfig.json" },
{ "path": "./src/plugins/url_forwarding/tsconfig.json" },
{ "path": "./src/plugins/usage_collection/tsconfig.json" },
]

View file

@ -2,17 +2,24 @@
"include": [],
"references": [
{ "path": "./src/core/tsconfig.json" },
{ "path": "./src/plugins/bfetch/tsconfig.json" },
{ "path": "./src/plugins/data/tsconfig.json" },
{ "path": "./src/plugins/dev_tools/tsconfig.json" },
{ "path": "./src/plugins/embeddable/tsconfig.json" },
{ "path": "./src/plugins/expressions/tsconfig.json" },
{ "path": "./src/plugins/inspector/tsconfig.json" },
{ "path": "./src/plugins/kibana_legacy/tsconfig.json" },
{ "path": "./src/plugins/kibana_react/tsconfig.json" },
{ "path": "./src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "./src/plugins/kibana_utils/tsconfig.json" },
{ "path": "./src/plugins/navigation/tsconfig.json" },
{ "path": "./src/plugins/newsfeed/tsconfig.json" },
{ "path": "./src/plugins/saved_objects/tsconfig.json" },
{ "path": "./src/plugins/security_oss/tsconfig.json" },
{ "path": "./src/plugins/share/tsconfig.json" },
{ "path": "./src/plugins/telemetry/tsconfig.json" },
{ "path": "./src/plugins/telemetry_collection_manager/tsconfig.json" },
{ "path": "./src/plugins/ui_actions/tsconfig.json" },
{ "path": "./src/plugins/url_forwarding/tsconfig.json" },
{ "path": "./src/plugins/usage_collection/tsconfig.json" },
]

View file

@ -0,0 +1,28 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true,
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*",
"config.ts",
// have to declare *.json explicitly due to https://github.com/microsoft/TypeScript/issues/25636
"public/autocomplete/providers/kql_query_suggestion/__fixtures__/*.json"
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/bfetch/tsconfig.json" },
{ "path": "../../../src/plugins/data/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../../../src/plugins/usage_collection/tsconfig.json" },
{ "path": "../features/tsconfig.json" },
]
}

View file

@ -0,0 +1,21 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"public/**/*",
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/embeddable/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../../../src/plugins/ui_actions/tsconfig.json" },
{ "path": "../ui_actions_enhanced/tsconfig.json" },
]
}

View file

@ -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;
* you may not use this file except in compliance with the Elastic License.
*/
// the file created to remove TS cicular dependency between features and security pluin
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
export { featurePrivilegeIterator } from '../../security/server/authorization';

View file

@ -5,7 +5,8 @@
*/
import { buildOSSFeatures } from './oss_features';
import { featurePrivilegeIterator } from '../../security/server/authorization';
// @ts-expect-error
import { featurePrivilegeIterator } from './feature_privilege_iterator';
import { KibanaFeature } from '.';
import { LicenseType } from '../../licensing/server';

View file

@ -13,7 +13,6 @@ import {
PluginInitializerContext,
} from '../../../../src/core/server';
import { Capabilities as UICapabilities } from '../../../../src/core/server';
import { PluginSetupContract as TimelionSetupContract } from '../../../../src/plugins/vis_type_timelion/server';
import { FeatureRegistry } from './feature_registry';
import { uiCapabilitiesForFeatures } from './ui_capabilities_for_features';
import { buildOSSFeatures } from './oss_features';
@ -51,6 +50,10 @@ export interface PluginStartContract {
getKibanaFeatures(): KibanaFeature[];
}
interface TimelionSetupContract {
uiEnabled: boolean;
}
/**
* Represents Features Plugin instance that will be managed by the Kibana plugin system.
*/

View file

@ -0,0 +1,19 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"common/**/*",
"public/**/*",
"server/**/*",
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../licensing/tsconfig.json" },
]
}

View file

@ -10,8 +10,7 @@
"include": [
"public/**/*",
"server/**/*",
"common/**/*",
"../../../typings/**/*"
"common/**/*"
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },

View file

@ -4,10 +4,8 @@
* you may not use this file except in compliance with the Elastic License.
*/
import { canInheritTimeRange } from './can_inherit_time_range';
/** eslint-disable */
import { HelloWorldContainer } from '../../../../src/plugins/embeddable/public/lib/test_samples';
import { HelloWorldEmbeddable } from '../../../../examples/embeddable_examples/public';
/** eslint-enable */
import { HelloWorldEmbeddable } from '../../../../src/plugins/embeddable/public/tests/fixtures';
import { TimeRangeEmbeddable, TimeRangeContainer } from './test_helpers';
test('canInheritTimeRange returns false if embeddable is inside container without a time range', () => {

View file

@ -16,7 +16,7 @@ import { HelloWorldContainer } from '../../../../src/plugins/embeddable/public/l
import {
HelloWorldEmbeddable,
HELLO_WORLD_EMBEDDABLE,
} from '../../../../examples/embeddable_examples/public';
} from '../../../../src/plugins/embeddable/public/tests/fixtures';
import { nextTick } from '@kbn/test/jest';
import { ReactElement } from 'react';

View file

@ -0,0 +1,26 @@
{
"extends": "../../../tsconfig.base.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
"emitDeclarationOnly": true,
"declaration": true,
"declarationMap": true
},
"include": [
"public/**/*",
"server/**/*",
"common/**/*",
"../../typings/**/*"
],
"references": [
{ "path": "../../../src/core/tsconfig.json" },
{ "path": "../../../src/plugins/data/tsconfig.json" },
{ "path": "../../../src/plugins/embeddable/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../../../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../../../src/plugins/ui_actions/tsconfig.json" },
{ "path": "../licensing/tsconfig.json" },
]
}

View file

@ -9,16 +9,28 @@
"exclude": ["../typings/jest.d.ts"],
"references": [
{ "path": "../../src/core/tsconfig.json" },
{ "path": "../../src/plugins/bfetch/tsconfig.json" },
{ "path": "../../src/plugins/data/tsconfig.json" },
{ "path": "../../src/plugins/embeddable/tsconfig.json" },
{ "path": "../../src/plugins/expressions/tsconfig.json" },
{ "path": "../../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../../src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "../../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../../src/plugins/navigation/tsconfig.json" },
{ "path": "../../src/plugins/newsfeed/tsconfig.json" },
{ "path": "../../src/plugins/saved_objects/tsconfig.json" },
{ "path": "../../src/plugins/share/tsconfig.json" },
{ "path": "../../src/plugins/telemetry_collection_manager/tsconfig.json" },
{ "path": "../../src/plugins/telemetry/tsconfig.json" },
{ "path": "../../src/plugins/usage_collection/tsconfig.json" },
{ "path": "../../src/plugins/ui_actions/tsconfig.json" },
{ "path": "../plugins/data_enhanced/tsconfig.json" },
{ "path": "../plugins/global_search/tsconfig.json" },
{ "path": "../plugins/features/tsconfig.json" },
{ "path": "../plugins/embeddable_enhanced/tsconfig.json" },
{ "path": "../plugins/licensing/tsconfig.json" },
{ "path": "../plugins/telemetry_collection_xpack/tsconfig.json" }
{ "path": "../plugins/telemetry_collection_xpack/tsconfig.json" },
{ "path": "../plugins/ui_actions_enhanced/tsconfig.json" },
]
}

View file

@ -4,10 +4,14 @@
"exclude": [
"plugins/apm/e2e/cypress/**/*",
"plugins/apm/scripts/**/*",
"plugins/data_enhanced/**/*",
"plugins/global_search/**/*",
"plugins/features/**/*",
"plugins/embeddable_enhanced/**/*",
"plugins/licensing/**/*",
"plugins/security_solution/cypress/**/*",
"plugins/telemetry_collection_xpack/**/*",
"plugins/ui_actions_enhanced/**/*",
"test/**/*"
],
"compilerOptions": {
@ -16,22 +20,33 @@
},
"references": [
{ "path": "../src/core/tsconfig.json" },
{ "path": "../src/plugins/bfetch/tsconfig.json" },
{ "path": "../src/plugins/data/tsconfig.json" },
{ "path": "../src/plugins/dev_tools/tsconfig.json" },
{ "path": "../src/plugins/embeddable/tsconfig.json" },
{ "path": "../src/plugins/expressions/tsconfig.json" },
{ "path": "../src/plugins/inspector/tsconfig.json" },
{ "path": "../src/plugins/kibana_legacy/tsconfig.json" },
{ "path": "../src/plugins/kibana_react/tsconfig.json" },
{ "path": "../src/plugins/kibana_usage_collection/tsconfig.json" },
{ "path": "../src/plugins/kibana_utils/tsconfig.json" },
{ "path": "../src/plugins/navigation/tsconfig.json" },
{ "path": "../src/plugins/newsfeed/tsconfig.json" },
{ "path": "../src/plugins/saved_objects/tsconfig.json" },
{ "path": "../src/plugins/security_oss/tsconfig.json" },
{ "path": "../src/plugins/share/tsconfig.json" },
{ "path": "../src/plugins/telemetry/tsconfig.json" },
{ "path": "../src/plugins/telemetry_collection_manager/tsconfig.json" },
{ "path": "../src/plugins/url_forwarding/tsconfig.json" },
{ "path": "../src/plugins/ui_actions/tsconfig.json" },
{ "path": "../src/plugins/usage_collection/tsconfig.json" },
{ "path": "./plugins/data_enhanced/tsconfig.json" },
{ "path": "./plugins/global_search/tsconfig.json" },
{ "path": "./plugins/features/tsconfig.json" },
{ "path": "./plugins/embeddable_enhanced/tsconfig.json" },
{ "path": "./plugins/licensing/tsconfig.json" },
{ "path": "./plugins/telemetry_collection_xpack/tsconfig.json" }
{ "path": "./plugins/telemetry_collection_xpack/tsconfig.json" },
{ "path": "./plugins/ui_actions_enhanced/tsconfig.json" }
]
}

View file

@ -2,7 +2,11 @@
"include": [],
"references": [
{ "path": "./plugins/licensing/tsconfig.json" },
{ "path": "./plugins/data_enhanced/tsconfig.json" },
{ "path": "./plugins/global_search/tsconfig.json" },
{ "path": "./plugins/features/tsconfig.json" },
{ "path": "./plugins/embeddable_enhanced/tsconfig.json" },
{ "path": "./plugins/telemetry_collection_xpack/tsconfig.json" },
{ "path": "./plugins/ui_actions_enhanced/tsconfig.json" },
]
}