[nit][pre-req] Strongly-type Shipper and Category (#114412)

This commit is contained in:
Clint Andrew Hall 2021-10-11 21:35:00 -05:00 committed by GitHub
parent c926b14c32
commit 243c2133af
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -9,13 +9,11 @@
export const PLUGIN_ID = 'customIntegrations';
export const PLUGIN_NAME = 'customIntegrations';
export interface IntegrationCategoryCount {
count: number;
id: IntegrationCategory;
}
/**
* A map of category names and their corresponding titles.
*/
// TODO: consider i18n
export const INTEGRATION_CATEGORY_DISPLAY = {
// Known EPR
aws: 'AWS',
azure: 'Azure',
cloud: 'Cloud',
@ -49,13 +47,62 @@ export const INTEGRATION_CATEGORY_DISPLAY = {
updates_available: 'Updates available',
};
/**
* A category applicable to an Integration.
*/
export type IntegrationCategory = keyof typeof INTEGRATION_CATEGORY_DISPLAY;
/**
* The list of all available categories.
*/
// This `as` is necessary, as Object.keys cannot be strongly typed.
// see: https://github.com/Microsoft/TypeScript/issues/12870
export const category = Object.keys(INTEGRATION_CATEGORY_DISPLAY) as IntegrationCategory[];
/**
* An object containing the id of an `IntegrationCategory` and the count of all Integrations in that category.
*/
export interface IntegrationCategoryCount {
count: number;
id: IntegrationCategory;
}
/**
* A map of shipper names and their corresponding titles.
*/
// TODO: consider i18n
export const SHIPPER_DISPLAY = {
beats: 'Beats',
language_clients: 'Language clients',
other: 'Other',
sample_data: 'Sample data',
tests: 'Tests',
tutorial: 'Tutorials',
};
/**
* A shipper-- an internal or external system capable of storing data in ES/Kibana-- applicable to an Integration.
*/
export type Shipper = keyof typeof SHIPPER_DISPLAY;
/**
* The list of all known shippers.
*/
// This `as` is necessary, as Object.keys cannot be strongly typed.
// see: https://github.com/Microsoft/TypeScript/issues/12870
export const shipper = Object.keys(SHIPPER_DISPLAY) as Shipper[];
/**
* An icon representing an Integration.
*/
export interface CustomIntegrationIcon {
src: string;
type: 'eui' | 'svg';
}
/**
* A definition of a dataintegration, which can be registered with Kibana.
*/
export interface CustomIntegration {
id: string;
title: string;
@ -65,7 +112,7 @@ export interface CustomIntegration {
isBeta: boolean;
icons: CustomIntegrationIcon[];
categories: IntegrationCategory[];
shipper: string;
shipper: Shipper;
eprOverlap?: string; // name of the equivalent Elastic Agent integration in EPR. e.g. a beat module can correspond to an EPR-package, or an APM-tutorial. When completed, Integrations-UX can preferentially show the EPR-package, rather than the custom-integration
}