import { type InferRunTypes, type RunHandleFromTypes, type AnyTask, type TaskIdentifier, type TaskPayload, type TriggerOptions, type RealtimeRunSkipColumns } from "@trigger.dev/core/v3"; import { type UseApiClientOptions } from "./useApiClient.js"; import { type UseRealtimeRunInstance, type UseRealtimeRunWithStreamsInstance } from "./useRealtime.js"; /** * Base interface for task trigger instances. * * @template TTask - The type of the task */ export interface TriggerInstance { /** Function to submit the task with a payload */ submit: (payload: TaskPayload, options?: TriggerOptions) => void; /** Whether the task is currently being submitted */ isLoading: boolean; /** The handle returned after successful task submission */ handle?: RunHandleFromTypes>; /** Any error that occurred during submission */ error?: Error; } export type UseTaskTriggerOptions = UseApiClientOptions; /** * Hook to trigger a task and manage its initial execution state. * * @template TTask - The type of the task * @param {TaskIdentifier} id - The identifier of the task to trigger * @param {UseTaskTriggerOptions} [options] - Configuration options for the task trigger * @returns {TriggerInstance} An object containing the submit function, loading state, handle, and any errors * * @example * ```ts * import type { myTask } from './path/to/task'; * const { submit, isLoading, handle, error } = useTaskTrigger('my-task-id'); * * // Submit the task with payload * submit({ foo: 'bar' }); * ``` */ export declare function useTaskTrigger(id: TaskIdentifier, options?: UseTaskTriggerOptions): TriggerInstance; /** * Configuration options for task triggers with realtime updates. */ export type UseRealtimeTaskTriggerOptions = UseTaskTriggerOptions & { /** Whether the realtime subscription is enabled */ enabled?: boolean; /** Optional throttle time in milliseconds for stream updates */ experimental_throttleInMs?: number; /** * Skip columns from the subscription. * * @default [] */ skipColumns?: RealtimeRunSkipColumns; }; export type RealtimeTriggerInstanceWithStreams = Record> = UseRealtimeRunWithStreamsInstance & { submit: (payload: TaskPayload, options?: TriggerOptions) => void; isLoading: boolean; handle?: RunHandleFromTypes>; }; /** * Hook to trigger a task and subscribe to its realtime updates including stream data. * * @template TTask - The type of the task * @template TStreams - The type of the streams data * @param {TaskIdentifier} id - The identifier of the task to trigger * @param {UseRealtimeTaskTriggerOptions} [options] - Configuration options for the task trigger and realtime updates * @returns {RealtimeTriggerInstanceWithStreams} An object containing the submit function, loading state, * handle, run state, streams data, and error handling * * @example * ```ts * import type { myTask } from './path/to/task'; * const { submit, run, streams, error } = useRealtimeTaskTriggerWithStreams< * typeof myTask, * { output: string } * >('my-task-id'); * * // Submit and monitor the task with streams * submit({ foo: 'bar' }); * ``` */ export declare function useRealtimeTaskTriggerWithStreams = Record>(id: TaskIdentifier, options?: UseRealtimeTaskTriggerOptions): RealtimeTriggerInstanceWithStreams; export type RealtimeTriggerInstance = UseRealtimeRunInstance & { submit: (payload: TaskPayload, options?: TriggerOptions) => void; isLoading: boolean; handle?: RunHandleFromTypes>; }; /** * Hook to trigger a task and subscribe to its realtime updates. * * @template TTask - The type of the task * @param {TaskIdentifier} id - The identifier of the task to trigger * @param {UseRealtimeTaskTriggerOptions} [options] - Configuration options for the task trigger and realtime updates * @returns {RealtimeTriggerInstance} An object containing the submit function, loading state, * handle, run state, and error handling * * @example * ```ts * import type { myTask } from './path/to/task'; * const { submit, run, error, stop } = useRealtimeTaskTrigger('my-task-id'); * * // Submit and monitor the task * submit({ foo: 'bar' }); * * // Stop monitoring when needed * stop(); * ``` */ export declare function useRealtimeTaskTrigger(id: TaskIdentifier, options?: UseRealtimeTaskTriggerOptions): RealtimeTriggerInstance;