import { Abortable } from '../core/jobs/job'; import { Table, Row } from '../webapp/models/table'; import { ToolbarText } from '../webapp/views/toolbar-text'; import { UsageModel } from '../core/usage-error'; import MultiModalResponse from './mmr/types'; import { NavResponse } from './NavResponse'; import { CommentaryResponse } from './CommentaryResponse'; import RadioTable from './RadioTable'; import Presentation from '../webapp/views/presentation'; import { ReactNode } from 'react'; import TabLayoutModificationResponse from './TabLayoutModificationResponse'; import { XtermResponse } from './XtermResponse'; export interface MessageBearingEntity { message: string; } export declare function isMessageBearingEntity(entity: Entity | MessageBearingEntity): entity is MessageBearingEntity; /** * The name part of a metadata bearing resource. * */ export interface MetadataNamedResource { kind?: string; metadata?: { name: string; namespace?: string; generation?: string; creationTimestamp?: string; labels?: Record; }; } /** * A minimal subset of a kubernetes-like resource specification that * identifies a resource * */ export interface MetadataBearing extends MetadataNamedResource { apiVersion?: string; /** optional designation of resource version */ version?: string; /** name hash, e.g. the hash part of auto-generated names, or an openwhisk activation id */ prettyName?: string; nameHash?: string; /** family of onclick handlers */ onclick?: { kind?: string; name?: string; nameHash?: string; namespace?: string; }; content?: Content; contentType?: string; toolbarText?: ToolbarText; presentation?: Presentation; } export type MetadataBearingWithContent = MetadataBearing; export declare function isMetadataBearing(spec: MetadataBearing | Entity): spec is MetadataBearing; export interface WithDisplayName extends MetadataBearing { spec: { displayName: string; }; } export declare function hasDisplayName(resource: MetadataBearing): resource is WithDisplayName; /** * Entity with a "resource" field that is MetadataBearing * */ export interface MetadataBearingByReference extends MetadataBearing { resource: MetadataBearing; } export type MetadataBearingByReferenceWithContent = MetadataBearingByReference; export declare function isMetadataBearingByReference(spec: MetadataBearing | Entity | MetadataBearingWithContent | T): spec is T; /** * A mostly scalar entity * */ export type SimpleEntity = boolean | string | number | HTMLElement | /* MessageBearingEntity | */ Error | MarkdownResponse | ReactResponse; export type MarkdownResponse = { content: string; contentType: 'text/markdown'; }; export declare function isMarkdownResponse(entity: Entity): entity is MarkdownResponse; export type ReactResponse = { react: ReactNode; }; export declare function isReactResponse(entity: Entity): entity is ReactResponse; /** * The plugin returns a mix of types; e.g. `helm status` returns * [string, Table, string], where the status `Table` is sandwiched by * preface and trailing `string` messages * */ export type MixedResponsePart = number | boolean | string | Table | HTMLElement; export type MixedResponse = MixedResponsePart[]; export declare function isMixedResponse(response: Entity): response is MixedResponse; /** * This allows commands to pass through raw responses from their backend * */ export type RawContent = any; export interface RawResponse { mode: 'raw'; content: Content; } export declare function isRawResponse(entity: Entity): entity is RawResponse; type RandomErrorResponse1 = { code: string | number; message?: string; }; export declare function isRandomErrorResponse1(response: Entity): response is RandomErrorResponse1; type RandomErrorResponse2 = { errno: string | number; }; export declare function isRandomErrorResponse2(response: Entity): response is RandomErrorResponse2; /** * This type covers all responses with no complex internal structure * that views may wish to interpret into fancier views. * */ export type ScalarResponse = SimpleEntity | (Table & Partial) | MixedResponse | CommentaryResponse | TabLayoutModificationResponse | XtermResponse | RandomErrorResponse1 | RandomErrorResponse2; export declare function isScalarResponse(response: Entity): response is ScalarResponse; export type ViewableResponse = MultiModalResponse | NavResponse | RadioTable; export type StructuredResponse = MetadataBearing> = ViewableResponse | UsageModel | SomeSortOfResource | RawResponse | SomeSortOfResource[]; export interface SourceRef { templates: { filepath: string; data: string; isFor: string; kind?: 'source' | 'template'; contentType?: string; }[]; customization?: { filepath: string; data: string; isFor: string; }; } export interface WithSourceReferences { kuiSourceRef: SourceRef; } export declare function hasSourceReferences(response: Partial): response is Required; type AbortableResponse = Abortable & { response: T; }; export declare function isAbortableResponse(entity: Entity): entity is AbortableResponse; /** * A potentially more complex entity with a "spec" * */ export type Entity = MetadataBearing> = ScalarResponse | AbortableResponse | StructuredResponse; export {};