diff --git a/x-pack/package.json b/x-pack/package.json index 3ee025072c4cf..2c741c83ea987 100644 --- a/x-pack/package.json +++ b/x-pack/package.json @@ -80,6 +80,7 @@ "fetch-mock": "^5.13.1", "graphql-code-generator": "^0.13.0", "graphql-codegen-introspection-template": "^0.13.0", + "graphql-codegen-typescript-resolvers-template": "^0.13.0", "graphql-codegen-typescript-template": "^0.13.0", "gulp": "3.9.1", "gulp-mocha": "2.2.0", diff --git a/x-pack/plugins/infra/common/graphql/typed_resolvers.ts b/x-pack/plugins/infra/common/graphql/typed_resolvers.ts deleted file mode 100644 index 3be4fc4d64b09..0000000000000 --- a/x-pack/plugins/infra/common/graphql/typed_resolvers.ts +++ /dev/null @@ -1,82 +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. - */ - -import { GraphQLResolveInfo } from 'graphql'; - -type BasicResolver = ( - parent: any, - args: Args, - context: any, - info: GraphQLResolveInfo -) => Promise | Result; - -type InfraResolverResult = - | Promise - | Promise<{ [P in keyof R]: () => Promise }> - | { [P in keyof R]: () => Promise } - | { [P in keyof R]: () => R[P] } - | R; - -export type InfraResolvedResult = Resolver extends InfraResolver< - infer Result, - any, - any, - any -> - ? Result - : never; - -export type SubsetResolverWithFields = R extends BasicResolver< - Array, - infer ArgsInArray -> - ? BasicResolver< - Array>>, - ArgsInArray - > - : R extends BasicResolver - ? BasicResolver>, Args> - : never; - -export type SubsetResolverWithoutFields = R extends BasicResolver< - Array, - infer ArgsInArray -> - ? BasicResolver< - Array>>, - ArgsInArray - > - : R extends BasicResolver - ? BasicResolver>, Args> - : never; - -export type InfraResolver = ( - parent: Parent, - args: Args, - context: Context, - info: GraphQLResolveInfo -) => InfraResolverResult; - -export type InfraResolverOf = Resolver extends BasicResolver< - infer Result, - infer Args -> - ? InfraResolver - : never; - -export type InfraResolverWithFields< - Resolver, - Parent, - Context, - IncludedFields extends string -> = InfraResolverOf, Parent, Context>; - -export type InfraResolverWithoutFields< - Resolver, - Parent, - Context, - ExcludedFields extends string -> = InfraResolverOf, Parent, Context>; diff --git a/x-pack/plugins/infra/common/graphql/types.ts b/x-pack/plugins/infra/common/graphql/types.ts deleted file mode 100644 index 42cb52b4e4059..0000000000000 --- a/x-pack/plugins/infra/common/graphql/types.ts +++ /dev/null @@ -1,856 +0,0 @@ -/* tslint:disable */ -import { GraphQLResolveInfo } from 'graphql'; - -type Resolver = ( - parent: any, - args: Args, - context: any, - info: GraphQLResolveInfo -) => Promise | Result; - -export interface Query { - source: InfraSource /** Get an infrastructure data source by id */; - allSources: InfraSource[] /** Get a list of all infrastructure data sources */; -} -/** A source of infrastructure data */ -export interface InfraSource { - id: string /** The id of the source */; - configuration: InfraSourceConfiguration /** The raw configuration of the source */; - status: InfraSourceStatus /** The status of the source */; - metadataByNode: (InfraNodeMetadata | null)[] /** A hierarchy of metadata entries by node */; - logEntriesAround: InfraLogEntryInterval /** A consecutive span of log entries surrounding a point in time */; - logEntriesBetween: InfraLogEntryInterval /** A consecutive span of log entries within an interval */; - logSummaryBetween: InfraLogSummaryInterval /** A consecutive span of summary buckets within an interval */; - map?: InfraResponse | null /** A hierarchy of hosts, pods, containers, services or arbitrary groups */; - metrics: InfraMetricData[]; -} -/** A set of configuration options for an infrastructure data source */ -export interface InfraSourceConfiguration { - metricAlias: string /** The alias to read metric data from */; - logAlias: string /** The alias to read log data from */; - fields: InfraSourceFields /** The field mapping to use for this source */; -} -/** A mapping of semantic fields to their document counterparts */ -export interface InfraSourceFields { - container: string /** The field to identify a container by */; - host: string /** The fields to identify a host by */; - message: string[] /** The fields that may contain the log event message. The first field found win. */; - pod: string /** The field to identify a pod by */; - tiebreaker: string /** The field to use as a tiebreaker for log events that have identical timestamps */; - timestamp: string /** The field to use as a timestamp for metrics and logs */; -} -/** The status of an infrastructure data source */ -export interface InfraSourceStatus { - metricAliasExists: boolean /** Whether the configured metric alias exists */; - logAliasExists: boolean /** Whether the configured log alias exists */; - metricIndicesExist: boolean /** Whether the configured alias or wildcard pattern resolve to any metric indices */; - logIndicesExist: boolean /** Whether the configured alias or wildcard pattern resolve to any log indices */; - metricIndices: string[] /** The list of indices in the metric alias */; - logIndices: string[] /** The list of indices in the log alias */; - indexFields: InfraIndexField[] /** The list of fields defined in the index mappings */; -} -/** A descriptor of a field in an index */ -export interface InfraIndexField { - name: string /** The name of the field */; - type: string /** The type of the field's values as recognized by Kibana */; - searchable: boolean /** Whether the field's values can be efficiently searched for */; - aggregatable: boolean /** Whether the field's values can be aggregated */; -} -/** One metadata entry for a node. */ -export interface InfraNodeMetadata { - name: string; - source: string; -} -/** A consecutive sequence of log entries */ -export interface InfraLogEntryInterval { - start?: InfraTimeKey | null /** The key corresponding to the start of the interval covered by the entries */; - end?: InfraTimeKey | null /** The key corresponding to the end of the interval covered by the entries */; - hasMoreBefore: boolean /** Whether there are more log entries available before the start */; - hasMoreAfter: boolean /** Whether there are more log entries available after the end */; - filterQuery?: string | null /** The query the log entries were filtered by */; - highlightQuery?: string | null /** The query the log entries were highlighted with */; - entries: InfraLogEntry[] /** A list of the log entries */; -} -/** A representation of the log entry's position in the event stream */ -export interface InfraTimeKey { - time: number /** The timestamp of the event that the log entry corresponds to */; - tiebreaker: number /** The tiebreaker that disambiguates events with the same timestamp */; -} -/** A log entry */ -export interface InfraLogEntry { - key: InfraTimeKey /** A unique representation of the log entry's position in the event stream */; - gid: string /** The log entry's id */; - source: string /** The source id */; - message: InfraLogMessageSegment[] /** A list of the formatted log entry segments */; -} -/** A segment of the log entry message that was derived from a field */ -export interface InfraLogMessageFieldSegment { - field: string /** The field the segment was derived from */; - value: string /** The segment's message */; - highlights: string[] /** A list of highlighted substrings of the value */; -} -/** A segment of the log entry message that was derived from a field */ -export interface InfraLogMessageConstantSegment { - constant: string /** The segment's message */; -} -/** A consecutive sequence of log summary buckets */ -export interface InfraLogSummaryInterval { - start?: - | number - | null /** The millisecond timestamp corresponding to the start of the interval covered by the summary */; - end?: - | number - | null /** The millisecond timestamp corresponding to the end of the interval covered by the summary */; - filterQuery?: string | null /** The query the log entries were filtered by */; - buckets: InfraLogSummaryBucket[] /** A list of the log entries */; -} -/** A log summary bucket */ -export interface InfraLogSummaryBucket { - start: number /** The start timestamp of the bucket */; - end: number /** The end timestamp of the bucket */; - entriesCount: number /** The number of entries inside the bucket */; -} - -export interface InfraResponse { - nodes: InfraNode[]; -} - -export interface InfraNode { - path: InfraNodePath[]; - metric: InfraNodeMetric; -} - -export interface InfraNodePath { - value: string; -} - -export interface InfraNodeMetric { - name: InfraMetricType; - value: number; -} - -export interface InfraMetricData { - id?: InfraMetric | null; - series: InfraDataSeries[]; -} - -export interface InfraDataSeries { - id: string; - data: InfraDataPoint[]; -} - -export interface InfraDataPoint { - timestamp: number; - value?: number | null; -} - -export namespace QueryResolvers { - export interface Resolvers { - source?: SourceResolver /** Get an infrastructure data source by id */; - allSources?: AllSourcesResolver /** Get a list of all infrastructure data sources */; - } - - export type SourceResolver = Resolver; - export interface SourceArgs { - id: string /** The id of the source */; - } - - export type AllSourcesResolver = Resolver; -} -/** A source of infrastructure data */ -export namespace InfraSourceResolvers { - export interface Resolvers { - id?: IdResolver /** The id of the source */; - configuration?: ConfigurationResolver /** The raw configuration of the source */; - status?: StatusResolver /** The status of the source */; - metadataByNode?: MetadataByNodeResolver /** A hierarchy of metadata entries by node */; - logEntriesAround?: LogEntriesAroundResolver /** A consecutive span of log entries surrounding a point in time */; - logEntriesBetween?: LogEntriesBetweenResolver /** A consecutive span of log entries within an interval */; - logSummaryBetween?: LogSummaryBetweenResolver /** A consecutive span of summary buckets within an interval */; - map?: MapResolver /** A hierarchy of hosts, pods, containers, services or arbitrary groups */; - metrics?: MetricsResolver; - } - - export type IdResolver = Resolver; - export type ConfigurationResolver = Resolver; - export type StatusResolver = Resolver; - export type MetadataByNodeResolver = Resolver<(InfraNodeMetadata | null)[], MetadataByNodeArgs>; - export interface MetadataByNodeArgs { - nodeName: string; - nodeType: InfraNodeType; - } - - export type LogEntriesAroundResolver = Resolver; - export interface LogEntriesAroundArgs { - key: InfraTimeKeyInput /** The sort key that corresponds to the point in time */; - countBefore?: number | null /** The maximum number of preceding to return */; - countAfter?: number | null /** The maximum number of following to return */; - filterQuery?: string | null /** The query to filter the log entries by */; - highlightQuery?: string | null /** The query to highlight the log entries with */; - } - - export type LogEntriesBetweenResolver = Resolver; - export interface LogEntriesBetweenArgs { - startKey: InfraTimeKeyInput /** The sort key that corresponds to the start of the interval */; - endKey: InfraTimeKeyInput /** The sort key that corresponds to the end of the interval */; - filterQuery?: string | null /** The query to filter the log entries by */; - highlightQuery?: string | null /** The query to highlight the log entries with */; - } - - export type LogSummaryBetweenResolver = Resolver; - export interface LogSummaryBetweenArgs { - start: number /** The millisecond timestamp that corresponds to the start of the interval */; - end: number /** The millisecond timestamp that corresponds to the end of the interval */; - bucketSize: number /** The size of each bucket in milliseconds */; - filterQuery?: string | null /** The query to filter the log entries by */; - } - - export type MapResolver = Resolver; - export interface MapArgs { - timerange: InfraTimerangeInput; - filterQuery?: string | null; - } - - export type MetricsResolver = Resolver; - export interface MetricsArgs { - nodeId: string; - nodeType: InfraNodeType; - timerange: InfraTimerangeInput; - metrics: InfraMetric[]; - } -} -/** A set of configuration options for an infrastructure data source */ -export namespace InfraSourceConfigurationResolvers { - export interface Resolvers { - metricAlias?: MetricAliasResolver /** The alias to read metric data from */; - logAlias?: LogAliasResolver /** The alias to read log data from */; - fields?: FieldsResolver /** The field mapping to use for this source */; - } - - export type MetricAliasResolver = Resolver; - export type LogAliasResolver = Resolver; - export type FieldsResolver = Resolver; -} -/** A mapping of semantic fields to their document counterparts */ -export namespace InfraSourceFieldsResolvers { - export interface Resolvers { - container?: ContainerResolver /** The field to identify a container by */; - host?: HostResolver /** The fields to identify a host by */; - message?: MessageResolver /** The fields that may contain the log event message. The first field found win. */; - pod?: PodResolver /** The field to identify a pod by */; - tiebreaker?: TiebreakerResolver /** The field to use as a tiebreaker for log events that have identical timestamps */; - timestamp?: TimestampResolver /** The field to use as a timestamp for metrics and logs */; - } - - export type ContainerResolver = Resolver; - export type HostResolver = Resolver; - export type MessageResolver = Resolver; - export type PodResolver = Resolver; - export type TiebreakerResolver = Resolver; - export type TimestampResolver = Resolver; -} -/** The status of an infrastructure data source */ -export namespace InfraSourceStatusResolvers { - export interface Resolvers { - metricAliasExists?: MetricAliasExistsResolver /** Whether the configured metric alias exists */; - logAliasExists?: LogAliasExistsResolver /** Whether the configured log alias exists */; - metricIndicesExist?: MetricIndicesExistResolver /** Whether the configured alias or wildcard pattern resolve to any metric indices */; - logIndicesExist?: LogIndicesExistResolver /** Whether the configured alias or wildcard pattern resolve to any log indices */; - metricIndices?: MetricIndicesResolver /** The list of indices in the metric alias */; - logIndices?: LogIndicesResolver /** The list of indices in the log alias */; - indexFields?: IndexFieldsResolver /** The list of fields defined in the index mappings */; - } - - export type MetricAliasExistsResolver = Resolver; - export type LogAliasExistsResolver = Resolver; - export type MetricIndicesExistResolver = Resolver; - export type LogIndicesExistResolver = Resolver; - export type MetricIndicesResolver = Resolver; - export type LogIndicesResolver = Resolver; - export type IndexFieldsResolver = Resolver; - export interface IndexFieldsArgs { - indexType?: InfraIndexType | null; - } -} -/** A descriptor of a field in an index */ -export namespace InfraIndexFieldResolvers { - export interface Resolvers { - name?: NameResolver /** The name of the field */; - type?: TypeResolver /** The type of the field's values as recognized by Kibana */; - searchable?: SearchableResolver /** Whether the field's values can be efficiently searched for */; - aggregatable?: AggregatableResolver /** Whether the field's values can be aggregated */; - } - - export type NameResolver = Resolver; - export type TypeResolver = Resolver; - export type SearchableResolver = Resolver; - export type AggregatableResolver = Resolver; -} -/** One metadata entry for a node. */ -export namespace InfraNodeMetadataResolvers { - export interface Resolvers { - name?: NameResolver; - source?: SourceResolver; - } - - export type NameResolver = Resolver; - export type SourceResolver = Resolver; -} -/** A consecutive sequence of log entries */ -export namespace InfraLogEntryIntervalResolvers { - export interface Resolvers { - start?: StartResolver /** The key corresponding to the start of the interval covered by the entries */; - end?: EndResolver /** The key corresponding to the end of the interval covered by the entries */; - hasMoreBefore?: HasMoreBeforeResolver /** Whether there are more log entries available before the start */; - hasMoreAfter?: HasMoreAfterResolver /** Whether there are more log entries available after the end */; - filterQuery?: FilterQueryResolver /** The query the log entries were filtered by */; - highlightQuery?: HighlightQueryResolver /** The query the log entries were highlighted with */; - entries?: EntriesResolver /** A list of the log entries */; - } - - export type StartResolver = Resolver; - export type EndResolver = Resolver; - export type HasMoreBeforeResolver = Resolver; - export type HasMoreAfterResolver = Resolver; - export type FilterQueryResolver = Resolver; - export type HighlightQueryResolver = Resolver; - export type EntriesResolver = Resolver; -} -/** A representation of the log entry's position in the event stream */ -export namespace InfraTimeKeyResolvers { - export interface Resolvers { - time?: TimeResolver /** The timestamp of the event that the log entry corresponds to */; - tiebreaker?: TiebreakerResolver /** The tiebreaker that disambiguates events with the same timestamp */; - } - - export type TimeResolver = Resolver; - export type TiebreakerResolver = Resolver; -} -/** A log entry */ -export namespace InfraLogEntryResolvers { - export interface Resolvers { - key?: KeyResolver /** A unique representation of the log entry's position in the event stream */; - gid?: GidResolver /** The log entry's id */; - source?: SourceResolver /** The source id */; - message?: MessageResolver /** A list of the formatted log entry segments */; - } - - export type KeyResolver = Resolver; - export type GidResolver = Resolver; - export type SourceResolver = Resolver; - export type MessageResolver = Resolver; -} -/** A segment of the log entry message that was derived from a field */ -export namespace InfraLogMessageFieldSegmentResolvers { - export interface Resolvers { - field?: FieldResolver /** The field the segment was derived from */; - value?: ValueResolver /** The segment's message */; - highlights?: HighlightsResolver /** A list of highlighted substrings of the value */; - } - - export type FieldResolver = Resolver; - export type ValueResolver = Resolver; - export type HighlightsResolver = Resolver; -} -/** A segment of the log entry message that was derived from a field */ -export namespace InfraLogMessageConstantSegmentResolvers { - export interface Resolvers { - constant?: ConstantResolver /** The segment's message */; - } - - export type ConstantResolver = Resolver; -} -/** A consecutive sequence of log summary buckets */ -export namespace InfraLogSummaryIntervalResolvers { - export interface Resolvers { - start?: StartResolver /** The millisecond timestamp corresponding to the start of the interval covered by the summary */; - end?: EndResolver /** The millisecond timestamp corresponding to the end of the interval covered by the summary */; - filterQuery?: FilterQueryResolver /** The query the log entries were filtered by */; - buckets?: BucketsResolver /** A list of the log entries */; - } - - export type StartResolver = Resolver; - export type EndResolver = Resolver; - export type FilterQueryResolver = Resolver; - export type BucketsResolver = Resolver; -} -/** A log summary bucket */ -export namespace InfraLogSummaryBucketResolvers { - export interface Resolvers { - start?: StartResolver /** The start timestamp of the bucket */; - end?: EndResolver /** The end timestamp of the bucket */; - entriesCount?: EntriesCountResolver /** The number of entries inside the bucket */; - } - - export type StartResolver = Resolver; - export type EndResolver = Resolver; - export type EntriesCountResolver = Resolver; -} - -export namespace InfraResponseResolvers { - export interface Resolvers { - nodes?: NodesResolver; - } - - export type NodesResolver = Resolver; - export interface NodesArgs { - path: InfraPathInput[]; - metric: InfraMetricInput; - } -} - -export namespace InfraNodeResolvers { - export interface Resolvers { - path?: PathResolver; - metric?: MetricResolver; - } - - export type PathResolver = Resolver; - export type MetricResolver = Resolver; -} - -export namespace InfraNodePathResolvers { - export interface Resolvers { - value?: ValueResolver; - } - - export type ValueResolver = Resolver; -} - -export namespace InfraNodeMetricResolvers { - export interface Resolvers { - name?: NameResolver; - value?: ValueResolver; - } - - export type NameResolver = Resolver; - export type ValueResolver = Resolver; -} - -export namespace InfraMetricDataResolvers { - export interface Resolvers { - id?: IdResolver; - series?: SeriesResolver; - } - - export type IdResolver = Resolver; - export type SeriesResolver = Resolver; -} - -export namespace InfraDataSeriesResolvers { - export interface Resolvers { - id?: IdResolver; - data?: DataResolver; - } - - export type IdResolver = Resolver; - export type DataResolver = Resolver; -} - -export namespace InfraDataPointResolvers { - export interface Resolvers { - timestamp?: TimestampResolver; - value?: ValueResolver; - } - - export type TimestampResolver = Resolver; - export type ValueResolver = Resolver; -} - -export interface InfraTimeKeyInput { - time: number; - tiebreaker: number; -} - -export interface InfraTimerangeInput { - interval: string /** The interval string to use for last bucket. The format is '{value}{unit}'. For example '5m' would return the metrics for the last 5 minutes of the timespan. */; - to: number /** The end of the timerange */; - from: number /** The beginning of the timerange */; -} - -export interface InfraPathInput { - type: InfraPathType /** The type of path */; - label?: - | string - | null /** The label to use in the results for the group by for the terms group by */; - field?: - | string - | null /** The field to group by from a terms aggregation, this is ignored by the filter type */; - filters?: InfraPathFilterInput[] | null /** The fitlers for the filter group by */; -} -/** A group by filter */ -export interface InfraPathFilterInput { - label: string /** The label for the filter, this will be used as the group name in the final results */; - query: string /** The query string query */; -} - -export interface InfraMetricInput { - type: InfraMetricType /** The type of metric */; -} -export interface SourceQueryArgs { - id: string /** The id of the source */; -} -export interface MetadataByNodeInfraSourceArgs { - nodeName: string; - nodeType: InfraNodeType; -} -export interface LogEntriesAroundInfraSourceArgs { - key: InfraTimeKeyInput /** The sort key that corresponds to the point in time */; - countBefore?: number | null /** The maximum number of preceding to return */; - countAfter?: number | null /** The maximum number of following to return */; - filterQuery?: string | null /** The query to filter the log entries by */; - highlightQuery?: string | null /** The query to highlight the log entries with */; -} -export interface LogEntriesBetweenInfraSourceArgs { - startKey: InfraTimeKeyInput /** The sort key that corresponds to the start of the interval */; - endKey: InfraTimeKeyInput /** The sort key that corresponds to the end of the interval */; - filterQuery?: string | null /** The query to filter the log entries by */; - highlightQuery?: string | null /** The query to highlight the log entries with */; -} -export interface LogSummaryBetweenInfraSourceArgs { - start: number /** The millisecond timestamp that corresponds to the start of the interval */; - end: number /** The millisecond timestamp that corresponds to the end of the interval */; - bucketSize: number /** The size of each bucket in milliseconds */; - filterQuery?: string | null /** The query to filter the log entries by */; -} -export interface MapInfraSourceArgs { - timerange: InfraTimerangeInput; - filterQuery?: string | null; -} -export interface MetricsInfraSourceArgs { - nodeId: string; - nodeType: InfraNodeType; - timerange: InfraTimerangeInput; - metrics: InfraMetric[]; -} -export interface IndexFieldsInfraSourceStatusArgs { - indexType?: InfraIndexType | null; -} -export interface NodesInfraResponseArgs { - path: InfraPathInput[]; - metric: InfraMetricInput; -} - -export enum InfraIndexType { - ANY = 'ANY', - LOGS = 'LOGS', - METRICS = 'METRICS', -} - -export enum InfraNodeType { - pod = 'pod', - container = 'container', - host = 'host', -} - -export enum InfraPathType { - terms = 'terms', - filters = 'filters', - hosts = 'hosts', - pods = 'pods', - containers = 'containers', -} - -export enum InfraMetricType { - count = 'count', - cpu = 'cpu', - load = 'load', - memory = 'memory', - tx = 'tx', - rx = 'rx', - logRate = 'logRate', -} - -export enum InfraMetric { - hostSystemOverview = 'hostSystemOverview', - hostCpuUsage = 'hostCpuUsage', - hostFilesystem = 'hostFilesystem', - hostK8sOverview = 'hostK8sOverview', - hostK8sCpuCap = 'hostK8sCpuCap', - hostK8sDiskCap = 'hostK8sDiskCap', - hostK8sMemoryCap = 'hostK8sMemoryCap', - hostK8sPodCap = 'hostK8sPodCap', - hostLoad = 'hostLoad', - hostMemoryUsage = 'hostMemoryUsage', - hostNetworkTraffic = 'hostNetworkTraffic', - podOverview = 'podOverview', - podCpuUsage = 'podCpuUsage', - podMemoryUsage = 'podMemoryUsage', - podLogUsage = 'podLogUsage', - podNetworkTraffic = 'podNetworkTraffic', - containerOverview = 'containerOverview', - containerCpuKernel = 'containerCpuKernel', - containerCpuUsage = 'containerCpuUsage', - containerDiskIOOps = 'containerDiskIOOps', - containerDiskIOBytes = 'containerDiskIOBytes', - containerMemory = 'containerMemory', - containerNetworkTraffic = 'containerNetworkTraffic', - nginxHits = 'nginxHits', - nginxRequestRate = 'nginxRequestRate', - nginxActiveConnections = 'nginxActiveConnections', - nginxRequestsPerConnection = 'nginxRequestsPerConnection', -} - -export enum InfraOperator { - gt = 'gt', - gte = 'gte', - lt = 'lt', - lte = 'lte', - eq = 'eq', -} -/** A segment of the log entry message */ -export type InfraLogMessageSegment = InfraLogMessageFieldSegment | InfraLogMessageConstantSegment; - -export namespace MetadataQuery { - export type Variables = { - sourceId: string; - nodeId: string; - nodeType: InfraNodeType; - }; - - export type Query = { - __typename?: 'Query'; - source: Source; - }; - - export type Source = { - __typename?: 'InfraSource'; - id: string; - metadataByNode: (MetadataByNode | null)[]; - }; - - export type MetadataByNode = { - __typename?: 'InfraNodeMetadata'; - name: string; - source: string; - }; -} -export namespace MetricsQuery { - export type Variables = { - sourceId: string; - timerange: InfraTimerangeInput; - metrics: InfraMetric[]; - nodeId: string; - nodeType: InfraNodeType; - }; - - export type Query = { - __typename?: 'Query'; - source: Source; - }; - - export type Source = { - __typename?: 'InfraSource'; - id: string; - metrics: Metrics[]; - }; - - export type Metrics = { - __typename?: 'InfraMetricData'; - id?: InfraMetric | null; - series: Series[]; - }; - - export type Series = { - __typename?: 'InfraDataSeries'; - id: string; - data: Data[]; - }; - - export type Data = { - __typename?: 'InfraDataPoint'; - timestamp: number; - value?: number | null; - }; -} -export namespace WaffleNodesQuery { - export type Variables = { - sourceId: string; - timerange: InfraTimerangeInput; - filterQuery?: string | null; - metric: InfraMetricInput; - path: InfraPathInput[]; - }; - - export type Query = { - __typename?: 'Query'; - source: Source; - }; - - export type Source = { - __typename?: 'InfraSource'; - id: string; - map?: Map | null; - }; - - export type Map = { - __typename?: 'InfraResponse'; - nodes: Nodes[]; - }; - - export type Nodes = { - __typename?: 'InfraNode'; - path: Path[]; - metric: Metric; - }; - - export type Path = { - __typename?: 'InfraNodePath'; - value: string; - }; - - export type Metric = { - __typename?: 'InfraNodeMetric'; - name: InfraMetricType; - value: number; - }; -} -export namespace SourceQuery { - export type Variables = { - sourceId?: string | null; - }; - - export type Query = { - __typename?: 'Query'; - source: Source; - }; - - export type Source = { - __typename?: 'InfraSource'; - id: string; - configuration: Configuration; - status: Status; - }; - - export type Configuration = { - __typename?: 'InfraSourceConfiguration'; - metricAlias: string; - logAlias: string; - fields: Fields; - }; - - export type Fields = { - __typename?: 'InfraSourceFields'; - container: string; - host: string; - pod: string; - }; - - export type Status = { - __typename?: 'InfraSourceStatus'; - indexFields: IndexFields[]; - logIndicesExist: boolean; - metricIndicesExist: boolean; - }; - - export type IndexFields = { - __typename?: 'InfraIndexField'; - name: string; - type: string; - searchable: boolean; - aggregatable: boolean; - }; -} -export namespace LogEntries { - export type Variables = { - sourceId?: string | null; - timeKey: InfraTimeKeyInput; - countBefore?: number | null; - countAfter?: number | null; - filterQuery?: string | null; - }; - - export type Query = { - __typename?: 'Query'; - source: Source; - }; - - export type Source = { - __typename?: 'InfraSource'; - id: string; - logEntriesAround: LogEntriesAround; - }; - - export type LogEntriesAround = { - __typename?: 'InfraLogEntryInterval'; - start?: Start | null; - end?: End | null; - hasMoreBefore: boolean; - hasMoreAfter: boolean; - entries: Entries[]; - }; - - export type Start = InfraTimeKeyFields.Fragment; - - export type End = InfraTimeKeyFields.Fragment; - - export type Entries = { - __typename?: 'InfraLogEntry'; - gid: string; - key: Key; - message: Message[]; - }; - - export type Key = { - __typename?: 'InfraTimeKey'; - time: number; - tiebreaker: number; - }; - - export type Message = - | InfraLogMessageFieldSegmentInlineFragment - | InfraLogMessageConstantSegmentInlineFragment; - - export type InfraLogMessageFieldSegmentInlineFragment = { - __typename?: 'InfraLogMessageFieldSegment'; - field: string; - value: string; - }; - - export type InfraLogMessageConstantSegmentInlineFragment = { - __typename?: 'InfraLogMessageConstantSegment'; - constant: string; - }; -} -export namespace LogSummary { - export type Variables = { - sourceId?: string | null; - start: number; - end: number; - bucketSize: number; - filterQuery?: string | null; - }; - - export type Query = { - __typename?: 'Query'; - source: Source; - }; - - export type Source = { - __typename?: 'InfraSource'; - id: string; - logSummaryBetween: LogSummaryBetween; - }; - - export type LogSummaryBetween = { - __typename?: 'InfraLogSummaryInterval'; - start?: number | null; - end?: number | null; - buckets: Buckets[]; - }; - - export type Buckets = { - __typename?: 'InfraLogSummaryBucket'; - start: number; - end: number; - entriesCount: number; - }; -} - -export namespace InfraTimeKeyFields { - export type Fragment = { - __typename?: 'InfraTimeKey'; - time: number; - tiebreaker: number; - }; -} diff --git a/x-pack/plugins/infra/public/components/metrics/index.tsx b/x-pack/plugins/infra/public/components/metrics/index.tsx index dc12a289deafb..8a0bdb8e84437 100644 --- a/x-pack/plugins/infra/public/components/metrics/index.tsx +++ b/x-pack/plugins/infra/public/components/metrics/index.tsx @@ -8,7 +8,7 @@ import { EuiPageContentBody, EuiTitle } from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React from 'react'; -import { InfraMetricData } from '../../../common/graphql/types'; +import { InfraMetricData } from '../../graphql/types'; import { InfraMetricLayout, InfraMetricLayoutSection } from '../../pages/metrics/layouts/types'; import { metricTimeActions } from '../../store'; import { InfraLoadingPanel } from '../loading'; diff --git a/x-pack/plugins/infra/public/components/metrics/section.tsx b/x-pack/plugins/infra/public/components/metrics/section.tsx index 89170d053b3a9..4d0b9cab69557 100644 --- a/x-pack/plugins/infra/public/components/metrics/section.tsx +++ b/x-pack/plugins/infra/public/components/metrics/section.tsx @@ -5,7 +5,7 @@ */ import React from 'react'; -import { InfraMetricData } from '../../../common/graphql/types'; +import { InfraMetricData } from '../../graphql/types'; import { InfraMetricLayoutSection } from '../../pages/metrics/layouts/types'; import { metricTimeActions } from '../../store'; import { sections } from './sections'; diff --git a/x-pack/plugins/infra/public/components/metrics/sections/chart_section.tsx b/x-pack/plugins/infra/public/components/metrics/sections/chart_section.tsx index 15f39f61ed86c..a98f77588f10b 100644 --- a/x-pack/plugins/infra/public/components/metrics/sections/chart_section.tsx +++ b/x-pack/plugins/infra/public/components/metrics/sections/chart_section.tsx @@ -21,7 +21,7 @@ import Color from 'color'; import { get } from 'lodash'; import moment from 'moment'; import React, { ReactText } from 'react'; -import { InfraDataSeries, InfraMetricData } from '../../../../common/graphql/types'; +import { InfraDataSeries, InfraMetricData } from '../../../graphql/types'; import { InfraFormatter, InfraFormatterType } from '../../../lib/lib'; import { InfraMetricLayoutSection, diff --git a/x-pack/plugins/infra/public/components/metrics/sections/gauges_section.tsx b/x-pack/plugins/infra/public/components/metrics/sections/gauges_section.tsx index af58fe80230d4..0f3bf13f198cc 100644 --- a/x-pack/plugins/infra/public/components/metrics/sections/gauges_section.tsx +++ b/x-pack/plugins/infra/public/components/metrics/sections/gauges_section.tsx @@ -16,7 +16,7 @@ import { import { get, last, max } from 'lodash'; import React, { ReactText } from 'react'; import styled from 'styled-components'; -import { InfraMetricData } from '../../../../common/graphql/types'; +import { InfraMetricData } from '../../../graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; import { InfraMetricLayoutSection } from '../../../pages/metrics/layouts/types'; import { createFormatter } from '../../../utils/formatters'; diff --git a/x-pack/plugins/infra/public/components/waffle/group_name.tsx b/x-pack/plugins/infra/public/components/waffle/group_name.tsx index 5e4cd29a65f48..22c58b3a7dc92 100644 --- a/x-pack/plugins/infra/public/components/waffle/group_name.tsx +++ b/x-pack/plugins/infra/public/components/waffle/group_name.tsx @@ -6,7 +6,7 @@ import { EuiLink, EuiToolTip } from '@elastic/eui'; import React from 'react'; import styled from 'styled-components'; -import { InfraPathType } from '../../../common/graphql/types'; +import { InfraPathType } from '../../graphql/types'; import { InfraWaffleMapGroup, InfraWaffleMapOptions } from '../../lib/lib'; interface Props { @@ -62,7 +62,7 @@ const GroupNameContainer = styled.div` position: relative; text-align: center font-size: 16px; - margin-bottom: 5px; + margin-bottom: 5px; top: 20px; display: flex; justify-content: center; diff --git a/x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx b/x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx index a835bd4355168..7005c1d8f03b9 100644 --- a/x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx +++ b/x-pack/plugins/infra/public/components/waffle/group_of_groups.tsx @@ -6,7 +6,7 @@ import React from 'react'; import styled from 'styled-components'; -import { InfraNodeType, InfraTimerangeInput } from '../../../common/graphql/types'; +import { InfraNodeType, InfraTimerangeInput } from '../../graphql/types'; import { InfraWaffleMapBounds, InfraWaffleMapGroupOfGroups, diff --git a/x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx b/x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx index 613c958c76836..f81203dfab4da 100644 --- a/x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx +++ b/x-pack/plugins/infra/public/components/waffle/group_of_nodes.tsx @@ -6,7 +6,7 @@ import React from 'react'; import styled from 'styled-components'; -import { InfraNodeType, InfraTimerangeInput } from '../../../common/graphql/types'; +import { InfraNodeType, InfraTimerangeInput } from '../../graphql/types'; import { InfraWaffleMapBounds, InfraWaffleMapGroupOfNodes, diff --git a/x-pack/plugins/infra/public/components/waffle/index.tsx b/x-pack/plugins/infra/public/components/waffle/index.tsx index 80e409dcfa032..37decfa498e28 100644 --- a/x-pack/plugins/infra/public/components/waffle/index.tsx +++ b/x-pack/plugins/infra/public/components/waffle/index.tsx @@ -8,11 +8,12 @@ import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import { get, max, min } from 'lodash'; import React from 'react'; import styled from 'styled-components'; -import { InfraMetricType, InfraNodeType, InfraTimerangeInput } from '../../../common/graphql/types'; + import { isWaffleMapGroupWithGroups, isWaffleMapGroupWithNodes, } from '../../containers/waffle/type_guards'; +import { InfraMetricType, InfraNodeType, InfraTimerangeInput } from '../../graphql/types'; import { InfraFormatterType, InfraWaffleData, diff --git a/x-pack/plugins/infra/public/components/waffle/node.tsx b/x-pack/plugins/infra/public/components/waffle/node.tsx index b4129565bf958..0aec476c418e1 100644 --- a/x-pack/plugins/infra/public/components/waffle/node.tsx +++ b/x-pack/plugins/infra/public/components/waffle/node.tsx @@ -8,8 +8,9 @@ import { EuiToolTip } from '@elastic/eui'; import { darken, readableColor } from 'polished'; import React from 'react'; import styled from 'styled-components'; -import { InfraTimerangeInput } from 'x-pack/plugins/infra/common/graphql/types'; + import { InfraNodeType } from '../../../server/lib/adapters/nodes'; +import { InfraTimerangeInput } from '../../graphql/types'; import { InfraWaffleMapBounds, InfraWaffleMapNode, InfraWaffleMapOptions } from '../../lib/lib'; import { colorFromValue } from './lib/color_from_value'; import { NodeContextMenu } from './node_context_menu'; diff --git a/x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx b/x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx index 3f25f1708e8f7..f34dd96f2f51e 100644 --- a/x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx +++ b/x-pack/plugins/infra/public/components/waffle/node_context_menu.tsx @@ -8,7 +8,7 @@ import { EuiContextMenu, EuiContextMenuPanelDescriptor, EuiPopover } from '@elas import { InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React from 'react'; -import { InfraNodeType, InfraTimerangeInput } from '../../../common/graphql/types'; +import { InfraNodeType, InfraTimerangeInput } from '../../graphql/types'; import { InfraWaffleMapNode, InfraWaffleMapOptions } from '../../lib/lib'; import { getNodeDetailUrl, getNodeLogsUrl } from '../../pages/link_to'; diff --git a/x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx b/x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx index 403d7503a8dc1..e492e153c67a0 100644 --- a/x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx +++ b/x-pack/plugins/infra/public/components/waffle/waffle_group_by_controls.tsx @@ -14,7 +14,7 @@ import { } from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React from 'react'; -import { InfraNodeType, InfraPathInput, InfraPathType } from '../../../common/graphql/types'; +import { InfraNodeType, InfraPathInput, InfraPathType } from '../../graphql/types'; interface Props { nodeType: InfraNodeType; diff --git a/x-pack/plugins/infra/public/components/waffle/waffle_metric_controls.tsx b/x-pack/plugins/infra/public/components/waffle/waffle_metric_controls.tsx index dcf5fdaef7d77..5879254a8c500 100644 --- a/x-pack/plugins/infra/public/components/waffle/waffle_metric_controls.tsx +++ b/x-pack/plugins/infra/public/components/waffle/waffle_metric_controls.tsx @@ -13,7 +13,9 @@ import { } from '@elastic/eui'; import { FormattedMessage, InjectedIntl, injectI18n } from '@kbn/i18n/react'; import React from 'react'; -import { InfraMetricInput, InfraMetricType, InfraNodeType } from '../../../common/graphql/types'; + +import { InfraMetricInput, InfraMetricType, InfraNodeType } from '../../graphql/types'; + interface Props { nodeType: InfraNodeType; metric: InfraMetricInput; diff --git a/x-pack/plugins/infra/public/components/waffle/waffle_node_type_switcher.tsx b/x-pack/plugins/infra/public/components/waffle/waffle_node_type_switcher.tsx index 5b6dfe0613855..bc59ac3288325 100644 --- a/x-pack/plugins/infra/public/components/waffle/waffle_node_type_switcher.tsx +++ b/x-pack/plugins/infra/public/components/waffle/waffle_node_type_switcher.tsx @@ -12,7 +12,7 @@ import { InfraMetricType, InfraNodeType, InfraPathInput, -} from '../../../common/graphql/types'; +} from '../../graphql/types'; interface Props { nodeType: InfraNodeType; diff --git a/x-pack/plugins/infra/public/containers/host/index.ts b/x-pack/plugins/infra/public/containers/host/index.ts deleted file mode 100644 index 706f05c80ed0d..0000000000000 --- a/x-pack/plugins/infra/public/containers/host/index.ts +++ /dev/null @@ -1,12 +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. - */ - -import { AllHosts } from './with_all_hosts'; -export { withAllHosts } from './with_all_hosts'; - -export const hostQueries = { - AllHosts, -}; diff --git a/x-pack/plugins/infra/public/containers/host/with_all_hosts.ts b/x-pack/plugins/infra/public/containers/host/with_all_hosts.ts deleted file mode 100644 index de4a7fb22b7bb..0000000000000 --- a/x-pack/plugins/infra/public/containers/host/with_all_hosts.ts +++ /dev/null @@ -1,30 +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. - */ - -// import { graphql } from 'react-apollo'; -// import gql from 'graphql-tag'; -// import { GetAllHosts } from '../../../common/graphql/types'; - -// type ChildProps = { -// hosts: GetAllHosts.Query['hosts']; -// }; - -export const AllHosts = null; - -export const withAllHosts: any = (wrappedComponent: any) => wrappedComponent; -// export const withAllHosts = graphql< -// {}, -// GetAllHosts.Query, -// GetAllHosts.Variables, -// ChildProps -// >(AllHosts, { -// props: ({ data, ownProps }) => { -// return { -// hosts: data && data.hosts ? data.hosts : [], -// ...ownProps, -// }; -// }, -// }); diff --git a/x-pack/plugins/infra/public/containers/metadata/with_metadata.tsx b/x-pack/plugins/infra/public/containers/metadata/with_metadata.tsx index df8f25c408792..d38624b242aef 100644 --- a/x-pack/plugins/infra/public/containers/metadata/with_metadata.tsx +++ b/x-pack/plugins/infra/public/containers/metadata/with_metadata.tsx @@ -5,10 +5,10 @@ */ import _ from 'lodash'; - import React from 'react'; import { Query } from 'react-apollo'; -import { InfraNodeType, MetadataQuery } from '../../../common/graphql/types'; + +import { InfraNodeType, MetadataQuery } from '../../graphql/types'; import { InfraMetricLayout } from '../../pages/metrics/layouts/types'; import { metadataQuery } from './metadata.gql_query'; diff --git a/x-pack/plugins/infra/public/containers/metrics/with_metrics.tsx b/x-pack/plugins/infra/public/containers/metrics/with_metrics.tsx index 9f44a24f4893c..52e8c6243cde8 100644 --- a/x-pack/plugins/infra/public/containers/metrics/with_metrics.tsx +++ b/x-pack/plugins/infra/public/containers/metrics/with_metrics.tsx @@ -12,7 +12,7 @@ import { InfraNodeType, InfraTimerangeInput, MetricsQuery, -} from '../../../common/graphql/types'; +} from '../../graphql/types'; import { InfraMetricLayout } from '../../pages/metrics/layouts/types'; import { metricsQuery } from './metrics.gql_query'; diff --git a/x-pack/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts b/x-pack/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts index 9da51d541a9c9..4b924afe27ac2 100644 --- a/x-pack/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts +++ b/x-pack/plugins/infra/public/containers/waffle/nodes_to_wafflemap.ts @@ -6,7 +6,8 @@ import { i18n } from '@kbn/i18n'; import { first, last } from 'lodash'; -import { InfraNode, InfraNodePath } from '../../../common/graphql/types'; + +import { InfraNode, InfraNodePath } from '../../graphql/types'; import { InfraWaffleMapGroup, InfraWaffleMapGroupOfGroups, diff --git a/x-pack/plugins/infra/public/containers/waffle/with_waffle_nodes.tsx b/x-pack/plugins/infra/public/containers/waffle/with_waffle_nodes.tsx index f8a5a7a607917..2f8a18ca45ab7 100644 --- a/x-pack/plugins/infra/public/containers/waffle/with_waffle_nodes.tsx +++ b/x-pack/plugins/infra/public/containers/waffle/with_waffle_nodes.tsx @@ -9,12 +9,12 @@ import { Query } from 'react-apollo'; import { InfraMetricInput, + InfraNodeType, InfraPathInput, InfraPathType, InfraTimerangeInput, WaffleNodesQuery, -} from '../../../common/graphql/types'; -import { InfraNodeType } from '../../../server/lib/adapters/nodes'; +} from '../../graphql/types'; import { InfraWaffleMapGroup } from '../../lib/lib'; import { nodesToWaffleMap } from './nodes_to_wafflemap'; import { waffleNodesQuery } from './waffle_nodes.gql_query'; diff --git a/x-pack/plugins/infra/public/containers/waffle/with_waffle_options.tsx b/x-pack/plugins/infra/public/containers/waffle/with_waffle_options.tsx index 0136ac6cf5fee..b03f1e003fc4b 100644 --- a/x-pack/plugins/infra/public/containers/waffle/with_waffle_options.tsx +++ b/x-pack/plugins/infra/public/containers/waffle/with_waffle_options.tsx @@ -7,8 +7,13 @@ import React from 'react'; import { connect } from 'react-redux'; import { createSelector } from 'reselect'; -import { InfraMetricInput, InfraMetricType, InfraPathType } from '../../../common/graphql/types'; -import { InfraNodeType } from '../../../server/lib/adapters/nodes'; + +import { + InfraMetricInput, + InfraMetricType, + InfraNodeType, + InfraPathType, +} from '../../graphql/types'; import { State, waffleOptionsActions, waffleOptionsSelectors } from '../../store'; import { asChildFunctionRenderer } from '../../utils/typed_react'; import { bindPlainActionCreators } from '../../utils/typed_redux'; diff --git a/x-pack/plugins/infra/public/containers/with_options.tsx b/x-pack/plugins/infra/public/containers/with_options.tsx index 0e92a6ef43edb..0dc9662348987 100644 --- a/x-pack/plugins/infra/public/containers/with_options.tsx +++ b/x-pack/plugins/infra/public/containers/with_options.tsx @@ -7,7 +7,7 @@ import moment from 'moment'; import React from 'react'; -import { InfraMetricType, InfraPathType } from '../../common/graphql/types'; +import { InfraMetricType, InfraPathType } from '../graphql/types'; import { InfraFormatterType, InfraOptions, diff --git a/x-pack/plugins/infra/public/containers/with_source/with_source.tsx b/x-pack/plugins/infra/public/containers/with_source/with_source.tsx index 37fd19dbcda16..bcd14f5c0bfa3 100644 --- a/x-pack/plugins/infra/public/containers/with_source/with_source.tsx +++ b/x-pack/plugins/infra/public/containers/with_source/with_source.tsx @@ -13,7 +13,7 @@ import { oc } from 'ts-optchain'; import { StaticIndexPattern } from 'ui/index_patterns'; import { memoizeLast } from 'ui/utils/memoize'; -import { SourceQuery } from '../../../common/graphql/types'; +import { SourceQuery } from '../../graphql/types'; import { createStatusActions, createStatusSelectors, diff --git a/x-pack/plugins/infra/common/graphql/introspection.json b/x-pack/plugins/infra/public/graphql/introspection.json similarity index 92% rename from x-pack/plugins/infra/common/graphql/introspection.json rename to x-pack/plugins/infra/public/graphql/introspection.json index e0a54aa142c60..7cb84b92bab92 100644 --- a/x-pack/plugins/infra/common/graphql/introspection.json +++ b/x-pack/plugins/infra/public/graphql/introspection.json @@ -61,8 +61,7 @@ { "kind": "SCALAR", "name": "ID", - "description": - "The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.", + "description": "The `ID` scalar type represents a unique identifier, often used to refetch an object or as key for a cache. The ID type appears in a JSON response as a String; however, it is not intended to be human-readable. When expected as an input type, any string (such as `\"4\"`) or integer (such as `4`) input value will be accepted as an ID.", "fields": null, "inputFields": null, "interfaces": null, @@ -245,8 +244,7 @@ "args": [ { "name": "start", - "description": - "The millisecond timestamp that corresponds to the start of the interval", + "description": "The millisecond timestamp that corresponds to the start of the interval", "type": { "kind": "NON_NULL", "name": null, @@ -256,8 +254,7 @@ }, { "name": "end", - "description": - "The millisecond timestamp that corresponds to the end of the interval", + "description": "The millisecond timestamp that corresponds to the end of the interval", "type": { "kind": "NON_NULL", "name": null, @@ -448,8 +445,7 @@ { "kind": "SCALAR", "name": "String", - "description": - "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", + "description": "The `String` scalar type represents textual data, represented as UTF-8 character sequences. The String type is most often used by GraphQL to represent free-form human-readable text.", "fields": null, "inputFields": null, "interfaces": null, @@ -487,8 +483,7 @@ }, { "name": "message", - "description": - "The fields that may contain the log event message. The first field found win.", + "description": "The fields that may contain the log event message. The first field found win.", "args": [], "type": { "kind": "NON_NULL", @@ -520,8 +515,7 @@ }, { "name": "tiebreaker", - "description": - "The field to use as a tiebreaker for log events that have identical timestamps", + "description": "The field to use as a tiebreaker for log events that have identical timestamps", "args": [], "type": { "kind": "NON_NULL", @@ -580,8 +574,7 @@ }, { "name": "metricIndicesExist", - "description": - "Whether the configured alias or wildcard pattern resolve to any metric indices", + "description": "Whether the configured alias or wildcard pattern resolve to any metric indices", "args": [], "type": { "kind": "NON_NULL", @@ -593,8 +586,7 @@ }, { "name": "logIndicesExist", - "description": - "Whether the configured alias or wildcard pattern resolve to any log indices", + "description": "Whether the configured alias or wildcard pattern resolve to any log indices", "args": [], "type": { "kind": "NON_NULL", @@ -848,8 +840,7 @@ { "kind": "SCALAR", "name": "Float", - "description": - "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ", + "description": "The `Float` scalar type represents signed double-precision fractional values as specified by [IEEE 754](http://en.wikipedia.org/wiki/IEEE_floating_point). ", "fields": null, "inputFields": null, "interfaces": null, @@ -859,8 +850,7 @@ { "kind": "SCALAR", "name": "Int", - "description": - "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ", + "description": "The `Int` scalar type represents non-fractional signed whole numeric values. Int can represent values between -(2^31) and 2^31 - 1. ", "fields": null, "inputFields": null, "interfaces": null, @@ -874,8 +864,7 @@ "fields": [ { "name": "start", - "description": - "The key corresponding to the start of the interval covered by the entries", + "description": "The key corresponding to the start of the interval covered by the entries", "args": [], "type": { "kind": "OBJECT", "name": "InfraTimeKey", "ofType": null }, "isDeprecated": false, @@ -883,8 +872,7 @@ }, { "name": "end", - "description": - "The key corresponding to the end of the interval covered by the entries", + "description": "The key corresponding to the end of the interval covered by the entries", "args": [], "type": { "kind": "OBJECT", "name": "InfraTimeKey", "ofType": null }, "isDeprecated": false, @@ -998,8 +986,7 @@ "fields": [ { "name": "key", - "description": - "A unique representation of the log entry's position in the event stream", + "description": "A unique representation of the log entry's position in the event stream", "args": [], "type": { "kind": "NON_NULL", @@ -1157,8 +1144,7 @@ "fields": [ { "name": "start", - "description": - "The millisecond timestamp corresponding to the start of the interval covered by the summary", + "description": "The millisecond timestamp corresponding to the start of the interval covered by the summary", "args": [], "type": { "kind": "SCALAR", "name": "Float", "ofType": null }, "isDeprecated": false, @@ -1166,8 +1152,7 @@ }, { "name": "end", - "description": - "The millisecond timestamp corresponding to the end of the interval covered by the summary", + "description": "The millisecond timestamp corresponding to the end of the interval covered by the summary", "args": [], "type": { "kind": "SCALAR", "name": "Float", "ofType": null }, "isDeprecated": false, @@ -1262,8 +1247,7 @@ "inputFields": [ { "name": "interval", - "description": - "The interval string to use for last bucket. The format is '{value}{unit}'. For example '5m' would return the metrics for the last 5 minutes of the timespan.", + "description": "The interval string to use for last bucket. The format is '{value}{unit}'. For example '5m' would return the metrics for the last 5 minutes of the timespan.", "type": { "kind": "NON_NULL", "name": null, @@ -1374,15 +1358,13 @@ }, { "name": "label", - "description": - "The label to use in the results for the group by for the terms group by", + "description": "The label to use in the results for the group by for the terms group by", "type": { "kind": "SCALAR", "name": "String", "ofType": null }, "defaultValue": null }, { "name": "field", - "description": - "The field to group by from a terms aggregation, this is ignored by the filter type", + "description": "The field to group by from a terms aggregation, this is ignored by the filter type", "type": { "kind": "SCALAR", "name": "String", "ofType": null }, "defaultValue": null }, @@ -1439,8 +1421,7 @@ "inputFields": [ { "name": "label", - "description": - "The label for the filter, this will be used as the group name in the final results", + "description": "The label for the filter, this will be used as the group name in the final results", "type": { "kind": "NON_NULL", "name": null, @@ -1892,8 +1873,7 @@ { "kind": "OBJECT", "name": "__Schema", - "description": - "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", + "description": "A GraphQL Schema defines the capabilities of a GraphQL server. It exposes all available types and directives on the server, as well as the entry points for query, mutation, and subscription operations.", "fields": [ { "name": "types", @@ -1929,8 +1909,7 @@ }, { "name": "mutationType", - "description": - "If this server supports mutation, the type that mutation operations will be rooted at.", + "description": "If this server supports mutation, the type that mutation operations will be rooted at.", "args": [], "type": { "kind": "OBJECT", "name": "__Type", "ofType": null }, "isDeprecated": false, @@ -1938,8 +1917,7 @@ }, { "name": "subscriptionType", - "description": - "If this server support subscription, the type that subscription operations will be rooted at.", + "description": "If this server support subscription, the type that subscription operations will be rooted at.", "args": [], "type": { "kind": "OBJECT", "name": "__Type", "ofType": null }, "isDeprecated": false, @@ -1974,8 +1952,7 @@ { "kind": "OBJECT", "name": "__Type", - "description": - "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", + "description": "The fundamental unit of any GraphQL Schema is the type. There are many kinds of types in GraphQL as represented by the `__TypeKind` enum.\n\nDepending on the kind of a type, certain fields describe information about that type. Scalar types provide no information beyond a name and description, while Enum types provide their values. Object and Interface types provide the fields they describe. Abstract types, Union and Interface, provide the Object types possible at runtime. List and NonNull types compose other types.", "fields": [ { "name": "kind", @@ -2129,15 +2106,13 @@ }, { "name": "OBJECT", - "description": - "Indicates this type is an object. `fields` and `interfaces` are valid fields.", + "description": "Indicates this type is an object. `fields` and `interfaces` are valid fields.", "isDeprecated": false, "deprecationReason": null }, { "name": "INTERFACE", - "description": - "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.", + "description": "Indicates this type is an interface. `fields` and `possibleTypes` are valid fields.", "isDeprecated": false, "deprecationReason": null }, @@ -2155,8 +2130,7 @@ }, { "name": "INPUT_OBJECT", - "description": - "Indicates this type is an input object. `inputFields` is a valid field.", + "description": "Indicates this type is an input object. `inputFields` is a valid field.", "isDeprecated": false, "deprecationReason": null }, @@ -2178,8 +2152,7 @@ { "kind": "OBJECT", "name": "__Field", - "description": - "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", + "description": "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type.", "fields": [ { "name": "name", @@ -2262,8 +2235,7 @@ { "kind": "OBJECT", "name": "__InputValue", - "description": - "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", + "description": "Arguments provided to Fields or Directives and the input fields of an InputObject are represented as Input Values which describe their type and optionally a default value.", "fields": [ { "name": "name", @@ -2299,8 +2271,7 @@ }, { "name": "defaultValue", - "description": - "A GraphQL-formatted string representing the default value for this input value.", + "description": "A GraphQL-formatted string representing the default value for this input value.", "args": [], "type": { "kind": "SCALAR", "name": "String", "ofType": null }, "isDeprecated": false, @@ -2315,8 +2286,7 @@ { "kind": "OBJECT", "name": "__EnumValue", - "description": - "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", + "description": "One possible value for a given Enum. Enum values are unique values, not a placeholder for a string or numeric value. However an Enum value is returned in a JSON response as a string.", "fields": [ { "name": "name", @@ -2367,8 +2337,7 @@ { "kind": "OBJECT", "name": "__Directive", - "description": - "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", + "description": "A Directive provides a way to describe alternate runtime execution and type validation behavior in a GraphQL document.\n\nIn some cases, you need to provide options to alter GraphQL's execution behavior in ways field arguments will not suffice, such as conditionally including or skipping a field. Directives provide this by describing additional information to the executor.", "fields": [ { "name": "name", @@ -2475,8 +2444,7 @@ { "kind": "ENUM", "name": "__DirectiveLocation", - "description": - "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.", + "description": "A Directive can be adjacent to many parts of the GraphQL language, a __DirectiveLocation describes one such possible adjacencies.", "fields": null, "inputFields": null, "interfaces": null, @@ -2612,8 +2580,7 @@ "directives": [ { "name": "skip", - "description": - "Directs the executor to skip this field or fragment when the `if` argument is true.", + "description": "Directs the executor to skip this field or fragment when the `if` argument is true.", "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], "args": [ { @@ -2630,8 +2597,7 @@ }, { "name": "include", - "description": - "Directs the executor to include this field or fragment only when the `if` argument is true.", + "description": "Directs the executor to include this field or fragment only when the `if` argument is true.", "locations": ["FIELD", "FRAGMENT_SPREAD", "INLINE_FRAGMENT"], "args": [ { @@ -2653,8 +2619,7 @@ "args": [ { "name": "reason", - "description": - "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).", + "description": "Explains why this element was deprecated, usually also including a suggestion for how to access supported similar data. Formatted in [Markdown](https://daringfireball.net/projects/markdown/).", "type": { "kind": "SCALAR", "name": "String", "ofType": null }, "defaultValue": "\"No longer supported\"" } diff --git a/x-pack/plugins/infra/public/graphql/types.ts b/x-pack/plugins/infra/public/graphql/types.ts new file mode 100644 index 0000000000000..7c67f7963b743 --- /dev/null +++ b/x-pack/plugins/infra/public/graphql/types.ts @@ -0,0 +1,725 @@ +/* tslint:disable */ + +// ==================================================== +// START: Typescript template +// ==================================================== + +// ==================================================== +// Types +// ==================================================== + +export interface Query { + /** Get an infrastructure data source by id */ + source: InfraSource; + /** Get a list of all infrastructure data sources */ + allSources: InfraSource[]; +} +/** A source of infrastructure data */ +export interface InfraSource { + /** The id of the source */ + id: string; + /** The raw configuration of the source */ + configuration: InfraSourceConfiguration; + /** The status of the source */ + status: InfraSourceStatus; + /** A hierarchy of metadata entries by node */ + metadataByNode: (InfraNodeMetadata | null)[]; + /** A consecutive span of log entries surrounding a point in time */ + logEntriesAround: InfraLogEntryInterval; + /** A consecutive span of log entries within an interval */ + logEntriesBetween: InfraLogEntryInterval; + /** A consecutive span of summary buckets within an interval */ + logSummaryBetween: InfraLogSummaryInterval; + /** A hierarchy of hosts, pods, containers, services or arbitrary groups */ + map?: InfraResponse | null; + + metrics: InfraMetricData[]; +} +/** A set of configuration options for an infrastructure data source */ +export interface InfraSourceConfiguration { + /** The alias to read metric data from */ + metricAlias: string; + /** The alias to read log data from */ + logAlias: string; + /** The field mapping to use for this source */ + fields: InfraSourceFields; +} +/** A mapping of semantic fields to their document counterparts */ +export interface InfraSourceFields { + /** The field to identify a container by */ + container: string; + /** The fields to identify a host by */ + host: string; + /** The fields that may contain the log event message. The first field found win. */ + message: string[]; + /** The field to identify a pod by */ + pod: string; + /** The field to use as a tiebreaker for log events that have identical timestamps */ + tiebreaker: string; + /** The field to use as a timestamp for metrics and logs */ + timestamp: string; +} +/** The status of an infrastructure data source */ +export interface InfraSourceStatus { + /** Whether the configured metric alias exists */ + metricAliasExists: boolean; + /** Whether the configured log alias exists */ + logAliasExists: boolean; + /** Whether the configured alias or wildcard pattern resolve to any metric indices */ + metricIndicesExist: boolean; + /** Whether the configured alias or wildcard pattern resolve to any log indices */ + logIndicesExist: boolean; + /** The list of indices in the metric alias */ + metricIndices: string[]; + /** The list of indices in the log alias */ + logIndices: string[]; + /** The list of fields defined in the index mappings */ + indexFields: InfraIndexField[]; +} +/** A descriptor of a field in an index */ +export interface InfraIndexField { + /** The name of the field */ + name: string; + /** The type of the field's values as recognized by Kibana */ + type: string; + /** Whether the field's values can be efficiently searched for */ + searchable: boolean; + /** Whether the field's values can be aggregated */ + aggregatable: boolean; +} +/** One metadata entry for a node. */ +export interface InfraNodeMetadata { + name: string; + + source: string; +} +/** A consecutive sequence of log entries */ +export interface InfraLogEntryInterval { + /** The key corresponding to the start of the interval covered by the entries */ + start?: InfraTimeKey | null; + /** The key corresponding to the end of the interval covered by the entries */ + end?: InfraTimeKey | null; + /** Whether there are more log entries available before the start */ + hasMoreBefore: boolean; + /** Whether there are more log entries available after the end */ + hasMoreAfter: boolean; + /** The query the log entries were filtered by */ + filterQuery?: string | null; + /** The query the log entries were highlighted with */ + highlightQuery?: string | null; + /** A list of the log entries */ + entries: InfraLogEntry[]; +} +/** A representation of the log entry's position in the event stream */ +export interface InfraTimeKey { + /** The timestamp of the event that the log entry corresponds to */ + time: number; + /** The tiebreaker that disambiguates events with the same timestamp */ + tiebreaker: number; +} +/** A log entry */ +export interface InfraLogEntry { + /** A unique representation of the log entry's position in the event stream */ + key: InfraTimeKey; + /** The log entry's id */ + gid: string; + /** The source id */ + source: string; + /** A list of the formatted log entry segments */ + message: InfraLogMessageSegment[]; +} +/** A segment of the log entry message that was derived from a field */ +export interface InfraLogMessageFieldSegment { + /** The field the segment was derived from */ + field: string; + /** The segment's message */ + value: string; + /** A list of highlighted substrings of the value */ + highlights: string[]; +} +/** A segment of the log entry message that was derived from a field */ +export interface InfraLogMessageConstantSegment { + /** The segment's message */ + constant: string; +} +/** A consecutive sequence of log summary buckets */ +export interface InfraLogSummaryInterval { + /** The millisecond timestamp corresponding to the start of the interval covered by the summary */ + start?: number | null; + /** The millisecond timestamp corresponding to the end of the interval covered by the summary */ + end?: number | null; + /** The query the log entries were filtered by */ + filterQuery?: string | null; + /** A list of the log entries */ + buckets: InfraLogSummaryBucket[]; +} +/** A log summary bucket */ +export interface InfraLogSummaryBucket { + /** The start timestamp of the bucket */ + start: number; + /** The end timestamp of the bucket */ + end: number; + /** The number of entries inside the bucket */ + entriesCount: number; +} + +export interface InfraResponse { + nodes: InfraNode[]; +} + +export interface InfraNode { + path: InfraNodePath[]; + + metric: InfraNodeMetric; +} + +export interface InfraNodePath { + value: string; +} + +export interface InfraNodeMetric { + name: InfraMetricType; + + value: number; +} + +export interface InfraMetricData { + id?: InfraMetric | null; + + series: InfraDataSeries[]; +} + +export interface InfraDataSeries { + id: string; + + data: InfraDataPoint[]; +} + +export interface InfraDataPoint { + timestamp: number; + + value?: number | null; +} + +// ==================================================== +// InputTypes +// ==================================================== + +export interface InfraTimeKeyInput { + time: number; + + tiebreaker: number; +} + +export interface InfraTimerangeInput { + /** The interval string to use for last bucket. The format is '{value}{unit}'. For example '5m' would return the metrics for the last 5 minutes of the timespan. */ + interval: string; + /** The end of the timerange */ + to: number; + /** The beginning of the timerange */ + from: number; +} + +export interface InfraPathInput { + /** The type of path */ + type: InfraPathType; + /** The label to use in the results for the group by for the terms group by */ + label?: string | null; + /** The field to group by from a terms aggregation, this is ignored by the filter type */ + field?: string | null; + /** The fitlers for the filter group by */ + filters?: InfraPathFilterInput[] | null; +} +/** A group by filter */ +export interface InfraPathFilterInput { + /** The label for the filter, this will be used as the group name in the final results */ + label: string; + /** The query string query */ + query: string; +} + +export interface InfraMetricInput { + /** The type of metric */ + type: InfraMetricType; +} + +// ==================================================== +// Arguments +// ==================================================== + +export interface SourceQueryArgs { + /** The id of the source */ + id: string; +} +export interface MetadataByNodeInfraSourceArgs { + nodeName: string; + + nodeType: InfraNodeType; +} +export interface LogEntriesAroundInfraSourceArgs { + /** The sort key that corresponds to the point in time */ + key: InfraTimeKeyInput; + /** The maximum number of preceding to return */ + countBefore?: number | null; + /** The maximum number of following to return */ + countAfter?: number | null; + /** The query to filter the log entries by */ + filterQuery?: string | null; + /** The query to highlight the log entries with */ + highlightQuery?: string | null; +} +export interface LogEntriesBetweenInfraSourceArgs { + /** The sort key that corresponds to the start of the interval */ + startKey: InfraTimeKeyInput; + /** The sort key that corresponds to the end of the interval */ + endKey: InfraTimeKeyInput; + /** The query to filter the log entries by */ + filterQuery?: string | null; + /** The query to highlight the log entries with */ + highlightQuery?: string | null; +} +export interface LogSummaryBetweenInfraSourceArgs { + /** The millisecond timestamp that corresponds to the start of the interval */ + start: number; + /** The millisecond timestamp that corresponds to the end of the interval */ + end: number; + /** The size of each bucket in milliseconds */ + bucketSize: number; + /** The query to filter the log entries by */ + filterQuery?: string | null; +} +export interface MapInfraSourceArgs { + timerange: InfraTimerangeInput; + + filterQuery?: string | null; +} +export interface MetricsInfraSourceArgs { + nodeId: string; + + nodeType: InfraNodeType; + + timerange: InfraTimerangeInput; + + metrics: InfraMetric[]; +} +export interface IndexFieldsInfraSourceStatusArgs { + indexType?: InfraIndexType | null; +} +export interface NodesInfraResponseArgs { + path: InfraPathInput[]; + + metric: InfraMetricInput; +} + +// ==================================================== +// Enums +// ==================================================== + +export enum InfraIndexType { + ANY = 'ANY', + LOGS = 'LOGS', + METRICS = 'METRICS', +} + +export enum InfraNodeType { + pod = 'pod', + container = 'container', + host = 'host', +} + +export enum InfraPathType { + terms = 'terms', + filters = 'filters', + hosts = 'hosts', + pods = 'pods', + containers = 'containers', +} + +export enum InfraMetricType { + count = 'count', + cpu = 'cpu', + load = 'load', + memory = 'memory', + tx = 'tx', + rx = 'rx', + logRate = 'logRate', +} + +export enum InfraMetric { + hostSystemOverview = 'hostSystemOverview', + hostCpuUsage = 'hostCpuUsage', + hostFilesystem = 'hostFilesystem', + hostK8sOverview = 'hostK8sOverview', + hostK8sCpuCap = 'hostK8sCpuCap', + hostK8sDiskCap = 'hostK8sDiskCap', + hostK8sMemoryCap = 'hostK8sMemoryCap', + hostK8sPodCap = 'hostK8sPodCap', + hostLoad = 'hostLoad', + hostMemoryUsage = 'hostMemoryUsage', + hostNetworkTraffic = 'hostNetworkTraffic', + podOverview = 'podOverview', + podCpuUsage = 'podCpuUsage', + podMemoryUsage = 'podMemoryUsage', + podLogUsage = 'podLogUsage', + podNetworkTraffic = 'podNetworkTraffic', + containerOverview = 'containerOverview', + containerCpuKernel = 'containerCpuKernel', + containerCpuUsage = 'containerCpuUsage', + containerDiskIOOps = 'containerDiskIOOps', + containerDiskIOBytes = 'containerDiskIOBytes', + containerMemory = 'containerMemory', + containerNetworkTraffic = 'containerNetworkTraffic', + nginxHits = 'nginxHits', + nginxRequestRate = 'nginxRequestRate', + nginxActiveConnections = 'nginxActiveConnections', + nginxRequestsPerConnection = 'nginxRequestsPerConnection', +} + +export enum InfraOperator { + gt = 'gt', + gte = 'gte', + lt = 'lt', + lte = 'lte', + eq = 'eq', +} + +// ==================================================== +// Unions +// ==================================================== + +/** A segment of the log entry message */ +export type InfraLogMessageSegment = InfraLogMessageFieldSegment | InfraLogMessageConstantSegment; + +// ==================================================== +// END: Typescript template +// ==================================================== + +// ==================================================== +// Documents +// ==================================================== + +export namespace MetadataQuery { + export type Variables = { + sourceId: string; + nodeId: string; + nodeType: InfraNodeType; + }; + + export type Query = { + __typename?: 'Query'; + + source: Source; + }; + + export type Source = { + __typename?: 'InfraSource'; + + id: string; + + metadataByNode: (MetadataByNode | null)[]; + }; + + export type MetadataByNode = { + __typename?: 'InfraNodeMetadata'; + + name: string; + + source: string; + }; +} + +export namespace MetricsQuery { + export type Variables = { + sourceId: string; + timerange: InfraTimerangeInput; + metrics: InfraMetric[]; + nodeId: string; + nodeType: InfraNodeType; + }; + + export type Query = { + __typename?: 'Query'; + + source: Source; + }; + + export type Source = { + __typename?: 'InfraSource'; + + id: string; + + metrics: Metrics[]; + }; + + export type Metrics = { + __typename?: 'InfraMetricData'; + + id?: InfraMetric | null; + + series: Series[]; + }; + + export type Series = { + __typename?: 'InfraDataSeries'; + + id: string; + + data: Data[]; + }; + + export type Data = { + __typename?: 'InfraDataPoint'; + + timestamp: number; + + value?: number | null; + }; +} + +export namespace WaffleNodesQuery { + export type Variables = { + sourceId: string; + timerange: InfraTimerangeInput; + filterQuery?: string | null; + metric: InfraMetricInput; + path: InfraPathInput[]; + }; + + export type Query = { + __typename?: 'Query'; + + source: Source; + }; + + export type Source = { + __typename?: 'InfraSource'; + + id: string; + + map?: Map | null; + }; + + export type Map = { + __typename?: 'InfraResponse'; + + nodes: Nodes[]; + }; + + export type Nodes = { + __typename?: 'InfraNode'; + + path: Path[]; + + metric: Metric; + }; + + export type Path = { + __typename?: 'InfraNodePath'; + + value: string; + }; + + export type Metric = { + __typename?: 'InfraNodeMetric'; + + name: InfraMetricType; + + value: number; + }; +} + +export namespace SourceQuery { + export type Variables = { + sourceId?: string | null; + }; + + export type Query = { + __typename?: 'Query'; + + source: Source; + }; + + export type Source = { + __typename?: 'InfraSource'; + + id: string; + + configuration: Configuration; + + status: Status; + }; + + export type Configuration = { + __typename?: 'InfraSourceConfiguration'; + + metricAlias: string; + + logAlias: string; + + fields: Fields; + }; + + export type Fields = { + __typename?: 'InfraSourceFields'; + + container: string; + + host: string; + + pod: string; + }; + + export type Status = { + __typename?: 'InfraSourceStatus'; + + indexFields: IndexFields[]; + + logIndicesExist: boolean; + + metricIndicesExist: boolean; + }; + + export type IndexFields = { + __typename?: 'InfraIndexField'; + + name: string; + + type: string; + + searchable: boolean; + + aggregatable: boolean; + }; +} + +export namespace LogEntries { + export type Variables = { + sourceId?: string | null; + timeKey: InfraTimeKeyInput; + countBefore?: number | null; + countAfter?: number | null; + filterQuery?: string | null; + }; + + export type Query = { + __typename?: 'Query'; + + source: Source; + }; + + export type Source = { + __typename?: 'InfraSource'; + + id: string; + + logEntriesAround: LogEntriesAround; + }; + + export type LogEntriesAround = { + __typename?: 'InfraLogEntryInterval'; + + start?: Start | null; + + end?: End | null; + + hasMoreBefore: boolean; + + hasMoreAfter: boolean; + + entries: Entries[]; + }; + + export type Start = InfraTimeKeyFields.Fragment; + + export type End = InfraTimeKeyFields.Fragment; + + export type Entries = { + __typename?: 'InfraLogEntry'; + + gid: string; + + key: Key; + + message: Message[]; + }; + + export type Key = { + __typename?: 'InfraTimeKey'; + + time: number; + + tiebreaker: number; + }; + + export type Message = + | InfraLogMessageFieldSegmentInlineFragment + | InfraLogMessageConstantSegmentInlineFragment; + + export type InfraLogMessageFieldSegmentInlineFragment = { + __typename?: 'InfraLogMessageFieldSegment'; + + field: string; + + value: string; + }; + + export type InfraLogMessageConstantSegmentInlineFragment = { + __typename?: 'InfraLogMessageConstantSegment'; + + constant: string; + }; +} + +export namespace LogSummary { + export type Variables = { + sourceId?: string | null; + start: number; + end: number; + bucketSize: number; + filterQuery?: string | null; + }; + + export type Query = { + __typename?: 'Query'; + + source: Source; + }; + + export type Source = { + __typename?: 'InfraSource'; + + id: string; + + logSummaryBetween: LogSummaryBetween; + }; + + export type LogSummaryBetween = { + __typename?: 'InfraLogSummaryInterval'; + + start?: number | null; + + end?: number | null; + + buckets: Buckets[]; + }; + + export type Buckets = { + __typename?: 'InfraLogSummaryBucket'; + + start: number; + + end: number; + + entriesCount: number; + }; +} + +export namespace InfraTimeKeyFields { + export type Fragment = { + __typename?: 'InfraTimeKey'; + + time: number; + + tiebreaker: number; + }; +} diff --git a/x-pack/plugins/infra/public/lib/compose/kibana_compose.ts b/x-pack/plugins/infra/public/lib/compose/kibana_compose.ts index 3ce48d9a31b96..216d9051cf644 100644 --- a/x-pack/plugins/infra/public/lib/compose/kibana_compose.ts +++ b/x-pack/plugins/infra/public/lib/compose/kibana_compose.ts @@ -15,7 +15,7 @@ import { timezoneProvider } from 'ui/vis/lib/timezone'; import { InfraKibanaObservableApiAdapter } from '../adapters/observable_api/kibana_observable_api'; -import introspectionQueryResultData from '../../../common/graphql/introspection.json'; +import introspectionQueryResultData from '../../graphql/introspection.json'; import { InfraKibanaFrameworkAdapter } from '../adapters/framework/kibana_framework_adapter'; import { InfraFrontendLibs } from '../lib'; diff --git a/x-pack/plugins/infra/public/lib/lib.ts b/x-pack/plugins/infra/public/lib/lib.ts index 0df859fa81446..2ef59fbaeb6c6 100644 --- a/x-pack/plugins/infra/public/lib/lib.ts +++ b/x-pack/plugins/infra/public/lib/lib.ts @@ -17,7 +17,7 @@ import { InfraPathInput, InfraTimerangeInput, SourceQuery, -} from '../../common/graphql/types'; +} from '../graphql/types'; export interface InfraFrontendLibs { framework: InfraFrameworkAdapter; diff --git a/x-pack/plugins/infra/public/pages/home/toolbar.tsx b/x-pack/plugins/infra/public/pages/home/toolbar.tsx index c4b652063ce60..aa519564509cf 100644 --- a/x-pack/plugins/infra/public/pages/home/toolbar.tsx +++ b/x-pack/plugins/infra/public/pages/home/toolbar.tsx @@ -11,17 +11,16 @@ import React from 'react'; import { AutocompleteField } from '../../components/autocomplete_field'; import { Toolbar } from '../../components/eui/toolbar'; -import { WaffleTimeControls } from '../../components/waffle/waffle_time_controls'; - -import { InfraNodeType } from '../../../common/graphql/types'; import { WaffleGroupByControls } from '../../components/waffle/waffle_group_by_controls'; import { WaffleMetricControls } from '../../components/waffle/waffle_metric_controls'; import { WaffleNodeTypeSwitcher } from '../../components/waffle/waffle_node_type_switcher'; +import { WaffleTimeControls } from '../../components/waffle/waffle_time_controls'; import { WithWaffleFilter } from '../../containers/waffle/with_waffle_filters'; import { WithWaffleOptions } from '../../containers/waffle/with_waffle_options'; import { WithWaffleTime } from '../../containers/waffle/with_waffle_time'; import { WithKueryAutocompletion } from '../../containers/with_kuery_autocompletion'; import { WithSource } from '../../containers/with_source'; +import { InfraNodeType } from '../../graphql/types'; const getTitle = (nodeType: string) => { const TITLES = { diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx index 889412dfba874..bf70e06a629c8 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_detail.tsx @@ -6,8 +6,9 @@ import React from 'react'; import { Redirect, RouteComponentProps } from 'react-router-dom'; -import { InfraNodeType } from 'x-pack/plugins/infra/common/graphql/types'; + import { replaceMetricTimeInQueryString } from '../../containers/metrics/with_metrics_time'; +import { InfraNodeType } from '../../graphql/types'; import { getFromFromLocation, getToFromLocation } from './query_params'; type RedirectToNodeDetailProps = RouteComponentProps<{ diff --git a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx index dd28030076b92..5f444e3afdd3b 100644 --- a/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx +++ b/x-pack/plugins/infra/public/pages/link_to/redirect_to_node_logs.tsx @@ -9,11 +9,11 @@ import compose from 'lodash/fp/compose'; import React from 'react'; import { Redirect, RouteComponentProps } from 'react-router-dom'; -import { InfraNodeType } from 'x-pack/plugins/infra/common/graphql/types'; import { LoadingPage } from '../../components/loading_page'; import { replaceLogFilterInQueryString } from '../../containers/logs/with_log_filter'; import { replaceLogPositionInQueryString } from '../../containers/logs/with_log_position'; import { WithSource } from '../../containers/with_source'; +import { InfraNodeType } from '../../graphql/types'; import { getTimeFromLocation } from './query_params'; type RedirectToNodeLogsType = RouteComponentProps<{ diff --git a/x-pack/plugins/infra/public/pages/metrics/index.tsx b/x-pack/plugins/infra/public/pages/metrics/index.tsx index dd4db0f2a4c29..bcc7b89754ace 100644 --- a/x-pack/plugins/infra/public/pages/metrics/index.tsx +++ b/x-pack/plugins/infra/public/pages/metrics/index.tsx @@ -3,7 +3,6 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import React from 'react'; import { EuiHideFor, @@ -18,8 +17,9 @@ import { EuiTitle, } from '@elastic/eui'; import { InjectedIntl, injectI18n } from '@kbn/i18n/react'; +import React from 'react'; import styled, { withTheme } from 'styled-components'; -import { InfraNodeType, InfraTimerangeInput } from '../../../common/graphql/types'; + import { AutoSizer } from '../../components/auto_sizer'; import { InfrastructureBetaBadgeHeaderSection } from '../../components/beta_badge_header_section'; import { Header } from '../../components/header'; @@ -33,6 +33,7 @@ import { WithMetricsTimeUrlState, } from '../../containers/metrics/with_metrics_time'; import { WithOptions } from '../../containers/with_options'; +import { InfraNodeType, InfraTimerangeInput } from '../../graphql/types'; import { Error, ErrorPageBody } from '../error'; import { layoutCreators } from './layouts'; import { InfraMetricLayoutSection } from './layouts/types'; diff --git a/x-pack/plugins/infra/public/pages/metrics/layouts/container.ts b/x-pack/plugins/infra/public/pages/metrics/layouts/container.ts index c9b85021c108e..5c6d13f80643a 100644 --- a/x-pack/plugins/infra/public/pages/metrics/layouts/container.ts +++ b/x-pack/plugins/infra/public/pages/metrics/layouts/container.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { InfraMetric } from '../../../../common/graphql/types'; +import { InfraMetric } from '../../../graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; import { nginxLayoutCreator } from './nginx'; import { diff --git a/x-pack/plugins/infra/public/pages/metrics/layouts/host.ts b/x-pack/plugins/infra/public/pages/metrics/layouts/host.ts index 663d5f89802d8..73556a8a1b236 100644 --- a/x-pack/plugins/infra/public/pages/metrics/layouts/host.ts +++ b/x-pack/plugins/infra/public/pages/metrics/layouts/host.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { InfraMetric } from '../../../../common/graphql/types'; +import { InfraMetric } from '../../../graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; import { nginxLayoutCreator } from './nginx'; import { diff --git a/x-pack/plugins/infra/public/pages/metrics/layouts/nginx.ts b/x-pack/plugins/infra/public/pages/metrics/layouts/nginx.ts index cee9f2ea43ab7..a2b95ffa1a6bd 100644 --- a/x-pack/plugins/infra/public/pages/metrics/layouts/nginx.ts +++ b/x-pack/plugins/infra/public/pages/metrics/layouts/nginx.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { InfraMetric } from '../../../../common/graphql/types'; +import { InfraMetric } from '../../../graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; import { InfraMetricLayoutCreator, diff --git a/x-pack/plugins/infra/public/pages/metrics/layouts/pod.ts b/x-pack/plugins/infra/public/pages/metrics/layouts/pod.ts index 612ccc8c79a6b..fab30141e5090 100644 --- a/x-pack/plugins/infra/public/pages/metrics/layouts/pod.ts +++ b/x-pack/plugins/infra/public/pages/metrics/layouts/pod.ts @@ -5,7 +5,7 @@ */ import { i18n } from '@kbn/i18n'; -import { InfraMetric } from '../../../../common/graphql/types'; +import { InfraMetric } from '../../../graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; import { nginxLayoutCreator } from './nginx'; import { diff --git a/x-pack/plugins/infra/public/pages/metrics/layouts/types.ts b/x-pack/plugins/infra/public/pages/metrics/layouts/types.ts index d45e505a7d788..370fbbff67951 100644 --- a/x-pack/plugins/infra/public/pages/metrics/layouts/types.ts +++ b/x-pack/plugins/infra/public/pages/metrics/layouts/types.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraMetric } from '../../../../common/graphql/types'; +import { InfraMetric } from '../../../graphql/types'; import { InfraFormatterType } from '../../../lib/lib'; export enum InfraMetricLayoutVisualizationType { diff --git a/x-pack/plugins/infra/public/store/local/waffle_options/actions.ts b/x-pack/plugins/infra/public/store/local/waffle_options/actions.ts index 04c0a1d112306..229b915db07db 100644 --- a/x-pack/plugins/infra/public/store/local/waffle_options/actions.ts +++ b/x-pack/plugins/infra/public/store/local/waffle_options/actions.ts @@ -5,8 +5,8 @@ */ import actionCreatorFactory from 'typescript-fsa'; -import { InfraMetricInput, InfraPathInput } from '../../../../common/graphql/types'; -import { InfraNodeType } from '../../../../server/lib/adapters/nodes'; + +import { InfraMetricInput, InfraNodeType, InfraPathInput } from '../../../graphql/types'; const actionCreator = actionCreatorFactory('x-pack/infra/local/waffle_options'); diff --git a/x-pack/plugins/infra/public/store/local/waffle_options/reducer.ts b/x-pack/plugins/infra/public/store/local/waffle_options/reducer.ts index c736aa47de39c..f474462245f4d 100644 --- a/x-pack/plugins/infra/public/store/local/waffle_options/reducer.ts +++ b/x-pack/plugins/infra/public/store/local/waffle_options/reducer.ts @@ -10,9 +10,9 @@ import { reducerWithInitialState } from 'typescript-fsa-reducers'; import { InfraMetricInput, InfraMetricType, + InfraNodeType, InfraPathInput, -} from '../../../../common/graphql/types'; -import { InfraNodeType } from '../../../../server/lib/adapters/nodes'; +} from '../../../graphql/types'; import { changeGroupBy, changeMetric, changeNodeType } from './actions'; export interface WaffleOptionsState { diff --git a/x-pack/plugins/infra/public/store/remote/log_entries/operations/load.ts b/x-pack/plugins/infra/public/store/remote/log_entries/operations/load.ts index 5a92afd89024c..058d7c286d6a5 100644 --- a/x-pack/plugins/infra/public/store/remote/log_entries/operations/load.ts +++ b/x-pack/plugins/infra/public/store/remote/log_entries/operations/load.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LogEntries as LogEntriesQuery } from '../../../../../common/graphql/types'; +import { LogEntries as LogEntriesQuery } from '../../../../graphql/types'; import { createGraphqlOperationActionCreators, createGraphqlOperationReducer, diff --git a/x-pack/plugins/infra/public/store/remote/log_entries/operations/load_more.ts b/x-pack/plugins/infra/public/store/remote/log_entries/operations/load_more.ts index 0f58f38e52b11..7651b039083cf 100644 --- a/x-pack/plugins/infra/public/store/remote/log_entries/operations/load_more.ts +++ b/x-pack/plugins/infra/public/store/remote/log_entries/operations/load_more.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LogEntries as LogEntriesQuery } from '../../../../../common/graphql/types'; +import { LogEntries as LogEntriesQuery } from '../../../../graphql/types'; import { getLogEntryIndexAfterTime, getLogEntryIndexBeforeTime, diff --git a/x-pack/plugins/infra/public/store/remote/log_entries/state.ts b/x-pack/plugins/infra/public/store/remote/log_entries/state.ts index 6f8675b1efa83..8dbccf6c2bdd3 100644 --- a/x-pack/plugins/infra/public/store/remote/log_entries/state.ts +++ b/x-pack/plugins/infra/public/store/remote/log_entries/state.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LogEntries as LogEntriesQuery } from '../../../../common/graphql/types'; +import { LogEntries as LogEntriesQuery } from '../../../graphql/types'; import { createGraphqlInitialState, GraphqlState, diff --git a/x-pack/plugins/infra/public/store/remote/log_summary/operations/load.ts b/x-pack/plugins/infra/public/store/remote/log_summary/operations/load.ts index be3303586a568..65b2f5b426a5c 100644 --- a/x-pack/plugins/infra/public/store/remote/log_summary/operations/load.ts +++ b/x-pack/plugins/infra/public/store/remote/log_summary/operations/load.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LogSummary as LogSummaryQuery } from '../../../../../common/graphql/types'; +import { LogSummary as LogSummaryQuery } from '../../../../graphql/types'; import { createGraphqlOperationActionCreators, createGraphqlOperationReducer, diff --git a/x-pack/plugins/infra/public/store/remote/log_summary/state.ts b/x-pack/plugins/infra/public/store/remote/log_summary/state.ts index d6c10e0a2f2b1..5e4bacc6212c6 100644 --- a/x-pack/plugins/infra/public/store/remote/log_summary/state.ts +++ b/x-pack/plugins/infra/public/store/remote/log_summary/state.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { LogSummary as LogSummaryQuery } from '../../../../common/graphql/types'; +import { LogSummary as LogSummaryQuery } from '../../../graphql/types'; import { createGraphqlInitialState, GraphqlState, diff --git a/x-pack/plugins/infra/public/utils/log_entry/log_entry.ts b/x-pack/plugins/infra/public/utils/log_entry/log_entry.ts index d4eac795612b4..f2f5dfda00695 100644 --- a/x-pack/plugins/infra/public/utils/log_entry/log_entry.ts +++ b/x-pack/plugins/infra/public/utils/log_entry/log_entry.ts @@ -6,8 +6,8 @@ import { bisector } from 'd3-array'; -import { LogEntries as LogEntriesQuery } from '../../../common/graphql/types'; import { compareToTimeKey, getIndexAtTimeKey, TimeKey } from '../../../common/time'; +import { LogEntries as LogEntriesQuery } from '../../graphql/types'; export type LogEntry = LogEntriesQuery.Entries; diff --git a/x-pack/plugins/infra/scripts/generate_types_from_graphql.js b/x-pack/plugins/infra/scripts/generate_types_from_graphql.js index f36979c159376..2d9a65496c1c6 100644 --- a/x-pack/plugins/infra/scripts/generate_types_from_graphql.js +++ b/x-pack/plugins/infra/scripts/generate_types_from_graphql.js @@ -13,16 +13,18 @@ const GRAPHQL_GLOBS = [ join('public', 'store', '**', '*.gql_query.ts{,x}'), join('common', 'graphql', '**', '*.gql_query.ts{,x}'), ]; -const CONFIG_PATH = resolve(__dirname, 'gql_gen.json'); -const OUTPUT_INTROSPECTION_PATH = resolve('common', 'graphql', 'introspection.json'); -const OUTPUT_TYPES_PATH = resolve('common', 'graphql', 'types.ts'); +const CLIENT_CONFIG_PATH = resolve(__dirname, 'gql_gen_client.json'); +const SERVER_CONFIG_PATH = resolve(__dirname, 'gql_gen_server.json'); +const OUTPUT_INTROSPECTION_PATH = resolve('public', 'graphql', 'introspection.json'); +const OUTPUT_CLIENT_TYPES_PATH = resolve('public', 'graphql', 'types.ts'); +const OUTPUT_SERVER_TYPES_PATH = resolve('server', 'graphql', 'types.ts'); const SCHEMA_PATH = resolve(__dirname, 'combined_schema.ts'); async function main() { await generate( { args: GRAPHQL_GLOBS, - config: CONFIG_PATH, + config: SERVER_CONFIG_PATH, out: OUTPUT_INTROSPECTION_PATH, overwrite: true, require: ['ts-node/register'], @@ -34,14 +36,25 @@ async function main() { await generate( { args: GRAPHQL_GLOBS, - config: CONFIG_PATH, - out: OUTPUT_TYPES_PATH, + config: CLIENT_CONFIG_PATH, + out: OUTPUT_CLIENT_TYPES_PATH, overwrite: true, schema: SCHEMA_PATH, template: 'graphql-codegen-typescript-template', }, true ); + await generate( + { + args: [], + config: SERVER_CONFIG_PATH, + out: OUTPUT_SERVER_TYPES_PATH, + overwrite: true, + schema: SCHEMA_PATH, + template: 'graphql-codegen-typescript-resolvers-template', + }, + true + ); } if (require.main === module) { diff --git a/x-pack/plugins/infra/scripts/gql_gen.json b/x-pack/plugins/infra/scripts/gql_gen_client.json similarity index 100% rename from x-pack/plugins/infra/scripts/gql_gen.json rename to x-pack/plugins/infra/scripts/gql_gen_client.json diff --git a/x-pack/plugins/infra/scripts/gql_gen_server.json b/x-pack/plugins/infra/scripts/gql_gen_server.json new file mode 100644 index 0000000000000..f8f916897c2d4 --- /dev/null +++ b/x-pack/plugins/infra/scripts/gql_gen_server.json @@ -0,0 +1,14 @@ +{ + "flattenTypes": true, + "generatorConfig": { + "contextType": "InfraContext", + "prepend": ["import { InfraContext } from '../lib/infra_types';"] + }, + "primitives": { + "String": "string", + "Int": "number", + "Float": "number", + "Boolean": "boolean", + "ID": "string" + } +} diff --git a/x-pack/plugins/infra/server/graphql/log_entries/resolvers.ts b/x-pack/plugins/infra/server/graphql/log_entries/resolvers.ts index 3a16ff0c341db..8a0dd691f9978 100644 --- a/x-pack/plugins/infra/server/graphql/log_entries/resolvers.ts +++ b/x-pack/plugins/infra/server/graphql/log_entries/resolvers.ts @@ -9,30 +9,26 @@ import { InfraLogMessageFieldSegment, InfraLogMessageSegment, InfraSourceResolvers, -} from '../../../common/graphql/types'; -import { InfraResolvedResult, InfraResolverOf } from '../../lib/adapters/framework'; +} from '../../graphql/types'; import { InfraLogEntriesDomain } from '../../lib/domains/log_entries_domain'; -import { InfraContext } from '../../lib/infra_types'; import { UsageCollector } from '../../usage/usage_collector'; import { parseFilterQuery } from '../../utils/serialized_query'; +import { ChildResolverOf, InfraResolverOf } from '../../utils/typed_resolvers'; import { QuerySourceResolver } from '../sources/resolvers'; -export type InfraSourceLogEntriesAroundResolver = InfraResolverOf< - InfraSourceResolvers.LogEntriesAroundResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceLogEntriesAroundResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; -export type InfraSourceLogEntriesBetweenResolver = InfraResolverOf< - InfraSourceResolvers.LogEntriesBetweenResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceLogEntriesBetweenResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; -export type InfraSourceLogSummaryBetweenResolver = InfraResolverOf< - InfraSourceResolvers.LogSummaryBetweenResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceLogSummaryBetweenResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; export const createLogEntriesResolvers = (libs: { diff --git a/x-pack/plugins/infra/server/graphql/metadata/resolvers.ts b/x-pack/plugins/infra/server/graphql/metadata/resolvers.ts index 0d4c66643721c..618932d6433ee 100644 --- a/x-pack/plugins/infra/server/graphql/metadata/resolvers.ts +++ b/x-pack/plugins/infra/server/graphql/metadata/resolvers.ts @@ -4,16 +4,14 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraSourceResolvers } from '../../../common/graphql/types'; -import { InfraResolvedResult, InfraResolverOf } from '../../lib/adapters/framework'; +import { InfraSourceResolvers } from '../../graphql/types'; import { InfraMetadataDomain } from '../../lib/domains/metadata_domain'; -import { InfraContext } from '../../lib/infra_types'; +import { ChildResolverOf, InfraResolverOf } from '../../utils/typed_resolvers'; import { QuerySourceResolver } from '../sources/resolvers'; -type InfraSourceMetadataByNodeResolver = InfraResolverOf< - InfraSourceResolvers.MetadataByNodeResolver, - InfraResolvedResult, - InfraContext +type InfraSourceMetadataByNodeResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; export const createMetadataResolvers = (libs: { diff --git a/x-pack/plugins/infra/server/graphql/metrics/resolvers.ts b/x-pack/plugins/infra/server/graphql/metrics/resolvers.ts index e7403f7ce3fcb..7d007ab332645 100644 --- a/x-pack/plugins/infra/server/graphql/metrics/resolvers.ts +++ b/x-pack/plugins/infra/server/graphql/metrics/resolvers.ts @@ -4,17 +4,15 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraSourceResolvers } from '../../../common/graphql/types'; -import { InfraResolvedResult, InfraResolverOf } from '../../lib/adapters/framework'; +import { InfraSourceResolvers } from '../../graphql/types'; import { InfraMetricsDomain } from '../../lib/domains/metrics_domain'; -import { InfraContext } from '../../lib/infra_types'; import { UsageCollector } from '../../usage/usage_collector'; +import { ChildResolverOf, InfraResolverOf } from '../../utils/typed_resolvers'; import { QuerySourceResolver } from '../sources/resolvers'; -type InfraSourceMetricsResolver = InfraResolverOf< - InfraSourceResolvers.MetricsResolver, - InfraResolvedResult, - InfraContext +type InfraSourceMetricsResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; interface ResolverDeps { diff --git a/x-pack/plugins/infra/server/graphql/nodes/resolvers.ts b/x-pack/plugins/infra/server/graphql/nodes/resolvers.ts index 867cfc4dd49ed..b30752536e1f8 100644 --- a/x-pack/plugins/infra/server/graphql/nodes/resolvers.ts +++ b/x-pack/plugins/infra/server/graphql/nodes/resolvers.ts @@ -4,35 +4,29 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraResponseResolvers, InfraSourceResolvers } from '../../../common/graphql/types'; -import { - InfraResolvedResult, - InfraResolverOf, - InfraResolverWithoutFields, -} from '../../lib/adapters/framework'; +import { InfraResponseResolvers, InfraSourceResolvers } from '../../graphql/types'; import { InfraNodeRequestOptions } from '../../lib/adapters/nodes'; import { extractGroupByAndNodeFromPath } from '../../lib/adapters/nodes/extract_group_by_and_node_from_path'; import { InfraNodesDomain } from '../../lib/domains/nodes_domain'; -import { InfraContext } from '../../lib/infra_types'; import { UsageCollector } from '../../usage/usage_collector'; import { parseFilterQuery } from '../../utils/serialized_query'; +import { ChildResolverOf, InfraResolverOf, ResultOf } from '../../utils/typed_resolvers'; import { QuerySourceResolver } from '../sources/resolvers'; -type InfraSourceMapResolver = InfraResolverWithoutFields< - InfraSourceResolvers.MapResolver, - InfraResolvedResult, - InfraContext, - 'nodes' +type InfraSourceMapResolver = ChildResolverOf< + InfraResolverOf< + InfraSourceResolvers.MapResolver< + { + source: ResultOf; + } & InfraSourceResolvers.MapArgs + > + >, + QuerySourceResolver >; -interface QueryMapResponse extends InfraSourceResolvers.MapArgs { - source: InfraResolvedResult; -} - -type InfraNodesResolver = InfraResolverOf< - InfraResponseResolvers.NodesResolver, - QueryMapResponse, - InfraContext +type InfraNodesResolver = ChildResolverOf< + InfraResolverOf, + InfraSourceMapResolver >; interface NodesResolversDeps { diff --git a/x-pack/plugins/infra/server/graphql/source_status/resolvers.ts b/x-pack/plugins/infra/server/graphql/source_status/resolvers.ts index 4ae516a9c3988..848d66058e64c 100644 --- a/x-pack/plugins/infra/server/graphql/source_status/resolvers.ts +++ b/x-pack/plugins/infra/server/graphql/source_status/resolvers.ts @@ -4,53 +4,45 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraIndexType, InfraSourceStatusResolvers } from '../../../common/graphql/types'; -import { InfraResolvedResult, InfraResolverOf } from '../../lib/adapters/framework'; +import { InfraIndexType, InfraSourceStatusResolvers } from '../../graphql/types'; import { InfraFieldsDomain } from '../../lib/domains/fields_domain'; -import { InfraContext } from '../../lib/infra_types'; import { InfraSourceStatus } from '../../lib/source_status'; +import { ChildResolverOf, InfraResolverOf } from '../../utils/typed_resolvers'; import { QuerySourceResolver } from '../sources/resolvers'; -export type InfraSourceStatusMetricAliasExistsResolver = InfraResolverOf< - InfraSourceStatusResolvers.MetricAliasExistsResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceStatusMetricAliasExistsResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; -export type InfraSourceStatusMetricIndicesExistResolver = InfraResolverOf< - InfraSourceStatusResolvers.MetricIndicesExistResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceStatusMetricIndicesExistResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; -export type InfraSourceStatusMetricIndicesResolver = InfraResolverOf< - InfraSourceStatusResolvers.MetricIndicesResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceStatusMetricIndicesResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; -export type InfraSourceStatusLogAliasExistsResolver = InfraResolverOf< - InfraSourceStatusResolvers.LogAliasExistsResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceStatusLogAliasExistsResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; -export type InfraSourceStatusLogIndicesExistResolver = InfraResolverOf< - InfraSourceStatusResolvers.LogIndicesExistResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceStatusLogIndicesExistResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; -export type InfraSourceStatusLogIndicesResolver = InfraResolverOf< - InfraSourceStatusResolvers.LogIndicesResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceStatusLogIndicesResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; -export type InfraSourceStatusIndexFieldsResolver = InfraResolverOf< - InfraSourceStatusResolvers.IndexFieldsResolver, - InfraResolvedResult, - InfraContext +export type InfraSourceStatusIndexFieldsResolver = ChildResolverOf< + InfraResolverOf, + QuerySourceResolver >; export const createSourceStatusResolvers = (libs: { diff --git a/x-pack/plugins/infra/server/graphql/sources/resolvers.ts b/x-pack/plugins/infra/server/graphql/sources/resolvers.ts index 5a3ab5acb76d0..58e6d351e004d 100644 --- a/x-pack/plugins/infra/server/graphql/sources/resolvers.ts +++ b/x-pack/plugins/infra/server/graphql/sources/resolvers.ts @@ -4,31 +4,29 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraSourceResolvers, QueryResolvers } from '../../../common/graphql/types'; -import { InfraResolvedResult, InfraResolverWithFields } from '../../lib/adapters/framework'; -import { InfraContext } from '../../lib/infra_types'; +import { InfraSourceResolvers, QueryResolvers } from '../../graphql/types'; import { InfraSourceStatus } from '../../lib/source_status'; import { InfraSources } from '../../lib/sources'; +import { + ChildResolverOf, + InfraResolverOf, + InfraResolverWithFields, + ResultOf, +} from '../../utils/typed_resolvers'; export type QuerySourceResolver = InfraResolverWithFields< QueryResolvers.SourceResolver, - null, - InfraContext, 'id' | 'configuration' >; export type QueryAllSourcesResolver = InfraResolverWithFields< QueryResolvers.AllSourcesResolver, - null, - InfraContext, 'id' | 'configuration' >; -export type InfraSourceStatusResolver = InfraResolverWithFields< - InfraSourceResolvers.StatusResolver, - InfraResolvedResult, - InfraContext, - never +export type InfraSourceStatusResolver = ChildResolverOf< + InfraResolverOf>>, + QuerySourceResolver >; interface SourcesResolversDeps { diff --git a/x-pack/plugins/infra/server/graphql/types.ts b/x-pack/plugins/infra/server/graphql/types.ts new file mode 100644 index 0000000000000..9747790fb17c0 --- /dev/null +++ b/x-pack/plugins/infra/server/graphql/types.ts @@ -0,0 +1,1098 @@ +/* tslint:disable */ +import { InfraContext } from '../lib/infra_types'; +import { GraphQLResolveInfo } from 'graphql'; + +export type Resolver = ( + parent: Parent, + args: Args, + context: Context, + info: GraphQLResolveInfo +) => Promise | Result; + +export interface ISubscriptionResolverObject { + subscribe( + parent: P, + args: Args, + context: Context, + info: GraphQLResolveInfo + ): AsyncIterator; + resolve?( + parent: P, + args: Args, + context: Context, + info: GraphQLResolveInfo + ): R | Result | Promise; +} + +export type SubscriptionResolver = + | ((...args: any[]) => ISubscriptionResolverObject) + | ISubscriptionResolverObject; + +// ==================================================== +// START: Typescript template +// ==================================================== + +// ==================================================== +// Types +// ==================================================== + +export interface Query { + /** Get an infrastructure data source by id */ + source: InfraSource; + /** Get a list of all infrastructure data sources */ + allSources: InfraSource[]; +} +/** A source of infrastructure data */ +export interface InfraSource { + /** The id of the source */ + id: string; + /** The raw configuration of the source */ + configuration: InfraSourceConfiguration; + /** The status of the source */ + status: InfraSourceStatus; + /** A hierarchy of metadata entries by node */ + metadataByNode: (InfraNodeMetadata | null)[]; + /** A consecutive span of log entries surrounding a point in time */ + logEntriesAround: InfraLogEntryInterval; + /** A consecutive span of log entries within an interval */ + logEntriesBetween: InfraLogEntryInterval; + /** A consecutive span of summary buckets within an interval */ + logSummaryBetween: InfraLogSummaryInterval; + /** A hierarchy of hosts, pods, containers, services or arbitrary groups */ + map?: InfraResponse | null; + + metrics: InfraMetricData[]; +} +/** A set of configuration options for an infrastructure data source */ +export interface InfraSourceConfiguration { + /** The alias to read metric data from */ + metricAlias: string; + /** The alias to read log data from */ + logAlias: string; + /** The field mapping to use for this source */ + fields: InfraSourceFields; +} +/** A mapping of semantic fields to their document counterparts */ +export interface InfraSourceFields { + /** The field to identify a container by */ + container: string; + /** The fields to identify a host by */ + host: string; + /** The fields that may contain the log event message. The first field found win. */ + message: string[]; + /** The field to identify a pod by */ + pod: string; + /** The field to use as a tiebreaker for log events that have identical timestamps */ + tiebreaker: string; + /** The field to use as a timestamp for metrics and logs */ + timestamp: string; +} +/** The status of an infrastructure data source */ +export interface InfraSourceStatus { + /** Whether the configured metric alias exists */ + metricAliasExists: boolean; + /** Whether the configured log alias exists */ + logAliasExists: boolean; + /** Whether the configured alias or wildcard pattern resolve to any metric indices */ + metricIndicesExist: boolean; + /** Whether the configured alias or wildcard pattern resolve to any log indices */ + logIndicesExist: boolean; + /** The list of indices in the metric alias */ + metricIndices: string[]; + /** The list of indices in the log alias */ + logIndices: string[]; + /** The list of fields defined in the index mappings */ + indexFields: InfraIndexField[]; +} +/** A descriptor of a field in an index */ +export interface InfraIndexField { + /** The name of the field */ + name: string; + /** The type of the field's values as recognized by Kibana */ + type: string; + /** Whether the field's values can be efficiently searched for */ + searchable: boolean; + /** Whether the field's values can be aggregated */ + aggregatable: boolean; +} +/** One metadata entry for a node. */ +export interface InfraNodeMetadata { + name: string; + + source: string; +} +/** A consecutive sequence of log entries */ +export interface InfraLogEntryInterval { + /** The key corresponding to the start of the interval covered by the entries */ + start?: InfraTimeKey | null; + /** The key corresponding to the end of the interval covered by the entries */ + end?: InfraTimeKey | null; + /** Whether there are more log entries available before the start */ + hasMoreBefore: boolean; + /** Whether there are more log entries available after the end */ + hasMoreAfter: boolean; + /** The query the log entries were filtered by */ + filterQuery?: string | null; + /** The query the log entries were highlighted with */ + highlightQuery?: string | null; + /** A list of the log entries */ + entries: InfraLogEntry[]; +} +/** A representation of the log entry's position in the event stream */ +export interface InfraTimeKey { + /** The timestamp of the event that the log entry corresponds to */ + time: number; + /** The tiebreaker that disambiguates events with the same timestamp */ + tiebreaker: number; +} +/** A log entry */ +export interface InfraLogEntry { + /** A unique representation of the log entry's position in the event stream */ + key: InfraTimeKey; + /** The log entry's id */ + gid: string; + /** The source id */ + source: string; + /** A list of the formatted log entry segments */ + message: InfraLogMessageSegment[]; +} +/** A segment of the log entry message that was derived from a field */ +export interface InfraLogMessageFieldSegment { + /** The field the segment was derived from */ + field: string; + /** The segment's message */ + value: string; + /** A list of highlighted substrings of the value */ + highlights: string[]; +} +/** A segment of the log entry message that was derived from a field */ +export interface InfraLogMessageConstantSegment { + /** The segment's message */ + constant: string; +} +/** A consecutive sequence of log summary buckets */ +export interface InfraLogSummaryInterval { + /** The millisecond timestamp corresponding to the start of the interval covered by the summary */ + start?: number | null; + /** The millisecond timestamp corresponding to the end of the interval covered by the summary */ + end?: number | null; + /** The query the log entries were filtered by */ + filterQuery?: string | null; + /** A list of the log entries */ + buckets: InfraLogSummaryBucket[]; +} +/** A log summary bucket */ +export interface InfraLogSummaryBucket { + /** The start timestamp of the bucket */ + start: number; + /** The end timestamp of the bucket */ + end: number; + /** The number of entries inside the bucket */ + entriesCount: number; +} + +export interface InfraResponse { + nodes: InfraNode[]; +} + +export interface InfraNode { + path: InfraNodePath[]; + + metric: InfraNodeMetric; +} + +export interface InfraNodePath { + value: string; +} + +export interface InfraNodeMetric { + name: InfraMetricType; + + value: number; +} + +export interface InfraMetricData { + id?: InfraMetric | null; + + series: InfraDataSeries[]; +} + +export interface InfraDataSeries { + id: string; + + data: InfraDataPoint[]; +} + +export interface InfraDataPoint { + timestamp: number; + + value?: number | null; +} + +// ==================================================== +// InputTypes +// ==================================================== + +export interface InfraTimeKeyInput { + time: number; + + tiebreaker: number; +} + +export interface InfraTimerangeInput { + /** The interval string to use for last bucket. The format is '{value}{unit}'. For example '5m' would return the metrics for the last 5 minutes of the timespan. */ + interval: string; + /** The end of the timerange */ + to: number; + /** The beginning of the timerange */ + from: number; +} + +export interface InfraPathInput { + /** The type of path */ + type: InfraPathType; + /** The label to use in the results for the group by for the terms group by */ + label?: string | null; + /** The field to group by from a terms aggregation, this is ignored by the filter type */ + field?: string | null; + /** The fitlers for the filter group by */ + filters?: InfraPathFilterInput[] | null; +} +/** A group by filter */ +export interface InfraPathFilterInput { + /** The label for the filter, this will be used as the group name in the final results */ + label: string; + /** The query string query */ + query: string; +} + +export interface InfraMetricInput { + /** The type of metric */ + type: InfraMetricType; +} + +// ==================================================== +// Arguments +// ==================================================== + +export interface SourceQueryArgs { + /** The id of the source */ + id: string; +} +export interface MetadataByNodeInfraSourceArgs { + nodeName: string; + + nodeType: InfraNodeType; +} +export interface LogEntriesAroundInfraSourceArgs { + /** The sort key that corresponds to the point in time */ + key: InfraTimeKeyInput; + /** The maximum number of preceding to return */ + countBefore?: number | null; + /** The maximum number of following to return */ + countAfter?: number | null; + /** The query to filter the log entries by */ + filterQuery?: string | null; + /** The query to highlight the log entries with */ + highlightQuery?: string | null; +} +export interface LogEntriesBetweenInfraSourceArgs { + /** The sort key that corresponds to the start of the interval */ + startKey: InfraTimeKeyInput; + /** The sort key that corresponds to the end of the interval */ + endKey: InfraTimeKeyInput; + /** The query to filter the log entries by */ + filterQuery?: string | null; + /** The query to highlight the log entries with */ + highlightQuery?: string | null; +} +export interface LogSummaryBetweenInfraSourceArgs { + /** The millisecond timestamp that corresponds to the start of the interval */ + start: number; + /** The millisecond timestamp that corresponds to the end of the interval */ + end: number; + /** The size of each bucket in milliseconds */ + bucketSize: number; + /** The query to filter the log entries by */ + filterQuery?: string | null; +} +export interface MapInfraSourceArgs { + timerange: InfraTimerangeInput; + + filterQuery?: string | null; +} +export interface MetricsInfraSourceArgs { + nodeId: string; + + nodeType: InfraNodeType; + + timerange: InfraTimerangeInput; + + metrics: InfraMetric[]; +} +export interface IndexFieldsInfraSourceStatusArgs { + indexType?: InfraIndexType | null; +} +export interface NodesInfraResponseArgs { + path: InfraPathInput[]; + + metric: InfraMetricInput; +} + +// ==================================================== +// Enums +// ==================================================== + +export enum InfraIndexType { + ANY = 'ANY', + LOGS = 'LOGS', + METRICS = 'METRICS', +} + +export enum InfraNodeType { + pod = 'pod', + container = 'container', + host = 'host', +} + +export enum InfraPathType { + terms = 'terms', + filters = 'filters', + hosts = 'hosts', + pods = 'pods', + containers = 'containers', +} + +export enum InfraMetricType { + count = 'count', + cpu = 'cpu', + load = 'load', + memory = 'memory', + tx = 'tx', + rx = 'rx', + logRate = 'logRate', +} + +export enum InfraMetric { + hostSystemOverview = 'hostSystemOverview', + hostCpuUsage = 'hostCpuUsage', + hostFilesystem = 'hostFilesystem', + hostK8sOverview = 'hostK8sOverview', + hostK8sCpuCap = 'hostK8sCpuCap', + hostK8sDiskCap = 'hostK8sDiskCap', + hostK8sMemoryCap = 'hostK8sMemoryCap', + hostK8sPodCap = 'hostK8sPodCap', + hostLoad = 'hostLoad', + hostMemoryUsage = 'hostMemoryUsage', + hostNetworkTraffic = 'hostNetworkTraffic', + podOverview = 'podOverview', + podCpuUsage = 'podCpuUsage', + podMemoryUsage = 'podMemoryUsage', + podLogUsage = 'podLogUsage', + podNetworkTraffic = 'podNetworkTraffic', + containerOverview = 'containerOverview', + containerCpuKernel = 'containerCpuKernel', + containerCpuUsage = 'containerCpuUsage', + containerDiskIOOps = 'containerDiskIOOps', + containerDiskIOBytes = 'containerDiskIOBytes', + containerMemory = 'containerMemory', + containerNetworkTraffic = 'containerNetworkTraffic', + nginxHits = 'nginxHits', + nginxRequestRate = 'nginxRequestRate', + nginxActiveConnections = 'nginxActiveConnections', + nginxRequestsPerConnection = 'nginxRequestsPerConnection', +} + +export enum InfraOperator { + gt = 'gt', + gte = 'gte', + lt = 'lt', + lte = 'lte', + eq = 'eq', +} + +// ==================================================== +// Unions +// ==================================================== + +/** A segment of the log entry message */ +export type InfraLogMessageSegment = InfraLogMessageFieldSegment | InfraLogMessageConstantSegment; + +// ==================================================== +// END: Typescript template +// ==================================================== + +// ==================================================== +// Resolvers +// ==================================================== + +export namespace QueryResolvers { + export interface Resolvers { + /** Get an infrastructure data source by id */ + source?: SourceResolver; + /** Get a list of all infrastructure data sources */ + allSources?: AllSourcesResolver; + } + + export type SourceResolver = Resolver< + R, + Parent, + Context, + SourceArgs + >; + export interface SourceArgs { + /** The id of the source */ + id: string; + } + + export type AllSourcesResolver< + R = InfraSource[], + Parent = never, + Context = InfraContext + > = Resolver; +} +/** A source of infrastructure data */ +export namespace InfraSourceResolvers { + export interface Resolvers { + /** The id of the source */ + id?: IdResolver; + /** The raw configuration of the source */ + configuration?: ConfigurationResolver; + /** The status of the source */ + status?: StatusResolver; + /** A hierarchy of metadata entries by node */ + metadataByNode?: MetadataByNodeResolver<(InfraNodeMetadata | null)[], TypeParent, Context>; + /** A consecutive span of log entries surrounding a point in time */ + logEntriesAround?: LogEntriesAroundResolver; + /** A consecutive span of log entries within an interval */ + logEntriesBetween?: LogEntriesBetweenResolver; + /** A consecutive span of summary buckets within an interval */ + logSummaryBetween?: LogSummaryBetweenResolver; + /** A hierarchy of hosts, pods, containers, services or arbitrary groups */ + map?: MapResolver; + + metrics?: MetricsResolver; + } + + export type IdResolver = Resolver< + R, + Parent, + Context + >; + export type ConfigurationResolver< + R = InfraSourceConfiguration, + Parent = InfraSource, + Context = InfraContext + > = Resolver; + export type StatusResolver< + R = InfraSourceStatus, + Parent = InfraSource, + Context = InfraContext + > = Resolver; + export type MetadataByNodeResolver< + R = (InfraNodeMetadata | null)[], + Parent = InfraSource, + Context = InfraContext + > = Resolver; + export interface MetadataByNodeArgs { + nodeName: string; + + nodeType: InfraNodeType; + } + + export type LogEntriesAroundResolver< + R = InfraLogEntryInterval, + Parent = InfraSource, + Context = InfraContext + > = Resolver; + export interface LogEntriesAroundArgs { + /** The sort key that corresponds to the point in time */ + key: InfraTimeKeyInput; + /** The maximum number of preceding to return */ + countBefore?: number | null; + /** The maximum number of following to return */ + countAfter?: number | null; + /** The query to filter the log entries by */ + filterQuery?: string | null; + /** The query to highlight the log entries with */ + highlightQuery?: string | null; + } + + export type LogEntriesBetweenResolver< + R = InfraLogEntryInterval, + Parent = InfraSource, + Context = InfraContext + > = Resolver; + export interface LogEntriesBetweenArgs { + /** The sort key that corresponds to the start of the interval */ + startKey: InfraTimeKeyInput; + /** The sort key that corresponds to the end of the interval */ + endKey: InfraTimeKeyInput; + /** The query to filter the log entries by */ + filterQuery?: string | null; + /** The query to highlight the log entries with */ + highlightQuery?: string | null; + } + + export type LogSummaryBetweenResolver< + R = InfraLogSummaryInterval, + Parent = InfraSource, + Context = InfraContext + > = Resolver; + export interface LogSummaryBetweenArgs { + /** The millisecond timestamp that corresponds to the start of the interval */ + start: number; + /** The millisecond timestamp that corresponds to the end of the interval */ + end: number; + /** The size of each bucket in milliseconds */ + bucketSize: number; + /** The query to filter the log entries by */ + filterQuery?: string | null; + } + + export type MapResolver< + R = InfraResponse | null, + Parent = InfraSource, + Context = InfraContext + > = Resolver; + export interface MapArgs { + timerange: InfraTimerangeInput; + + filterQuery?: string | null; + } + + export type MetricsResolver< + R = InfraMetricData[], + Parent = InfraSource, + Context = InfraContext + > = Resolver; + export interface MetricsArgs { + nodeId: string; + + nodeType: InfraNodeType; + + timerange: InfraTimerangeInput; + + metrics: InfraMetric[]; + } +} +/** A set of configuration options for an infrastructure data source */ +export namespace InfraSourceConfigurationResolvers { + export interface Resolvers { + /** The alias to read metric data from */ + metricAlias?: MetricAliasResolver; + /** The alias to read log data from */ + logAlias?: LogAliasResolver; + /** The field mapping to use for this source */ + fields?: FieldsResolver; + } + + export type MetricAliasResolver< + R = string, + Parent = InfraSourceConfiguration, + Context = InfraContext + > = Resolver; + export type LogAliasResolver< + R = string, + Parent = InfraSourceConfiguration, + Context = InfraContext + > = Resolver; + export type FieldsResolver< + R = InfraSourceFields, + Parent = InfraSourceConfiguration, + Context = InfraContext + > = Resolver; +} +/** A mapping of semantic fields to their document counterparts */ +export namespace InfraSourceFieldsResolvers { + export interface Resolvers { + /** The field to identify a container by */ + container?: ContainerResolver; + /** The fields to identify a host by */ + host?: HostResolver; + /** The fields that may contain the log event message. The first field found win. */ + message?: MessageResolver; + /** The field to identify a pod by */ + pod?: PodResolver; + /** The field to use as a tiebreaker for log events that have identical timestamps */ + tiebreaker?: TiebreakerResolver; + /** The field to use as a timestamp for metrics and logs */ + timestamp?: TimestampResolver; + } + + export type ContainerResolver< + R = string, + Parent = InfraSourceFields, + Context = InfraContext + > = Resolver; + export type HostResolver< + R = string, + Parent = InfraSourceFields, + Context = InfraContext + > = Resolver; + export type MessageResolver< + R = string[], + Parent = InfraSourceFields, + Context = InfraContext + > = Resolver; + export type PodResolver< + R = string, + Parent = InfraSourceFields, + Context = InfraContext + > = Resolver; + export type TiebreakerResolver< + R = string, + Parent = InfraSourceFields, + Context = InfraContext + > = Resolver; + export type TimestampResolver< + R = string, + Parent = InfraSourceFields, + Context = InfraContext + > = Resolver; +} +/** The status of an infrastructure data source */ +export namespace InfraSourceStatusResolvers { + export interface Resolvers { + /** Whether the configured metric alias exists */ + metricAliasExists?: MetricAliasExistsResolver; + /** Whether the configured log alias exists */ + logAliasExists?: LogAliasExistsResolver; + /** Whether the configured alias or wildcard pattern resolve to any metric indices */ + metricIndicesExist?: MetricIndicesExistResolver; + /** Whether the configured alias or wildcard pattern resolve to any log indices */ + logIndicesExist?: LogIndicesExistResolver; + /** The list of indices in the metric alias */ + metricIndices?: MetricIndicesResolver; + /** The list of indices in the log alias */ + logIndices?: LogIndicesResolver; + /** The list of fields defined in the index mappings */ + indexFields?: IndexFieldsResolver; + } + + export type MetricAliasExistsResolver< + R = boolean, + Parent = InfraSourceStatus, + Context = InfraContext + > = Resolver; + export type LogAliasExistsResolver< + R = boolean, + Parent = InfraSourceStatus, + Context = InfraContext + > = Resolver; + export type MetricIndicesExistResolver< + R = boolean, + Parent = InfraSourceStatus, + Context = InfraContext + > = Resolver; + export type LogIndicesExistResolver< + R = boolean, + Parent = InfraSourceStatus, + Context = InfraContext + > = Resolver; + export type MetricIndicesResolver< + R = string[], + Parent = InfraSourceStatus, + Context = InfraContext + > = Resolver; + export type LogIndicesResolver< + R = string[], + Parent = InfraSourceStatus, + Context = InfraContext + > = Resolver; + export type IndexFieldsResolver< + R = InfraIndexField[], + Parent = InfraSourceStatus, + Context = InfraContext + > = Resolver; + export interface IndexFieldsArgs { + indexType?: InfraIndexType | null; + } +} +/** A descriptor of a field in an index */ +export namespace InfraIndexFieldResolvers { + export interface Resolvers { + /** The name of the field */ + name?: NameResolver; + /** The type of the field's values as recognized by Kibana */ + type?: TypeResolver; + /** Whether the field's values can be efficiently searched for */ + searchable?: SearchableResolver; + /** Whether the field's values can be aggregated */ + aggregatable?: AggregatableResolver; + } + + export type NameResolver = Resolver< + R, + Parent, + Context + >; + export type TypeResolver = Resolver< + R, + Parent, + Context + >; + export type SearchableResolver< + R = boolean, + Parent = InfraIndexField, + Context = InfraContext + > = Resolver; + export type AggregatableResolver< + R = boolean, + Parent = InfraIndexField, + Context = InfraContext + > = Resolver; +} +/** One metadata entry for a node. */ +export namespace InfraNodeMetadataResolvers { + export interface Resolvers { + name?: NameResolver; + + source?: SourceResolver; + } + + export type NameResolver< + R = string, + Parent = InfraNodeMetadata, + Context = InfraContext + > = Resolver; + export type SourceResolver< + R = string, + Parent = InfraNodeMetadata, + Context = InfraContext + > = Resolver; +} +/** A consecutive sequence of log entries */ +export namespace InfraLogEntryIntervalResolvers { + export interface Resolvers { + /** The key corresponding to the start of the interval covered by the entries */ + start?: StartResolver; + /** The key corresponding to the end of the interval covered by the entries */ + end?: EndResolver; + /** Whether there are more log entries available before the start */ + hasMoreBefore?: HasMoreBeforeResolver; + /** Whether there are more log entries available after the end */ + hasMoreAfter?: HasMoreAfterResolver; + /** The query the log entries were filtered by */ + filterQuery?: FilterQueryResolver; + /** The query the log entries were highlighted with */ + highlightQuery?: HighlightQueryResolver; + /** A list of the log entries */ + entries?: EntriesResolver; + } + + export type StartResolver< + R = InfraTimeKey | null, + Parent = InfraLogEntryInterval, + Context = InfraContext + > = Resolver; + export type EndResolver< + R = InfraTimeKey | null, + Parent = InfraLogEntryInterval, + Context = InfraContext + > = Resolver; + export type HasMoreBeforeResolver< + R = boolean, + Parent = InfraLogEntryInterval, + Context = InfraContext + > = Resolver; + export type HasMoreAfterResolver< + R = boolean, + Parent = InfraLogEntryInterval, + Context = InfraContext + > = Resolver; + export type FilterQueryResolver< + R = string | null, + Parent = InfraLogEntryInterval, + Context = InfraContext + > = Resolver; + export type HighlightQueryResolver< + R = string | null, + Parent = InfraLogEntryInterval, + Context = InfraContext + > = Resolver; + export type EntriesResolver< + R = InfraLogEntry[], + Parent = InfraLogEntryInterval, + Context = InfraContext + > = Resolver; +} +/** A representation of the log entry's position in the event stream */ +export namespace InfraTimeKeyResolvers { + export interface Resolvers { + /** The timestamp of the event that the log entry corresponds to */ + time?: TimeResolver; + /** The tiebreaker that disambiguates events with the same timestamp */ + tiebreaker?: TiebreakerResolver; + } + + export type TimeResolver = Resolver< + R, + Parent, + Context + >; + export type TiebreakerResolver< + R = number, + Parent = InfraTimeKey, + Context = InfraContext + > = Resolver; +} +/** A log entry */ +export namespace InfraLogEntryResolvers { + export interface Resolvers { + /** A unique representation of the log entry's position in the event stream */ + key?: KeyResolver; + /** The log entry's id */ + gid?: GidResolver; + /** The source id */ + source?: SourceResolver; + /** A list of the formatted log entry segments */ + message?: MessageResolver; + } + + export type KeyResolver< + R = InfraTimeKey, + Parent = InfraLogEntry, + Context = InfraContext + > = Resolver; + export type GidResolver = Resolver< + R, + Parent, + Context + >; + export type SourceResolver = Resolver< + R, + Parent, + Context + >; + export type MessageResolver< + R = InfraLogMessageSegment[], + Parent = InfraLogEntry, + Context = InfraContext + > = Resolver; +} +/** A segment of the log entry message that was derived from a field */ +export namespace InfraLogMessageFieldSegmentResolvers { + export interface Resolvers { + /** The field the segment was derived from */ + field?: FieldResolver; + /** The segment's message */ + value?: ValueResolver; + /** A list of highlighted substrings of the value */ + highlights?: HighlightsResolver; + } + + export type FieldResolver< + R = string, + Parent = InfraLogMessageFieldSegment, + Context = InfraContext + > = Resolver; + export type ValueResolver< + R = string, + Parent = InfraLogMessageFieldSegment, + Context = InfraContext + > = Resolver; + export type HighlightsResolver< + R = string[], + Parent = InfraLogMessageFieldSegment, + Context = InfraContext + > = Resolver; +} +/** A segment of the log entry message that was derived from a field */ +export namespace InfraLogMessageConstantSegmentResolvers { + export interface Resolvers { + /** The segment's message */ + constant?: ConstantResolver; + } + + export type ConstantResolver< + R = string, + Parent = InfraLogMessageConstantSegment, + Context = InfraContext + > = Resolver; +} +/** A consecutive sequence of log summary buckets */ +export namespace InfraLogSummaryIntervalResolvers { + export interface Resolvers { + /** The millisecond timestamp corresponding to the start of the interval covered by the summary */ + start?: StartResolver; + /** The millisecond timestamp corresponding to the end of the interval covered by the summary */ + end?: EndResolver; + /** The query the log entries were filtered by */ + filterQuery?: FilterQueryResolver; + /** A list of the log entries */ + buckets?: BucketsResolver; + } + + export type StartResolver< + R = number | null, + Parent = InfraLogSummaryInterval, + Context = InfraContext + > = Resolver; + export type EndResolver< + R = number | null, + Parent = InfraLogSummaryInterval, + Context = InfraContext + > = Resolver; + export type FilterQueryResolver< + R = string | null, + Parent = InfraLogSummaryInterval, + Context = InfraContext + > = Resolver; + export type BucketsResolver< + R = InfraLogSummaryBucket[], + Parent = InfraLogSummaryInterval, + Context = InfraContext + > = Resolver; +} +/** A log summary bucket */ +export namespace InfraLogSummaryBucketResolvers { + export interface Resolvers { + /** The start timestamp of the bucket */ + start?: StartResolver; + /** The end timestamp of the bucket */ + end?: EndResolver; + /** The number of entries inside the bucket */ + entriesCount?: EntriesCountResolver; + } + + export type StartResolver< + R = number, + Parent = InfraLogSummaryBucket, + Context = InfraContext + > = Resolver; + export type EndResolver< + R = number, + Parent = InfraLogSummaryBucket, + Context = InfraContext + > = Resolver; + export type EntriesCountResolver< + R = number, + Parent = InfraLogSummaryBucket, + Context = InfraContext + > = Resolver; +} + +export namespace InfraResponseResolvers { + export interface Resolvers { + nodes?: NodesResolver; + } + + export type NodesResolver< + R = InfraNode[], + Parent = InfraResponse, + Context = InfraContext + > = Resolver; + export interface NodesArgs { + path: InfraPathInput[]; + + metric: InfraMetricInput; + } +} + +export namespace InfraNodeResolvers { + export interface Resolvers { + path?: PathResolver; + + metric?: MetricResolver; + } + + export type PathResolver< + R = InfraNodePath[], + Parent = InfraNode, + Context = InfraContext + > = Resolver; + export type MetricResolver< + R = InfraNodeMetric, + Parent = InfraNode, + Context = InfraContext + > = Resolver; +} + +export namespace InfraNodePathResolvers { + export interface Resolvers { + value?: ValueResolver; + } + + export type ValueResolver = Resolver< + R, + Parent, + Context + >; +} + +export namespace InfraNodeMetricResolvers { + export interface Resolvers { + name?: NameResolver; + + value?: ValueResolver; + } + + export type NameResolver< + R = InfraMetricType, + Parent = InfraNodeMetric, + Context = InfraContext + > = Resolver; + export type ValueResolver< + R = number, + Parent = InfraNodeMetric, + Context = InfraContext + > = Resolver; +} + +export namespace InfraMetricDataResolvers { + export interface Resolvers { + id?: IdResolver; + + series?: SeriesResolver; + } + + export type IdResolver< + R = InfraMetric | null, + Parent = InfraMetricData, + Context = InfraContext + > = Resolver; + export type SeriesResolver< + R = InfraDataSeries[], + Parent = InfraMetricData, + Context = InfraContext + > = Resolver; +} + +export namespace InfraDataSeriesResolvers { + export interface Resolvers { + id?: IdResolver; + + data?: DataResolver; + } + + export type IdResolver = Resolver< + R, + Parent, + Context + >; + export type DataResolver< + R = InfraDataPoint[], + Parent = InfraDataSeries, + Context = InfraContext + > = Resolver; +} + +export namespace InfraDataPointResolvers { + export interface Resolvers { + timestamp?: TimestampResolver; + + value?: ValueResolver; + } + + export type TimestampResolver< + R = number, + Parent = InfraDataPoint, + Context = InfraContext + > = Resolver; + export type ValueResolver< + R = number | null, + Parent = InfraDataPoint, + Context = InfraContext + > = Resolver; +} diff --git a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts index 23de4c7b2b81d..fca78f8f6fbab 100644 --- a/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/framework/adapter_types.ts @@ -9,7 +9,6 @@ import { GraphQLSchema } from 'graphql'; import { Lifecycle, ResponseToolkit, RouteOptions } from 'hapi'; import { InfraMetricModel } from '../metrics/adapter_types'; -export * from '../../../../common/graphql/typed_resolvers'; import { JsonObject } from '../../../../common/typed_json'; export const internalInfraFrameworkRequest = Symbol('internalInfraFrameworkRequest'); diff --git a/x-pack/plugins/infra/server/lib/adapters/metrics/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/adapter_types.ts index 18a81e518c931..bce552b7f4fcc 100644 --- a/x-pack/plugins/infra/server/lib/adapters/metrics/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metrics/adapter_types.ts @@ -9,7 +9,7 @@ import { InfraMetricData, InfraNodeType, InfraTimerangeInput, -} from '../../../../common/graphql/types'; +} from '../../../graphql/types'; import { InfraSourceConfiguration } from '../../sources'; import { InfraFrameworkRequest } from '../framework'; diff --git a/x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts index 3c596695e24fa..24c8d75ffb80b 100644 --- a/x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metrics/kibana_metrics_adapter.ts @@ -6,7 +6,8 @@ import { i18n } from '@kbn/i18n'; import { flatten } from 'lodash'; -import { InfraMetric, InfraMetricData, InfraNodeType } from '../../../../common/graphql/types'; + +import { InfraMetric, InfraMetricData, InfraNodeType } from '../../../graphql/types'; import { InfraBackendFrameworkAdapter, InfraFrameworkRequest } from '../framework'; import { InfraMetricsAdapter, InfraMetricsRequestOptions } from './adapter_types'; import { checkValidNode } from './lib/check_valid_node'; diff --git a/x-pack/plugins/infra/server/lib/adapters/metrics/models/index.ts b/x-pack/plugins/infra/server/lib/adapters/metrics/models/index.ts index 0a1c6fab14a84..5bff803e5ed15 100644 --- a/x-pack/plugins/infra/server/lib/adapters/metrics/models/index.ts +++ b/x-pack/plugins/infra/server/lib/adapters/metrics/models/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraMetric } from '../../../../../common/graphql/types'; +import { InfraMetric } from '../../../../graphql/types'; import { InfraMetricModelCreator } from '../adapter_types'; import { hostCpuUsage } from './host/host_cpu_usage'; diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/adapter_types.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/adapter_types.ts index ed6fb4beda03d..a95d5a0b8f6c4 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/adapter_types.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/adapter_types.ts @@ -4,6 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ +import { JsonObject } from '../../../../common/typed_json'; import { InfraMetricInput, InfraNode, @@ -11,8 +12,7 @@ import { InfraPathInput, InfraPathType, InfraTimerangeInput, -} from '../../../../common/graphql/types'; -import { JsonObject } from '../../../../common/typed_json'; +} from '../../../graphql/types'; import { InfraSourceConfiguration } from '../../sources'; import { InfraFrameworkRequest } from '../framework'; diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/elasticsearch_nodes_adapter.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/elasticsearch_nodes_adapter.ts index 97459ad0cc04b..f4cfbc190f6c1 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/elasticsearch_nodes_adapter.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/elasticsearch_nodes_adapter.ts @@ -12,7 +12,7 @@ import { InfraNodesAggregations, } from './adapter_types'; -import { InfraNode } from '../../../../common/graphql/types'; +import { InfraNode } from '../../../graphql/types'; import { calculateCardinalityOfNodeField } from './lib/calculate_cardinality'; import { createPartitionBodies } from './lib/create_partition_bodies'; import { processNodes } from './lib/process_nodes'; diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/extract_group_by_and_node_from_path.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/extract_group_by_and_node_from_path.ts index 60fa22b4116e4..46434b0eaa127 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/extract_group_by_and_node_from_path.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/extract_group_by_and_node_from_path.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { InfraPathInput, InfraPathType } from '../../../../common/graphql/types'; +import { InfraPathInput, InfraPathType } from '../../../graphql/types'; import { InfraNodeType } from './adapter_types'; const getNodeType = (type: InfraPathType): InfraNodeType => { diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/convert_nodes_response_to_groups.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/convert_nodes_response_to_groups.ts index 9ee00be17b917..b26508a1ef3dc 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/convert_nodes_response_to_groups.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/convert_nodes_response_to_groups.ts @@ -3,7 +3,7 @@ * or more contributor license agreements. Licensed under the Elastic License; * you may not use this file except in compliance with the Elastic License. */ -import { InfraNode } from '../../../../../common/graphql/types'; +import { InfraNode } from '../../../../graphql/types'; import { InfraBucket, InfraNodeRequestOptions } from '../adapter_types'; import { extractGroupPaths } from './extract_group_paths'; diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_base_path.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_base_path.ts index f8480686cf48e..7053f21389b23 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_base_path.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_base_path.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraPathInput } from '../../../../../common/graphql/types'; +import { InfraPathInput } from '../../../../graphql/types'; export const createBasePath = (groupBy: InfraPathInput[]) => { const basePath = ['aggs', 'waffle', 'aggs', 'nodes', 'aggs']; return groupBy.reduce((acc, group, index) => { diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_node_item.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_node_item.ts index a2d072e0897d7..41c24ed13407c 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_node_item.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_node_item.ts @@ -7,7 +7,8 @@ import { last } from 'lodash'; import { isNumber } from 'lodash'; import moment from 'moment'; -import { InfraNode, InfraNodeMetric } from '../../../../../common/graphql/types'; + +import { InfraNode, InfraNodeMetric } from '../../../../graphql/types'; import { InfraBucket, InfraNodeRequestOptions } from '../adapter_types'; import { getBucketSizeInSeconds } from './get_bucket_size_in_seconds'; diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_partition_bodies.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_partition_bodies.ts index 7c5480a4d6adb..a7934b4d70980 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_partition_bodies.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_partition_bodies.ts @@ -6,7 +6,7 @@ import { times } from 'lodash'; -import { InfraMetricType } from '../../../../../common/graphql/types'; +import { InfraMetricType } from '../../../../graphql/types'; import { InfraESMSearchBody, InfraNodeRequestOptions, diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_query.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_query.ts index 0c56172c4c4d0..6eca507a7f5b7 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_query.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/create_query.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraPathFilterInput, InfraPathInput } from '../../../../../common/graphql/types'; +import { InfraPathFilterInput, InfraPathInput } from '../../../../graphql/types'; import { InfraESBoolQuery, diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/extract_group_paths.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/extract_group_paths.ts index 016a109e6e5a2..924687ac0e86b 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/extract_group_paths.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/extract_group_paths.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraNode, InfraPathInput } from '../../../../../common/graphql/types'; +import { InfraNode, InfraPathInput } from '../../../../graphql/types'; import { InfraBucket, InfraNodeRequestOptions } from '../adapter_types'; import { createNodeItem } from './create_node_item'; diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/process_nodes.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/process_nodes.ts index ef55628cb744d..668e5cfc94b0b 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/process_nodes.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/process_nodes.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraNode } from '../../../../../common/graphql/types'; +import { InfraNode } from '../../../../graphql/types'; import { InfraBucket, InfraNodeRequestOptions } from '../adapter_types'; import { convertNodesResponseToGroups } from './convert_nodes_response_to_groups'; import { createNodeItem } from './create_node_item'; diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/type_guards.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/type_guards.ts index 14423afbe0ff3..499565f4b4cc6 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/lib/type_guards.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/lib/type_guards.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraPathInput, InfraPathType } from '../../../../../common/graphql/types'; +import { InfraPathInput, InfraPathType } from '../../../../graphql/types'; import { InfraGroupByFilters, InfraGroupByTerms } from '../adapter_types'; export function isGroupByFilters(value: InfraPathInput): value is InfraGroupByFilters { diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/metric_aggregation_creators/index.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/metric_aggregation_creators/index.ts index da520d1d64941..1cee9b0f22354 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/metric_aggregation_creators/index.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/metric_aggregation_creators/index.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraMetricType } from '../../../../../common/graphql/types'; +import { InfraMetricType } from '../../../../graphql/types'; import { count } from './count'; import { cpu } from './cpu'; import { load } from './load'; diff --git a/x-pack/plugins/infra/server/lib/adapters/nodes/processors/common/group_by_processor.ts b/x-pack/plugins/infra/server/lib/adapters/nodes/processors/common/group_by_processor.ts index 0bd07cbeeb66e..a1196b15f121c 100644 --- a/x-pack/plugins/infra/server/lib/adapters/nodes/processors/common/group_by_processor.ts +++ b/x-pack/plugins/infra/server/lib/adapters/nodes/processors/common/group_by_processor.ts @@ -6,7 +6,7 @@ import { cloneDeep, set } from 'lodash'; -import { InfraPathFilterInput, InfraPathInput } from '../../../../../../common/graphql/types'; +import { InfraPathFilterInput, InfraPathInput } from '../../../../../graphql/types'; import { InfraESQueryStringQuery, InfraESSearchBody, diff --git a/x-pack/plugins/infra/server/lib/domains/fields_domain.ts b/x-pack/plugins/infra/server/lib/domains/fields_domain.ts index 2b6f29e0d6e20..f1ee960ba6ff0 100644 --- a/x-pack/plugins/infra/server/lib/domains/fields_domain.ts +++ b/x-pack/plugins/infra/server/lib/domains/fields_domain.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraIndexField, InfraIndexType } from '../../../common/graphql/types'; +import { InfraIndexField, InfraIndexType } from '../../graphql/types'; import { FieldsAdapter } from '../adapters/fields'; import { InfraFrameworkRequest } from '../adapters/framework'; import { InfraSources } from '../sources'; diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts index 27663abdecada..03feccf57c9fa 100644 --- a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/log_entries_domain.ts @@ -4,13 +4,13 @@ * you may not use this file except in compliance with the Elastic License. */ +import { TimeKey } from '../../../../common/time'; +import { JsonObject } from '../../../../common/typed_json'; import { InfraLogEntry, InfraLogMessageSegment, InfraLogSummaryBucket, -} from '../../../../common/graphql/types'; -import { TimeKey } from '../../../../common/time'; -import { JsonObject } from '../../../../common/typed_json'; +} from '../../../graphql/types'; import { InfraDateRangeAggregationBucket, InfraFrameworkRequest } from '../../adapters/framework'; import { InfraSourceConfiguration, InfraSources } from '../../sources'; import { builtinRules } from './builtin_rules'; diff --git a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/message.ts b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/message.ts index b97c2704cdfba..1a96f4c17e918 100644 --- a/x-pack/plugins/infra/server/lib/domains/log_entries_domain/message.ts +++ b/x-pack/plugins/infra/server/lib/domains/log_entries_domain/message.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraLogMessageSegment } from '../../../../common/graphql/types'; +import { InfraLogMessageSegment } from '../../../graphql/types'; export function compileFormattingRules(rules: LogMessageFormattingRule[]) { const compiledRules = rules.map(compileRule); diff --git a/x-pack/plugins/infra/server/lib/domains/metrics_domain.ts b/x-pack/plugins/infra/server/lib/domains/metrics_domain.ts index 522298579a5c4..862ca8b4c823f 100644 --- a/x-pack/plugins/infra/server/lib/domains/metrics_domain.ts +++ b/x-pack/plugins/infra/server/lib/domains/metrics_domain.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraMetricData } from '../../../common/graphql/types'; +import { InfraMetricData } from '../../graphql/types'; import { InfraFrameworkRequest } from '../adapters/framework/adapter_types'; import { InfraMetricsAdapter, InfraMetricsRequestOptions } from '../adapters/metrics/adapter_types'; diff --git a/x-pack/plugins/infra/server/lib/domains/nodes_domain.ts b/x-pack/plugins/infra/server/lib/domains/nodes_domain.ts index 4c6d990dbeb95..3f925e99f9bde 100644 --- a/x-pack/plugins/infra/server/lib/domains/nodes_domain.ts +++ b/x-pack/plugins/infra/server/lib/domains/nodes_domain.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraNode } from '../../../common/graphql/types'; +import { InfraNode } from '../../graphql/types'; import { InfraFrameworkRequest } from '../adapters/framework'; import { InfraNodeRequestOptions, InfraNodesAdapter } from '../adapters/nodes'; diff --git a/x-pack/plugins/infra/server/usage/usage_collector.ts b/x-pack/plugins/infra/server/usage/usage_collector.ts index 72e8dc251da8b..b50d627d2ce09 100644 --- a/x-pack/plugins/infra/server/usage/usage_collector.ts +++ b/x-pack/plugins/infra/server/usage/usage_collector.ts @@ -4,7 +4,7 @@ * you may not use this file except in compliance with the Elastic License. */ -import { InfraNodeType } from '../../common/graphql/types'; +import { InfraNodeType } from '../graphql/types'; import { KbnServer } from '../kibana.index'; const KIBANA_REPORTING_TYPE = 'infraops'; diff --git a/x-pack/plugins/infra/server/utils/typed_resolvers.ts b/x-pack/plugins/infra/server/utils/typed_resolvers.ts new file mode 100644 index 0000000000000..d5f2d00abd504 --- /dev/null +++ b/x-pack/plugins/infra/server/utils/typed_resolvers.ts @@ -0,0 +1,97 @@ +/* + * 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. + */ + +import { Resolver } from '../graphql/types'; + +type ResolverResult = R | Promise; + +type InfraResolverResult = + | Promise + | Promise<{ [P in keyof R]: () => Promise }> + | { [P in keyof R]: () => Promise } + | { [P in keyof R]: () => R[P] } + | R; + +export type ResultOf = Resolver_ extends Resolver> + ? Result + : never; + +export type SubsetResolverWithFields = R extends Resolver< + Array, + infer ParentInArray, + infer ContextInArray, + infer ArgsInArray +> + ? Resolver< + Array>>, + ParentInArray, + ContextInArray, + ArgsInArray + > + : R extends Resolver + ? Resolver>, Parent, Context, Args> + : never; + +export type SubsetResolverWithoutFields = R extends Resolver< + Array, + infer ParentInArray, + infer ContextInArray, + infer ArgsInArray +> + ? Resolver< + Array>>, + ParentInArray, + ContextInArray, + ArgsInArray + > + : R extends Resolver + ? Resolver>, Parent, Context, Args> + : never; + +export type ResolverWithParent = Resolver_ extends Resolver< + infer Result, + any, + infer Context, + infer Args +> + ? Resolver + : never; + +export type InfraResolver = Resolver< + InfraResolverResult, + Parent, + Context, + Args +>; + +export type InfraResolverOf = Resolver_ extends Resolver< + ResolverResult, + never, + infer ContextWithNeverParent, + infer ArgsWithNeverParent +> + ? InfraResolver + : Resolver_ extends Resolver< + ResolverResult, + infer Parent, + infer Context, + infer Args + > + ? InfraResolver + : never; + +export type InfraResolverWithFields = InfraResolverOf< + SubsetResolverWithFields +>; + +export type InfraResolverWithoutFields = InfraResolverOf< + SubsetResolverWithoutFields +>; + +export type ChildResolverOf = ResolverWithParent< + Resolver_, + ResultOf +>; diff --git a/yarn.lock b/yarn.lock index 4ae66d34f512e..bdd2e1a79c886 100644 --- a/yarn.lock +++ b/yarn.lock @@ -9773,7 +9773,14 @@ graphql-codegen-introspection-template@^0.13.0: resolved "https://registry.yarnpkg.com/graphql-codegen-introspection-template/-/graphql-codegen-introspection-template-0.13.0.tgz#7bd4ae777f1a8d078a09974866fe27a0d928a040" integrity sha512-qYzupnNEr6EI3r0sHhEl0wvlgTpuzWx4MkVCY5rgeSweLOLKlmrwCySMZ8lxzFR9D1Y5alvW3C8LrWHPTuWIug== -graphql-codegen-typescript-template@^0.13.0: +graphql-codegen-typescript-resolvers-template@^0.13.0: + version "0.13.0" + resolved "https://registry.yarnpkg.com/graphql-codegen-typescript-resolvers-template/-/graphql-codegen-typescript-resolvers-template-0.13.0.tgz#fd525e5199d15714f7cb079b7b7b44dd5ba3a531" + integrity sha512-guaQ+xbg+18TqiBSXWpgKf88tvoPaOtLkExhW5eMQnfBJ7PpX3AcOjExb+AKsQAH9DK6zL4n+txU7WeUfzGDbA== + dependencies: + graphql-codegen-typescript-template "0.13.0" + +graphql-codegen-typescript-template@0.13.0, graphql-codegen-typescript-template@^0.13.0: version "0.13.0" resolved "https://registry.yarnpkg.com/graphql-codegen-typescript-template/-/graphql-codegen-typescript-template-0.13.0.tgz#41398687cbf279f1d97d8cfb8aa7c412bf0e7192" integrity sha512-EYLd4v8toD+dpWHJsJliViaE52novhF9zbayFmY8IgLeHmYPVk2TfyS6CVvHmCoa0HTxOawvTY8a7UIgtnpw2w==