import type { ActionIdentifier } from "@garden-io/grow-sdk/actions/action"; import type { ActionType } from "@garden-io/grow-sdk/declarations/action-type"; import type { JSONObject } from "@garden-io/grow-sdk/util/types"; import type { BaseAction } from "../actions/base"; import type { GrowContext } from "../context"; import type { ConfigGraph } from "../graph/config-graph"; import type { GraphResults } from "../graph/results"; import type { Log } from "../logger/log-entry"; import { TypedEventEmitter } from "../util/events"; import type { ValidResultType } from "./base-action"; export declare function makeBaseKey(type: string, name: string): string; export interface CommonTaskParams { context: GrowContext; log: Log; /** * Force running the process method of the task, even if status method returned a status and it is clean and does not need processing. */ force: boolean; /** * We define a weak dependency as the relationship between two actions where action A only requires the status of action B, * which can be dirty or not. A weak dependency alone never triggers the run handler of the dependent action. * * A strong dependency is when action A requires action B's status to be healthy aka dirty=false. This is the default. * * We request execution for dependencies even in case we're just interested in the status. This is because * other requests for execution might come in until the status method completes. * If a strong dependency comes in, we want the action that has a weak dependency to run after the process method completed. * * This is useful for associated actions like logs and cleanup; These actions want to know the status, even if it's dirty, * and when run in isolation, e.g. as part of the logs command, we want to avoid side effects. * * On the other hand, if you are executing an action "strongly", and request associated actions like logs at the same time, * we want the framework to wait for the final result, and not invoke the logs handler too early with outdated information. */ weakDependency?: boolean; } export interface BaseActionTaskParams extends CommonTaskParams { log: Log; action: BaseAction; graph: ConfigGraph; forceActions?: ActionIdentifier[]; skipRuntimeDependencies?: boolean; } export interface TaskStatusParams { statusOnly: boolean; dependencyResults: GraphResults; } export interface TaskProcessParams extends TaskStatusParams { status: S | null; } export interface ResolveProcessDependenciesParams { status: S | null; } interface TaskEventPayload { error?: Error; result?: O | null; } export interface TaskEvents { statusResolved: TaskEventPayload; processed: TaskEventPayload; ready: { result: O; }; } export declare abstract class BaseTask extends TypedEventEmitter> { #private; abstract readonly type: string; get concurrencyGroup(): string; _ResultType: O; /** * How many execute task nodes of this exact type are allowed to run concurrently * * Children can override this to set a custom concurrency limit. */ abstract readonly executeConcurrencyLimit: number; /** * How many get-status task nodes of this exact type are allowed to run concurrently * * Children can override this to set a custom concurrency limit. */ abstract readonly statusConcurrencyLimit: number; readonly context: GrowContext; readonly log: Log; readonly uid: string; readonly force: boolean; get weakDependency(): boolean; set weakDependency(newVal: boolean); interactive: boolean; protected constructor(initArgs: CommonTaskParams); abstract getName(): string; /** * Which dependencies must be resolved to call this task's `getStatus` method */ abstract resolveStatusDependencies(): BaseTask[]; /** * Which dependencies must be resolved to call this task's `process` method, in addition to the above */ abstract resolveProcessDependencies(params: ResolveProcessDependenciesParams): BaseTask[]; abstract getDescription(): string; abstract getStatus(params: TaskStatusParams): null | Promise; abstract process(params: TaskProcessParams): Promise; /** * Returns a JSON-friendly representation of the task's result. This should be bounded in size, and not contain * any sensitive information. * * `result` should be the result of running the task's `process` method (i.e. passed back to the instance * for formatting / filtering / exporting in an appropriate way for the task class in question). */ abstract export(result: O): JSONObject; /** * The "input version" of a task generally refers to the version of the task's inputs, before * any resolution or execution happens. For action tasks, this will generally be the unresolved * version. * * The corresponding "output version" is what's returned by the `getStatus` and `process` handlers. */ getInputVersion(): string | null; /** * Wrapper around resolveStatusDependencies() that memoizes the results. */ getStatusDependencies(): BaseTask[]; /** * Wrapper around resolveProcessDependencies() that memoizes the results and applies filters. */ getProcessDependencies(params: ResolveProcessDependenciesParams): BaseTask[]; /** * The basic type and name of the task. */ getBaseKey(): string; /** * A key that factors in different parameters, e.g. sync mode for deploys, force flags, versioning etc. * Used to handle overlapping graph solve requests. */ getKey(): string; /** * A completely unique key for the instance of the task. */ getId(): string; toSanitizedValue(): string; } export type TaskResultType = T["_ResultType"]; export {};