mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
Migrate server-side savedObjects public types to packages (#137183)
* create empty package * start moving types * create explicit interface for ISavedObjectsRegistry * extract client factory types * extract service contract types * fix re-exports * [CI] Auto-commit changed files from 'node scripts/eslint --no-cache --fix' * start fixing internal imports * fix more core imports * lint * use serializer interface * use serializer interface again * fix missing re-export * move request handler context type to package * one less serializer impl usage * remove TODO * update readme * typo fix Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
2e490152a0
commit
4f4c160d56
144 changed files with 1416 additions and 1047 deletions
|
@ -227,6 +227,7 @@
|
|||
"@kbn/core-saved-objects-api-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-browser",
|
||||
"@kbn/core-saved-objects-api-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server",
|
||||
"@kbn/core-saved-objects-common": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-common",
|
||||
"@kbn/core-saved-objects-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-server",
|
||||
"@kbn/core-test-helpers-http-setup-browser": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-http-setup-browser",
|
||||
"@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",
|
||||
|
@ -836,6 +837,7 @@
|
|||
"@types/kbn__core-saved-objects-api-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-browser/npm_module_types",
|
||||
"@types/kbn__core-saved-objects-api-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-api-server/npm_module_types",
|
||||
"@types/kbn__core-saved-objects-common": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-common/npm_module_types",
|
||||
"@types/kbn__core-saved-objects-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-server/npm_module_types",
|
||||
"@types/kbn__core-server-internal-base": "link:bazel-bin/packages/core/server/internal-base/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-theme-browser": "link:bazel-bin/packages/core/theme/core-theme-browser/npm_module_types",
|
||||
|
|
|
@ -95,6 +95,7 @@ filegroup(
|
|||
"//packages/core/saved-objects/core-saved-objects-api-browser:build",
|
||||
"//packages/core/saved-objects/core-saved-objects-api-server:build",
|
||||
"//packages/core/saved-objects/core-saved-objects-common:build",
|
||||
"//packages/core/saved-objects/core-saved-objects-server:build",
|
||||
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build",
|
||||
"//packages/core/theme/core-theme-browser-internal:build",
|
||||
"//packages/core/theme/core-theme-browser-mocks:build",
|
||||
|
@ -328,6 +329,7 @@ filegroup(
|
|||
"//packages/core/saved-objects/core-saved-objects-api-browser:build_types",
|
||||
"//packages/core/saved-objects/core-saved-objects-api-server:build_types",
|
||||
"//packages/core/saved-objects/core-saved-objects-common:build_types",
|
||||
"//packages/core/saved-objects/core-saved-objects-server:build_types",
|
||||
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build_types",
|
||||
"//packages/core/theme/core-theme-browser-internal:build_types",
|
||||
"//packages/core/theme/core-theme-browser-mocks:build_types",
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
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-saved-objects-server"
|
||||
PKG_REQUIRE_NAME = "@kbn/core-saved-objects-server"
|
||||
|
||||
SOURCE_FILES = glob(
|
||||
[
|
||||
"src/**/*.ts",
|
||||
],
|
||||
exclude = [
|
||||
"**/*.test.*",
|
||||
"**/*.stories.*",
|
||||
],
|
||||
)
|
||||
|
||||
SRCS = SOURCE_FILES
|
||||
|
||||
filegroup(
|
||||
name = "srcs",
|
||||
srcs = SRCS,
|
||||
)
|
||||
|
||||
NPM_MODULE_EXTRA_FILES = [
|
||||
"package.json",
|
||||
]
|
||||
|
||||
RUNTIME_DEPS = [
|
||||
]
|
||||
|
||||
TYPES_DEPS = [
|
||||
"@npm//@types/node",
|
||||
"@npm//@types/jest",
|
||||
"@npm//@elastic/elasticsearch",
|
||||
"//packages/kbn-utility-types:npm_module_types",
|
||||
"//packages/kbn-config-schema:npm_module_types",
|
||||
"//packages/kbn-logging:npm_module_types",
|
||||
"//packages/core/http/core-http-server:npm_module_types",
|
||||
"//packages/core/elasticsearch/core-elasticsearch-server:npm_module_types",
|
||||
"//packages/core/saved-objects/core-saved-objects-common:npm_module_types",
|
||||
"//packages/core/saved-objects/core-saved-objects-api-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",
|
||||
root_dir = "src",
|
||||
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"],
|
||||
)
|
|
@ -0,0 +1,5 @@
|
|||
# @kbn/core-saved-objects-server
|
||||
|
||||
This package contains the public types for Core server-side savedObjects service and contracts.
|
||||
|
||||
Note: the types related to the savedObjects client and repository APIs can be found in the `@kbn/core-saved-objects-api-server` package.
|
|
@ -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/saved-objects/core-saved-objects-server'],
|
||||
};
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"name": "@kbn/core-saved-objects-server",
|
||||
"private": true,
|
||||
"version": "1.0.0",
|
||||
"main": "./target_node/index.js",
|
||||
"license": "SSPL-1.0 OR Elastic License 2.0"
|
||||
}
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* 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 type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import type {
|
||||
SavedObjectsClientContract,
|
||||
ISavedObjectsRepository,
|
||||
} from '@kbn/core-saved-objects-api-server';
|
||||
import type { ISavedObjectTypeRegistry } from './type_registry';
|
||||
|
||||
/**
|
||||
* Options passed to each SavedObjectsClientWrapperFactory to aid in creating the wrapper instance.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsClientWrapperOptions {
|
||||
client: SavedObjectsClientContract;
|
||||
typeRegistry: ISavedObjectTypeRegistry;
|
||||
request: KibanaRequest;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes the factory used to create instances of Saved Objects Client Wrappers.
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsClientWrapperFactory = (
|
||||
options: SavedObjectsClientWrapperOptions
|
||||
) => SavedObjectsClientContract;
|
||||
|
||||
/**
|
||||
* Describes the factory used to create instances of the Saved Objects Client.
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsClientFactory = ({
|
||||
request,
|
||||
includedHiddenTypes,
|
||||
}: {
|
||||
request: KibanaRequest;
|
||||
includedHiddenTypes?: string[];
|
||||
}) => SavedObjectsClientContract;
|
||||
|
||||
/**
|
||||
* Provider to invoke to retrieve a {@link SavedObjectsClientFactory}.
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsClientFactoryProvider = (
|
||||
repositoryFactory: SavedObjectsRepositoryFactory
|
||||
) => SavedObjectsClientFactory;
|
||||
|
||||
/**
|
||||
* Options to control the creation of the Saved Objects Client.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsClientProviderOptions {
|
||||
excludedWrappers?: string[];
|
||||
includedHiddenTypes?: string[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Factory provided when invoking a {@link SavedObjectsClientFactoryProvider | client factory provider}
|
||||
* See {@link SavedObjectsServiceSetup.setClientFactoryProvider}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsRepositoryFactory {
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the credentials from the passed in request to authenticate with
|
||||
* Elasticsearch.
|
||||
*
|
||||
* @param includedHiddenTypes - A list of additional hidden types the repository should have access to.
|
||||
*/
|
||||
createScopedRepository: (
|
||||
req: KibanaRequest,
|
||||
includedHiddenTypes?: string[]
|
||||
) => ISavedObjectsRepository;
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the internal Kibana user for authenticating with Elasticsearch.
|
||||
*
|
||||
* @param includedHiddenTypes - A list of additional hidden types the repository should have access to.
|
||||
*/
|
||||
createInternalRepository: (includedHiddenTypes?: string[]) => ISavedObjectsRepository;
|
||||
}
|
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
* 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 type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import type { SavedObjectAttributes } from '@kbn/core-saved-objects-common';
|
||||
import type {
|
||||
SavedObjectsClientContract,
|
||||
ISavedObjectsRepository,
|
||||
} from '@kbn/core-saved-objects-api-server';
|
||||
import type { ISavedObjectsSerializer } from './serialization';
|
||||
import type {
|
||||
SavedObjectsClientFactoryProvider,
|
||||
SavedObjectsClientWrapperFactory,
|
||||
SavedObjectsClientProviderOptions,
|
||||
} from './client_factory';
|
||||
import type { SavedObjectsType } from './saved_objects_type';
|
||||
import type { ISavedObjectTypeRegistry } from './type_registry';
|
||||
import type { ISavedObjectsExporter } from './export';
|
||||
import type { ISavedObjectsImporter } from './import';
|
||||
|
||||
/**
|
||||
* Saved Objects is Kibana's data persistence mechanism allowing plugins to
|
||||
* use Elasticsearch for storing and querying state. The SavedObjectsServiceSetup API exposes methods
|
||||
* for registering Saved Object types, creating and registering Saved Object client wrappers and factories.
|
||||
*
|
||||
* @remarks
|
||||
* When plugins access the Saved Objects client, a new client is created using
|
||||
* the factory provided to `setClientFactory` and wrapped by all wrappers
|
||||
* registered through `addClientWrapper`.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { SavedObjectsClient, CoreSetup } from 'src/core/server';
|
||||
*
|
||||
* export class Plugin() {
|
||||
* setup: (core: CoreSetup) => {
|
||||
* core.savedObjects.setClientFactory(({ request: KibanaRequest }) => {
|
||||
* return new SavedObjectsClient(core.savedObjects.scopedRepository(request));
|
||||
* })
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* import { SavedObjectsClient, CoreSetup } from 'src/core/server';
|
||||
* import { mySoType } from './saved_objects'
|
||||
*
|
||||
* export class Plugin() {
|
||||
* setup: (core: CoreSetup) => {
|
||||
* core.savedObjects.registerType(mySoType);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsServiceSetup {
|
||||
/**
|
||||
* Set the default {@link SavedObjectsClientFactoryProvider | factory provider} for creating Saved Objects clients.
|
||||
* Only one provider can be set, subsequent calls to this method will fail.
|
||||
*/
|
||||
setClientFactoryProvider: (clientFactoryProvider: SavedObjectsClientFactoryProvider) => void;
|
||||
|
||||
/**
|
||||
* Add a {@link SavedObjectsClientWrapperFactory | client wrapper factory} with the given priority.
|
||||
*/
|
||||
addClientWrapper: (
|
||||
priority: number,
|
||||
id: string,
|
||||
factory: SavedObjectsClientWrapperFactory
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Register a {@link SavedObjectsType | savedObjects type} definition.
|
||||
*
|
||||
* See the {@link SavedObjectsTypeMappingDefinition | mappings format} and
|
||||
* {@link SavedObjectMigrationMap | migration format} for more details about these.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* // src/plugins/my_plugin/server/saved_objects/my_type.ts
|
||||
* import { SavedObjectsType } from 'src/core/server';
|
||||
* import * as migrations from './migrations';
|
||||
* import * as schemas from './schemas';
|
||||
*
|
||||
* export const myType: SavedObjectsType = {
|
||||
* name: 'MyType',
|
||||
* hidden: false,
|
||||
* namespaceType: 'multiple',
|
||||
* mappings: {
|
||||
* properties: {
|
||||
* textField: {
|
||||
* type: 'text',
|
||||
* },
|
||||
* boolField: {
|
||||
* type: 'boolean',
|
||||
* },
|
||||
* },
|
||||
* },
|
||||
* migrations: {
|
||||
* '2.0.0': migrations.migrateToV2,
|
||||
* '2.1.0': migrations.migrateToV2_1
|
||||
* },
|
||||
* schemas: {
|
||||
* '2.0.0': schemas.v2,
|
||||
* '2.1.0': schemas.v2_1,
|
||||
* },
|
||||
* };
|
||||
*
|
||||
* // src/plugins/my_plugin/server/plugin.ts
|
||||
* import { SavedObjectsClient, CoreSetup } from 'src/core/server';
|
||||
* import { myType } from './saved_objects';
|
||||
*
|
||||
* export class Plugin() {
|
||||
* setup: (core: CoreSetup) => {
|
||||
* core.savedObjects.registerType(myType);
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
registerType: <Attributes extends SavedObjectAttributes = any>(
|
||||
type: SavedObjectsType<Attributes>
|
||||
) => void;
|
||||
|
||||
/**
|
||||
* Returns the default index used for saved objects.
|
||||
*/
|
||||
getKibanaIndex: () => string;
|
||||
}
|
||||
|
||||
/**
|
||||
* Saved Objects is Kibana's data persistence mechanism allowing plugins to
|
||||
* use Elasticsearch for storing and querying state. The
|
||||
* SavedObjectsServiceStart API provides a scoped Saved Objects client for
|
||||
* interacting with Saved Objects.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsServiceStart {
|
||||
/**
|
||||
* Creates a {@link SavedObjectsClientContract | Saved Objects client} that
|
||||
* uses the credentials from the passed in request to authenticate with
|
||||
* Elasticsearch. If other plugins have registered Saved Objects client
|
||||
* wrappers, these will be applied to extend the functionality of the client.
|
||||
*
|
||||
* A client that is already scoped to the incoming request is also exposed
|
||||
* from the route handler context see {@link RequestHandlerContext}.
|
||||
*/
|
||||
getScopedClient: (
|
||||
req: KibanaRequest,
|
||||
options?: SavedObjectsClientProviderOptions
|
||||
) => SavedObjectsClientContract;
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the credentials from the passed in request to authenticate with
|
||||
* Elasticsearch.
|
||||
*
|
||||
* @param req - The request to create the scoped repository from.
|
||||
* @param includedHiddenTypes - A list of additional hidden types the repository should have access to.
|
||||
*
|
||||
* @remarks
|
||||
* Prefer using `getScopedClient`. This should only be used when using methods
|
||||
* not exposed on {@link SavedObjectsClientContract}
|
||||
*/
|
||||
createScopedRepository: (
|
||||
req: KibanaRequest,
|
||||
includedHiddenTypes?: string[]
|
||||
) => ISavedObjectsRepository;
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsRepository | Saved Objects repository} that
|
||||
* uses the internal Kibana user for authenticating with Elasticsearch.
|
||||
*
|
||||
* @param includedHiddenTypes - A list of additional hidden types the repository should have access to.
|
||||
*/
|
||||
createInternalRepository: (includedHiddenTypes?: string[]) => ISavedObjectsRepository;
|
||||
/**
|
||||
* Creates a {@link ISavedObjectsSerializer | serializer} that is aware of all registered types.
|
||||
*/
|
||||
createSerializer: () => ISavedObjectsSerializer;
|
||||
/**
|
||||
* Creates an {@link ISavedObjectsExporter | exporter} bound to given client.
|
||||
*/
|
||||
createExporter: (client: SavedObjectsClientContract) => ISavedObjectsExporter;
|
||||
/**
|
||||
* Creates an {@link ISavedObjectsImporter | importer} bound to given client.
|
||||
*/
|
||||
createImporter: (client: SavedObjectsClientContract) => ISavedObjectsImporter;
|
||||
/**
|
||||
* Returns the {@link ISavedObjectTypeRegistry | registry} containing all registered
|
||||
* {@link SavedObjectsType | saved object types}
|
||||
*/
|
||||
getTypeRegistry: () => ISavedObjectTypeRegistry;
|
||||
}
|
|
@ -6,10 +6,36 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { Readable } from 'stream';
|
||||
import type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import type { SavedObject } from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObject, SavedObjectTypeIdTuple } from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsFindOptionsReference } from '@kbn/core-saved-objects-api-server';
|
||||
|
||||
/**
|
||||
* Utility class used to export savedObjects.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ISavedObjectsExporter {
|
||||
/**
|
||||
* Generates an export stream for given types.
|
||||
*
|
||||
* See the {@link SavedObjectsExportByTypeOptions | options} for more detailed information.
|
||||
*
|
||||
* @throws SavedObjectsExportError
|
||||
*/
|
||||
exportByTypes(options: SavedObjectsExportByTypeOptions): Promise<Readable>;
|
||||
|
||||
/**
|
||||
* Generates an export stream for given object references.
|
||||
*
|
||||
* See the {@link SavedObjectsExportByObjectOptions | options} for more detailed information.
|
||||
*
|
||||
* @throws SavedObjectsExportError
|
||||
*/
|
||||
exportByObjects(options: SavedObjectsExportByObjectOptions): Promise<Readable>;
|
||||
}
|
||||
|
||||
/** @public */
|
||||
export interface SavedObjectExportBaseOptions {
|
||||
/** The http request initiating the export. */
|
||||
|
@ -49,12 +75,7 @@ export interface SavedObjectsExportByTypeOptions extends SavedObjectExportBaseOp
|
|||
*/
|
||||
export interface SavedObjectsExportByObjectOptions extends SavedObjectExportBaseOptions {
|
||||
/** optional array of objects to export. */
|
||||
objects: Array<{
|
||||
/** the saved object id. */
|
||||
id: string;
|
||||
/** the saved object type. */
|
||||
type: string;
|
||||
}>;
|
||||
objects: SavedObjectTypeIdTuple[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -67,12 +88,7 @@ export interface SavedObjectsExportResultDetails {
|
|||
/** number of missing references */
|
||||
missingRefCount: number;
|
||||
/** missing references details */
|
||||
missingReferences: Array<{
|
||||
/** the missing reference id. */
|
||||
id: string;
|
||||
/** the missing reference type. */
|
||||
type: string;
|
||||
}>;
|
||||
missingReferences: SavedObjectTypeIdTuple[];
|
||||
/** number of objects that were excluded from the export */
|
||||
excludedObjectsCount: number;
|
||||
/** excluded objects details */
|
|
@ -11,8 +11,34 @@ import {
|
|||
SavedObject,
|
||||
SavedObjectsImportRetry,
|
||||
SavedObjectsImportWarning,
|
||||
SavedObjectsImportResponse,
|
||||
} from '@kbn/core-saved-objects-common';
|
||||
|
||||
/**
|
||||
* Utility class used to import savedObjects.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ISavedObjectsImporter {
|
||||
/**
|
||||
* Import saved objects from given stream. See the {@link SavedObjectsImportOptions | options} for more
|
||||
* detailed information.
|
||||
*
|
||||
* @throws SavedObjectsImportError
|
||||
*/
|
||||
import(options: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse>;
|
||||
|
||||
/**
|
||||
* Resolve and return saved object import errors.
|
||||
* See the {@link SavedObjectsResolveImportErrorsOptions | options} for more detailed information.
|
||||
*
|
||||
* @throws SavedObjectsImportError
|
||||
*/
|
||||
resolveImportErrors(
|
||||
options: SavedObjectsResolveImportErrorsOptions
|
||||
): Promise<SavedObjectsImportResponse>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Options to control the import operation.
|
||||
* @public
|
|
@ -0,0 +1,66 @@
|
|||
/*
|
||||
* 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 {
|
||||
SavedObjectsClientFactory,
|
||||
SavedObjectsClientFactoryProvider,
|
||||
SavedObjectsClientWrapperFactory,
|
||||
SavedObjectsRepositoryFactory,
|
||||
SavedObjectsClientProviderOptions,
|
||||
SavedObjectsClientWrapperOptions,
|
||||
} from './client_factory';
|
||||
export type { SavedObjectsServiceSetup, SavedObjectsServiceStart } from './contracts';
|
||||
export type {
|
||||
ISavedObjectsExporter,
|
||||
SavedObjectsExportTransform,
|
||||
SavedObjectsExportByObjectOptions,
|
||||
SavedObjectsExportByTypeOptions,
|
||||
SavedObjectExportBaseOptions,
|
||||
SavedObjectsExportExcludedObject,
|
||||
SavedObjectsExportTransformContext,
|
||||
SavedObjectsExportResultDetails,
|
||||
} from './export';
|
||||
export type {
|
||||
ISavedObjectsImporter,
|
||||
SavedObjectsImportHook,
|
||||
SavedObjectsImportHookResult,
|
||||
SavedObjectsImportOptions,
|
||||
SavedObjectsResolveImportErrorsOptions,
|
||||
CreatedObject,
|
||||
} from './import';
|
||||
export type {
|
||||
SavedObjectsTypeMappingDefinition,
|
||||
SavedObjectsFieldMapping,
|
||||
SavedObjectsMappingProperties,
|
||||
} from './mapping_definition';
|
||||
export type {
|
||||
SavedObjectMigrationMap,
|
||||
SavedObjectMigrationContext,
|
||||
SavedObjectsMigrationLogger,
|
||||
SavedObjectMigrationFn,
|
||||
} from './migration';
|
||||
export type { SavedObjectsRequestHandlerContext } from './request_handler_context';
|
||||
export type {
|
||||
SavedObjectsTypeManagementDefinition,
|
||||
SavedObjectsExportablePredicate,
|
||||
} from './saved_objects_management';
|
||||
export type { SavedObjectStatusMeta } from './saved_objects_status';
|
||||
export type {
|
||||
SavedObjectsType,
|
||||
SavedObjectTypeExcludeFromUpgradeFilterHook,
|
||||
} from './saved_objects_type';
|
||||
export type {
|
||||
ISavedObjectsSerializer,
|
||||
SavedObjectsRawDocSource,
|
||||
SavedObjectsRawDoc,
|
||||
SavedObjectSanitizedDoc,
|
||||
SavedObjectsRawDocParseOptions,
|
||||
SavedObjectUnsanitizedDoc,
|
||||
} from './serialization';
|
||||
export type { ISavedObjectTypeRegistry } from './type_registry';
|
||||
export type { SavedObjectsValidationMap, SavedObjectsValidationSpec } from './validation';
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* 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 type {
|
||||
PropertyName as EsPropertyName,
|
||||
MappingProperty as EsMappingProperty,
|
||||
} from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
|
||||
/**
|
||||
* Describe a saved object type mapping.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const typeDefinition: SavedObjectsTypeMappingDefinition = {
|
||||
* properties: {
|
||||
* enabled: {
|
||||
* type: "boolean"
|
||||
* },
|
||||
* sendUsageFrom: {
|
||||
* ignore_above: 256,
|
||||
* type: "keyword"
|
||||
* },
|
||||
* lastReported: {
|
||||
* type: "date"
|
||||
* },
|
||||
* lastVersionChecked: {
|
||||
* ignore_above: 256,
|
||||
* type: "keyword"
|
||||
* },
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsTypeMappingDefinition {
|
||||
/** The dynamic property of the mapping, either `false` or `'strict'`. If
|
||||
* unspecified `dynamic: 'strict'` will be inherited from the top-level
|
||||
* index mappings. */
|
||||
dynamic?: false | 'strict';
|
||||
/** The underlying properties of the type mapping */
|
||||
properties: SavedObjectsMappingProperties;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe the fields of a {@link SavedObjectsTypeMappingDefinition | saved object type}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsMappingProperties {
|
||||
[field: string]: SavedObjectsFieldMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe a {@link SavedObjectsTypeMappingDefinition | saved object type mapping} field.
|
||||
*
|
||||
* Please refer to {@link https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html | elasticsearch documentation}
|
||||
* For the mapping documentation
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsFieldMapping = EsMappingProperty & {
|
||||
/**
|
||||
* The dynamic property of the mapping, either `false` or `'strict'`. If
|
||||
* unspecified `dynamic: 'strict'` will be inherited from the top-level
|
||||
* index mappings.
|
||||
*
|
||||
* Note: To limit the number of mapping fields Saved Object types should
|
||||
* *never* use `dynamic: true`.
|
||||
*/
|
||||
dynamic?: false | 'strict';
|
||||
/**
|
||||
* Some mapping types do not accept the `properties` attributes. Explicitly adding it as optional to our type
|
||||
* to avoid type failures on all code using accessing them via `SavedObjectsFieldMapping.properties`.
|
||||
*/
|
||||
properties?: Record<EsPropertyName, EsMappingProperty>;
|
||||
};
|
|
@ -0,0 +1,106 @@
|
|||
/*
|
||||
* 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 type { LogMeta } from '@kbn/logging';
|
||||
import type { SavedObjectUnsanitizedDoc } from './serialization';
|
||||
|
||||
/**
|
||||
* A migration function for a {@link SavedObjectsType | saved object type}
|
||||
* used to migrate it to a given version
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* interface TypeV1Attributes {
|
||||
* someKey: string;
|
||||
* obsoleteProperty: number;
|
||||
* }
|
||||
*
|
||||
* interface TypeV2Attributes {
|
||||
* someKey: string;
|
||||
* newProperty: string;
|
||||
* }
|
||||
*
|
||||
* const migrateToV2: SavedObjectMigrationFn<TypeV1Attributes, TypeV2Attributes> = (doc, { log }) => {
|
||||
* const { obsoleteProperty, ...otherAttributes } = doc.attributes;
|
||||
* // instead of mutating `doc` we make a shallow copy so that we can use separate types for the input
|
||||
* // and output attributes. We don't need to make a deep copy, we just need to ensure that obsolete
|
||||
* // attributes are not present on the returned doc.
|
||||
* return {
|
||||
* ...doc,
|
||||
* attributes: {
|
||||
* ...otherAttributes,
|
||||
* newProperty: migrate(obsoleteProperty),
|
||||
* },
|
||||
* };
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectMigrationFn<InputAttributes = unknown, MigratedAttributes = unknown> = (
|
||||
doc: SavedObjectUnsanitizedDoc<InputAttributes>,
|
||||
context: SavedObjectMigrationContext
|
||||
) => SavedObjectUnsanitizedDoc<MigratedAttributes>;
|
||||
|
||||
/** @public */
|
||||
export interface SavedObjectsMigrationLogger {
|
||||
debug: (msg: string) => void;
|
||||
info: (msg: string) => void;
|
||||
/**
|
||||
* @deprecated Use `warn` instead.
|
||||
* @removeBy 8.8.0
|
||||
*/
|
||||
warning: (msg: string) => void;
|
||||
warn: (msg: string) => void;
|
||||
error: <Meta extends LogMeta = LogMeta>(msg: string, meta: Meta) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
* Migration context provided when invoking a {@link SavedObjectMigrationFn | migration handler}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectMigrationContext {
|
||||
/**
|
||||
* logger instance to be used by the migration handler
|
||||
*/
|
||||
readonly log: SavedObjectsMigrationLogger;
|
||||
/**
|
||||
* The migration version that this migration function is defined for
|
||||
*/
|
||||
readonly migrationVersion: string;
|
||||
/**
|
||||
* The version in which this object type is being converted to a multi-namespace type
|
||||
*/
|
||||
readonly convertToMultiNamespaceTypeVersion?: string;
|
||||
/**
|
||||
* Whether this is a single-namespace type or not
|
||||
*/
|
||||
readonly isSingleNamespaceType: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A map of {@link SavedObjectMigrationFn | migration functions} to be used for a given type.
|
||||
* The map's keys must be valid semver versions, and they cannot exceed the current Kibana version.
|
||||
*
|
||||
* For a given document, only migrations with a higher version number than that of the document will be applied.
|
||||
* Migrations are executed in order, starting from the lowest version and ending with the highest one.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const migrationsMap: SavedObjectMigrationMap = {
|
||||
* '1.0.0': migrateToV1,
|
||||
* '2.1.0': migrateToV21
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectMigrationMap {
|
||||
[version: string]: SavedObjectMigrationFn<any, any>;
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* 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 type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type { ISavedObjectsExporter } from './export';
|
||||
import type { ISavedObjectsImporter } from './import';
|
||||
import type { ISavedObjectTypeRegistry } from './type_registry';
|
||||
import type { SavedObjectsClientProviderOptions } from './client_factory';
|
||||
|
||||
/**
|
||||
* Core's `savedObjects` request handler context.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsRequestHandlerContext {
|
||||
client: SavedObjectsClientContract;
|
||||
typeRegistry: ISavedObjectTypeRegistry;
|
||||
getClient: (options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract;
|
||||
getExporter: (client: SavedObjectsClientContract) => ISavedObjectsExporter;
|
||||
getImporter: (client: SavedObjectsClientContract) => ISavedObjectsImporter;
|
||||
}
|
|
@ -6,132 +6,9 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObject, SavedObjectsNamespaceType } from '@kbn/core-saved-objects-common';
|
||||
import { SavedObjectsTypeMappingDefinition } from './mappings';
|
||||
import { SavedObjectMigrationMap } from './migrations';
|
||||
import { SavedObjectsExportTransform } from './export';
|
||||
import { SavedObjectsImportHook } from './import/types';
|
||||
import { SavedObjectsValidationMap } from './validation';
|
||||
|
||||
/**
|
||||
* Meta information about the SavedObjectService's status. Available to plugins via {@link CoreSetup.status}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectStatusMeta {
|
||||
migratedIndices: {
|
||||
[status: string]: number;
|
||||
skipped: number;
|
||||
migrated: number;
|
||||
};
|
||||
}
|
||||
|
||||
export type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsType<Attributes = any> {
|
||||
/**
|
||||
* The name of the type, which is also used as the internal id.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Is the type hidden by default. If true, repositories will not have access to this type unless explicitly
|
||||
* declared as an `extraType` when creating the repository.
|
||||
*
|
||||
* See {@link SavedObjectsServiceStart.createInternalRepository | createInternalRepository}.
|
||||
*/
|
||||
hidden: boolean;
|
||||
/**
|
||||
* The {@link SavedObjectsNamespaceType | namespace type} for the type.
|
||||
*/
|
||||
namespaceType: SavedObjectsNamespaceType;
|
||||
/**
|
||||
* If defined, the type instances will be stored in the given index instead of the default one.
|
||||
*/
|
||||
indexPattern?: string;
|
||||
/**
|
||||
* If defined, will be used to convert the type to an alias.
|
||||
*/
|
||||
convertToAliasScript?: string;
|
||||
/**
|
||||
* If defined, allows a type to exclude unneeded documents from the migration process and effectively be deleted.
|
||||
* See {@link SavedObjectTypeExcludeFromUpgradeFilterHook} for more details.
|
||||
*/
|
||||
excludeOnUpgrade?: SavedObjectTypeExcludeFromUpgradeFilterHook;
|
||||
/**
|
||||
* The {@link SavedObjectsTypeMappingDefinition | mapping definition} for the type.
|
||||
*/
|
||||
mappings: SavedObjectsTypeMappingDefinition;
|
||||
/**
|
||||
* An optional map of {@link SavedObjectMigrationFn | migrations} or a function returning a map of {@link SavedObjectMigrationFn | migrations} to be used to migrate the type.
|
||||
*/
|
||||
migrations?: SavedObjectMigrationMap | (() => SavedObjectMigrationMap);
|
||||
/**
|
||||
* An optional schema that can be used to validate the attributes of the type.
|
||||
*
|
||||
* When provided, calls to {@link SavedObjectsClient.create | create} will be validated against this schema.
|
||||
*
|
||||
* See {@link SavedObjectsValidationMap} for more details.
|
||||
*/
|
||||
schemas?: SavedObjectsValidationMap | (() => SavedObjectsValidationMap);
|
||||
/**
|
||||
* If defined, objects of this type will be converted to a 'multiple' or 'multiple-isolated' namespace type when migrating to this
|
||||
* version.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* 1. This string value must be a valid semver version
|
||||
* 2. This type must have previously specified {@link SavedObjectsNamespaceType | `namespaceType: 'single'`}
|
||||
* 3. This type must also specify {@link SavedObjectsNamespaceType | `namespaceType: 'multiple'`} *or*
|
||||
* {@link SavedObjectsNamespaceType | `namespaceType: 'multiple-isolated'`}
|
||||
*
|
||||
* Example of a single-namespace type in 7.12:
|
||||
*
|
||||
* ```ts
|
||||
* {
|
||||
* name: 'foo',
|
||||
* hidden: false,
|
||||
* namespaceType: 'single',
|
||||
* mappings: {...}
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Example after converting to a multi-namespace (isolated) type in 8.0:
|
||||
*
|
||||
* ```ts
|
||||
* {
|
||||
* name: 'foo',
|
||||
* hidden: false,
|
||||
* namespaceType: 'multiple-isolated',
|
||||
* mappings: {...},
|
||||
* convertToMultiNamespaceTypeVersion: '8.0.0'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Example after converting to a multi-namespace (shareable) type in 8.1:
|
||||
*
|
||||
* ```ts
|
||||
* {
|
||||
* name: 'foo',
|
||||
* hidden: false,
|
||||
* namespaceType: 'multiple',
|
||||
* mappings: {...},
|
||||
* convertToMultiNamespaceTypeVersion: '8.0.0'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Note: migration function(s) can be optionally specified for any of these versions and will not interfere with the conversion process.
|
||||
*/
|
||||
convertToMultiNamespaceTypeVersion?: string;
|
||||
/**
|
||||
* An optional {@link SavedObjectsTypeManagementDefinition | saved objects management section} definition for the type.
|
||||
*/
|
||||
management?: SavedObjectsTypeManagementDefinition<Attributes>;
|
||||
}
|
||||
import type { SavedObject } from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsExportTransform } from './export';
|
||||
import type { SavedObjectsImportHook } from './import';
|
||||
|
||||
/**
|
||||
* Configuration options for the {@link SavedObjectsType | type}'s management section.
|
||||
|
@ -294,18 +171,3 @@ export interface SavedObjectsTypeManagementDefinition<Attributes = any> {
|
|||
export type SavedObjectsExportablePredicate<Attributes = unknown> = (
|
||||
obj: SavedObject<Attributes>
|
||||
) => boolean;
|
||||
|
||||
/**
|
||||
* If defined, allows a type to run a search query and return a query filter that may match any documents which may
|
||||
* be excluded from the next migration upgrade process. Useful for cleaning up large numbers of old documents which
|
||||
* are no longer needed and may slow the migration process.
|
||||
*
|
||||
* If this hook fails, the migration will proceed without these documents having been filtered out, so this
|
||||
* should not be used as a guarantee that these documents have been deleted.
|
||||
*
|
||||
* @public
|
||||
* @alpha Experimental and subject to change
|
||||
*/
|
||||
export type SavedObjectTypeExcludeFromUpgradeFilterHook = (toolkit: {
|
||||
readonlyEsClient: Pick<ElasticsearchClient, 'search'>;
|
||||
}) => estypes.QueryDslQueryContainer | Promise<estypes.QueryDslQueryContainer>;
|
|
@ -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.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Meta information about the SavedObjectService's status. Available to plugins via {@link CoreSetup.status}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectStatusMeta {
|
||||
migratedIndices: {
|
||||
[status: string]: number;
|
||||
skipped: number;
|
||||
migrated: number;
|
||||
};
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
/*
|
||||
* 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 type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { MaybePromise } from '@kbn/utility-types';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsNamespaceType } from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsTypeManagementDefinition } from './saved_objects_management';
|
||||
import type { SavedObjectsValidationMap } from './validation';
|
||||
import type { SavedObjectMigrationMap } from './migration';
|
||||
import type { SavedObjectsTypeMappingDefinition } from './mapping_definition';
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsType<Attributes = any> {
|
||||
/**
|
||||
* The name of the type, which is also used as the internal id.
|
||||
*/
|
||||
name: string;
|
||||
/**
|
||||
* Is the type hidden by default. If true, repositories will not have access to this type unless explicitly
|
||||
* declared as an `extraType` when creating the repository.
|
||||
*
|
||||
* See {@link SavedObjectsServiceStart.createInternalRepository | createInternalRepository}.
|
||||
*/
|
||||
hidden: boolean;
|
||||
/**
|
||||
* The {@link SavedObjectsNamespaceType | namespace type} for the type.
|
||||
*/
|
||||
namespaceType: SavedObjectsNamespaceType;
|
||||
/**
|
||||
* If defined, the type instances will be stored in the given index instead of the default one.
|
||||
*/
|
||||
indexPattern?: string;
|
||||
/**
|
||||
* If defined, will be used to convert the type to an alias.
|
||||
*/
|
||||
convertToAliasScript?: string;
|
||||
/**
|
||||
* If defined, allows a type to exclude unneeded documents from the migration process and effectively be deleted.
|
||||
* See {@link SavedObjectTypeExcludeFromUpgradeFilterHook} for more details.
|
||||
*/
|
||||
excludeOnUpgrade?: SavedObjectTypeExcludeFromUpgradeFilterHook;
|
||||
/**
|
||||
* The {@link SavedObjectsTypeMappingDefinition | mapping definition} for the type.
|
||||
*/
|
||||
mappings: SavedObjectsTypeMappingDefinition;
|
||||
/**
|
||||
* An optional map of {@link SavedObjectMigrationFn | migrations} or a function returning a map of {@link SavedObjectMigrationFn | migrations} to be used to migrate the type.
|
||||
*/
|
||||
migrations?: SavedObjectMigrationMap | (() => SavedObjectMigrationMap);
|
||||
/**
|
||||
* An optional schema that can be used to validate the attributes of the type.
|
||||
*
|
||||
* When provided, calls to {@link SavedObjectsClient.create | create} will be validated against this schema.
|
||||
*
|
||||
* See {@link SavedObjectsValidationMap} for more details.
|
||||
*/
|
||||
schemas?: SavedObjectsValidationMap | (() => SavedObjectsValidationMap);
|
||||
/**
|
||||
* If defined, objects of this type will be converted to a 'multiple' or 'multiple-isolated' namespace type when migrating to this
|
||||
* version.
|
||||
*
|
||||
* Requirements:
|
||||
*
|
||||
* 1. This string value must be a valid semver version
|
||||
* 2. This type must have previously specified {@link SavedObjectsNamespaceType | `namespaceType: 'single'`}
|
||||
* 3. This type must also specify {@link SavedObjectsNamespaceType | `namespaceType: 'multiple'`} *or*
|
||||
* {@link SavedObjectsNamespaceType | `namespaceType: 'multiple-isolated'`}
|
||||
*
|
||||
* Example of a single-namespace type in 7.12:
|
||||
*
|
||||
* ```ts
|
||||
* {
|
||||
* name: 'foo',
|
||||
* hidden: false,
|
||||
* namespaceType: 'single',
|
||||
* mappings: {...}
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Example after converting to a multi-namespace (isolated) type in 8.0:
|
||||
*
|
||||
* ```ts
|
||||
* {
|
||||
* name: 'foo',
|
||||
* hidden: false,
|
||||
* namespaceType: 'multiple-isolated',
|
||||
* mappings: {...},
|
||||
* convertToMultiNamespaceTypeVersion: '8.0.0'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Example after converting to a multi-namespace (shareable) type in 8.1:
|
||||
*
|
||||
* ```ts
|
||||
* {
|
||||
* name: 'foo',
|
||||
* hidden: false,
|
||||
* namespaceType: 'multiple',
|
||||
* mappings: {...},
|
||||
* convertToMultiNamespaceTypeVersion: '8.0.0'
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* Note: migration function(s) can be optionally specified for any of these versions and will not interfere with the conversion process.
|
||||
*/
|
||||
convertToMultiNamespaceTypeVersion?: string;
|
||||
/**
|
||||
* An optional {@link SavedObjectsTypeManagementDefinition | saved objects management section} definition for the type.
|
||||
*/
|
||||
management?: SavedObjectsTypeManagementDefinition<Attributes>;
|
||||
}
|
||||
|
||||
/**
|
||||
* If defined, allows a type to run a search query and return a query filter that may match any documents which may
|
||||
* be excluded from the next migration upgrade process. Useful for cleaning up large numbers of old documents which
|
||||
* are no longer needed and may slow the migration process.
|
||||
*
|
||||
* If this hook fails, the migration will proceed without these documents having been filtered out, so this
|
||||
* should not be used as a guarantee that these documents have been deleted.
|
||||
*
|
||||
* @public
|
||||
* @alpha Experimental and subject to change
|
||||
*/
|
||||
export type SavedObjectTypeExcludeFromUpgradeFilterHook = (toolkit: {
|
||||
readonlyEsClient: Pick<ElasticsearchClient, 'search'>;
|
||||
}) => MaybePromise<QueryDslQueryContainer>;
|
|
@ -11,6 +11,58 @@ import type {
|
|||
SavedObjectReference,
|
||||
} from '@kbn/core-saved-objects-common';
|
||||
|
||||
/**
|
||||
* A serializer that can be used to manually convert {@link SavedObjectsRawDoc | raw} or
|
||||
* {@link SavedObjectSanitizedDoc | sanitized} documents to the other kind.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ISavedObjectsSerializer {
|
||||
/**
|
||||
* Determines whether the raw document can be converted to a saved object.
|
||||
*
|
||||
* @param {SavedObjectsRawDoc} doc - The raw ES document to be tested
|
||||
* @param {SavedObjectsRawDocParseOptions} options - Options for parsing the raw document.
|
||||
*/
|
||||
isRawSavedObject(doc: SavedObjectsRawDoc, options?: SavedObjectsRawDocParseOptions): boolean;
|
||||
|
||||
/**
|
||||
* Converts a document from the format that is stored in elasticsearch to the saved object client format.
|
||||
*
|
||||
* @param {SavedObjectsRawDoc} doc - The raw ES document to be converted to saved object format.
|
||||
* @param {SavedObjectsRawDocParseOptions} options - Options for parsing the raw document.
|
||||
*/
|
||||
rawToSavedObject<T = unknown>(
|
||||
doc: SavedObjectsRawDoc,
|
||||
options?: SavedObjectsRawDocParseOptions
|
||||
): SavedObjectSanitizedDoc<T>;
|
||||
|
||||
/**
|
||||
* Converts a document from the saved object client format to the format that is stored in elasticsearch.
|
||||
*
|
||||
* @param {SavedObjectSanitizedDoc} savedObj - The saved object to be converted to raw ES format.
|
||||
*/
|
||||
savedObjectToRaw(savedObj: SavedObjectSanitizedDoc): SavedObjectsRawDoc;
|
||||
|
||||
/**
|
||||
* Given a saved object type and id, generates the compound id that is stored in the raw document.
|
||||
*
|
||||
* @param {string} namespace - The namespace of the saved object
|
||||
* @param {string} type - The saved object type
|
||||
* @param {string} id - The id of the saved object
|
||||
*/
|
||||
generateRawId(namespace: string | undefined, type: string, id: string): string;
|
||||
|
||||
/**
|
||||
* Given a saved object type and id, generates the compound id that is stored in the raw document for its legacy URL alias.
|
||||
*
|
||||
* @param {string} namespace - The namespace of the saved object
|
||||
* @param {string} type - The saved object type
|
||||
* @param {string} id - The id of the saved object
|
||||
*/
|
||||
generateRawLegacyUrlAliasId(namespace: string | undefined, type: string, id: string): string;
|
||||
}
|
||||
|
||||
/**
|
||||
* A raw document as represented directly in the saved object index.
|
||||
*
|
||||
|
@ -38,6 +90,8 @@ export interface SavedObjectsRawDocSource {
|
|||
|
||||
/**
|
||||
* Saved Object base document
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
interface SavedObjectDoc<T = unknown> {
|
||||
attributes: T;
|
||||
|
@ -52,10 +106,6 @@ interface SavedObjectDoc<T = unknown> {
|
|||
originId?: string;
|
||||
}
|
||||
|
||||
interface Referencable {
|
||||
references: SavedObjectReference[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes Saved Object documents from Kibana < 7.0.0 which don't have a
|
||||
* `references` root property defined. This type should only be used in
|
||||
|
@ -63,7 +113,9 @@ interface Referencable {
|
|||
*
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectUnsanitizedDoc<T = unknown> = SavedObjectDoc<T> & Partial<Referencable>;
|
||||
export type SavedObjectUnsanitizedDoc<T = unknown> = SavedObjectDoc<T> & {
|
||||
references?: SavedObjectReference[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Describes Saved Object documents that have passed through the migration
|
||||
|
@ -71,7 +123,9 @@ export type SavedObjectUnsanitizedDoc<T = unknown> = SavedObjectDoc<T> & Partial
|
|||
*
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectSanitizedDoc<T = unknown> = SavedObjectDoc<T> & Referencable;
|
||||
export type SavedObjectSanitizedDoc<T = unknown> = SavedObjectDoc<T> & {
|
||||
references: SavedObjectReference[];
|
||||
};
|
||||
|
||||
/**
|
||||
* Options that can be specified when using the saved objects serializer to parse a raw document.
|
|
@ -0,0 +1,80 @@
|
|||
/*
|
||||
* 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 type { SavedObjectsType } from './saved_objects_type';
|
||||
|
||||
/**
|
||||
* Registry holding information about all the registered {@link SavedObjectsType | saved object types}.
|
||||
*/
|
||||
export interface ISavedObjectTypeRegistry {
|
||||
/**
|
||||
* Return the {@link SavedObjectsType | type} definition for given type name.
|
||||
*/
|
||||
getType(type: string): SavedObjectsType | undefined;
|
||||
|
||||
/**
|
||||
* Returns all visible {@link SavedObjectsType | types}.
|
||||
*
|
||||
* A visible type is a type that doesn't explicitly define `hidden=true` during registration.
|
||||
*/
|
||||
getVisibleTypes(): SavedObjectsType[];
|
||||
|
||||
/**
|
||||
* Return all {@link SavedObjectsType | types} currently registered, including the hidden ones.
|
||||
*
|
||||
* To only get the visible types (which is the most common use case), use `getVisibleTypes` instead.
|
||||
*/
|
||||
getAllTypes(): SavedObjectsType[];
|
||||
|
||||
/**
|
||||
* Return all {@link SavedObjectsType | types} currently registered that are importable/exportable.
|
||||
*/
|
||||
getImportableAndExportableTypes(): SavedObjectsType[];
|
||||
|
||||
/**
|
||||
* Returns whether the type is namespace-agnostic (global);
|
||||
* resolves to `false` if the type is not registered
|
||||
*/
|
||||
isNamespaceAgnostic(type: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether the type is single-namespace (isolated);
|
||||
* resolves to `true` if the type is not registered
|
||||
*/
|
||||
isSingleNamespace(type: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether the type is multi-namespace (shareable *or* isolated);
|
||||
* resolves to `false` if the type is not registered
|
||||
*/
|
||||
isMultiNamespace(type: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns whether the type is multi-namespace (shareable);
|
||||
* resolves to `false` if the type is not registered
|
||||
*/
|
||||
isShareable(type: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns the `hidden` property for given type, or `false` if
|
||||
* the type is not registered.
|
||||
*/
|
||||
isHidden(type: string): boolean;
|
||||
|
||||
/**
|
||||
* Returns the `indexPattern` property for given type, or `undefined` if
|
||||
* the type is not registered.
|
||||
*/
|
||||
getIndex(type: string): string | undefined;
|
||||
|
||||
/**
|
||||
* Returns the `management.importableAndExportable` property for given type, or
|
||||
* `false` if the type is not registered or does not define a management section.
|
||||
*/
|
||||
isImportableAndExportable(type: string): boolean;
|
||||
}
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { ObjectType } from '@kbn/config-schema';
|
||||
import type { ObjectType } from '@kbn/config-schema';
|
||||
|
||||
/**
|
||||
* Allows for validating properties using @kbn/config-schema validations.
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"extends": "../../../../tsconfig.bazel.json",
|
||||
"compilerOptions": {
|
||||
"declaration": true,
|
||||
"declarationMap": true,
|
||||
"emitDeclarationOnly": true,
|
||||
"outDir": "target_types",
|
||||
"rootDir": "src",
|
||||
"stripInternal": false,
|
||||
"types": [
|
||||
"jest",
|
||||
"node"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*"
|
||||
]
|
||||
}
|
|
@ -9,16 +9,14 @@
|
|||
import type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import type { ElasticsearchRequestHandlerContext } from '@kbn/core-elasticsearch-server';
|
||||
import { CoreElasticsearchRouteHandlerContext } from '@kbn/core-elasticsearch-server-internal';
|
||||
import type { InternalCoreStart } from './internal_types';
|
||||
import {
|
||||
CoreSavedObjectsRouteHandlerContext,
|
||||
SavedObjectsRequestHandlerContext,
|
||||
} from './saved_objects';
|
||||
import type { SavedObjectsRequestHandlerContext } from '@kbn/core-saved-objects-server';
|
||||
import { CoreSavedObjectsRouteHandlerContext } from './saved_objects';
|
||||
import { CoreUiSettingsRouteHandlerContext, UiSettingsRequestHandlerContext } from './ui_settings';
|
||||
import {
|
||||
CoreDeprecationsRouteHandlerContext,
|
||||
DeprecationsRequestHandlerContext,
|
||||
} from './deprecations';
|
||||
import type { InternalCoreStart } from './internal_types';
|
||||
|
||||
/**
|
||||
* The `core` context provided to route handler.
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectsType } from '../saved_objects';
|
||||
import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import { CORE_USAGE_STATS_TYPE } from './constants';
|
||||
import { migrateTo7141 } from './migrations';
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { SavedObjectUnsanitizedDoc } from '../saved_objects';
|
||||
import type { SavedObjectUnsanitizedDoc } from '@kbn/core-saved-objects-server';
|
||||
import { migrateTo7141 } from './migrations';
|
||||
import type { CoreUsageStats } from './types';
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import { cloneDeep } from 'lodash';
|
||||
import type { SavedObjectUnsanitizedDoc } from '../saved_objects';
|
||||
import type { SavedObjectUnsanitizedDoc } from '@kbn/core-saved-objects-server';
|
||||
import type { CoreUsageStats } from './types';
|
||||
|
||||
export const migrateTo7141 = (doc: SavedObjectUnsanitizedDoc<CoreUsageStats>) => {
|
||||
|
|
|
@ -10,14 +10,14 @@ import { firstValueFrom } from 'rxjs';
|
|||
import type { Logger } from '@kbn/logging';
|
||||
import type { IConfigService } from '@kbn/config';
|
||||
import type { CoreContext, CoreService } from '@kbn/core-base-server-internal';
|
||||
import { DomainDeprecationDetails } from '@kbn/core-deprecations-common';
|
||||
import type { DomainDeprecationDetails } from '@kbn/core-deprecations-common';
|
||||
import type { InternalHttpServiceSetup } from '@kbn/core-http-server-internal';
|
||||
import type { IScopedClusterClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import { DeprecationsFactory } from './deprecations_factory';
|
||||
import { RegisterDeprecationsConfig } from './types';
|
||||
import { registerRoutes } from './routes';
|
||||
import { config as deprecationConfig, DeprecationConfigType } from './deprecation_config';
|
||||
import { SavedObjectsClientContract } from '../saved_objects/types';
|
||||
|
||||
/**
|
||||
* The deprecations service provides a way for the Kibana platform to communicate deprecated
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import type { MaybePromise } from '@kbn/utility-types';
|
||||
import type { DeprecationsDetails } from '@kbn/core-deprecations-common';
|
||||
import type { IScopedClusterClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsClientContract } from '../saved_objects/types';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
|
||||
/**
|
||||
* @public
|
||||
|
|
|
@ -60,11 +60,14 @@ import {
|
|||
} from '@kbn/core-elasticsearch-server';
|
||||
import { configSchema as elasticsearchConfigSchema } from '@kbn/core-elasticsearch-server-internal';
|
||||
import type { CapabilitiesSetup, CapabilitiesStart } from '@kbn/core-capabilities-server';
|
||||
import type {
|
||||
SavedObjectsServiceSetup,
|
||||
SavedObjectsServiceStart,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
|
||||
import { HttpResources } from './http_resources';
|
||||
import { PluginsServiceSetup, PluginsServiceStart, PluginOpaqueId } from './plugins';
|
||||
import { UiSettingsServiceSetup, UiSettingsServiceStart } from './ui_settings';
|
||||
import { SavedObjectsServiceSetup, SavedObjectsServiceStart } from './saved_objects';
|
||||
import { StatusServiceSetup } from './status';
|
||||
import { CoreUsageDataStart, CoreUsageDataSetup } from './core_usage_data';
|
||||
import { I18nServiceSetup } from './i18n';
|
||||
|
@ -274,15 +277,6 @@ export type {
|
|||
ExposedToBrowserDescriptor,
|
||||
} from './plugins';
|
||||
|
||||
export {
|
||||
SavedObjectsClient,
|
||||
SavedObjectsErrorHelpers,
|
||||
SavedObjectsSerializer,
|
||||
SavedObjectTypeRegistry,
|
||||
SavedObjectsUtils,
|
||||
mergeSavedObjectMigrationMaps,
|
||||
} from './saved_objects';
|
||||
|
||||
export type {
|
||||
SavedObject,
|
||||
SavedObjectAttribute,
|
||||
|
@ -351,6 +345,8 @@ export type {
|
|||
SavedObjectsPitParams,
|
||||
} from '@kbn/core-saved-objects-api-server';
|
||||
export type {
|
||||
SavedObjectsServiceSetup,
|
||||
SavedObjectsServiceStart,
|
||||
SavedObjectsClientProviderOptions,
|
||||
SavedObjectsClientWrapperFactory,
|
||||
SavedObjectsClientWrapperOptions,
|
||||
|
@ -363,15 +359,13 @@ export type {
|
|||
SavedObjectMigrationContext,
|
||||
SavedObjectsMigrationLogger,
|
||||
SavedObjectsRawDoc,
|
||||
SavedObjectsRawDocSource,
|
||||
SavedObjectsRawDocParseOptions,
|
||||
SavedObjectSanitizedDoc,
|
||||
SavedObjectUnsanitizedDoc,
|
||||
SavedObjectsRepositoryFactory,
|
||||
SavedObjectsResolveImportErrorsOptions,
|
||||
SavedObjectsServiceStart,
|
||||
SavedObjectsServiceSetup,
|
||||
SavedObjectStatusMeta,
|
||||
SavedObjectsRepository,
|
||||
SavedObjectsFieldMapping,
|
||||
SavedObjectsTypeMappingDefinition,
|
||||
SavedObjectsMappingProperties,
|
||||
|
@ -380,22 +374,35 @@ export type {
|
|||
SavedObjectsTypeManagementDefinition,
|
||||
SavedObjectMigrationMap,
|
||||
SavedObjectMigrationFn,
|
||||
SavedObjectsExporter,
|
||||
ISavedObjectsExporter,
|
||||
SavedObjectExportBaseOptions,
|
||||
SavedObjectsExportByObjectOptions,
|
||||
SavedObjectsExportByTypeOptions,
|
||||
SavedObjectsExportError,
|
||||
SavedObjectsExportTransform,
|
||||
SavedObjectsExportTransformContext,
|
||||
SavedObjectsImporter,
|
||||
ISavedObjectsImporter,
|
||||
SavedObjectsImportError,
|
||||
SavedObjectsImportHook,
|
||||
SavedObjectsImportHookResult,
|
||||
SavedObjectsValidationMap,
|
||||
SavedObjectsValidationSpec,
|
||||
ISavedObjectsSerializer,
|
||||
SavedObjectsRequestHandlerContext,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
|
||||
export type {
|
||||
SavedObjectsRepository,
|
||||
SavedObjectsExporter,
|
||||
SavedObjectsExportError,
|
||||
SavedObjectsImporter,
|
||||
SavedObjectsImportError,
|
||||
} from './saved_objects';
|
||||
export {
|
||||
SavedObjectsClient,
|
||||
SavedObjectsErrorHelpers,
|
||||
SavedObjectsSerializer,
|
||||
SavedObjectTypeRegistry,
|
||||
SavedObjectsUtils,
|
||||
mergeSavedObjectMigrationMaps,
|
||||
} from './saved_objects';
|
||||
|
||||
export type {
|
||||
|
|
|
@ -11,9 +11,9 @@ import * as Either from 'fp-ts/lib/Either';
|
|||
import * as Option from 'fp-ts/lib/Option';
|
||||
import { errors } from '@elastic/elasticsearch';
|
||||
import type { TaskEither } from 'fp-ts/lib/TaskEither';
|
||||
import type { ElasticsearchClient } from '../../../..';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import * as kbnTestServer from '../../../../../test_helpers/kbn_server';
|
||||
import type { SavedObjectsRawDoc } from '../../../../saved_objects/serialization';
|
||||
import {
|
||||
bulkOverwriteTransformedDocuments,
|
||||
closePit,
|
||||
|
|
|
@ -14,8 +14,8 @@ import { REPO_ROOT } from '@kbn/utils';
|
|||
import { Env } from '@kbn/config';
|
||||
import { getEnvOptions } from '@kbn/config-mocks';
|
||||
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
|
||||
import { SavedObjectsRawDoc } from '../../../saved_objects/serialization';
|
||||
import { InternalCoreStart } from '../../../internal_types';
|
||||
import { Root } from '../../../root';
|
||||
|
||||
|
|
|
@ -13,9 +13,9 @@ import Semver from 'semver';
|
|||
import { REPO_ROOT } from '@kbn/utils';
|
||||
import { Env } from '@kbn/config';
|
||||
import { getEnvOptions } from '@kbn/config-mocks';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
|
||||
import { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import { SavedObjectsRawDoc } from '../../../saved_objects/serialization';
|
||||
import { InternalCoreStart } from '../../../internal_types';
|
||||
import { Root } from '../../../root';
|
||||
|
||||
|
|
|
@ -10,9 +10,9 @@ import Path from 'path';
|
|||
import del from 'del';
|
||||
import { esTestConfig, kibanaServerTestUser } from '@kbn/test';
|
||||
import { kibanaPackageJson as pkg } from '@kbn/utils';
|
||||
import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import * as kbnTestServer from '../../../../test_helpers/kbn_server';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import { SavedObjectsType } from '../../../saved_objects/types';
|
||||
import type { Root } from '../../../root';
|
||||
|
||||
const LOG_FILE_PREFIX = 'migration_test_multiple_kibana_nodes';
|
||||
|
|
|
@ -13,7 +13,7 @@ import { Env } from '@kbn/config';
|
|||
import { schema } from '@kbn/config-schema';
|
||||
import { REPO_ROOT } from '@kbn/utils';
|
||||
import type { ISavedObjectsRepository } from '@kbn/core-saved-objects-api-server';
|
||||
import { SavedObjectsType } from '../../../saved_objects/types';
|
||||
import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import { getEnvOptions } from '@kbn/config-mocks';
|
||||
import { InternalCoreSetup, InternalCoreStart } from '../../../internal_types';
|
||||
import { Root } from '../../../root';
|
||||
|
|
|
@ -6,8 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectsClientContract } from '../../saved_objects/types';
|
||||
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import {
|
||||
createTestServers,
|
||||
TestElasticsearchUtils,
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import type { RegisterDeprecationsConfig } from '../../deprecations';
|
||||
import type { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import type { SavedObjectConfig } from '../saved_objects_config';
|
||||
import { getUnknownTypesDeprecations } from './unknown_object_types';
|
||||
|
||||
|
|
|
@ -9,9 +9,9 @@
|
|||
import { i18n } from '@kbn/i18n';
|
||||
import type { DeprecationsDetails } from '@kbn/core-deprecations-common';
|
||||
import type { IScopedClusterClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import { getAggregatedTypesDocuments } from '../migrations/actions/check_for_unknown_docs';
|
||||
import { addExcludedTypesToBoolQuery } from '../migrations/model/helpers';
|
||||
import { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import { getIndexForType } from '../service/lib';
|
||||
|
||||
interface UnknownTypesDeprecationOptions {
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
import { CoreKibanaRequest } from '@kbn/core-http-router-server-internal';
|
||||
import { httpServerMock } from '@kbn/core-http-server-mocks';
|
||||
import type { SavedObject } from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsExportTransform } from '@kbn/core-saved-objects-server';
|
||||
import { applyExportTransforms } from './apply_export_transforms';
|
||||
import { SavedObjectsExportTransform } from './types';
|
||||
|
||||
const createObj = (
|
||||
type: string,
|
||||
|
|
|
@ -8,8 +8,11 @@
|
|||
|
||||
import type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import type { SavedObject } from '@kbn/core-saved-objects-common';
|
||||
import type {
|
||||
SavedObjectsExportTransform,
|
||||
SavedObjectsExportTransformContext,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { SavedObjectsExportError } from './errors';
|
||||
import { SavedObjectsExportTransform, SavedObjectsExportTransformContext } from './types';
|
||||
import { getObjKey, SavedObjectComparator } from './utils';
|
||||
|
||||
interface ApplyExportTransformsOptions {
|
||||
|
|
|
@ -8,13 +8,15 @@
|
|||
|
||||
import { httpServerMock } from '@kbn/core-http-server-mocks';
|
||||
import type { SavedObject, SavedObjectError } from '@kbn/core-saved-objects-common';
|
||||
import type {
|
||||
SavedObjectsExportTransform,
|
||||
SavedObjectsExportablePredicate,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { applyExportTransformsMock } from './collect_exported_objects.test.mocks';
|
||||
import { savedObjectsClientMock } from '../../mocks';
|
||||
import { loggerMock } from '@kbn/logging-mocks';
|
||||
import { SavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import type { SavedObjectsExportTransform } from './types';
|
||||
import { collectExportedObjects, ExclusionReason } from './collect_exported_objects';
|
||||
import { SavedObjectsExportablePredicate } from '../types';
|
||||
|
||||
const createObject = (parts: Partial<SavedObject>): SavedObject => ({
|
||||
id: 'id',
|
||||
|
|
|
@ -10,9 +10,11 @@ import type { Logger } from '@kbn/logging';
|
|||
import type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import type { SavedObject } from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import { SavedObjectsExportablePredicate } from '../types';
|
||||
import { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import type { SavedObjectsExportTransform } from './types';
|
||||
import type {
|
||||
SavedObjectsExportablePredicate,
|
||||
ISavedObjectTypeRegistry,
|
||||
SavedObjectsExportTransform,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { applyExportTransforms } from './apply_export_transforms';
|
||||
|
||||
interface CollectExportedObjectOptions {
|
||||
|
|
|
@ -6,15 +6,5 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
export type {
|
||||
SavedObjectsExportByObjectOptions,
|
||||
SavedObjectExportBaseOptions,
|
||||
SavedObjectsExportByTypeOptions,
|
||||
SavedObjectsExportResultDetails,
|
||||
SavedObjectsExportTransformContext,
|
||||
SavedObjectsExportTransform,
|
||||
SavedObjectsExportExcludedObject,
|
||||
} from './types';
|
||||
export { SavedObjectsExporter } from './saved_objects_exporter';
|
||||
export type { ISavedObjectsExporter } from './saved_objects_exporter';
|
||||
export { SavedObjectsExportError } from './errors';
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { ISavedObjectsExporter } from './saved_objects_exporter';
|
||||
import type { ISavedObjectsExporter } from '@kbn/core-saved-objects-server';
|
||||
|
||||
const createExporterMock = () => {
|
||||
const mock: jest.Mocked<ISavedObjectsExporter> = {
|
||||
|
|
|
@ -14,43 +14,19 @@ import type {
|
|||
SavedObjectsClientContract,
|
||||
SavedObjectsFindResult,
|
||||
} from '@kbn/core-saved-objects-api-server';
|
||||
import { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import { sortObjects } from './sort_objects';
|
||||
import {
|
||||
import type {
|
||||
ISavedObjectsExporter,
|
||||
ISavedObjectTypeRegistry,
|
||||
SavedObjectsExportResultDetails,
|
||||
SavedObjectExportBaseOptions,
|
||||
SavedObjectsExportByObjectOptions,
|
||||
SavedObjectsExportByTypeOptions,
|
||||
} from './types';
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { sortObjects } from './sort_objects';
|
||||
import { SavedObjectsExportError } from './errors';
|
||||
import { collectExportedObjects } from './collect_exported_objects';
|
||||
import { byIdAscComparator, getPreservedOrderComparator, SavedObjectComparator } from './utils';
|
||||
|
||||
/**
|
||||
* Utility class used to export savedObjects.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ISavedObjectsExporter {
|
||||
/**
|
||||
* Generates an export stream for given types.
|
||||
*
|
||||
* See the {@link SavedObjectsExportByTypeOptions | options} for more detailed information.
|
||||
*
|
||||
* @throws SavedObjectsExportError
|
||||
*/
|
||||
exportByTypes(options: SavedObjectsExportByTypeOptions): Promise<Readable>;
|
||||
|
||||
/**
|
||||
* Generates an export stream for given object references.
|
||||
*
|
||||
* See the {@link SavedObjectsExportByObjectOptions | options} for more detailed information.
|
||||
*
|
||||
* @throws SavedObjectsExportError
|
||||
*/
|
||||
exportByObjects(options: SavedObjectsExportByObjectOptions): Promise<Readable>;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
*/
|
||||
|
|
|
@ -24,12 +24,15 @@ import type {
|
|||
SavedObjectsImportFailure,
|
||||
SavedObjectsImportWarning,
|
||||
} from '@kbn/core-saved-objects-common';
|
||||
import { SavedObjectsClientContract, SavedObjectsType } from '../types';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type {
|
||||
SavedObjectsType,
|
||||
ISavedObjectTypeRegistry,
|
||||
SavedObjectsImportHook,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { savedObjectsClientMock } from '../../mocks';
|
||||
import { ISavedObjectTypeRegistry } from '..';
|
||||
import { typeRegistryMock } from '../saved_objects_type_registry.mock';
|
||||
import { importSavedObjectsFromStream, ImportSavedObjectsOptions } from './import_saved_objects';
|
||||
import { SavedObjectsImportHook } from './types';
|
||||
import type { ImportStateMap } from './lib';
|
||||
|
||||
describe('#importSavedObjectsFromStream', () => {
|
||||
|
|
|
@ -12,8 +12,10 @@ import type {
|
|||
SavedObjectsImportResponse,
|
||||
} from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import { SavedObjectsImportHook } from './types';
|
||||
import type {
|
||||
ISavedObjectTypeRegistry,
|
||||
SavedObjectsImportHook,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import {
|
||||
checkReferenceOrigins,
|
||||
validateReferences,
|
||||
|
|
|
@ -7,11 +7,4 @@
|
|||
*/
|
||||
|
||||
export { SavedObjectsImporter } from './saved_objects_importer';
|
||||
export type { ISavedObjectsImporter } from './saved_objects_importer';
|
||||
export type {
|
||||
SavedObjectsImportOptions,
|
||||
SavedObjectsResolveImportErrorsOptions,
|
||||
SavedObjectsImportHook,
|
||||
SavedObjectsImportHookResult,
|
||||
} from './types';
|
||||
export { SavedObjectsImportError } from './errors';
|
||||
|
|
|
@ -14,11 +14,11 @@ import type {
|
|||
SavedObjectsImportFailure,
|
||||
SavedObjectsImportRetry,
|
||||
} from '@kbn/core-saved-objects-common';
|
||||
import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import { checkOriginConflicts } from './check_origin_conflicts';
|
||||
import { savedObjectsClientMock } from '../../../mocks';
|
||||
import { typeRegistryMock } from '../../saved_objects_type_registry.mock';
|
||||
import { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry';
|
||||
import type { ImportStateMap } from './types';
|
||||
|
||||
jest.mock('uuid', () => ({
|
||||
|
|
|
@ -14,7 +14,7 @@ import type {
|
|||
SavedObjectsImportRetry,
|
||||
} from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry';
|
||||
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import { getObjectKey } from '../../service/lib/internal_utils';
|
||||
import type { ImportStateMap } from './types';
|
||||
import { createOriginQuery } from './utils';
|
||||
|
|
|
@ -8,12 +8,14 @@
|
|||
|
||||
import { mockCreateOriginQuery } from './check_reference_origins.test.mock';
|
||||
|
||||
import type { SavedObjectsFindResult } from '@kbn/core-saved-objects-api-server';
|
||||
import type { SavedObjectsClientContract } from '../../types';
|
||||
import type {
|
||||
SavedObjectsFindResult,
|
||||
SavedObjectsClientContract,
|
||||
} from '@kbn/core-saved-objects-api-server';
|
||||
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import { checkReferenceOrigins, CheckReferenceOriginsParams } from './check_reference_origins';
|
||||
import { savedObjectsClientMock } from '../../../mocks';
|
||||
import { typeRegistryMock } from '../../saved_objects_type_registry.mock';
|
||||
import { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry';
|
||||
import type { ImportStateMap } from './types';
|
||||
|
||||
const MULTI_NS_TYPE = 'multi';
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
*/
|
||||
|
||||
import pMap from 'p-map';
|
||||
import { SavedObjectsClientContract } from '../../types';
|
||||
import { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import type { ImportStateMap, ImportStateValue } from './types';
|
||||
import { getObjectKey, parseObjectKey } from '../../service/lib/internal_utils';
|
||||
import { createOriginQuery } from './utils';
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
*/
|
||||
|
||||
import type { SavedObject, SavedObjectsImportFailure } from '@kbn/core-saved-objects-common';
|
||||
import { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type { CreatedObject } from '@kbn/core-saved-objects-server';
|
||||
import { extractErrors } from './extract_errors';
|
||||
import { CreatedObject } from '../types';
|
||||
import type { ImportStateMap } from './types';
|
||||
|
||||
export interface CreateSavedObjectsParams<T> {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import type { SavedObject, SavedObjectsImportWarning } from '@kbn/core-saved-objects-common';
|
||||
import { SavedObjectsImportHookResult } from '../types';
|
||||
import type { SavedObjectsImportHookResult } from '@kbn/core-saved-objects-server';
|
||||
import { executeImportHooks } from './execute_import_hooks';
|
||||
|
||||
const createObject = (type: string, id: string): SavedObject => ({
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import type { SavedObject, SavedObjectsImportWarning } from '@kbn/core-saved-objects-common';
|
||||
import { SavedObjectsImportHook } from '../types';
|
||||
import type { SavedObjectsImportHook } from '@kbn/core-saved-objects-server';
|
||||
|
||||
export interface ExecuteImportHooksOptions {
|
||||
objects: SavedObject[];
|
||||
|
|
|
@ -7,9 +7,9 @@
|
|||
*/
|
||||
|
||||
import type { SavedObject } from '@kbn/core-saved-objects-common';
|
||||
import type { CreatedObject } from '@kbn/core-saved-objects-server';
|
||||
import { extractErrors } from './extract_errors';
|
||||
import { SavedObjectsErrorHelpers } from '../../service';
|
||||
import { CreatedObject } from '../types';
|
||||
|
||||
describe('extractErrors()', () => {
|
||||
test('returns empty array when no errors exist', () => {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import type { SavedObject, SavedObjectsImportFailure } from '@kbn/core-saved-objects-common';
|
||||
import { CreatedObject } from '../types';
|
||||
import type { CreatedObject } from '@kbn/core-saved-objects-server';
|
||||
|
||||
export function extractErrors(
|
||||
// TODO: define saved object type
|
||||
|
|
|
@ -31,9 +31,12 @@ import type {
|
|||
SavedObjectsImportWarning,
|
||||
} from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import { SavedObjectsType } from '../types';
|
||||
import type {
|
||||
SavedObjectsType,
|
||||
ISavedObjectTypeRegistry,
|
||||
SavedObjectsImportHook,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { savedObjectsClientMock } from '../../mocks';
|
||||
import { ISavedObjectTypeRegistry, SavedObjectsImportHook } from '..';
|
||||
import { typeRegistryMock } from '../saved_objects_type_registry.mock';
|
||||
import {
|
||||
resolveSavedObjectsImportErrors,
|
||||
|
|
|
@ -15,8 +15,10 @@ import type {
|
|||
SavedObjectsImportSuccess,
|
||||
} from '@kbn/core-saved-objects-common';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import { SavedObjectsImportHook } from './types';
|
||||
import type {
|
||||
ISavedObjectTypeRegistry,
|
||||
SavedObjectsImportHook,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import {
|
||||
collectSavedObjects,
|
||||
createObjectsFilter,
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { ISavedObjectsImporter } from './saved_objects_importer';
|
||||
import type { ISavedObjectsImporter } from '@kbn/core-saved-objects-server';
|
||||
|
||||
const createImporterMock = () => {
|
||||
const mock: jest.Mocked<ISavedObjectsImporter> = {
|
||||
|
|
|
@ -7,40 +7,16 @@
|
|||
*/
|
||||
|
||||
import type { SavedObjectsImportResponse } from '@kbn/core-saved-objects-common';
|
||||
import { SavedObjectsClientContract } from '../types';
|
||||
import { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import { importSavedObjectsFromStream } from './import_saved_objects';
|
||||
import { resolveSavedObjectsImportErrors } from './resolve_import_errors';
|
||||
import {
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type {
|
||||
ISavedObjectTypeRegistry,
|
||||
ISavedObjectsImporter,
|
||||
SavedObjectsImportOptions,
|
||||
SavedObjectsResolveImportErrorsOptions,
|
||||
SavedObjectsImportHook,
|
||||
} from './types';
|
||||
|
||||
/**
|
||||
* Utility class used to import savedObjects.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface ISavedObjectsImporter {
|
||||
/**
|
||||
* Import saved objects from given stream. See the {@link SavedObjectsImportOptions | options} for more
|
||||
* detailed information.
|
||||
*
|
||||
* @throws SavedObjectsImportError
|
||||
*/
|
||||
import(options: SavedObjectsImportOptions): Promise<SavedObjectsImportResponse>;
|
||||
|
||||
/**
|
||||
* Resolve and return saved object import errors.
|
||||
* See the {@link SavedObjectsResolveImportErrorsOptions | options} for more detailed information.
|
||||
*
|
||||
* @throws SavedObjectsImportError
|
||||
*/
|
||||
resolveImportErrors(
|
||||
options: SavedObjectsResolveImportErrorsOptions
|
||||
): Promise<SavedObjectsImportResponse>;
|
||||
}
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { importSavedObjectsFromStream } from './import_saved_objects';
|
||||
import { resolveSavedObjectsImportErrors } from './resolve_import_errors';
|
||||
|
||||
/**
|
||||
* @internal
|
||||
|
|
|
@ -10,74 +10,23 @@ export * from './service';
|
|||
|
||||
export { SavedObjectsImporter } from './import';
|
||||
|
||||
export type {
|
||||
ISavedObjectsImporter,
|
||||
SavedObjectsImportOptions,
|
||||
SavedObjectsResolveImportErrorsOptions,
|
||||
SavedObjectsImportError,
|
||||
SavedObjectsImportHook,
|
||||
SavedObjectsImportHookResult,
|
||||
} from './import';
|
||||
export type { SavedObjectsImportError } from './import';
|
||||
|
||||
export type {
|
||||
SavedObjectsExporter,
|
||||
ISavedObjectsExporter,
|
||||
SavedObjectExportBaseOptions,
|
||||
SavedObjectsExportByTypeOptions,
|
||||
SavedObjectsExportByObjectOptions,
|
||||
SavedObjectsExportResultDetails,
|
||||
SavedObjectsExportError,
|
||||
SavedObjectsExportTransformContext,
|
||||
SavedObjectsExportTransform,
|
||||
SavedObjectsExportExcludedObject,
|
||||
} from './export';
|
||||
export type { SavedObjectsExporter, SavedObjectsExportError } from './export';
|
||||
|
||||
export { SavedObjectsSerializer } from './serialization';
|
||||
|
||||
export type {
|
||||
SavedObjectsRawDoc,
|
||||
SavedObjectsRawDocParseOptions,
|
||||
SavedObjectSanitizedDoc,
|
||||
SavedObjectUnsanitizedDoc,
|
||||
} from './serialization';
|
||||
|
||||
export type { SavedObjectsMigrationLogger } from './migrations/core/migration_logger';
|
||||
|
||||
export { SavedObjectsService } from './saved_objects_service';
|
||||
|
||||
export type {
|
||||
InternalSavedObjectsServiceStart,
|
||||
SavedObjectsServiceStart,
|
||||
SavedObjectsServiceSetup,
|
||||
InternalSavedObjectsServiceSetup,
|
||||
SavedObjectsRepositoryFactory,
|
||||
} from './saved_objects_service';
|
||||
|
||||
export type {
|
||||
SavedObjectsFieldMapping,
|
||||
SavedObjectsMappingProperties,
|
||||
SavedObjectsTypeMappingDefinition,
|
||||
SavedObjectsTypeMappingDefinitions,
|
||||
} from './mappings';
|
||||
export type { SavedObjectsTypeMappingDefinitions } from './mappings';
|
||||
|
||||
export type {
|
||||
SavedObjectMigrationMap,
|
||||
SavedObjectMigrationFn,
|
||||
SavedObjectMigrationContext,
|
||||
} from './migrations';
|
||||
export { mergeSavedObjectMigrationMaps } from './migrations';
|
||||
|
||||
export type {
|
||||
SavedObjectStatusMeta,
|
||||
SavedObjectsType,
|
||||
SavedObjectsTypeManagementDefinition,
|
||||
SavedObjectTypeExcludeFromUpgradeFilterHook,
|
||||
} from './types';
|
||||
|
||||
export type { SavedObjectsValidationMap, SavedObjectsValidationSpec } from './validation';
|
||||
|
||||
export { savedObjectsConfig, savedObjectsMigrationConfig } from './saved_objects_config';
|
||||
export { SavedObjectTypeRegistry } from './saved_objects_type_registry';
|
||||
export type { ISavedObjectTypeRegistry } from './saved_objects_type_registry';
|
||||
export { CoreSavedObjectsRouteHandlerContext } from './saved_objects_route_handler_context';
|
||||
export type { SavedObjectsRequestHandlerContext } from './saved_objects_route_handler_context';
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
import type { IRouter, RequestHandlerContextBase } from '@kbn/core-http-server';
|
||||
import type { ElasticsearchRequestHandlerContext } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsRequestHandlerContext } from './saved_objects_route_handler_context';
|
||||
import type { SavedObjectsRequestHandlerContext } from '@kbn/core-saved-objects-server';
|
||||
|
||||
/**
|
||||
* Request handler context used by core's savedObjects routes.
|
||||
|
|
|
@ -7,11 +7,4 @@
|
|||
*/
|
||||
|
||||
export { getTypes, getProperty, getRootProperties, getRootPropertiesObjects } from './lib';
|
||||
export type {
|
||||
SavedObjectsTypeMappingDefinition,
|
||||
SavedObjectsTypeMappingDefinitions,
|
||||
SavedObjectsMappingProperties,
|
||||
SavedObjectsFieldMapping,
|
||||
IndexMappingMeta,
|
||||
IndexMapping,
|
||||
} from './types';
|
||||
export type { SavedObjectsTypeMappingDefinitions, IndexMappingMeta, IndexMapping } from './types';
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectsFieldMapping, IndexMapping } from '../types';
|
||||
import type { SavedObjectsFieldMapping } from '@kbn/core-saved-objects-server';
|
||||
import type { IndexMapping } from '../types';
|
||||
import { getProperty } from './get_property';
|
||||
|
||||
const MAPPINGS = {
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
*/
|
||||
|
||||
import { toPath } from 'lodash';
|
||||
import { SavedObjectsFieldMapping, IndexMapping } from '../types';
|
||||
import type { SavedObjectsFieldMapping } from '@kbn/core-saved-objects-server';
|
||||
import { IndexMapping } from '../types';
|
||||
|
||||
function getPropertyMappingFromObjectMapping(
|
||||
mapping: IndexMapping | SavedObjectsFieldMapping,
|
||||
|
|
|
@ -6,7 +6,11 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectsFieldMapping, IndexMapping, SavedObjectsMappingProperties } from '../types';
|
||||
import type {
|
||||
SavedObjectsFieldMapping,
|
||||
SavedObjectsMappingProperties,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { IndexMapping } from '../types';
|
||||
import { getRootProperties } from './get_root_properties';
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,42 +6,10 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
/**
|
||||
* Describe a saved object type mapping.
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* const typeDefinition: SavedObjectsTypeMappingDefinition = {
|
||||
* properties: {
|
||||
* enabled: {
|
||||
* type: "boolean"
|
||||
* },
|
||||
* sendUsageFrom: {
|
||||
* ignore_above: 256,
|
||||
* type: "keyword"
|
||||
* },
|
||||
* lastReported: {
|
||||
* type: "date"
|
||||
* },
|
||||
* lastVersionChecked: {
|
||||
* ignore_above: 256,
|
||||
* type: "keyword"
|
||||
* },
|
||||
* }
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsTypeMappingDefinition {
|
||||
/** The dynamic property of the mapping, either `false` or `'strict'`. If
|
||||
* unspecified `dynamic: 'strict'` will be inherited from the top-level
|
||||
* index mappings. */
|
||||
dynamic?: false | 'strict';
|
||||
/** The underlying properties of the type mapping */
|
||||
properties: SavedObjectsMappingProperties;
|
||||
}
|
||||
import type {
|
||||
SavedObjectsTypeMappingDefinition,
|
||||
SavedObjectsMappingProperties,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
|
||||
/**
|
||||
* A map of {@link SavedObjectsTypeMappingDefinition | saved object type mappings}
|
||||
|
@ -80,40 +48,6 @@ export interface SavedObjectsTypeMappingDefinitions {
|
|||
[type: string]: SavedObjectsTypeMappingDefinition;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe the fields of a {@link SavedObjectsTypeMappingDefinition | saved object type}.
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsMappingProperties {
|
||||
[field: string]: SavedObjectsFieldMapping;
|
||||
}
|
||||
|
||||
/**
|
||||
* Describe a {@link SavedObjectsTypeMappingDefinition | saved object type mapping} field.
|
||||
*
|
||||
* Please refer to {@link https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-types.html | elasticsearch documentation}
|
||||
* For the mapping documentation
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectsFieldMapping = estypes.MappingProperty & {
|
||||
/**
|
||||
* The dynamic property of the mapping, either `false` or `'strict'`. If
|
||||
* unspecified `dynamic: 'strict'` will be inherited from the top-level
|
||||
* index mappings.
|
||||
*
|
||||
* Note: To limit the number of mapping fields Saved Object types should
|
||||
* *never* use `dynamic: true`.
|
||||
*/
|
||||
dynamic?: false | 'strict';
|
||||
/**
|
||||
* Some mapping types do not accept the `properties` attributes. Explicitly adding it as optional to our type
|
||||
* to avoid type failures on all code using accessing them via `SavedObjectsFieldMapping.properties`.
|
||||
*/
|
||||
properties?: Record<estypes.PropertyName, estypes.MappingProperty>;
|
||||
};
|
||||
|
||||
/** @internal */
|
||||
export interface IndexMapping {
|
||||
dynamic?: boolean | 'strict';
|
||||
|
|
|
@ -11,7 +11,7 @@ import * as TaskEither from 'fp-ts/lib/TaskEither';
|
|||
import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import { errors as esErrors } from '@elastic/elasticsearch';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsRawDoc } from '../../serialization';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import {
|
||||
catchRetryableEsClientErrors,
|
||||
RetryableEsClientError,
|
||||
|
|
|
@ -11,8 +11,8 @@ import { withTimeout } from '@kbn/std';
|
|||
import * as Either from 'fp-ts/lib/Either';
|
||||
import * as TaskEither from 'fp-ts/lib/TaskEither';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectTypeExcludeFromUpgradeFilterHook } from '@kbn/core-saved-objects-server';
|
||||
import type { RetryableEsClientError } from '.';
|
||||
import type { SavedObjectTypeExcludeFromUpgradeFilterHook } from '../../types';
|
||||
import { catchRetryableEsClientErrors } from './catch_retryable_es_client_errors';
|
||||
|
||||
export interface CalculateExcludeFiltersParams {
|
||||
|
|
|
@ -16,7 +16,7 @@ import type {
|
|||
SearchRequest,
|
||||
} from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsRawDocSource } from '../../serialization';
|
||||
import type { SavedObjectsRawDocSource } from '@kbn/core-saved-objects-server';
|
||||
import {
|
||||
catchRetryableEsClientErrors,
|
||||
type RetryableEsClientError,
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as Either from 'fp-ts/lib/Either';
|
|||
import * as TaskEither from 'fp-ts/lib/TaskEither';
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsRawDoc } from '../../serialization';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import {
|
||||
catchRetryableEsClientErrors,
|
||||
RetryableEsClientError,
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as Either from 'fp-ts/lib/Either';
|
|||
import * as TaskEither from 'fp-ts/lib/TaskEither';
|
||||
import * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsRawDoc, SavedObjectsRawDocSource } from '../../serialization';
|
||||
import type { SavedObjectsRawDoc, SavedObjectsRawDocSource } from '@kbn/core-saved-objects-server';
|
||||
import {
|
||||
catchRetryableEsClientErrors,
|
||||
RetryableEsClientError,
|
||||
|
|
|
@ -5,9 +5,10 @@
|
|||
* in compliance with, at your election, the Elastic License 2.0 or the Server
|
||||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import * as TaskEither from 'fp-ts/lib/TaskEither';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import type { TransformRawDocs } from '../types';
|
||||
import type { SavedObjectsRawDoc } from '../../serialization';
|
||||
import { DocumentsTransformFailed, DocumentsTransformSuccess } from '../core/migrate_raw_docs';
|
||||
|
||||
/** @internal */
|
||||
|
|
|
@ -12,11 +12,8 @@
|
|||
|
||||
import crypto from 'crypto';
|
||||
import { cloneDeep, mapValues } from 'lodash';
|
||||
import {
|
||||
IndexMapping,
|
||||
SavedObjectsMappingProperties,
|
||||
SavedObjectsTypeMappingDefinitions,
|
||||
} from '../../mappings';
|
||||
import type { SavedObjectsMappingProperties } from '@kbn/core-saved-objects-server';
|
||||
import { IndexMapping, SavedObjectsTypeMappingDefinitions } from '../../mappings';
|
||||
|
||||
/**
|
||||
* Creates an index mapping with the core properties required by saved object
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import { createIndexMap } from './build_index_map';
|
||||
import { SavedObjectTypeRegistry } from '../../saved_objects_type_registry';
|
||||
import { SavedObjectsType } from '../../types';
|
||||
|
||||
const createRegistry = (...types: Array<Partial<SavedObjectsType>>) => {
|
||||
const registry = new SavedObjectTypeRegistry();
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectsTypeMappingDefinitions } from '../../mappings';
|
||||
import { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry';
|
||||
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import type { SavedObjectsTypeMappingDefinitions } from '../../mappings';
|
||||
|
||||
export interface CreateIndexMapOptions {
|
||||
kibanaIndexName: string;
|
||||
|
|
|
@ -6,7 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectsMappingProperties, IndexMapping } from '../../mappings';
|
||||
import type { SavedObjectsMappingProperties } from '@kbn/core-saved-objects-server';
|
||||
import { IndexMapping } from '../../mappings';
|
||||
|
||||
/**
|
||||
* Merges the active mappings and the source mappings while disabling the
|
||||
|
|
|
@ -9,11 +9,10 @@
|
|||
import { mockGetConvertedObjectId } from './document_migrator.test.mock';
|
||||
import { set } from '@elastic/safer-lodash-set';
|
||||
import _ from 'lodash';
|
||||
import { SavedObjectUnsanitizedDoc } from '../../serialization';
|
||||
import type { SavedObjectUnsanitizedDoc, SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import { DocumentMigrator } from './document_migrator';
|
||||
import { TransformSavedObjectDocumentError } from './transform_saved_object_document_error';
|
||||
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
|
||||
import { SavedObjectsType } from '../../types';
|
||||
import { SavedObjectTypeRegistry } from '../../saved_objects_type_registry';
|
||||
import { LEGACY_URL_ALIAS_TYPE } from '../../object_types';
|
||||
|
||||
|
@ -115,7 +114,9 @@ describe('DocumentMigrator', () => {
|
|||
expect(migrationObj.prepareMigrations).toThrow(/expected a function, but got 23/i);
|
||||
});
|
||||
it('validates definitions with migrations: Function | Objects', () => {
|
||||
const validMigrationMap = { '1.2.3': () => {} };
|
||||
const validMigrationMap = {
|
||||
'1.2.3': () => {},
|
||||
};
|
||||
const migrationFn = new DocumentMigrator(createDefinition(() => validMigrationMap));
|
||||
const migrationObj = new DocumentMigrator(createDefinition(validMigrationMap));
|
||||
expect(migrationFn.prepareMigrations).not.toThrow();
|
||||
|
|
|
@ -51,12 +51,15 @@ import type {
|
|||
SavedObjectsMigrationVersion,
|
||||
SavedObjectsNamespaceType,
|
||||
} from '@kbn/core-saved-objects-common';
|
||||
import { SavedObjectUnsanitizedDoc } from '../../serialization';
|
||||
import { SavedObjectsType } from '../../types';
|
||||
import type {
|
||||
SavedObjectUnsanitizedDoc,
|
||||
SavedObjectsType,
|
||||
ISavedObjectTypeRegistry,
|
||||
SavedObjectMigrationFn,
|
||||
SavedObjectMigrationMap,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { MigrationLogger } from './migration_logger';
|
||||
import { TransformSavedObjectDocumentError } from '.';
|
||||
import { ISavedObjectTypeRegistry } from '../../saved_objects_type_registry';
|
||||
import { SavedObjectMigrationFn, SavedObjectMigrationMap } from '../types';
|
||||
import { DEFAULT_NAMESPACE_STRING, SavedObjectsUtils } from '../../service/lib/utils';
|
||||
import { LegacyUrlAlias, LEGACY_URL_ALIAS_TYPE } from '../../object_types';
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
export { DocumentMigrator } from './document_migrator';
|
||||
export { buildActiveMappings } from './build_active_mappings';
|
||||
export type { LogFn, SavedObjectsMigrationLogger } from './migration_logger';
|
||||
export type { LogFn } from './migration_logger';
|
||||
export { excludeUnusedTypesQuery, REMOVED_TYPES } from './unused_types';
|
||||
export { TransformSavedObjectDocumentError } from './transform_saved_object_document_error';
|
||||
export type {
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
*/
|
||||
import * as TaskEither from 'fp-ts/lib/TaskEither';
|
||||
import * as Either from 'fp-ts/lib/Either';
|
||||
import {
|
||||
import type {
|
||||
SavedObjectSanitizedDoc,
|
||||
SavedObjectsRawDoc,
|
||||
SavedObjectsSerializer,
|
||||
SavedObjectUnsanitizedDoc,
|
||||
} from '../../serialization';
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { SavedObjectsSerializer } from '../../serialization';
|
||||
import { MigrateAndConvertFn } from './document_migrator';
|
||||
import { TransformSavedObjectDocumentError } from '.';
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
import type { Logger, LogMeta } from '@kbn/logging';
|
||||
import type { SavedObjectsMigrationLogger } from '@kbn/core-saved-objects-server';
|
||||
|
||||
/*
|
||||
* This file provides a helper class for ensuring that all logging
|
||||
|
@ -15,19 +16,6 @@ import type { Logger, LogMeta } from '@kbn/logging';
|
|||
|
||||
export type LogFn = (path: string[], message: string) => void;
|
||||
|
||||
/** @public */
|
||||
export interface SavedObjectsMigrationLogger {
|
||||
debug: (msg: string) => void;
|
||||
info: (msg: string) => void;
|
||||
/**
|
||||
* @deprecated Use `warn` instead.
|
||||
* @removeBy 8.8.0
|
||||
*/
|
||||
warning: (msg: string) => void;
|
||||
warn: (msg: string) => void;
|
||||
error: <Meta extends LogMeta = LogMeta>(msg: string, meta: Meta) => void;
|
||||
}
|
||||
|
||||
export class MigrationLogger implements SavedObjectsMigrationLogger {
|
||||
private logger: Logger;
|
||||
|
||||
|
|
|
@ -9,9 +9,4 @@
|
|||
export type { MigrationResult } from './core';
|
||||
export { KibanaMigrator } from './kibana_migrator';
|
||||
export type { IKibanaMigrator, KibanaMigratorStatus } from './kibana_migrator';
|
||||
export type {
|
||||
SavedObjectMigrationFn,
|
||||
SavedObjectMigrationMap,
|
||||
SavedObjectMigrationContext,
|
||||
} from './types';
|
||||
export { mergeSavedObjectMigrationMaps } from './utils';
|
||||
|
|
|
@ -10,9 +10,9 @@ import * as Option from 'fp-ts/Option';
|
|||
import type { DocLinksServiceStart } from '@kbn/core-doc-links-server';
|
||||
import type { Logger } from '@kbn/logging';
|
||||
import type { SavedObjectsMigrationVersion } from '@kbn/core-saved-objects-common';
|
||||
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import type { IndexMapping } from '../mappings';
|
||||
import type { SavedObjectsMigrationConfigType } from '../saved_objects_config';
|
||||
import type { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import type { InitState } from './state';
|
||||
import { excludeUnusedTypesQuery } from './core';
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { IKibanaMigrator, KibanaMigratorStatus } from './kibana_migrator';
|
|||
import { buildActiveMappings } from './core';
|
||||
|
||||
const { mergeTypes } = jest.requireActual('./kibana_migrator');
|
||||
import { SavedObjectsType } from '../types';
|
||||
import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
|
||||
const defaultSavedObjectTypes: SavedObjectsType[] = [
|
||||
|
|
|
@ -11,9 +11,9 @@ import type * as estypes from '@elastic/elasticsearch/lib/api/typesWithBodyKey';
|
|||
|
||||
import { loggingSystemMock } from '@kbn/core-logging-server-mocks';
|
||||
import { elasticsearchClientMock } from '@kbn/core-elasticsearch-client-server-mocks';
|
||||
import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import { KibanaMigratorOptions, KibanaMigrator } from './kibana_migrator';
|
||||
import { SavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import { SavedObjectsType } from '../types';
|
||||
import { DocumentMigrator } from './core/document_migrator';
|
||||
import { ByteSizeValue } from '@kbn/config-schema';
|
||||
import { docLinksServiceMock } from '@kbn/core-doc-links-server-mocks';
|
||||
|
|
|
@ -16,18 +16,18 @@ import Semver from 'semver';
|
|||
import type { Logger } from '@kbn/logging';
|
||||
import type { DocLinksServiceStart } from '@kbn/core-doc-links-server';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import { IndexMapping, SavedObjectsTypeMappingDefinitions } from '../mappings';
|
||||
import {
|
||||
import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import type {
|
||||
SavedObjectUnsanitizedDoc,
|
||||
SavedObjectsSerializer,
|
||||
SavedObjectsRawDoc,
|
||||
} from '../serialization';
|
||||
ISavedObjectTypeRegistry,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { IndexMapping, SavedObjectsTypeMappingDefinitions } from '../mappings';
|
||||
import { SavedObjectsSerializer } from '../serialization';
|
||||
import { buildActiveMappings, MigrationResult, MigrationStatus } from './core';
|
||||
import { DocumentMigrator, VersionedTransformer } from './core/document_migrator';
|
||||
import { createIndexMap } from './core/build_index_map';
|
||||
import { SavedObjectsMigrationConfigType } from '../saved_objects_config';
|
||||
import { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
import { SavedObjectsType } from '../types';
|
||||
import { runResilientMigrator } from './run_resilient_migrator';
|
||||
import { migrateRawDocsSafely } from './core/migrate_raw_docs';
|
||||
|
||||
|
|
|
@ -14,10 +14,10 @@ import {
|
|||
getErrorMessage,
|
||||
getRequestDebugMeta,
|
||||
} from '@kbn/core-elasticsearch-client-server-internal';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import { Model, Next, stateActionMachine } from './state_action_machine';
|
||||
import { cleanup } from './migrations_state_machine_cleanup';
|
||||
import { ReindexSourceToTempTransform, ReindexSourceToTempIndexBulk, State } from './state';
|
||||
import { SavedObjectsRawDoc } from '../serialization';
|
||||
|
||||
interface StateTransitionLogMeta extends LogMeta {
|
||||
kibana: {
|
||||
|
|
|
@ -6,8 +6,10 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectMigrationContext } from './types';
|
||||
import { SavedObjectsMigrationLogger } from './core';
|
||||
import type {
|
||||
SavedObjectMigrationContext,
|
||||
SavedObjectsMigrationLogger,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
|
||||
export const createSavedObjectsMigrationLoggerMock =
|
||||
(): jest.Mocked<SavedObjectsMigrationLogger> => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
import * as Either from 'fp-ts/lib/Either';
|
||||
import { SavedObjectsRawDoc } from '../../serialization';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import { createBatches } from './create_batches';
|
||||
|
||||
describe('createBatches', () => {
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
*/
|
||||
|
||||
import * as Either from 'fp-ts/lib/Either';
|
||||
import { SavedObjectsRawDoc } from '../..';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import { createBulkOperationBody } from '../actions/bulk_overwrite_transformed_documents';
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
import * as Either from 'fp-ts/lib/Either';
|
||||
import * as Option from 'fp-ts/lib/Option';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import type {
|
||||
FatalState,
|
||||
State,
|
||||
|
@ -41,7 +42,6 @@ import type {
|
|||
CheckUnknownDocumentsState,
|
||||
CalculateExcludeFiltersState,
|
||||
} from '../state';
|
||||
import { SavedObjectsRawDoc } from '../../serialization';
|
||||
import { TransformErrorObjects, TransformSavedObjectDocumentError } from '../core';
|
||||
import { AliasAction, RetryableEsClientError } from '../actions';
|
||||
import { ResponseType } from '../next';
|
||||
|
|
|
@ -10,6 +10,7 @@ import type { Logger } from '@kbn/logging';
|
|||
import type { DocLinksServiceStart } from '@kbn/core-doc-links-server';
|
||||
import type { ElasticsearchClient } from '@kbn/core-elasticsearch-server';
|
||||
import type { SavedObjectsMigrationVersion } from '@kbn/core-saved-objects-common';
|
||||
import type { ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
|
||||
import { IndexMapping } from '../mappings';
|
||||
import type { TransformRawDocs } from './types';
|
||||
import { MigrationResult } from './core';
|
||||
|
@ -18,7 +19,6 @@ import { model } from './model';
|
|||
import { createInitialState } from './initial_state';
|
||||
import { migrationStateActionMachine } from './migrations_state_action_machine';
|
||||
import { SavedObjectsMigrationConfigType } from '../saved_objects_config';
|
||||
import type { ISavedObjectTypeRegistry } from '../saved_objects_type_registry';
|
||||
|
||||
/**
|
||||
* To avoid the Elasticsearch-js client aborting our requests before we
|
||||
|
|
|
@ -9,12 +9,14 @@
|
|||
import * as Option from 'fp-ts/lib/Option';
|
||||
import type { QueryDslQueryContainer } from '@elastic/elasticsearch/lib/api/types';
|
||||
import type { DocLinks } from '@kbn/doc-links';
|
||||
import type {
|
||||
SavedObjectsRawDoc,
|
||||
SavedObjectTypeExcludeFromUpgradeFilterHook,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import type { ControlState } from './state_action_machine';
|
||||
import type { AliasAction } from './actions';
|
||||
import type { IndexMapping } from '../mappings';
|
||||
import type { SavedObjectsRawDoc } from '..';
|
||||
import type { TransformErrorObjects } from './core';
|
||||
import type { SavedObjectTypeExcludeFromUpgradeFilterHook } from '../types';
|
||||
import type { MigrationLog, Progress } from './types';
|
||||
|
||||
export interface BaseState extends ControlState {
|
||||
|
|
|
@ -7,94 +7,9 @@
|
|||
*/
|
||||
|
||||
import * as TaskEither from 'fp-ts/TaskEither';
|
||||
import type { SavedObjectUnsanitizedDoc } from '../serialization';
|
||||
import type { SavedObjectsMigrationLogger } from './core';
|
||||
import { SavedObjectsRawDoc } from '../serialization';
|
||||
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
|
||||
import { DocumentsTransformFailed, DocumentsTransformSuccess } from './core';
|
||||
|
||||
/**
|
||||
* A migration function for a {@link SavedObjectsType | saved object type}
|
||||
* used to migrate it to a given version
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* interface TypeV1Attributes {
|
||||
* someKey: string;
|
||||
* obsoleteProperty: number;
|
||||
* }
|
||||
*
|
||||
* interface TypeV2Attributes {
|
||||
* someKey: string;
|
||||
* newProperty: string;
|
||||
* }
|
||||
*
|
||||
* const migrateToV2: SavedObjectMigrationFn<TypeV1Attributes, TypeV2Attributes> = (doc, { log }) => {
|
||||
* const { obsoleteProperty, ...otherAttributes } = doc.attributes;
|
||||
* // instead of mutating `doc` we make a shallow copy so that we can use separate types for the input
|
||||
* // and output attributes. We don't need to make a deep copy, we just need to ensure that obsolete
|
||||
* // attributes are not present on the returned doc.
|
||||
* return {
|
||||
* ...doc,
|
||||
* attributes: {
|
||||
* ...otherAttributes,
|
||||
* newProperty: migrate(obsoleteProperty),
|
||||
* },
|
||||
* };
|
||||
* };
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export type SavedObjectMigrationFn<InputAttributes = unknown, MigratedAttributes = unknown> = (
|
||||
doc: SavedObjectUnsanitizedDoc<InputAttributes>,
|
||||
context: SavedObjectMigrationContext
|
||||
) => SavedObjectUnsanitizedDoc<MigratedAttributes>;
|
||||
|
||||
/**
|
||||
* Migration context provided when invoking a {@link SavedObjectMigrationFn | migration handler}
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectMigrationContext {
|
||||
/**
|
||||
* logger instance to be used by the migration handler
|
||||
*/
|
||||
readonly log: SavedObjectsMigrationLogger;
|
||||
/**
|
||||
* The migration version that this migration function is defined for
|
||||
*/
|
||||
readonly migrationVersion: string;
|
||||
/**
|
||||
* The version in which this object type is being converted to a multi-namespace type
|
||||
*/
|
||||
readonly convertToMultiNamespaceTypeVersion?: string;
|
||||
/**
|
||||
* Whether this is a single-namespace type or not
|
||||
*/
|
||||
readonly isSingleNamespaceType: boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
* A map of {@link SavedObjectMigrationFn | migration functions} to be used for a given type.
|
||||
* The map's keys must be valid semver versions, and they cannot exceed the current Kibana version.
|
||||
*
|
||||
* For a given document, only migrations with a higher version number than that of the document will be applied.
|
||||
* Migrations are executed in order, starting from the lowest version and ending with the highest one.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* const migrationsMap: SavedObjectMigrationMap = {
|
||||
* '1.0.0': migrateToV1,
|
||||
* '2.1.0': migrateToV21
|
||||
* }
|
||||
* ```
|
||||
*
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectMigrationMap {
|
||||
[version: string]: SavedObjectMigrationFn<any, any>;
|
||||
}
|
||||
|
||||
/** @internal */
|
||||
export type TransformRawDocs = (
|
||||
rawDocs: SavedObjectsRawDoc[]
|
||||
|
|
|
@ -6,9 +6,12 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import { SavedObjectMigrationContext, SavedObjectMigrationMap } from '.';
|
||||
import type {
|
||||
SavedObjectMigrationContext,
|
||||
SavedObjectMigrationMap,
|
||||
SavedObjectUnsanitizedDoc,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { mergeSavedObjectMigrationMaps } from './utils';
|
||||
import { SavedObjectUnsanitizedDoc } from '..';
|
||||
|
||||
describe('mergeSavedObjectMigrationMaps', () => {
|
||||
const obj1: SavedObjectMigrationMap = {
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
import type { ISavedObjectTypeRegistry, SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import { LEGACY_URL_ALIAS_TYPE } from './constants';
|
||||
import { ISavedObjectTypeRegistry, SavedObjectsType, SavedObjectTypeRegistry } from '..';
|
||||
import { SavedObjectTypeRegistry } from '..';
|
||||
import type { LegacyUrlAlias } from './types';
|
||||
|
||||
const legacyUrlAliasType: SavedObjectsType = {
|
||||
|
|
|
@ -11,13 +11,13 @@ import stringify from 'json-stable-stringify';
|
|||
import { createPromiseFromStreams, createMapStream, createConcatStream } from '@kbn/utils';
|
||||
|
||||
import type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import { InternalCoreUsageDataSetup } from '../../core_usage_data';
|
||||
import { SavedObjectConfig } from '../saved_objects_config';
|
||||
import {
|
||||
import type {
|
||||
SavedObjectsExportByTypeOptions,
|
||||
SavedObjectsExportByObjectOptions,
|
||||
SavedObjectsExportError,
|
||||
} from '../export';
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import { InternalCoreUsageDataSetup } from '../../core_usage_data';
|
||||
import { SavedObjectConfig } from '../saved_objects_config';
|
||||
import { SavedObjectsExportError } from '../export';
|
||||
import type { InternalSavedObjectRouter } from '../internal_types';
|
||||
import { validateTypes, validateObjects, catchAndReturnBoomErrors } from './utils';
|
||||
|
||||
|
|
|
@ -9,8 +9,8 @@
|
|||
import { executionContextServiceMock } from '@kbn/core-execution-context-server-mocks';
|
||||
import { ContextService } from '@kbn/core-http-context-server-internal';
|
||||
import { createHttpServer, createCoreContext } from '@kbn/core-http-server-mocks';
|
||||
import type { SavedObjectsType } from '@kbn/core-saved-objects-server';
|
||||
import { contextServiceMock, coreMock } from '../../mocks';
|
||||
import { SavedObjectsType } from '../types';
|
||||
import type { InternalSavedObjectsRequestHandlerContext } from '../internal_types';
|
||||
|
||||
const defaultCoreId = Symbol('core');
|
||||
|
|
|
@ -7,24 +7,13 @@
|
|||
*/
|
||||
|
||||
import type { KibanaRequest } from '@kbn/core-http-server';
|
||||
import type { SavedObjectsClientContract } from '@kbn/core-saved-objects-api-server';
|
||||
import type {
|
||||
SavedObjectsRequestHandlerContext,
|
||||
ISavedObjectTypeRegistry,
|
||||
SavedObjectsClientProviderOptions,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import type { InternalSavedObjectsServiceStart } from './saved_objects_service';
|
||||
import type { ISavedObjectTypeRegistry } from './saved_objects_type_registry';
|
||||
import type { SavedObjectsClientContract } from './types';
|
||||
import type { SavedObjectsClientProviderOptions } from './service';
|
||||
import type { ISavedObjectsExporter } from './export';
|
||||
import type { ISavedObjectsImporter } from './import';
|
||||
|
||||
/**
|
||||
* Core's `savedObjects` request handler context.
|
||||
* @public
|
||||
*/
|
||||
export interface SavedObjectsRequestHandlerContext {
|
||||
client: SavedObjectsClientContract;
|
||||
typeRegistry: ISavedObjectTypeRegistry;
|
||||
getClient: (options?: SavedObjectsClientProviderOptions) => SavedObjectsClientContract;
|
||||
getExporter: (client: SavedObjectsClientContract) => ISavedObjectsExporter;
|
||||
getImporter: (client: SavedObjectsClientContract) => ISavedObjectsImporter;
|
||||
}
|
||||
|
||||
/**
|
||||
* The {@link SavedObjectsRequestHandlerContext} implementation.
|
||||
|
|
|
@ -8,12 +8,15 @@
|
|||
|
||||
import { BehaviorSubject } from 'rxjs';
|
||||
import type { PublicMethodsOf } from '@kbn/utility-types';
|
||||
import type {
|
||||
SavedObjectsServiceSetup,
|
||||
SavedObjectsServiceStart,
|
||||
ISavedObjectTypeRegistry,
|
||||
} from '@kbn/core-saved-objects-server';
|
||||
import type {
|
||||
SavedObjectsService,
|
||||
InternalSavedObjectsServiceSetup,
|
||||
InternalSavedObjectsServiceStart,
|
||||
SavedObjectsServiceSetup,
|
||||
SavedObjectsServiceStart,
|
||||
} from './saved_objects_service';
|
||||
|
||||
import { savedObjectsRepositoryMock } from './service/lib/repository.mock';
|
||||
|
@ -23,7 +26,6 @@ import { savedObjectsExporterMock } from './export/saved_objects_exporter.mock';
|
|||
import { savedObjectsImporterMock } from './import/saved_objects_importer.mock';
|
||||
import { migrationMocks } from './migrations/mocks';
|
||||
import { ServiceStatusLevels } from '../status';
|
||||
import { ISavedObjectTypeRegistry } from './saved_objects_type_registry';
|
||||
|
||||
type SavedObjectsServiceContract = PublicMethodsOf<SavedObjectsService>;
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue