[8.16] [APM][ML] Update cytoscape with new index.d.ts def, fix typing issues (#206651) (#207224)

# Backport

This will backport the following commits from `main` to `8.16`:
- [[APM][ML] Update cytoscape with new index.d.ts def, fix typing issues
(#206651)](https://github.com/elastic/kibana/pull/206651)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Gonçalo Rica Pais da
Silva","email":"goncalo.rica@elastic.co"},"sourceCommit":{"committedDate":"2025-01-20T13:36:22Z","message":"[APM][ML]
Update cytoscape with new index.d.ts def, fix typing issues
(#206651)\n\n## Summary\r\n\r\n`cytoscape` released yet another semver
breaking change, affecting\r\ntyping once more in a couple of places.
They now have their own\r\n`index.d.ts` file for Typescript support, but
this causes some issues as\r\nthey don't always have the same type name
as the `@types` version. Had\r\nto fix in a couple of places, both in
APM and in ML codebases.\r\n\r\nSupersedes #206498\r\n\r\n## How to
test\r\n\r\n* This PR passes the CI with no typing issues, or failed
tests\r\n* Going to APM or ML pages with cytoscape being loaded shows
no\r\nregressions.","sha":"a0bdc1968456f0db02a18becefdc19bdcc5469f5","branchLabelMapping":{"^v9.0.0$":"main","^v8.18.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","v9.0.0","backport:all-open","Team:obs-ux-infra_services"],"title":"[APM][ML]
Update cytoscape with new index.d.ts def, fix typing
issues","number":206651,"url":"https://github.com/elastic/kibana/pull/206651","mergeCommit":{"message":"[APM][ML]
Update cytoscape with new index.d.ts def, fix typing issues
(#206651)\n\n## Summary\r\n\r\n`cytoscape` released yet another semver
breaking change, affecting\r\ntyping once more in a couple of places.
They now have their own\r\n`index.d.ts` file for Typescript support, but
this causes some issues as\r\nthey don't always have the same type name
as the `@types` version. Had\r\nto fix in a couple of places, both in
APM and in ML codebases.\r\n\r\nSupersedes #206498\r\n\r\n## How to
test\r\n\r\n* This PR passes the CI with no typing issues, or failed
tests\r\n* Going to APM or ML pages with cytoscape being loaded shows
no\r\nregressions.","sha":"a0bdc1968456f0db02a18becefdc19bdcc5469f5"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/206651","number":206651,"mergeCommit":{"message":"[APM][ML]
Update cytoscape with new index.d.ts def, fix typing issues
(#206651)\n\n## Summary\r\n\r\n`cytoscape` released yet another semver
breaking change, affecting\r\ntyping once more in a couple of places.
They now have their own\r\n`index.d.ts` file for Typescript support, but
this causes some issues as\r\nthey don't always have the same type name
as the `@types` version. Had\r\nto fix in a couple of places, both in
APM and in ML codebases.\r\n\r\nSupersedes #206498\r\n\r\n## How to
test\r\n\r\n* This PR passes the CI with no typing issues, or failed
tests\r\n* Going to APM or ML pages with cytoscape being loaded shows
no\r\nregressions.","sha":"a0bdc1968456f0db02a18becefdc19bdcc5469f5"}}]}]
BACKPORT-->
This commit is contained in:
Gonçalo Rica Pais da Silva 2025-01-20 18:34:01 +01:00 committed by GitHub
parent e98f9f3d17
commit 030bac4924
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 8 additions and 14 deletions

View file

@ -1090,7 +1090,7 @@
"css-box-model": "^1.2.1",
"css.escape": "^1.5.1",
"cypress-data-session": "^2.8.0",
"cytoscape": "^3.30.4",
"cytoscape": "^3.31.0",
"cytoscape-dagre": "^2.5.0",
"d3": "3.5.17",
"d3-array": "2.12.1",
@ -1541,7 +1541,6 @@
"@types/classnames": "^2.2.9",
"@types/cli-progress": "^3.11.5",
"@types/color": "^3.0.3",
"@types/cytoscape": "^3.21.8",
"@types/d3": "^3.5.43",
"@types/d3-array": "^2.12.1",
"@types/d3-brush": "^3.0.0",

View file

@ -8,7 +8,7 @@
import type { CSSProperties, PropsWithChildren } from 'react';
import React, { useState, useRef, useEffect, createContext, useCallback, useMemo } from 'react';
import { css } from '@emotion/react';
import cytoscape, { type Stylesheet } from 'cytoscape';
import cytoscape, { type StylesheetJson } from 'cytoscape';
// @ts-ignore no declaration file
import dagre from 'cytoscape-dagre';
import { getCytoscapeOptions } from './cytoscape_options';
@ -37,7 +37,7 @@ function useCytoscape(options: cytoscape.CytoscapeOptions) {
setCy(cytoscape({ ...options, container: ref.current }));
} else {
// update styles for existing instance
cy.style(options.style as unknown as Stylesheet);
cy.style(options.style as StylesheetJson);
}
}, [options, cy]);

View file

@ -96,7 +96,7 @@ function isService(el: cytoscape.NodeSingular) {
return el.data(SERVICE_NAME) !== undefined;
}
const getStyle = (theme: EuiTheme, isTraceExplorerEnabled: boolean): cytoscape.Stylesheet[] => {
const getStyle = (theme: EuiTheme, isTraceExplorerEnabled: boolean): cytoscape.StylesheetJson => {
const lineColor = theme.eui.euiColorMediumShade;
return [
{

View file

@ -10370,11 +10370,6 @@
resolved "https://registry.yarnpkg.com/@types/cookiejar/-/cookiejar-2.1.5.tgz#14a3e83fa641beb169a2dd8422d91c3c345a9a78"
integrity sha512-he+DHOWReW0nghN24E1WUqM0efK4kI9oTqDm6XmK8ZPe2djZ90BSNdGnIyCLzCPw7/pogPlGbzI2wHGGmi4O/Q==
"@types/cytoscape@^3.21.8":
version "3.21.8"
resolved "https://registry.yarnpkg.com/@types/cytoscape/-/cytoscape-3.21.8.tgz#6166a2eabd66d3ae3259024875e037492adb8db6"
integrity sha512-6Bo9ZDrv0vfwe8Sg/ERc5VL0yU0gYvP4dgZi0fAXYkKHfyHaNqWRMcwYm3mu4sLsXbB8ZuXE75sR7qnaOL5JgQ==
"@types/d3-array@^2.12.1":
version "2.12.3"
resolved "https://registry.yarnpkg.com/@types/d3-array/-/d3-array-2.12.3.tgz#8d16d51fb04ad5a5a8ebe14eb8263a579f1efdd1"
@ -15543,10 +15538,10 @@ cytoscape-dagre@^2.5.0:
dependencies:
dagre "^0.8.5"
cytoscape@^3.30.4:
version "3.30.4"
resolved "https://registry.yarnpkg.com/cytoscape/-/cytoscape-3.30.4.tgz#3404da0a159c00a1a3df2c85b2b43fdc66a0e28e"
integrity sha512-OxtlZwQl1WbwMmLiyPSEBuzeTIQnwZhJYYWFzZ2PhEHVFwpeaqNIkUzSiso00D98qk60l8Gwon2RP304d3BJ1A==
cytoscape@^3.31.0:
version "3.31.0"
resolved "https://registry.yarnpkg.com/cytoscape/-/cytoscape-3.31.0.tgz#cffbbb8ca51db01cbf360e0cf59088db6d429837"
integrity sha512-zDGn1K/tfZwEnoGOcHc0H4XazqAAXAuDpcYw9mUnUjATjqljyCNGJv8uEvbvxGaGHaVshxMecyl6oc6uKzRfbw==
"d3-array@1 - 3", "d3-array@2 - 3", "d3-array@2.10.0 - 3", "d3-array@2.5.0 - 3", d3-array@3.2.2, d3-array@^3.2.2:
version "3.2.2"