diff --git a/x-pack/plugins/ingest_manager/common/types/epm.ts b/x-pack/plugins/ingest_manager/common/types/epm.ts deleted file mode 100644 index 908fa80b028ea..0000000000000 --- a/x-pack/plugins/ingest_manager/common/types/epm.ts +++ /dev/null @@ -1,178 +0,0 @@ -/* - * Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one - * or more contributor license agreements. Licensed under the Elastic License; - * you may not use this file except in compliance with the Elastic License. - */ - -// Follow pattern from https://github.com/elastic/kibana/pull/52447 -// TODO: Update when https://github.com/elastic/kibana/issues/53021 is closed -import { - SavedObject, - SavedObjectAttributes, - SavedObjectReference, -} from '../../../../../src/core/public'; -import { AssetType as IngestAssetType } from '../../../../legacy/plugins/ingest/common/types/domain_data'; - -export enum InstallationStatus { - installed = 'installed', - notInstalled = 'not_installed', -} - -export type ServiceName = 'kibana' | 'elasticsearch'; -export type AssetType = KibanaAssetType | ElasticsearchAssetType | AgentAssetType; - -export enum KibanaAssetType { - dashboard = 'dashboard', - visualization = 'visualization', - search = 'search', - indexPattern = 'index-pattern', -} - -export enum ElasticsearchAssetType { - ingestPipeline = 'ingest-pipeline', - indexTemplate = 'index-template', - ilmPolicy = 'ilm-policy', -} - -export enum AgentAssetType { - input = 'input', -} - -// from /package/{name} -// type Package struct at https://github.com/elastic/package-registry/blob/master/util/package.go -// https://github.com/elastic/package-registry/blob/master/docs/api/package.json -export interface RegistryPackage { - name: string; - title?: string; - version: string; - readme?: string; - description: string; - type: string; - categories: string[]; - requirement: RequirementsByServiceName; - screenshots?: ScreenshotItem[]; - icons?: string[]; - assets?: string[]; - internal?: boolean; - format_version: string; - datasets?: Dataset[]; - download: string; - path: string; -} - -export type RequirementVersion = string; -export type RequirementVersionRange = string; -export interface ServiceRequirements { - versions: RequirementVersionRange; -} - -// Registry's response types -// from /search -// https://github.com/elastic/package-registry/blob/master/docs/api/search.json -export type RegistrySearchResults = RegistrySearchResult[]; -// from getPackageOutput at https://github.com/elastic/package-registry/blob/master/search.go -export type RegistrySearchResult = Pick< - RegistryPackage, - 'name' | 'title' | 'version' | 'description' | 'type' | 'icons' | 'internal' | 'download' | 'path' ->; - -export interface ScreenshotItem { - src: string; - title?: string; -} - -// from /categories -// https://github.com/elastic/package-registry/blob/master/docs/api/categories.json -export type CategorySummaryList = CategorySummaryItem[]; -export type CategoryId = string; -export interface CategorySummaryItem { - id: CategoryId; - title: string; - count: number; -} - -export type RequirementsByServiceName = Record; -export interface AssetParts { - pkgkey: string; - dataset?: string; - service: ServiceName; - type: AssetType; - file: string; -} -export type AssetTypeToParts = KibanaAssetTypeToParts & ElasticsearchAssetTypeToParts; -export type AssetsGroupedByServiceByType = Record< - Extract, - KibanaAssetTypeToParts ->; -// & Record, ElasticsearchAssetTypeToParts>; - -export type KibanaAssetParts = AssetParts & { - service: Extract; - type: KibanaAssetType; -}; - -export type ElasticsearchAssetParts = AssetParts & { - service: Extract; - type: ElasticsearchAssetType; -}; - -export type KibanaAssetTypeToParts = Record; -export type ElasticsearchAssetTypeToParts = Record< - ElasticsearchAssetType, - ElasticsearchAssetParts[] ->; - -export interface Dataset { - title: string; - name: string; - release: string; - ingest_pipeline: string; - vars?: VarsEntry[]; - type: string; - package: string; -} - -export interface VarsEntry { - name: string; - default: string; -} - -// some properties are optional in Registry responses but required in EPM -// internal until we need them -interface PackageAdditions { - title: string; - assets: AssetsGroupedByServiceByType; -} - -// Managers public HTTP response types -export type PackageList = PackageListItem[]; - -export type PackageListItem = Installable; -export type PackagesGroupedByStatus = Record; -export type PackageInfo = Installable; - -export interface Installation extends SavedObjectAttributes { - installed: AssetReference[]; -} - -export type Installable = Installed | NotInstalled; - -export type Installed = T & { - status: InstallationStatus.installed; - savedObject: SavedObject; -}; - -export type NotInstalled = T & { - status: InstallationStatus.notInstalled; -}; - -export type AssetReference = Pick & { - type: AssetType | IngestAssetType; -}; - -// Calling Object.entries(PackagesGroupedByStatus) gave `status: string` -// which causes a "string is not assignable to type InstallationStatus` error -// see https://github.com/Microsoft/TypeScript/issues/20322 -// and https://github.com/Microsoft/TypeScript/pull/12253#issuecomment-263132208 -// and https://github.com/Microsoft/TypeScript/issues/21826#issuecomment-479851685 -export const entries = Object.entries as (o: T) => Array<[keyof T, T[keyof T]]>; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/assets_facet_group.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/assets_facet_group.tsx index 16b7ca424ff9f..1dea67c84d477 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/assets_facet_group.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/assets_facet_group.tsx @@ -21,7 +21,7 @@ import { AssetTypeToParts, KibanaAssetType, entries, -} from '../../../../../../common/types/epm'; +} from '../../../types'; import { AssetIcons, AssetTitleMap, diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/package_card.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/package_card.tsx index bbc22ba48c251..8289e445d6931 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/package_card.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/package_card.tsx @@ -6,7 +6,7 @@ import { EuiCard, EuiIcon, ICON_TYPES } from '@elastic/eui'; import React from 'react'; import styled from 'styled-components'; -import { PackageInfo, PackageListItem } from '../../../../../../common/types/epm'; +import { PackageInfo, PackageListItem } from '../../../types'; import { useLinks } from '../hooks'; export interface BadgeProps { diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/package_list_grid.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/package_list_grid.tsx index f21c9cbda3f75..34e1763c44255 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/package_list_grid.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/package_list_grid.tsx @@ -5,7 +5,7 @@ */ import { EuiFlexGrid, EuiFlexGroup, EuiFlexItem, EuiSpacer, EuiText } from '@elastic/eui'; import React, { Fragment, ReactNode } from 'react'; -import { PackageList } from '../../../../../../common/types/epm'; +import { PackageList } from '../../../types'; import { BadgeProps, PackageCard } from './package_card'; type ListProps = { diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/requirements.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/requirements.tsx index 919df9cb19e0f..c447cb52fd315 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/requirements.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/requirements.tsx @@ -7,7 +7,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiIcon, EuiText, EuiTextColor, EuiTitle } from '@elastic/eui'; import React, { Fragment } from 'react'; import styled from 'styled-components'; -import { RequirementsByServiceName, entries } from '../../../../../../common/types/epm'; +import { RequirementsByServiceName, entries } from '../../../types'; import { ServiceTitleMap } from '../constants'; // import { useCore } from '../hooks/use_core'; import { Version } from './version'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/version.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/version.tsx index cd89c038a8f2e..6fa091494b64f 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/version.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/components/version.tsx @@ -6,7 +6,7 @@ import React from 'react'; import styled from 'styled-components'; -import { RequirementVersion } from '../../../../../../common/types/epm'; +import { RequirementVersion } from '../../../types'; // const CodeText = styled.span` // font-family: ${props => props.theme.eui.euiCodeFontFamily}; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx index 305bbff1630aa..384cbbeed378e 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/content.tsx @@ -8,7 +8,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiHorizontalRule, EuiSpacer } from '@elasti import React from 'react'; import styled from 'styled-components'; import { DEFAULT_PANEL, DetailParams } from '.'; -import { PackageInfo } from '../../../../../../../common/types/epm'; +import { PackageInfo } from '../../../../types'; import { AssetsFacetGroup } from '../../components/assets_facet_group'; import { Requirements } from '../../components/requirements'; import { CenterColumn, LeftColumn, RightColumn } from './layout'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/header.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/header.tsx index 3da3639644949..684894adf4662 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/header.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/header.tsx @@ -7,7 +7,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiPage, EuiTitle, IconType } from '@elastic import React, { Fragment } from 'react'; import styled from 'styled-components'; // import { PLUGIN } from '../../../common/constants'; -import { PackageInfo } from '../../../../../../../common/types/epm'; +import { PackageInfo } from '../../../../types'; import { IconPanel } from '../../components/icon_panel'; import { NavButtonBack } from '../../components/nav_button_back'; import { Version } from '../../components/version'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/index.tsx index 278d9e1a73e8c..fe564b1f06483 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/index.tsx @@ -8,7 +8,7 @@ import React, { Fragment, useEffect, useState } from 'react'; import { useParams } from 'react-router-dom'; import styled from 'styled-components'; import { DetailViewPanelName } from '../../types'; -import { PackageInfo } from '../../../../../../../common/types/epm'; +import { PackageInfo } from '../../../../types'; import { getPackageInfoByKey } from '../../data'; // import { useSetPackageInstallStatus } from '../../hooks'; // import { useCore } from '../../hooks/use_core'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/installation_button.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/installation_button.tsx index a407edd7bbf22..38fc975ab165c 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/installation_button.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/installation_button.tsx @@ -5,7 +5,7 @@ */ import { EuiButton } from '@elastic/eui'; import React, { Fragment, useCallback, useMemo, useState } from 'react'; -import { PackageInfo } from '../../../../../../../common/types/epm'; +import { PackageInfo } from '../../../../types'; // import { useDeletePackage, useGetPackageInstallStatus, useInstallPackage } from '../../hooks'; // import { InstallStatus } from '../../types'; import { ConfirmPackageDelete } from './confirm_package_delete'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/overview_panel.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/overview_panel.tsx index 82a9cf84bfda2..ca6aceabe7f36 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/overview_panel.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/overview_panel.tsx @@ -5,7 +5,7 @@ */ import { EuiSpacer } from '@elastic/eui'; import React, { Fragment } from 'react'; -import { PackageInfo } from '../../../../../../../common/types/epm'; +import { PackageInfo } from '../../../../types'; import { Readme } from './readme'; import { Screenshots } from './screenshots'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/screenshots.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/screenshots.tsx index 0e3d13c70b8c2..b1677ccd86f01 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/screenshots.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/screenshots.tsx @@ -6,7 +6,7 @@ import { EuiFlexGroup, EuiFlexItem, EuiImage, EuiSpacer, EuiText, EuiTitle } from '@elastic/eui'; import React, { Fragment } from 'react'; import styled from 'styled-components'; -import { ScreenshotItem } from '../../../../../../../common/types/epm'; +import { ScreenshotItem } from '../../../../types'; // import { useCore, useLinks } from '../../hooks'; interface ScreenshotProps { diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/side_nav_links.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/side_nav_links.tsx index 8077390284ae6..67f5c87887c4f 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/side_nav_links.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/detail/side_nav_links.tsx @@ -8,7 +8,7 @@ import { EuiButtonEmpty, EuiButtonEmptyProps } from '@elastic/eui'; import React, { Fragment } from 'react'; import styled from 'styled-components'; import { DetailViewPanelName } from '../../types'; -import { PackageInfo, entries } from '../../../../../../../common/types/epm'; +import { PackageInfo, entries } from '../../../../types'; // import { useLinks, useGetPackageInstallStatus } from '../../hooks'; // import { InstallStatus } from '../../types'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/category_facets.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/category_facets.tsx index f1ce296bf8c26..e138f9f531a39 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/category_facets.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/category_facets.tsx @@ -5,7 +5,7 @@ */ import { EuiFacetButton, EuiFacetGroup } from '@elastic/eui'; import React from 'react'; -import { CategorySummaryItem, CategorySummaryList } from '../../../../../../../common/types/epm'; +import { CategorySummaryItem, CategorySummaryList } from '../../../../types'; export function CategoryFacets({ categories, diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/hooks.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/hooks.tsx index 9e8ed134f497f..d33f75be50310 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/hooks.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/hooks.tsx @@ -5,7 +5,7 @@ */ import { useEffect, useRef, useState } from 'react'; -import { CategorySummaryList, PackageList } from '../../../../../../../common/types/epm'; +import { CategorySummaryList, PackageList } from '../../../../types'; import { getCategories, getPackages } from '../../data'; import { fieldsToSearch, LocalSearch, searchIdField } from './search_packages'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/index.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/index.tsx index 772b3cc3ea01b..609880d4fe5d0 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/index.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/index.tsx @@ -7,7 +7,7 @@ import { EuiHorizontalRule, EuiPage, EuiPageBody, EuiSpacer } from '@elastic/eui import React, { Fragment, useState } from 'react'; import styled from 'styled-components'; // import { PLUGIN } from '../../../common/constants'; -import { CategorySummaryItem, PackageList } from '../../../../../../../common/types/epm'; +import { CategorySummaryItem, PackageList } from '../../../../types'; import { PackageListGrid } from '../../components/package_list_grid'; // import { useBreadcrumbs, useLinks } from '../../hooks'; // import { useLinks } from '../../hooks'; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/search_packages.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/search_packages.tsx index 5d5912eead739..adffdefd30a4f 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/search_packages.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/search_packages.tsx @@ -6,7 +6,7 @@ import { Search as LocalSearch } from 'js-search'; import React from 'react'; -import { PackageList, PackageListItem } from '../../../../../../../common/types/epm'; +import { PackageList, PackageListItem } from '../../../../types'; import { SearchResults } from './search_results'; export { LocalSearch }; diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/search_results.tsx b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/search_results.tsx index db800dcc02927..fbdcaac01931b 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/search_results.tsx +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/sections/epm/screens/home/search_results.tsx @@ -6,7 +6,7 @@ import { EuiText, EuiTitle } from '@elastic/eui'; import React from 'react'; -import { PackageList } from '../../../../../../../common/types/epm'; +import { PackageList } from '../../../../types'; import { PackageListGrid } from '../../components/package_list_grid'; interface SearchResultsProps { diff --git a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts index 8597d6fd59323..ed327d5fc6ecc 100644 --- a/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts +++ b/x-pack/plugins/ingest_manager/public/applications/ingest_manager/types/index.ts @@ -16,4 +16,23 @@ export { UpdateAgentConfigResponse, DeleteAgentConfigsRequestSchema, DeleteAgentConfigsResponse, + // EPM types + AssetsGroupedByServiceByType, + AssetTypeToParts, + CategorySummaryItem, + CategorySummaryList, + KibanaAssetType, + PackageInfo, + PackageList, + PackageListItem, + RequirementsByServiceName, + RequirementVersion, + ScreenshotItem, } from '../../../../common'; + +// Calling Object.entries(PackagesGroupedByStatus) gave `status: string` +// which causes a "string is not assignable to type InstallationStatus` error +// see https://github.com/Microsoft/TypeScript/issues/20322 +// and https://github.com/Microsoft/TypeScript/pull/12253#issuecomment-263132208 +// and https://github.com/Microsoft/TypeScript/issues/21826#issuecomment-479851685 +export const entries = Object.entries as (o: T) => Array<[keyof T, T[keyof T]]>;