Skip to content

Commit

Permalink
Merge branch 'main' into discover-refactor-sort-functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Aug 22, 2022
2 parents 6d14142 + 750de11 commit 130e99b
Show file tree
Hide file tree
Showing 236 changed files with 3,161 additions and 936 deletions.
6 changes: 6 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,14 @@
"@kbn/core-preboot-server-mocks": "link:bazel-bin/packages/core/preboot/core-preboot-server-mocks",
"@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-base-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-base-server-internal",
"@kbn/core-saved-objects-base-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-base-server-mocks",
"@kbn/core-saved-objects-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser",
"@kbn/core-saved-objects-browser-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser-internal",
"@kbn/core-saved-objects-browser-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser-mocks",
"@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-saved-objects-utils-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-utils-server",
"@kbn/core-test-helpers-deprecations-getters": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-deprecations-getters",
"@kbn/core-test-helpers-http-setup-browser": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-http-setup-browser",
"@kbn/core-theme-browser": "link:bazel-bin/packages/core/theme/core-theme-browser",
Expand Down Expand Up @@ -894,11 +897,14 @@
"@types/kbn__core-public-internal-base": "link:bazel-bin/packages/core/public/internal-base/npm_module_types",
"@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-base-server-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-base-server-internal/npm_module_types",
"@types/kbn__core-saved-objects-base-server-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-base-server-mocks/npm_module_types",
"@types/kbn__core-saved-objects-browser": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser/npm_module_types",
"@types/kbn__core-saved-objects-browser-internal": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser-internal/npm_module_types",
"@types/kbn__core-saved-objects-browser-mocks": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-browser-mocks/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-saved-objects-utils-server": "link:bazel-bin/packages/core/saved-objects/core-saved-objects-utils-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-deprecations-getters": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-deprecations-getters/npm_module_types",
"@types/kbn__core-test-helpers-http-setup-browser": "link:bazel-bin/packages/core/test-helpers/core-test-helpers-http-setup-browser/npm_module_types",
Expand Down
6 changes: 6 additions & 0 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,14 @@ filegroup(
"//packages/core/preboot/core-preboot-server:build",
"//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-base-server-internal:build",
"//packages/core/saved-objects/core-saved-objects-base-server-mocks:build",
"//packages/core/saved-objects/core-saved-objects-browser-internal:build",
"//packages/core/saved-objects/core-saved-objects-browser-mocks:build",
"//packages/core/saved-objects/core-saved-objects-browser:build",
"//packages/core/saved-objects/core-saved-objects-common:build",
"//packages/core/saved-objects/core-saved-objects-server:build",
"//packages/core/saved-objects/core-saved-objects-utils-server:build",
"//packages/core/test-helpers/core-test-helpers-deprecations-getters:build",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build",
"//packages/core/theme/core-theme-browser-internal:build",
Expand Down Expand Up @@ -375,11 +378,14 @@ filegroup(
"//packages/core/preboot/core-preboot-server:build_types",
"//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-base-server-internal:build_types",
"//packages/core/saved-objects/core-saved-objects-base-server-mocks:build_types",
"//packages/core/saved-objects/core-saved-objects-browser-internal:build_types",
"//packages/core/saved-objects/core-saved-objects-browser-mocks:build_types",
"//packages/core/saved-objects/core-saved-objects-browser:build_types",
"//packages/core/saved-objects/core-saved-objects-common:build_types",
"//packages/core/saved-objects/core-saved-objects-server:build_types",
"//packages/core/saved-objects/core-saved-objects-utils-server:build_types",
"//packages/core/test-helpers/core-test-helpers-deprecations-getters:build_types",
"//packages/core/test-helpers/core-test-helpers-http-setup-browser:build_types",
"//packages/core/theme/core-theme-browser-internal:build_types",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
load("@npm//@bazel/typescript:index.bzl", "ts_config")
load("@build_bazel_rules_nodejs//:index.bzl", "js_library")
load("//src/dev/bazel:index.bzl", "jsts_transpiler", "pkg_npm", "pkg_npm_types", "ts_project")

PKG_DIRNAME = "core-saved-objects-base-server-internal"
PKG_REQUIRE_NAME = "@kbn/core-saved-objects-base-server-internal"

SOURCE_FILES = glob(
[
"src/**/*.ts",
],
exclude = [
"**/*.test.*",
"**/*.stories.*",
],
)

SRCS = SOURCE_FILES

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

NPM_MODULE_EXTRA_FILES = [
"package.json",
]

RUNTIME_DEPS = [
"@npm//lodash",
"@npm//semver",
"//packages/kbn-config-schema",
### test dependencies
"//packages/kbn-logging-mocks",
"@npm//@hapi/boom",
]

TYPES_DEPS = [
"@npm//@types/node",
"@npm//@types/jest",
"@npm//@types/lodash",
"@npm//@types/semver",
"//packages/kbn-logging:npm_module_types",
"//packages/kbn-config-schema:npm_module_types",
"//packages/core/base/core-base-server-internal:npm_module_types",
"//packages/core/saved-objects/core-saved-objects-server:npm_module_types",
"//packages/core/saved-objects/core-saved-objects-utils-server:npm_module_types",
]

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

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"],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# @kbn/core-saved-objects-base-server-internal

This package contains the base parts of the server-side savedObjects internal implementation,
used by all the other internal server-side savedObjects packages.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

module.exports = {
preset: '@kbn/test/jest_node',
rootDir: '../../../..',
roots: ['<rootDir>/packages/core/saved-objects/core-saved-objects-base-server-internal'],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"name": "@kbn/core-saved-objects-base-server-internal",
"private": true,
"version": "1.0.0",
"main": "./target_node/index.js",
"license": "SSPL-1.0 OR Elastic License 2.0"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* 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 { LEGACY_URL_ALIAS_TYPE, type LegacyUrlAlias } from './legacy_alias';
export {
getProperty,
getRootProperties,
getRootPropertiesObjects,
getTypes,
type IndexMapping,
type IndexMappingMeta,
type SavedObjectsTypeMappingDefinitions,
} from './mappings';
export { SavedObjectsSerializer } from './serialization';
export { SavedObjectsTypeValidator } from './validation';
export { decodeRequestVersion, decodeVersion, encodeVersion, encodeHitVersion } from './version';
export {
savedObjectsConfig,
savedObjectsMigrationConfig,
SavedObjectConfig,
type SavedObjectsConfigType,
type SavedObjectsMigrationConfigType,
} from './saved_objects_config';
export { SavedObjectTypeRegistry } from './saved_objects_type_registry';
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,5 @@
* Side Public License, v 1.
*/

export * from './encode_version';
export * from './encode_hit_version';
export * from './decode_version';
export * from './decode_request_version';
export type { LegacyUrlAlias } from './types';
export { LEGACY_URL_ALIAS_TYPE } from './constants';
Original file line number Diff line number Diff line change
Expand Up @@ -7,28 +7,47 @@
*/

import _ from 'lodash';
import type { SavedObjectsRawDoc } from '@kbn/core-saved-objects-server';
import type { SavedObjectsRawDoc, ISavedObjectTypeRegistry } from '@kbn/core-saved-objects-server';
import { SavedObjectsSerializer } from './serializer';
import { typeRegistryMock } from '../saved_objects_type_registry.mock';
import { encodeVersion } from '../version';
import { LEGACY_URL_ALIAS_TYPE } from '../object_types';
import { LEGACY_URL_ALIAS_TYPE } from '../legacy_alias';

const createMockedTypeRegistry = ({
isNamespaceAgnostic,
isSingleNamespace,
isMultiNamespace,
}: {
isNamespaceAgnostic: boolean;
isSingleNamespace: boolean;
isMultiNamespace: boolean;
}): ISavedObjectTypeRegistry => {
const typeRegistry: Partial<ISavedObjectTypeRegistry> = {
isNamespaceAgnostic: jest.fn().mockReturnValue(isNamespaceAgnostic),
isSingleNamespace: jest.fn().mockReturnValue(isSingleNamespace),
isMultiNamespace: jest.fn().mockReturnValue(isMultiNamespace),
};
return typeRegistry as ISavedObjectTypeRegistry;
};

let typeRegistry = typeRegistryMock.create();
typeRegistry.isNamespaceAgnostic.mockReturnValue(true);
typeRegistry.isSingleNamespace.mockReturnValue(false);
typeRegistry.isMultiNamespace.mockReturnValue(false);
let typeRegistry = createMockedTypeRegistry({
isNamespaceAgnostic: true,
isSingleNamespace: false,
isMultiNamespace: false,
});
const namespaceAgnosticSerializer = new SavedObjectsSerializer(typeRegistry);

typeRegistry = typeRegistryMock.create();
typeRegistry.isNamespaceAgnostic.mockReturnValue(false);
typeRegistry.isSingleNamespace.mockReturnValue(true);
typeRegistry.isMultiNamespace.mockReturnValue(false);
typeRegistry = typeRegistry = createMockedTypeRegistry({
isNamespaceAgnostic: false,
isSingleNamespace: true,
isMultiNamespace: false,
});
const singleNamespaceSerializer = new SavedObjectsSerializer(typeRegistry);

typeRegistry = typeRegistryMock.create();
typeRegistry.isNamespaceAgnostic.mockReturnValue(false);
typeRegistry.isSingleNamespace.mockReturnValue(false);
typeRegistry.isMultiNamespace.mockReturnValue(true);
typeRegistry = typeRegistry = createMockedTypeRegistry({
isNamespaceAgnostic: false,
isSingleNamespace: false,
isMultiNamespace: true,
});
const multiNamespaceSerializer = new SavedObjectsSerializer(typeRegistry);

const sampleTemplate = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import type {
SavedObjectSanitizedDoc,
SavedObjectsRawDocParseOptions,
} from '@kbn/core-saved-objects-server';
import { LEGACY_URL_ALIAS_TYPE } from '../object_types';
import { SavedObjectsUtils } from '@kbn/core-saved-objects-utils-server';
import { LEGACY_URL_ALIAS_TYPE } from '../legacy_alias';
import { decodeVersion, encodeVersion } from '../version';
import { SavedObjectsUtils } from '../service';

/**
* Core internal implementation of {@link ISavedObjectsSerializer}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { schema, Type } from '@kbn/config-schema';
import { schema, type Type } from '@kbn/config-schema';
import type {
SavedObjectsValidationSpec,
SavedObjectSanitizedDoc,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
*/

import { schema } from '@kbn/config-schema';
import { loggerMock, type MockedLogger } from '@kbn/logging-mocks';
import type {
SavedObjectSanitizedDoc,
SavedObjectsValidationMap,
} from '@kbn/core-saved-objects-server';
import { SavedObjectsTypeValidator } from '.';
import { loggerMock, MockedLogger } from '@kbn/logging-mocks';
import { SavedObjectsTypeValidator } from './validator';

describe('Saved Objects type validator', () => {
let validator: SavedObjectsTypeValidator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { SavedObjectsErrorHelpers } from '../service/lib/errors';
import { SavedObjectsErrorHelpers } from '@kbn/core-saved-objects-utils-server';
import { decodeBase64 } from './base64';

/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
* 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 { encodeVersion } from './encode_version';
export { encodeHitVersion } from './encode_hit_version';
export { decodeVersion } from './decode_version';
export { decodeRequestVersion } from './decode_request_version';
Original file line number Diff line number Diff line change
@@ -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/**/*"
]
}
Loading

0 comments on commit 130e99b

Please sign in to comment.