import { Execution } from './execution' ; /**
 * `ExecutionContract` is a wrapper around `Execution` class. It provides the
 * same functionality but does not expose Expressions plugin internals.
 */ export class ExecutionContract < ExtraContext extends Record < string , unknown > = Record < string , unknown > , Input = unknown , Output = unknown , InspectorAdapters = unknown > { public get isPending ( ) : boolean { const state = this . execution . state . get ( ) . state ; const finished = state === 'error' || state === 'result' ; return ! finished ; } constructor ( protected readonly execution ) { } /**
     * Cancel the execution of the expression. This will set abort signal
     * (available in execution context) to aborted state, letting expression
     * functions to stop their execution.
     */ cancel = ( ) => { this . execution . cancel ( ) ; } ; /**
     * Returns the final output of expression, if any error happens still
     * wraps that error into `ExpressionValueError` type and returns that.
     * This function never throws.
     */ getData = async ( ) => { try { return await this . execution . result ; } catch ( e ) { return { type : 'error' , error : { type : e . type , message : e . message , stack : e . stack , } , } ; } } ; /**
     * Get string representation of the expression. Returns the original string
     * if execution was started from a string. If execution was started from an
     * AST this method returns a string generated from AST.
     */ getExpression = ( ) => { return this . execution . expression ; } ; /**
     * Get AST used to execute the expression.
     */ getAst = ( ) => this . execution . state . get ( ) . ast ; /**
     * Get Inspector adapters provided to all functions of expression through
     * execution context.
     */ inspect = ( ) => this . execution . inspectorAdapters ; }