import type { ZodTypeAny } from "zod"; import type { ActionDeclarationInput } from "@garden-io/grow-sdk/actions/types"; import type { DeclaredAction, DeclaredActionAssociation } from "@garden-io/grow-sdk/declarations/action"; import type { ActionType } from "@garden-io/grow-sdk/declarations/action-type"; import type { CommandArgumentSpec, CommandOptionSpec, DeclaredCommand, ObjectFromSpecs } from "@garden-io/grow-sdk/declarations/command"; import { BooleanParameter, IntegerParameter, IntegersParameter, StringParameter, StringsParameter } from "@garden-io/grow-sdk/declarations/params"; import type { Parameter, ParameterValues } from "@garden-io/grow-sdk/declarations/params"; import { GrowError } from "@garden-io/grow-sdk/errors"; import type { s } from "@garden-io/grow-sdk/schema"; import type { EmptyObject, KeyedBy, PrimitiveMap } from "@garden-io/grow-sdk/util/types"; import type { GrowCli } from "../cli/cli"; import type { GlobalOptions } from "../cli/params"; import type { CloudApi } from "../cloud/api"; import type { BuiltinCommand } from "../commands/base"; import type { GrowContext } from "../context"; import { ConfigGraph } from "../graph/config-graph"; import type { Issue } from "../issues"; import type { Log } from "../logger/log-entry"; export declare abstract class ConfigWrapper { readonly path: string; readonly cliInputs: PrimitiveMap; private sdkModule; private didLoadModule; constructor(path: string, cliInputs: PrimitiveMap); /** * Will only be called once by the abstract base class. * * This method is expected to call the protected methods `registerAction` and `registerCommand` when discovering * declared actions or commands, which will return validation issues. * * `registerAction` and `registerCommand` can also be called dynamically in a command invocation through the `ctx.run` method. */ abstract loadModule(log: Log): Promise; getConfigDirPath(): string; getGraph(log: Log): Promise; getModule(log: Log): Promise; refresh(log: Log): { message: string; type: "validation" | "processing" | "parsing"; severity: "error" | "warning"; entity?: { key: string; type: "command" | "action"; } | undefined; detail?: any; }[]; getActions(log: Log): Promise; getCommands(log: Log): Promise; getCommandsWrapped(log: Log): Promise; registerAction(log: Log, action: DeclaredAction, scanAssociatedActions?: boolean, scanDependencies?: boolean): Issue[]; registerCommand(log: Log, command: DeclaredCommand): Issue[]; } export declare class DummyConfigWrapper extends ConfigWrapper { getConfigDirPath(): string; loadModule(_: Log): Promise; } export declare class TypescriptConfigWrapper extends ConfigWrapper { load(): Promise; loadModule(log: Log): Promise<{ message: string; type: "validation" | "processing" | "parsing"; severity: "error" | "warning"; entity?: { key: string; type: "command" | "action"; } | undefined; detail?: any; }[]>; } export declare class ModuleWrapperMakeContext { readonly module: ModuleWrapper; constructor(module: ModuleWrapper); private createAction; run(name: string, actionType: ActionType, config: Omit, "name">): DeclaredAction; } export declare class ModuleWrapper { readonly actions: Record>; readonly commands: { [name: string]: DeclaredCommand; }; readonly make: ModuleWrapperMakeContext; readonly path: string | undefined; constructor(path: string); validateAction(action: DeclaredAction): Issue[]; addAction(action: DeclaredAction): Issue[]; getActions(): DeclaredAction>[]; validateCommand(command: DeclaredCommand): Issue[]; addCommand(command: DeclaredCommand): Issue[]; getCommands(): DeclaredCommand, Record, import("@garden-io/grow-sdk/declarations/command").DefaultAdditionalHandlerArgs>[]; } export declare function validateDeclaredAction(action: DeclaredAction): Issue[]; export declare function validateDeclaredCommand(command: DeclaredCommand): Issue[]; export type BuiltinCommandResult = { readonly errors: GrowError[]; readonly exitCode: number; readonly result: Omit; }; export interface BuiltinArgs { "$all"?: string[]; "--"?: string[]; } export interface CommandHandlerParams { args: T & BuiltinArgs; opts: U; globalOpts: ParameterValues; log: Log; cli?: GrowCli; grow: GrowContext; } export interface RunCommandParams extends CommandHandlerParams { cloudApi?: CloudApi; sessionId: string; } export declare abstract class CommandWrapper = s.ZodType> { abstract name: string; abstract help: string; description?: string; aliases?: string[]; allowUndefinedArguments: boolean; arguments: ParamSpecsToParameterObject | undefined; options: ParamSpecsToParameterObject | undefined; needsConfig: boolean; usesCloud: boolean; isHidden: boolean; isCustom: boolean; ignoreOptions: boolean; enableAnalytics: boolean; terminated: boolean; constructor(); /** * Shorthand helper to call the action method on the given command class. * Also validates the result against the outputsSchema on the command, if applicable. * * @returns The result from the command action */ run(params: RunCommandParams, ObjectFromSpecs>): Promise>; getName(): string; getPath(): string[]; /** * Returns all paths that this command should match, including all aliases and permutations of those. */ getPaths(): string[][]; describe(): { name: string; help: string; description: string | undefined; arguments: { help: string; type: string; schema: s.ZodSchema; defaultValue: any; required: boolean; aliases?: string[]; hints?: string; overrides: string[]; hidden: boolean; spread: boolean; suggestionPriority: number; name: string; usageName: string; }[] | undefined; options: { help: string; type: string; schema: s.ZodSchema; defaultValue: any; required: boolean; aliases?: string[]; hints?: string; overrides: string[]; hidden: boolean; spread: boolean; suggestionPriority: number; name: string; usageName: string; }[] | undefined; }; /** * Called by e.g. the WebSocket server to terminate persistent commands. */ terminate(): void; abstract action(params: CommandHandlerParams, ObjectFromSpecs>): Promise>; renderHelp(): string; } export declare class BuiltinCommandWrapper>>> extends CommandWrapper { wrapped: BuiltinCommand; name: string; help: string; constructor(wrapped: BuiltinCommand); action({ grow, log, args, opts, globalOpts, }: CommandHandlerParams, ObjectFromSpecs>): Promise>; } export declare class DeclaredCommandWrapper extends CommandWrapper { wrapped: DeclaredCommand; name: string; help: string; isCustom: boolean; allowUndefinedArguments: boolean; constructor(wrapped: DeclaredCommand); action({ grow, log, args, opts, }: CommandHandlerParams, ObjectFromSpecs>): Promise>; } type ParamSpecIsPlural, Plural extends Parameter> = T extends { many: true; } | { spread: true; } ? Plural : Singular; export type ParamSpecToParameterClass = T["type"] extends "string" ? ParamSpecIsPlural : T["type"] extends "integer" ? ParamSpecIsPlural : T["type"] extends "boolean" ? BooleanParameter : never; export type ParamSpecsToParameterClasses = { [K in keyof T]: ParamSpecToParameterClass; }; export type ParamSpecsToParameterObject = { [K in keyof KeyedBy]: ParamSpecToParameterClass[K]>; }; export declare function convertParameterSpecs(specs: readonly A[]): ParamSpecsToParameterObject; export declare function inferAssociatedActionName({ partnerAction, association, }: { partnerAction: DeclaredAction; association: DeclaredActionAssociation; }): void; export {};