import { Cache, RecursivePartial, StateCallback, StateEvents, StateObject, StatePropCallback, StringAnyMap, XMLNode } from "@hpcc-js/util";
import { IConnection, IOptions } from "../connection.ts";
import { WsSMC } from "../services/wsSMC.ts";
import * as WsTopology from "../services/wsTopology.ts";
import { WsWorkunits, WUStateID, WorkunitsService, WUUpdate } from "../services/wsWorkunits.ts";
import { ECLGraph, ScopeGraph, XGMMLGraph } from "./graph.ts";
import { Resource } from "./resource.ts";
import { Result } from "./result.ts";
import { BaseScope, Scope } from "./scope.ts";
import { SourceFile } from "./sourceFile.ts";
import { Timer } from "./timer.ts";
export declare const PropertyType: string[];
export declare const RelatedProperty: string[];
export interface IPropertyValue {
    Key: string;
    Value?: string;
    Avg?: string;
    Min?: string;
    Max?: string;
    Delta?: string;
    StdDev?: string;
    StdDevs?: number;
    SkewMin?: string;
    SkewMax?: string;
    NodeMin?: string;
    NodeMax?: string;
}
export interface IScope {
    __parentName?: string;
    __children?: IScope[];
    __formattedProps: {
        [key: string]: any;
    };
    __groupedProps: {
        [key: string]: IPropertyValue;
    };
    __StdDevs: number;
    __StdDevsSource: string;
    id: string;
    name: string;
    type: string;
    Kind: string;
    Label: string;
    [key: string]: any;
}
export interface ISplitMetric {
    measure: string;
    ext: string;
    label: string;
}
export declare function splitMetric(key: string): ISplitMetric;
export declare class WorkunitCache extends Cache<{
    BaseUrl: string;
    Wuid: string;
}, Workunit> {
    constructor();
}
export interface DebugState {
    sequence: number;
    state: string;
    [key: string]: any;
}
export interface IWorkunit {
    ResultViews: WsWorkunits.ResultViews;
    HelpersCount: number;
}
export interface IDebugWorkunit {
    DebugState?: DebugState;
}
export interface ITimeElapsed {
    scope: string;
    start: string;
    elapsed: number;
    finish: string;
}
export type WorkunitEvents = "completed" | StateEvents;
export type UWorkunitState = WsWorkunits.ECLWorkunit & WsWorkunits.Workunit & WsSMC.ActiveWorkunit & IWorkunit & IDebugWorkunit;
export type IWorkunitState = WsWorkunits.ECLWorkunit | WsWorkunits.Workunit | WsSMC.ActiveWorkunit | IWorkunit | IDebugWorkunit;
export declare class Workunit extends StateObject<UWorkunitState, IWorkunitState> implements WsWorkunits.Workunit {
    connection: WorkunitsService;
    topologyConnection: WsTopology.TopologyService;
    get BaseUrl(): string;
    private _debugMode;
    private _debugAllGraph;
    private _submitAction;
    get properties(): WsWorkunits.ECLWorkunit & WsWorkunits.Workunit;
    get Wuid(): string;
    get Owner(): string;
    get Cluster(): string;
    get Jobname(): string;
    get Description(): string;
    get ActionEx(): string;
    get StateID(): WUStateID;
    get State(): string;
    get Protected(): boolean;
    get Exceptions(): WsWorkunits.Exceptions2;
    get ResultViews(): WsWorkunits.ResultViews;
    private _resultCache;
    get ResultCount(): number;
    get Results(): WsWorkunits.Results;
    get CResults(): Result[];
    get SequenceResults(): {
        [key: number]: Result;
    };
    get Timers(): WsWorkunits.Timers;
    get CTimers(): Timer[];
    private _graphCache;
    get GraphCount(): number;
    get Graphs(): WsWorkunits.Graphs;
    get CGraphs(): ECLGraph[];
    get ThorLogList(): WsWorkunits.ThorLogList;
    get ResourceURLCount(): number;
    get ResourceURLs(): WsWorkunits.ResourceURLs;
    get CResourceURLs(): Resource[];
    get TotalClusterTime(): string;
    get DateTimeScheduled(): string;
    get IsPausing(): boolean;
    get ThorLCR(): boolean;
    get ApplicationValues(): WsWorkunits.ApplicationValues;
    get HasArchiveQuery(): boolean;
    get StateEx(): string;
    get PriorityClass(): number;
    get PriorityLevel(): number;
    get Snapshot(): string;
    get ResultLimit(): number;
    get EventSchedule(): number;
    get Query(): WsWorkunits.Query;
    get HelpersCount(): number;
    get Helpers(): WsWorkunits.Helpers;
    get DebugValues(): WsWorkunits.DebugValues;
    get AllowedClusters(): WsWorkunits.AllowedClusters;
    get ErrorCount(): number;
    get WarningCount(): number;
    get InfoCount(): number;
    get AlertCount(): number;
    get SourceFileCount(): number;
    get SourceFiles(): WsWorkunits.SourceFiles;
    get CSourceFiles(): SourceFile[];
    get VariableCount(): number;
    get Variables(): WsWorkunits.Variables;
    get TimerCount(): number;
    get HasDebugValue(): boolean;
    get ApplicationValueCount(): number;
    get XmlParams(): string;
    get AccessFlag(): number;
    get ClusterFlag(): number;
    get ResultViewCount(): number;
    get DebugValueCount(): number;
    get WorkflowCount(): number;
    get Archived(): boolean;
    get RoxieCluster(): string;
    get DebugState(): DebugState;
    get Queue(): string;
    get Active(): boolean;
    get Action(): number;
    get Scope(): string;
    get AbortBy(): string;
    get AbortTime(): string;
    get Workflows(): WsWorkunits.Workflows;
    get TimingData(): WsWorkunits.TimingData;
    get HelpersDesc(): string;
    get GraphsDesc(): string;
    get SourceFilesDesc(): string;
    get ResultsDesc(): string;
    get VariablesDesc(): string;
    get TimersDesc(): string;
    get DebugValuesDesc(): string;
    get ApplicationValuesDesc(): string;
    get WorkflowsDesc(): string;
    get ServiceNames(): WsWorkunits.ServiceNames;
    get CompileCost(): number;
    get ExecuteCost(): number;
    get FileAccessCost(): number;
    get NoAccess(): boolean;
    get ECLWUProcessList(): WsWorkunits.ECLWUProcessList;
    get CostSavingPotential(): number;
    static create(optsConnection: IOptions | IConnection): Promise<Workunit>;
    static attach(optsConnection: IOptions | IConnection, wuid: string, state?: IWorkunitState): Workunit;
    static existsLocal(baseUrl: string, wuid: string): boolean;
    static submit(server: IOptions | IConnection, target: string, ecl: string, compileOnly?: boolean): Promise<Workunit>;
    static compile(server: IOptions | IConnection, target: string, ecl: string): Promise<Workunit>;
    static query(server: IOptions | IConnection, opts: Partial<WsWorkunits.WUQuery>): Promise<Workunit[]>;
    protected constructor(optsConnection: IOptions | IConnection, wuid?: string);
    clearState(wuid?: string): void;
    update(request: Partial<WsWorkunits.WUUpdate>): Promise<Workunit>;
    submit(_cluster?: string, action?: WUUpdate.Action, resultLimit?: number): Promise<Workunit>;
    isComplete(): boolean;
    isFailed(): boolean;
    isDeleted(): boolean;
    isDebugging(): boolean;
    isRunning(): boolean;
    setToFailed(): Promise<WsWorkunits.WUActionResponse>;
    pause(): Promise<WsWorkunits.WUActionResponse>;
    pauseNow(): Promise<WsWorkunits.WUActionResponse>;
    resume(): Promise<WsWorkunits.WUActionResponse>;
    abort(): Promise<WsWorkunits.WUActionResponse>;
    protect(): Promise<WsWorkunits.WUActionResponse>;
    unprotect(): Promise<WsWorkunits.WUActionResponse>;
    delete(): Promise<WsWorkunits.WUActionResponse>;
    restore(): Promise<WsWorkunits.WUActionResponse>;
    deschedule(): Promise<WsWorkunits.WUActionResponse>;
    reschedule(): Promise<WsWorkunits.WUActionResponse>;
    resubmit(): Promise<Workunit>;
    clone(): Promise<Workunit>;
    refreshState(): Promise<this>;
    refreshInfo(request?: Partial<WsWorkunits.WUInfo>): Promise<this>;
    refreshDebug(): Promise<this>;
    refresh(full?: boolean, request?: Partial<WsWorkunits.WUInfo>): Promise<this>;
    eclExceptions(): WsWorkunits.ECLException[];
    fetchArchive(): Promise<string>;
    fetchECLExceptions(): Promise<WsWorkunits.ECLException[]>;
    fetchResults(): Promise<Result[]>;
    fetchGraphs(): Promise<ECLGraph[]>;
    fetchQuery(): Promise<WsWorkunits.Query>;
    fetchHelpers(): Promise<WsWorkunits.ECLHelpFile[]>;
    fetchAllowedClusters(): Promise<string[]>;
    fetchTotalClusterTime(): Promise<string>;
    fetchServiceNames(): Promise<string[]>;
    fetchDetailsMeta(request?: RecursivePartial<WsWorkunits.WUDetailsMeta>): Promise<WsWorkunits.WUDetailsMetaResponse>;
    fetchDetailsRaw(request?: RecursivePartial<WsWorkunits.WUDetails>): Promise<WsWorkunits.Scope[]>;
    normalizeDetails(meta: WsWorkunits.WUDetailsMetaResponse, scopes: WsWorkunits.Scope[]): {
        meta: WsWorkunits.WUDetailsMetaResponse;
        columns: {
            [id: string]: any;
        };
        data: IScope[];
    };
    fetchDetailsNormalized(request?: RecursivePartial<WsWorkunits.WUDetails>): Promise<{
        meta: WsWorkunits.WUDetailsMetaResponse;
        columns: {
            [id: string]: any;
        };
        data: IScope[];
    }>;
    fetchInfo(request?: Partial<WsWorkunits.WUInfo>): Promise<WsWorkunits.WUInfoResponse>;
    fetchDetails(request?: RecursivePartial<WsWorkunits.WUDetails>): Promise<Scope[]>;
    fetchDetailsHierarchy(request?: Partial<WsWorkunits.WUDetails>): Promise<Scope[]>;
    fetchGraphDetails(graphIDs: string[], rootTypes: string[]): Promise<BaseScope[]>;
    fetchScopeGraphs(graphIDs?: string[]): Promise<ScopeGraph>;
    fetchTimeElapsed(): Promise<ITimeElapsed[]>;
    protected _monitor(): void;
    protected _monitorTimeoutDuration(): number;
    on(eventID: WorkunitEvents, propIDorCallback: StateCallback | keyof UWorkunitState, callback?: StatePropCallback): this;
    watchUntilComplete(callback?: StateCallback): Promise<this>;
    watchUntilRunning(callback?: StateCallback): Promise<this>;
    protected WUQuery(_request?: Partial<WsWorkunits.WUQuery>): Promise<WsWorkunits.WUQueryResponse>;
    protected WUCreate(): Promise<WsWorkunits.WUCreateResponse>;
    protected WUInfo(_request?: Partial<WsWorkunits.WUInfo>): Promise<WsWorkunits.WUInfoResponse>;
    protected WUResubmit(request: Partial<WsWorkunits.WUResubmit>): Promise<WsWorkunits.WUResubmitResponse>;
    protected WUDetailsMeta(request: Partial<WsWorkunits.WUDetailsMeta>): Promise<WsWorkunits.WUDetailsMetaResponse>;
    protected WUDetails(request: RecursivePartial<WsWorkunits.WUDetails>): Promise<WsWorkunits.WUDetailsResponse>;
    protected WUAction(actionType: WsWorkunits.ECLWUActions): Promise<WsWorkunits.WUActionResponse>;
    publish(name?: string): Promise<WsWorkunits.WUPublishWorkunitResponse>;
    publishEx(request: Partial<WsWorkunits.WUPublishWorkunit>): Promise<WsWorkunits.WUPublishWorkunitResponse>;
    protected WUCDebug(command: string, opts?: any): Promise<XMLNode | null>;
    debug(command: string, opts?: object): Promise<XMLNode>;
    debugStatus(): Promise<XMLNode>;
    debugContinue(mode?: string): Promise<XMLNode>;
    debugStep(mode: string): Promise<XMLNode>;
    debugPause(): Promise<XMLNode>;
    debugQuit(): Promise<XMLNode>;
    debugDeleteAllBreakpoints(): Promise<XMLNode>;
    protected debugBreakpointResponseParser(rootNode: StringAnyMap): any;
    debugBreakpointAdd(id: string, mode: string, action: string): Promise<XMLNode>;
    debugBreakpointList(): Promise<any[]>;
    debugGraph(): Promise<XGMMLGraph>;
    debugBreakpointValid(path: string): Promise<IECLDefintion[]>;
    debugPrint(edgeID: string, startRow?: number, numRows?: number): Promise<StringAnyMap[]>;
}
export interface IECLDefintion {
    id: string;
    file: string;
    line: number;
    column: number;
}
