Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -1950,8 +1950,10 @@ x-pack/platform/plugins/shared/ml/server/models/data_recognizer/modules/security
/config/serverless.security.essentials.yml @elastic/security-solution @elastic/kibana-security
/config/serverless.security.complete.yml @elastic/security-solution @elastic/kibana-security
/typings/ @elastic/kibana-core
/typings/vega/ @elastic/kibana-visualizations
^/src/platform/test/analytics @elastic/kibana-core
/src/platform/packages/shared/kbn-test/src/jest/setup/mocks.kbn_i18n_react.js @elastic/kibana-core
/src/platform/packages/shared/kbn-test/src/jest/setup/mocks.vega.js @elastic/kibana-visualizations
/x-pack/platform/test/saved_objects_field_count/ @elastic/kibana-core
/x-pack/test_serverless/**/test_suites/common/saved_objects_management/ @elastic/kibana-core
/x-pack/platform/test/serverless/**/test_suites/saved_objects_management/ @elastic/kibana-core
Expand Down
17 changes: 7 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,7 @@
"@types/react-dom": "~18.2.0",
"@xstate5/react/**/xstate": "^5.19.2",
"apache-arrow": "20.x - 21.x",
"globby/fast-glob": "^3.3.2",
"vega-expression": "5.2.1",
"vega-interpreter": "1.2.1",
"vega-util": "1.17.4"
"globby/fast-glob": "^3.3.2"
},
"dependencies": {
"@ai-sdk/langchain": "^1.0.102",
Expand Down Expand Up @@ -1340,12 +1337,12 @@
"usng.js": "^0.4.5",
"utility-types": "^3.10.0",
"uuid": "10.0.0",
"vega": "^5.33.0",
"vega-interpreter": "1.2.1",
"vega-lite": "^5.21.0",
"vega-schema-url-parser": "^2.2.0",
"vega-spec-injector": "^0.0.2",
"vega-tooltip": "^0.34.0",
"vega": "6.2.0",
"vega-interpreter": "2.2.1",
"vega-lite": "6.4.1",
"vega-schema-url-parser": "3.0.2",
"vega-spec-injector": "0.0.2",
"vega-tooltip": "1.1.0",
"vinyl": "^3.0.0",
"wellknown": "^0.5.0",
"xml2js": "^0.5.0",
Expand Down
4 changes: 4 additions & 0 deletions packages/kbn-babel-preset/common_preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@
*/

module.exports = () => ({
// Enables import-attributes syntax on imports
generatorOpts: {
importAttributesKeyword: 'with',
},
presets: [
// plugins always run before presets, but in this case we need the
// @babel/preset-typescript preset to run first so we have to move
Expand Down
5 changes: 4 additions & 1 deletion packages/kbn-eslint-config/javascript.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ module.exports = {
ecmaVersion: 2018,
requireConfigFile: false,
babelOptions: {
presets: ['@kbn/babel-preset/node_preset']
presets: ['@kbn/babel-preset/node_preset'],
parserOpts: {
plugins: ['importAttributes']
}
},
},

Expand Down
6 changes: 1 addition & 5 deletions packages/kbn-optimizer/src/worker/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,7 @@ export function getWebpackConfig(
// no parse rules for a few known large packages which have no require() statements
// or which have require() statements that should be ignored because the file is
// already bundled with all its necessary dependencies
noParse: [
/[\/\\]node_modules[\/\\]lodash[\/\\]index\.js$/,
/[\/\\]node_modules[\/\\]vega[\/\\]build-es5[\/\\]vega\.js$/,
],
noParse: [/[\/\\]node_modules[\/\\]lodash[\/\\]index\.js$/],

rules: [
{
Expand Down Expand Up @@ -293,7 +290,6 @@ export function getWebpackConfig(
worker.repoRoot,
'src/core/public/styles/core_app/images'
),
vega: Path.resolve(worker.repoRoot, 'node_modules/vega/build-es5/vega.js'),
'react-dom$':
worker.reactVersion === '18' ? 'react-dom-18/profiling' : 'react-dom/profiling',
'scheduler/tracing': 'scheduler/tracing-profiling',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,14 @@ export class ImportResolver {
return Path.resolve(REPO_ROOT, `node_modules/zod/v3/index.cjs`);
}

if (req.startsWith('vega-lite')) {
return Path.resolve(REPO_ROOT, `node_modules/vega-lite/build`);
}

if (req.startsWith('vega-tooltip')) {
return Path.resolve(REPO_ROOT, `node_modules/vega-tooltip/build`);
}

// turn root-relative paths into relative paths
if (
req.startsWith('src/') ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,6 @@ export default ({ config: storybookConfig }: { config: Configuration }) => {
},
externals,
module: {
// no parse rules for a few known large packages which have no require() statements
// or which have require() statements that should be ignored because the file is
// already bundled with all its necessary dependencies
noParse: [/[\/\\]node_modules[\/\\]vega[\/\\]build-es5[\/\\]vega\.js$/],
rules: [
{
test: /\.mjs$/,
Expand All @@ -55,7 +51,6 @@ export default ({ config: storybookConfig }: { config: Configuration }) => {
alias: {
core_app_image_assets: resolve(REPO_ROOT, 'src/core/public/styles/core_app/images'),
core_styles: resolve(REPO_ROOT, 'src/core/public/index.scss'),
vega: resolve(REPO_ROOT, 'node_modules/vega/build-es5/vega.js'),
},
},
stats: 'errors-only',
Expand Down
3 changes: 2 additions & 1 deletion src/platform/packages/shared/kbn-test/jest-preset.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ module.exports = {
'<rootDir>/src/platform/packages/shared/kbn-test/src/jest/setup/mocks.eui.js',
'<rootDir>/src/platform/packages/shared/kbn-test/src/jest/setup/react_testing_library.js',
'<rootDir>/src/platform/packages/shared/kbn-test/src/jest/setup/mocks.kbn_i18n_react.js',
'<rootDir>/src/platform/packages/shared/kbn-test/src/jest/setup/mocks.vega.js',
process.env.CI
? '<rootDir>/src/platform/packages/shared/kbn-test/src/jest/setup/disable_console_logs.js'
: [],
Expand Down Expand Up @@ -119,7 +120,7 @@ module.exports = {
transformIgnorePatterns: [
// ignore all node_modules except monaco-editor, monaco-yaml which requires babel transforms to handle dynamic import()
// since ESM modules are not natively supported in Jest yet (https://github.com/facebook/jest/issues/4842)
'[/\\\\]node_modules(?![\\/\\\\](byte-size|monaco-editor|monaco-yaml|monaco-languageserver-types|monaco-marker-data-provider|monaco-worker-manager|vscode-languageserver-types|d3-interpolate|d3-color|langchain|langsmith|@cfworker|gpt-tokenizer|flat|@langchain|eventsource-parser|@assemblyscript|quickselect|rbush|zod/v4))[/\\\\].+\\.js$',
'[/\\\\]node_modules(?![\\/\\\\](byte-size|monaco-editor|monaco-yaml|monaco-languageserver-types|monaco-marker-data-provider|monaco-worker-manager|vscode-languageserver-types|d3-interpolate|d3-color|langchain|langsmith|@cfworker|gpt-tokenizer|flat|@langchain|eventsource-parser|fast-check|@fast-check/jest|@assemblyscript|quickselect|rbush|zod/v4|vega-interpreter|vega-util|vega-tooltip))[/\\\\].+\\.js$',
'packages/kbn-pm/dist/index.js',
'[/\\\\]node_modules(?![\\/\\\\](langchain|langsmith|@langchain|zod/v4))/dist/[/\\\\].+\\.js$',
'[/\\\\]node_modules(?![\\/\\\\](langchain|langsmith|@langchain|zod/v4))/dist/util/[/\\\\].+\\.js$',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

/* eslint-env jest */

const fs = require('fs');
const vm = require('vm');
const path = require('path');

let cached = null;

const loadVegaAndVegaLite = () => {
if (cached) return cached;

const sandbox = {
window: {},
globalThis: {},
structuredClone: (obj) => JSON.parse(JSON.stringify(obj)),
};

// vega
const vegaPath = path.resolve('node_modules/vega/build/vega.min.js');
const vegaCode = fs.readFileSync(vegaPath, 'utf8');
vm.createContext(sandbox);
vm.runInContext(vegaCode, sandbox);

sandbox.window.vega = sandbox.globalThis.vega = sandbox.window.vega || sandbox.globalThis.vega;

// vega-lite
const litePath = path.resolve('node_modules/vega-lite/build/vega-lite.min.js');
const liteCode = fs.readFileSync(litePath, 'utf8');
vm.runInContext(liteCode, sandbox);

cached = {
vega: sandbox.window.vega || sandbox.globalThis.vega,
vegaLite: sandbox.window.vegaLite || sandbox.globalThis.vegaLite,
};

// both Vega and Vega-Lite
return cached;
};

jest.mock('vega', () => {
const { vega } = loadVegaAndVegaLite();
return { ...vega };
});

jest.mock('vega-lite', () => {
const { vegaLite } = loadVegaAndVegaLite();
return { ...vegaLite };
});

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2230,7 +2230,9 @@
"@elastic/opentelemetry-node/sdk": ["typings/@elastic/opentelemetry-node/sdk"],
"@typescript-eslint/parser": ["typings/@typescript-eslint/parser"],
"zod": ["typings/zod/v3"],
"zod/v4": ["typings/zod/v4"]
"zod/v4": ["typings/zod/v4"],
"vega-lite": ["typings/vega/vega_lite"],
"vega-tooltip": ["typings/vega/vega_tooltip"]
},
// Support .tsx files and transform JSX into calls to React.createElement
"jsx": "react",
Expand Down
12 changes: 12 additions & 0 deletions typings/vega/vega_lite.d.ts
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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

declare module 'vega-lite' {
export * from 'vega-lite/build';
}
12 changes: 12 additions & 0 deletions typings/vega/vega_tooltip.d.ts
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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
* License v3.0 only", or the "Server Side Public License, v 1".
*/

declare module 'vega-tooltip' {
export * from 'vega-tooltip/build';
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@

import 'jest-canvas-mock';

// @ts-ignore
import { compile } from 'vega-lite/build/vega-lite';
import { compile } from 'vega-lite';

import { euiLightVars as euiThemeLight } from '@kbn/ui-theme';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,8 @@
import type { FC } from 'react';
import React, { useMemo, useEffect } from 'react';

// There is still an issue with Vega Lite's typings with the strict mode Kibana is using.
// @ts-ignore
import type { TopLevelSpec } from 'vega-lite/build/vega-lite';

// There is still an issue with Vega Lite's typings with the strict mode Kibana is using.
// @ts-ignore
import { compile } from 'vega-lite/build/vega-lite';
import type { TopLevelSpec } from 'vega-lite';
import { compile } from 'vega-lite';
import { parse, View, Warn } from 'vega';
import { expressionInterpreter } from 'vega-interpreter';
import { Handler } from 'vega-tooltip';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export function createTestConfig(
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 4 * 1000, // 4 minutes
preferCached: true,
},
}),
servicesRequiredForTestAnalysis: ['datasetQualityFtrConfig', 'registry'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export default async function createTestConfig({
args: dockerArgs,
waitForLogLine: 'package manifests loaded',
waitForLogLineTimeoutMs: 60 * 4 * 1000, // 4 minutes
preferCached: true,
},
}),
services: {
Expand Down
Loading