Skip to content

Commit

Permalink
Merge branch 'main' into 123297/fix-a11y-h1
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Apr 11, 2022
2 parents daf52a5 + 2894e40 commit fd67ff6
Show file tree
Hide file tree
Showing 254 changed files with 1,657 additions and 1,020 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,8 +304,8 @@ module.exports = {
*/
{
files: [
'packages/elastic-datemath/**/*.{js,mjs,ts,tsx}',
'packages/elastic-eslint-config-kibana/**/*.{js,mjs,ts,tsx}',
'packages/kbn-datemath/**/*.{js,mjs,ts,tsx}',
],
rules: {
'@kbn/eslint/require-license-header': [
Expand Down
3 changes: 2 additions & 1 deletion .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
/examples/field_formats_example/ @elastic/kibana-app-services
/examples/partial_results_example/ @elastic/kibana-app-services
/examples/search_examples/ @elastic/kibana-app-services
/packages/elastic-datemath/ @elastic/kibana-app-services
/packages/kbn-datemath/ @elastic/kibana-app-services
/packages/kbn-interpreter/ @elastic/kibana-app-services
/packages/kbn-react-field/ @elastic/kibana-app-services
/packages/kbn-es-query/ @elastic/kibana-app-services
Expand Down Expand Up @@ -324,6 +324,7 @@
/src/plugins/interactive_setup/ @elastic/kibana-security
/test/interactive_setup_api_integration/ @elastic/kibana-security
/test/interactive_setup_functional/ @elastic/kibana-security
/test/plugin_functional/test_suites/core_plugins/rendering.ts @elastic/kibana-security
/x-pack/plugins/spaces/ @elastic/kibana-security
/x-pack/plugins/encrypted_saved_objects/ @elastic/kibana-security
/x-pack/plugins/security/ @elastic/kibana-security
Expand Down
16 changes: 8 additions & 8 deletions WORKSPACE.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
# Fetch Node.js rules
http_archive(
name = "build_bazel_rules_nodejs",
sha256 = "8a7c981217239085f78acc9898a1f7ba99af887c1996ceb3b4504655383a2c3c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/4.0.0/rules_nodejs-4.0.0.tar.gz"],
sha256 = "523da2d6b50bc00eaf14b00ed28b1a366b3ab456e14131e9812558b26599125c",
urls = ["https://github.com/bazelbuild/rules_nodejs/releases/download/5.3.1/rules_nodejs-5.3.1.tar.gz"],
)

# Now that we have the rules let's import from them to complete the work
load("@build_bazel_rules_nodejs//:index.bzl", "check_rules_nodejs_version", "node_repositories", "yarn_install")
# Build Node.js rules dependencies
load("@build_bazel_rules_nodejs//:repositories.bzl", "build_bazel_rules_nodejs_dependencies")
build_bazel_rules_nodejs_dependencies()

# Assure we have at least a given rules_nodejs version
check_rules_nodejs_version(minimum_version_string = "4.0.0")
# Now that we have the rules let's import from them to complete the work
load("@build_bazel_rules_nodejs//:index.bzl", "node_repositories", "yarn_install")

# Setup the Node.js toolchain for the architectures we want to support
#
Expand All @@ -38,14 +39,13 @@ node_repositories(
node_urls = [
"https://nodejs.org/dist/v{version}/{filename}",
],
yarn_repositories = {
yarn_releases = {
"1.21.1": ("yarn-v1.21.1.tar.gz", "yarn-v1.21.1", "d1d9f4a0f16f5ed484e814afeb98f39b82d4728c6c8beaafb5abc99c02db6674"),
},
yarn_version = "1.21.1",
yarn_urls = [
"https://github.com/yarnpkg/yarn/releases/download/v{version}/{filename}",
],
package_json = ["//:package.json"],
)

# Run yarn_install rule to take care of dependencies
Expand Down
2 changes: 1 addition & 1 deletion docs/developer/getting-started/monorepo-packages.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ yarn kbn watch
[discrete]
=== List of Already Migrated Packages to Bazel

- @elastic/datemath
- @elastic/eslint-config-kibana
- @elastic/safer-lodash-set
- @kbn/ace
Expand All @@ -64,6 +63,7 @@ yarn kbn watch
- @kbn/config
- @kbn/config-schema
- @kbn/crypto
- @kbn/datemath
- @kbn/dev-utils
- @kbn/docs-utils
- @kbn/es
Expand Down
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"@elastic/apm-rum-react": "^1.3.4",
"@elastic/apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace",
"@elastic/charts": "45.1.1",
"@elastic/datemath": "link:bazel-bin/packages/elastic-datemath",
"@elastic/datemath": "5.0.3",
"@elastic/elasticsearch": "npm:@elastic/[email protected]",
"@elastic/ems-client": "8.2.0",
"@elastic/eui": "53.0.1",
Expand Down Expand Up @@ -140,6 +140,7 @@
"@kbn/config": "link:bazel-bin/packages/kbn-config",
"@kbn/config-schema": "link:bazel-bin/packages/kbn-config-schema",
"@kbn/crypto": "link:bazel-bin/packages/kbn-crypto",
"@kbn/datemath": "link:bazel-bin/packages/kbn-datemath",
"@kbn/doc-links": "link:bazel-bin/packages/kbn-doc-links",
"@kbn/es-query": "link:bazel-bin/packages/kbn-es-query",
"@kbn/eslint-plugin-imports": "link:bazel-bin/packages/kbn-eslint-plugin-imports",
Expand Down Expand Up @@ -310,7 +311,7 @@
"mime-types": "^2.1.27",
"mini-css-extract-plugin": "1.1.0",
"minimatch": "^3.1.2",
"moment": "^2.24.0",
"moment": "^2.29.2",
"moment-duration-format": "^2.3.2",
"moment-timezone": "^0.5.27",
"monaco-editor": "^0.22.3",
Expand Down Expand Up @@ -455,7 +456,7 @@
"@babel/traverse": "^7.17.3",
"@babel/types": "^7.17.0",
"@bazel/ibazel": "^0.16.2",
"@bazel/typescript": "4.0.0",
"@bazel/typescript": "5.3.1",
"@cypress/code-coverage": "^3.9.12",
"@cypress/snapshot": "^2.1.7",
"@cypress/webpack-preprocessor": "^5.6.0",
Expand Down Expand Up @@ -545,7 +546,6 @@
"@types/delete-empty": "^2.0.0",
"@types/ejs": "^3.0.6",
"@types/elastic__apm-synthtrace": "link:bazel-bin/packages/elastic-apm-synthtrace/npm_module_types",
"@types/elastic__datemath": "link:bazel-bin/packages/elastic-datemath/npm_module_types",
"@types/enzyme": "^3.10.8",
"@types/eslint": "^7.28.0",
"@types/express": "^4.17.13",
Expand Down Expand Up @@ -595,6 +595,7 @@
"@types/kbn__config": "link:bazel-bin/packages/kbn-config/npm_module_types",
"@types/kbn__config-schema": "link:bazel-bin/packages/kbn-config-schema/npm_module_types",
"@types/kbn__crypto": "link:bazel-bin/packages/kbn-crypto/npm_module_types",
"@types/kbn__datemath": "link:bazel-bin/packages/kbn-datemath/npm_module_types",
"@types/kbn__dev-utils": "link:bazel-bin/packages/kbn-dev-utils/npm_module_types",
"@types/kbn__doc-links": "link:bazel-bin/packages/kbn-doc-links/npm_module_types",
"@types/kbn__docs-utils": "link:bazel-bin/packages/kbn-docs-utils/npm_module_types",
Expand Down
4 changes: 2 additions & 2 deletions packages/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ filegroup(
srcs = [
"//packages/elastic-analytics:build",
"//packages/elastic-apm-synthtrace:build",
"//packages/elastic-datemath:build",
"//packages/elastic-eslint-config-kibana:build",
"//packages/elastic-safer-lodash-set:build",
"//packages/kbn-ace:build",
Expand All @@ -30,6 +29,7 @@ filegroup(
"//packages/kbn-config-schema:build",
"//packages/kbn-config:build",
"//packages/kbn-crypto:build",
"//packages/kbn-datemath:build",
"//packages/kbn-dev-utils:build",
"//packages/kbn-doc-links:build",
"//packages/kbn-docs-utils:build",
Expand Down Expand Up @@ -102,7 +102,6 @@ filegroup(
srcs = [
"//packages/elastic-analytics:build_types",
"//packages/elastic-apm-synthtrace:build_types",
"//packages/elastic-datemath:build_types",
"//packages/elastic-safer-lodash-set:build_types",
"//packages/kbn-ace:build_types",
"//packages/kbn-alerts:build_types",
Expand All @@ -116,6 +115,7 @@ filegroup(
"//packages/kbn-config-schema:build_types",
"//packages/kbn-config:build_types",
"//packages/kbn-crypto:build_types",
"//packages/kbn-datemath:build_types",
"//packages/kbn-dev-utils:build_types",
"//packages/kbn-doc-links:build_types",
"//packages/kbn-docs-utils:build_types",
Expand Down
4 changes: 2 additions & 2 deletions packages/elastic-apm-synthtrace/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ NPM_MODULE_EXTRA_FILES = [
]

RUNTIME_DEPS = [
"//packages/elastic-datemath",
"//packages/kbn-datemath",
"@npm//@elastic/elasticsearch",
"@npm//lodash",
"@npm//moment",
Expand All @@ -36,7 +36,7 @@ RUNTIME_DEPS = [
]

TYPES_DEPS = [
"//packages/elastic-datemath:npm_module_types",
"//packages/kbn-datemath:npm_module_types",
"@npm//@elastic/elasticsearch",
"@npm//@types/jest",
"@npm//@types/lodash",
Expand Down
2 changes: 1 addition & 1 deletion packages/elastic-apm-synthtrace/src/scripts/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/
import datemath from '@elastic/datemath';
import datemath from '@kbn/datemath';
import yargs from 'yargs/yargs';
import { Argv } from 'yargs';
import { intervalToMs } from './utils/interval_to_ms';
Expand Down
3 changes: 2 additions & 1 deletion packages/kbn-config-schema/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
NullableProps,
RecordOfOptions,
RecordOfType,
SchemaStructureEntry,
StringOptions,
StringType,
Type,
Expand All @@ -49,7 +50,7 @@ import {
StreamType,
} from './types';

export type { AnyType, ConditionalType, TypeOf, Props, NullableProps };
export type { AnyType, ConditionalType, TypeOf, Props, SchemaStructureEntry, NullableProps };
export { ObjectType, Type };
export { ByteSizeValue } from './byte_size_value';
export { SchemaTypeError, ValidationError } from './errors';
Expand Down
1 change: 1 addition & 0 deletions packages/kbn-config-schema/src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
*/

export type { TypeOptions } from './type';
export type { SchemaStructureEntry } from './type';
export { Type } from './type';
export { AnyType } from './any_type';
export type { ArrayOptions } from './array_type';
Expand Down
73 changes: 73 additions & 0 deletions packages/kbn-config-schema/src/types/object_type.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -490,3 +490,76 @@ describe('#extends', () => {
expect(extended.validate(undefined)).toEqual({ initial: 'bar', added: 42 });
});
});

test('returns schema structure', () => {
// This test covers different schema types that may or may not be nested
const objSchema = schema.object({
any: schema.any(),
array: schema.arrayOf(schema.string()),
boolean: schema.boolean(),
buffer: schema.buffer(),
byteSize: schema.byteSize(),
conditional: schema.conditional(
schema.contextRef('context_value_1'),
schema.contextRef('context_value_2'),
schema.string(),
schema.string()
),
duration: schema.duration(),
ip: schema.ip(),
literal: schema.literal('foo'),
map: schema.mapOf(schema.string(), schema.string()),
maybe: schema.maybe(schema.string()),
never: schema.never(),
nullable: schema.nullable(schema.string()),
number: schema.number(),
record: schema.recordOf(schema.string(), schema.string()),
stream: schema.stream(),
string: schema.string(),
union: schema.oneOf([schema.string()]),
uri: schema.uri(),
});
const type = objSchema.extends({
nested: objSchema,
});
expect(type.getSchemaStructure()).toEqual([
{ path: ['any'], type: 'any' },
{ path: ['array'], type: 'array' },
{ path: ['boolean'], type: 'boolean' },
{ path: ['buffer'], type: 'binary' },
{ path: ['byteSize'], type: 'bytes' },
{ path: ['conditional'], type: 'any' },
{ path: ['duration'], type: 'duration' },
{ path: ['ip'], type: 'string' },
{ path: ['literal'], type: 'any' },
{ path: ['map'], type: 'map' },
{ path: ['maybe'], type: 'string' },
{ path: ['never'], type: 'any' },
{ path: ['nullable'], type: 'alternatives' },
{ path: ['number'], type: 'number' },
{ path: ['record'], type: 'record' },
{ path: ['stream'], type: 'stream' },
{ path: ['string'], type: 'string' },
{ path: ['union'], type: 'alternatives' },
{ path: ['uri'], type: 'string' },
{ path: ['nested', 'any'], type: 'any' },
{ path: ['nested', 'array'], type: 'array' },
{ path: ['nested', 'boolean'], type: 'boolean' },
{ path: ['nested', 'buffer'], type: 'binary' },
{ path: ['nested', 'byteSize'], type: 'bytes' },
{ path: ['nested', 'conditional'], type: 'any' },
{ path: ['nested', 'duration'], type: 'duration' },
{ path: ['nested', 'ip'], type: 'string' },
{ path: ['nested', 'literal'], type: 'any' },
{ path: ['nested', 'map'], type: 'map' },
{ path: ['nested', 'maybe'], type: 'string' },
{ path: ['nested', 'never'], type: 'any' },
{ path: ['nested', 'nullable'], type: 'alternatives' },
{ path: ['nested', 'number'], type: 'number' },
{ path: ['nested', 'record'], type: 'record' },
{ path: ['nested', 'stream'], type: 'stream' },
{ path: ['nested', 'string'], type: 'string' },
{ path: ['nested', 'union'], type: 'alternatives' },
{ path: ['nested', 'uri'], type: 'string' },
]);
});
1 change: 1 addition & 0 deletions packages/kbn-config-schema/src/types/string_type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class StringType extends Type<string> {
);
}

schema.type = 'string';
super(schema, options);
}

Expand Down
23 changes: 23 additions & 0 deletions packages/kbn-config-schema/src/types/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export interface TypeOptions<T> {
validate?: (value: T) => string | void;
}

export interface SchemaStructureEntry {
path: string[];
type: string;
}

export const convertValidationFunction = <T = unknown>(
validate: (value: T) => string | void
): CustomValidator<T> => {
Expand Down Expand Up @@ -98,6 +103,10 @@ export abstract class Type<V> {
return this.internalSchema;
}

public getSchemaStructure() {
return recursiveGetSchemaStructure(this.internalSchema);
}

protected handleError(
type: string,
context: Record<string, any>,
Expand Down Expand Up @@ -141,3 +150,17 @@ export abstract class Type<V> {
return new SchemaTypeError(message || code, convertedPath);
}
}

function recursiveGetSchemaStructure(internalSchema: AnySchema, path: string[] = []) {
const array: SchemaStructureEntry[] = [];
// Note: we are relying on Joi internals to obtain the schema structure (recursive keys).
// This is not ideal, but it works for now and we only need it for some integration test assertions.
// If it breaks in the future, we'll need to update our tests.
for (const [key, val] of (internalSchema as any)._ids._byKey.entries()) {
array.push(...recursiveGetSchemaStructure(val.schema, [...path, key]));
}
if (!array.length) {
array.push({ path, type: internalSchema.type ?? 'unknown' });
}
return array;
}
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ 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", "ts_project", "pkg_npm", "pkg_npm_types")

PKG_BASE_NAME = "elastic-datemath"
PKG_REQUIRE_NAME = "@elastic/datemath"
PKG_BASE_NAME = "kbn-datemath"
PKG_REQUIRE_NAME = "@kbn/datemath"

SOURCE_FILES = glob([
"src/index.ts",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# datemath

Datemath string parser used in Kibana. This is published to NPM for use in a limited number of locations outside of Kibana, but is not regularly updated and may get seriously out of date.
Datemath string parser used in Kibana. This is published to NPM under (@elastic/datemath) for use in a limited number of locations outside of Kibana, but is not regularly updated and may get seriously out of date.

If you file an issue in elastic/kibana we can probably update it for you if needed, though you probably shouldn't depend on this package for anything important.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
module.exports = {
preset: '@kbn/test',
rootDir: '../..',
roots: ['<rootDir>/packages/elastic-datemath'],
roots: ['<rootDir>/packages/kbn-datemath'],
testEnvironment: 'jsdom',
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elastic/datemath",
"version": "5.0.3",
"name": "@kbn/datemath",
"version": "5.0.4",
"description": "elasticsearch datemath parser, used in kibana",
"license": "Apache-2.0",
"main": "./target_node/index.js",
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 2 additions & 1 deletion packages/kbn-doc-links/src/get_doc_links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
},
logstash: {
base: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}`,
inputElasticAgent: `${ELASTIC_WEBSITE_URL}guide/en/logstash/${DOC_LINK_VERSION}/plugins-inputs-elastic_agent.html`,
},
functionbeat: {
base: `${ELASTIC_WEBSITE_URL}guide/en/beats/functionbeat/${DOC_LINK_VERSION}`,
Expand Down Expand Up @@ -579,7 +580,7 @@ export const getDocLinks = ({ kibanaBranch }: GetDocLinkOptions): DocLinks => {
guide: `${FLEET_DOCS}index.html`,
fleetServer: `${FLEET_DOCS}fleet-server.html`,
fleetServerAddFleetServer: `${FLEET_DOCS}add-a-fleet-server.html`,
settings: `${FLEET_DOCS}fleet-settings.html#fleet-server-hosts-setting`,
settings: `${FLEET_DOCS}fleet-settings.html`,
settingsFleetServerHostSettings: `${FLEET_DOCS}fleet-settings.html#fleet-server-hosts-setting`,
settingsFleetServerProxySettings: `${KIBANA_DOCS}fleet-settings-kb.html#fleet-data-visualizer-settings`,
troubleshooting: `${FLEET_DOCS}fleet-troubleshooting.html`,
Expand Down
Loading

0 comments on commit fd67ff6

Please sign in to comment.