import { Run } from "airplane/api"; import { DefaultOutput, DefaultParams, ParamValues } from "../client"; import { MutationHookOptions } from "../state"; import { RunbookMutationHookOptions } from "../state/tasks/useRunbookMutation"; import { UseTaskQueryOptions } from "../state/tasks/useTaskQuery"; export type AirplaneFunc = (paramValues: TParams) => Promise>; /** * FullQuery is a query that uses an airplane function or a slug. It is always * an object and does not include the shorthands of just slug or just function. */ export type FullQuery = FunctionQuery | SlugQuery; /** FunctionQuery is a query that takes an airplane function and params. */ export type FunctionQuery = (Record extends TParams ? { /** * A function returned by airplane.task to execute. * @example * // myTask can be used as fn. * const myTask = airplane.task(async (params) => {... */ fn: AirplaneFunc; params?: TParams; slug?: never; } : { /** * A function returned by airplane.task to execute. * @example * // myTask can be used as fn. * const myTask = airplane.task(async (params) => {... */ fn: AirplaneFunc; params: TParams; slug?: never; }) & UseTaskQueryOptions; /** SlugQuery is a query that takes a slug and params. */ export type SlugQuery = { /** The slug of the task to execute. */ slug: string; fn?: never; } & UseTaskQueryOptions; /** * TaskQuery is a query that uses an airplane function or a slug. If the task's * parameters are optional then it can take a shorthand of a string slug or a function. */ export type TaskQuery = SlugQuery | string | FunctionQuery | (Record extends TParams ? AirplaneFunc : never); /** * getFullQuery gets a FullQuery given a TaskQuery. It converts shorthands (just string or function) * to their full form. */ export declare function getFullQuery(q: TaskQuery): FullQuery; /** * FullMutation is a mutation that uses an airplane function or a slug. It is always * an object and does not include the shorthands of just slug or just function. */ export type FullMutation = FunctionMutation | SlugMutation; /** FunctionMutation is a mutation that takes an airplane function and params. */ export type FunctionMutation = (Record extends TParams ? { /** * A function returned by airplane.task to execute. * @example * // myTask can be used as fn. * const myTask = airplane.task(async (params) => {... */ fn: AirplaneFunc; params?: TParams; slug?: never; } : { /** * A function returned by airplane.task to execute. * @example * // myTask can be used as fn. * const myTask = airplane.task(async (params) => {... */ fn: AirplaneFunc; params: TParams; slug?: never; }) & MutationHookOptions; /** SlugMutation is a mutation that takes a slug and params. */ export type SlugMutation = { /** The slug of the task to execute. */ slug: string; } & MutationHookOptions; /** * TaskMutation is a mutation that uses an airplane function or a slug. If the task's * parameters are optional then it can take a shorthand of a string slug or a function. */ export type TaskMutation = SlugMutation | string | FunctionMutation | (Record extends TParams ? AirplaneFunc : never); /** * getFullMutation gets a FullMutation given a TaskMutation. * It converts shorthands (just string or function) to their full form. */ export declare function getFullMutation(m: TaskMutation): FullMutation; /** * getSlug takes a full query or mutation and returns the task slug. */ export declare function getSlug(fullQuery: FullQuery | FullMutation): string; /** * getRunbookFullMutation gets a RunbookFullMutation given a RunbookMutation. * It converts a shorthand string slug into the full runbook form. */ export declare function getRunbookFullMutation(m: RunbookMutation): RunbookFullMutation; /** 4XX errors from executing task or runbook (except for 403 missing execute permissions) */ type ClientExecuteError = { message: string; type: "CLIENT_ERROR"; }; /** All other API errors (403 and 5XX errors) */ type InternalExecuteError = { message: string; type: "AIRPLANE_INTERNAL"; }; /** Run/session failure errors */ type FailedExecuteError = { message: string; type: "FAILED"; }; export type ExecuteError = ClientExecuteError | InternalExecuteError | FailedExecuteError; export type RunbookSlugMutation = { slug: string; } & RunbookMutationHookOptions; export type RunbookFullMutation = RunbookSlugMutation; export type RunbookMutation = RunbookSlugMutation | string; export type RefetchQuery = { slug: string; params?: ParamValues; } | string | { fn: AirplaneFunc; params?: ParamValues; } | AirplaneFunc; export {};