Skip to content

Commit

Permalink
Merge branch 'main' into fix_bulk_actions_alignment
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Oct 6, 2022
2 parents c10b683 + b076e4b commit c590ed5
Show file tree
Hide file tree
Showing 29 changed files with 1,128 additions and 159 deletions.
17 changes: 9 additions & 8 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -332,15 +332,15 @@ x-pack/examples/files_example @elastic/kibana-app-services
/x-pack/plugins/event_log/ @elastic/response-ops
/x-pack/plugins/task_manager/ @elastic/response-ops
/x-pack/plugins/stack_connectors/ @elastic/response-ops
/x-pack/plugins/stack_connectors/public/connector_types/stack/ @elastic/response-ops-execution
/x-pack/plugins/stack_connectors/server/connector_types/stack/ @elastic/response-ops-execution
/x-pack/plugins/stack_connectors/public/connector_types/cases/ @elastic/response-ops-cases
/x-pack/plugins/stack_connectors/server/connector_types/cases/ @elastic/response-ops-cases
/x-pack/plugins/stack_connectors/public/connector_types/stack/ @elastic/response-ops @elastic/response-ops-execution
/x-pack/plugins/stack_connectors/server/connector_types/stack/ @elastic/response-ops @elastic/response-ops-execution
/x-pack/plugins/stack_connectors/public/connector_types/cases/ @elastic/response-ops @elastic/response-ops-cases
/x-pack/plugins/stack_connectors/server/connector_types/cases/ @elastic/response-ops @elastic/response-ops-cases
/x-pack/test/alerting_api_integration/ @elastic/response-ops
/x-pack/test/alerting_api_integration/basic/tests/actions/connector_types/stack/ @elastic/response-ops-execution
/x-pack/test/alerting_api_integration/basic/tests/actions/connector_types/cases/ @elastic/response-ops-cases
/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/stack/ @elastic/response-ops-execution
/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/cases/ @elastic/response-ops-cases
/x-pack/test/alerting_api_integration/basic/tests/actions/connector_types/stack/ @elastic/response-ops @elastic/response-ops-execution
/x-pack/test/alerting_api_integration/basic/tests/actions/connector_types/cases/ @elastic/response-ops @elastic/response-ops-cases
/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/stack/ @elastic/response-ops @elastic/response-ops-execution
/x-pack/test/alerting_api_integration/security_and_spaces/group2/tests/actions/connector_types/cases/ @elastic/response-ops @elastic/response-ops-cases
/x-pack/test/plugin_api_integration/test_suites/task_manager/ @elastic/response-ops
/x-pack/plugins/triggers_actions_ui/ @elastic/response-ops
/x-pack/test/functional_with_es_ssl/apps/triggers_actions_ui/ @elastic/response-ops
Expand Down Expand Up @@ -833,6 +833,7 @@ packages/core/status/core-status-server-internal @elastic/kibana-core
packages/core/status/core-status-server-mocks @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-deprecations-getters @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-http-setup-browser @elastic/kibana-core
packages/core/test-helpers/core-test-helpers-so-type-serializer @elastic/kibana-core
packages/core/theme/core-theme-browser @elastic/kibana-core
packages/core/theme/core-theme-browser-internal @elastic/kibana-core
packages/core/theme/core-theme-browser-mocks @elastic/kibana-core
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@
"@kbn/core-status-server-mocks": "link:bazel-bin/packages/core/status/core-status-server-mocks",
"@kbn/core-test-helpers-deprecations-getters": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-deprecations-getters",
"@kbn/core-test-helpers-http-setup-browser": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-http-setup-browser",
"@kbn/core-test-helpers-so-type-serializer": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-so-type-serializer",
"@kbn/core-theme-browser": "link:bazel-bin/packages/core/theme/core-theme-browser",
"@kbn/core-theme-browser-internal": "link:bazel-bin/packages/core/theme/core-theme-browser-internal",
"@kbn/core-theme-browser-mocks": "link:bazel-bin/packages/core/theme/core-theme-browser-mocks",
Expand Down Expand Up @@ -1025,6 +1026,7 @@
"@types/kbn__core-status-server-mocks": "link:bazel-bin/packages/core/status/core-status-server-mocks/npm_module_types",
"@types/kbn__core-test-helpers-deprecations-getters": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-deprecations-getters/npm_module_types",
"@types/kbn__core-test-helpers-http-setup-browser": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-http-setup-browser/npm_module_types",
"@types/kbn__core-test-helpers-so-type-serializer": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-so-type-serializer/npm_module_types",
"@types/kbn__core-theme-browser": "link:bazel-bin/packages/core/theme/core-theme-browser/npm_module_types",
"@types/kbn__core-theme-browser-internal": "link:bazel-bin/packages/core/theme/core-theme-browser-internal/npm_module_types",
"@types/kbn__core-theme-browser-mocks": "link:bazel-bin/packages/core/theme/core-theme-browser-mocks/npm_module_types",
Expand Down
2 changes: 2 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ filegroup(
"//packages/core/status/core-status-server-mocks:build",
"//packages/core/test-helpers/core-test-helpers-deprecations-getters:build",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build",
"//packages/core/test-helpers/core-test-helpers-so-type-serializer:build",
"//packages/core/theme/core-theme-browser:build",
"//packages/core/theme/core-theme-browser-internal:build",
"//packages/core/theme/core-theme-browser-mocks:build",
Expand Down Expand Up @@ -500,6 +501,7 @@ filegroup(
"//packages/core/status/core-status-server-mocks:build_types",
"//packages/core/test-helpers/core-test-helpers-deprecations-getters:build_types",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build_types",
"//packages/core/test-helpers/core-test-helpers-so-type-serializer:build_types",
"//packages/core/theme/core-theme-browser:build_types",
"//packages/core/theme/core-theme-browser-internal:build_types",
"//packages/core/theme/core-theme-browser-mocks:build_types",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_DIRNAME = "core-test-helpers-so-type-serializer"
PKG_REQUIRE_NAME = "@kbn/core-test-helpers-so-type-serializer"

SOURCE_FILES = glob(
[
"**/*.ts",
],
exclude = [
"**/*.config.js",
"**/*.mock.*",
"**/*.test.*",
"**/*.stories.*",
"**/__snapshots__/**",
"**/integration_tests/**",
"**/mocks/**",
"**/scripts/**",
"**/storybook/**",
"**/test_fixtures/**",
"**/test_helpers/**",
],
)

SRCS = SOURCE_FILES

filegroup(
name = "srcs",
srcs = SRCS,
)

NPM_MODULE_EXTRA_FILES = [
"package.json",
]

RUNTIME_DEPS = [
"@npm//semver",
"//packages/kbn-std",
]

TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/semver",
"//packages/kbn-std:npm_module_types",
"//packages/core/saved-objects/core-saved-objects-common:npm_module_types",
"//packages/core/saved-objects/core-saved-objects-server:npm_module_types",
]

jsts_transpiler(
name = "target_node",
srcs = SRCS,
build_pkg_name = package_name(),
)

ts_config(
name = "tsconfig",
src = "tsconfig.json",
deps = [
"//:tsconfig.base.json",
"//:tsconfig.bazel.json",
],
)

ts_project(
name = "tsc_types",
args = ['--pretty'],
srcs = SRCS,
deps = TYPES_DEPS,
declaration = True,
declaration_map = True,
emit_declaration_only = True,
out_dir = "target_types",
tsconfig = ":tsconfig",
)

js_library(
name = PKG_DIRNAME,
srcs = NPM_MODULE_EXTRA_FILES,
deps = RUNTIME_DEPS + [":target_node"],
package_name = PKG_REQUIRE_NAME,
visibility = ["//visibility:public"],
)

pkg_npm(
name = "npm_module",
deps = [":" + PKG_DIRNAME],
)

filegroup(
name = "build",
srcs = [":npm_module"],
visibility = ["//visibility:public"],
)

pkg_npm_types(
name = "npm_module_types",
srcs = SRCS,
deps = [":tsc_types"],
package_name = PKG_REQUIRE_NAME,
tsconfig = ":tsconfig",
visibility = ["//visibility:public"],
)

filegroup(
name = "build_types",
srcs = [":npm_module_types"],
visibility = ["//visibility:public"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @kbn/core-test-helpers-so-type-serializer

Utility package for savedObjects integration tests.
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 type { SavedObjectTypeMigrationInfo } from './src/extract_migration_info';
export { extractMigrationInfo } from './src/extract_migration_info';
export { getMigrationHash } from './src/get_migration_hash';
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/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/test-helpers/core-test-helpers-so-type-serializer'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "shared-common",
"id": "@kbn/core-test-helpers-so-type-serializer",
"owner": "@elastic/kibana-core",
"runtimeDeps": [],
"typeDeps": [],
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "@kbn/core-test-helpers-so-type-serializer",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"author": "Kibana Core",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
/*
* 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 { schema } from '@kbn/config-schema';
import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
import { extractMigrationInfo } from './extract_migration_info';

const createType = (parts: Partial<SavedObjectsType>): SavedObjectsType => ({
name: 'test-type',
hidden: false,
namespaceType: 'multiple',
mappings: { properties: {} },
...parts,
});

const dummyMigration = jest.fn();
const dummySchema = schema.object({});

describe('extractMigrationInfo', () => {
describe('simple fields', () => {
it('returns the `name` from the SO type', () => {
const type = createType({ name: 'my-type' });
const output = extractMigrationInfo(type);
expect(output.name).toEqual('my-type');
});

it('returns the `namespaceType` from the SO type', () => {
const type = createType({ namespaceType: 'multiple-isolated' });
const output = extractMigrationInfo(type);
expect(output.namespaceType).toEqual('multiple-isolated');
});

it('returns the `convertToMultiNamespaceTypeVersion` from the SO type', () => {
const type = createType({ convertToMultiNamespaceTypeVersion: '6.6.6' });
const output = extractMigrationInfo(type);
expect(output.convertToMultiNamespaceTypeVersion).toEqual('6.6.6');
});

it('returns the `convertToAliasScript` from the SO type', () => {
const type = createType({ convertToAliasScript: 'some_value' });
const output = extractMigrationInfo(type);
expect(output.convertToAliasScript).toEqual('some_value');
});

it('returns true for `hasExcludeOnUpgrade` if the SO type specifies `excludeOnUpgrade`', () => {
expect(
extractMigrationInfo(createType({ excludeOnUpgrade: jest.fn() })).hasExcludeOnUpgrade
).toEqual(true);
expect(
extractMigrationInfo(createType({ excludeOnUpgrade: undefined })).hasExcludeOnUpgrade
).toEqual(false);
});
});

describe('migrations', () => {
it('returns the versions with registered migrations, sorted asc', () => {
const type = createType({
migrations: {
'8.3.3': dummyMigration,
'7.17.7': dummyMigration,
'8.0.2': dummyMigration,
},
});

const output = extractMigrationInfo(type);

expect(output.migrationVersions).toEqual(['7.17.7', '8.0.2', '8.3.3']);
});

it('supports migration provider functions', () => {
const type = createType({
migrations: () => ({
'8.3.3': dummyMigration,
'7.17.7': dummyMigration,
'8.0.2': dummyMigration,
}),
});

const output = extractMigrationInfo(type);

expect(output.migrationVersions).toEqual(['7.17.7', '8.0.2', '8.3.3']);
});

it('returns an empty list when migrations are not defined', () => {
const type = createType({
migrations: undefined,
});

const output = extractMigrationInfo(type);

expect(output.migrationVersions).toEqual([]);
});
});

describe('schemas', () => {
it('returns the versions with registered schemas, sorted asc', () => {
const type = createType({
schemas: {
'8.3.2': dummySchema,
'7.15.2': dummySchema,
'8.1.2': dummySchema,
},
});

const output = extractMigrationInfo(type);

expect(output.schemaVersions).toEqual(['7.15.2', '8.1.2', '8.3.2']);
});

it('supports schema provider functions', () => {
const type = createType({
schemas: () => ({
'8.3.2': dummySchema,
'7.15.2': dummySchema,
'8.1.2': dummySchema,
}),
});

const output = extractMigrationInfo(type);

expect(output.schemaVersions).toEqual(['7.15.2', '8.1.2', '8.3.2']);
});

it('returns an empty list when schemas are not defined', () => {
const type = createType({
schemas: undefined,
});

const output = extractMigrationInfo(type);

expect(output.schemaVersions).toEqual([]);
});
});

describe('mappings', () => {
it('returns a flattened version of the mappings', () => {
const type = createType({
mappings: {
dynamic: false,
properties: {
description: { type: 'text' },
hits: { type: 'integer', index: false, doc_values: false },
},
},
});
const output = extractMigrationInfo(type);
expect(output.mappings).toEqual({
dynamic: false,
'properties.description.type': 'text',
'properties.hits.doc_values': false,
'properties.hits.index': false,
'properties.hits.type': 'integer',
});
});
});
});
Loading

0 comments on commit c590ed5

Please sign in to comment.