import { isObject , TaskObserver , } from "@adpt/utils" ; import { isFunction , isString } from "lodash" ; import { AdaptMountedElement , } from "../jsx" ; import { Deployment } from "../server/deployment" ; import { DeployOpID , DeployStepID } from "../server/deployment_data" ; import { ActionChange , DeployedWhenMethod , DeployStatus , DeployStatusExt , ExecuteComplete , ExecuteOptions , GoalStatus , isDependsOn , RelationExt , } from "./deploy_types" ; export interface ExecutePassOptions extends Required < ExecuteOptions > { nodeStatus : StatusTracker ; timeoutTime : number ; } export interface WaitInfo { deployedWhen : ( gs : GoalStatus ) => ReturnType < DeployedWhenMethod > ; description : string ; actingFor ? : ActionChange [ ] ; action ? : ( ) => void | Promise < void > ; /**
     * True if there is an Action that affects this node in the current
     * execution plan.
     */ activeAction ? : boolean ; dependsOn ? : RelationExt ; logAction ? : boolean ; } export function isWaitInfo ( v ) { return ( isObject ( v ) && isFunction ( v . deployedWhen ) && isString ( v . description ) && ( v . actingFor === undefined || Array . isArray ( v . actingFor ) ) && ( v . action === undefined || isFunction ( v . action ) ) && ( v . dependsOn === undefined || isDependsOn ( v . dependsOn ) ) ) ; } export interface EPNode { /**
     * For Element nodes, this contains all the Element's original children
     * and its successor.
     */ children : Set < EPNode > ; /** Actions do not have an Element directly associated with them. */ element ? : AdaptMountedElement ; goalStatus : GoalStatus ; waitInfo : WaitInfo ; } export type EPObject = EPNode | AdaptMountedElement | WaitInfo ; export type EPNodeId = string ; export interface StatusTracker { readonly deployment : Deployment ; readonly dryRun : boolean ; readonly goalStatus : GoalStatus ; readonly nodeStatus : Record < DeployStatus , number > ; readonly deployOpID : DeployOpID ; readonly primStatus : Record < DeployStatus , number > ; readonly statMap : Map < EPNode , DeployStatusExt > ; readonly taskMap : Map < EPNode , TaskObserver > ; readonly stepID ? : DeployStepID ; get ( n ) : DeployStatusExt ; set ( n , statExt , err , description ? ) : Promise < boolean > ; isFinal ( n ) : boolean ; isActive ( n ) : boolean ; output ( n , s ) : void ; complete ( stateChanged ) : Promise < ExecuteComplete > ; debug ( getId ) : string ; }