import type { FailedRunNotification, IntegrationConfig, InvokeOptions, JobMetadata, Prettify, RunNotification, SuccessfulRunNotification } from "@systemfsoftware/trigger.dev_core-v2"; import type { LogLevel } from "@systemfsoftware/trigger.dev_core-backend"; import { ConcurrencyLimit } from "./concurrencyLimit.js"; import type { IOWithIntegrations, TriggerIntegration } from "./integrations.js"; import { TriggerClient } from "./triggerClient.js"; import type { EventSpecification, Trigger, TriggerContext, TriggerEventType, TriggerInvokeType } from "./types.js"; export type { FailedRunNotification, IntegrationConfig, InvokeOptions, JobMetadata, Prettify, RunNotification, SuccessfulRunNotification, } from "@systemfsoftware/trigger.dev_core-v2"; export type JobOptions>, TIntegrations extends Record = {}, TOutput extends any = any> = { /** The `id` property is used to uniquely identify the Job. Only change this if you want to create a new Job. */ id: string; /** The `name` of the Job that you want to appear in the dashboard and logs. You can change this without creating a new Job. */ name: string; /** The `version` property is used to version your Job. A new version will be created if you change this property. We recommend using [semantic versioning](https://www.baeldung.com/cs/semantic-versioning), e.g. `1.0.3`. */ version: string; /** The `trigger` property is used to define when the Job should run. There are currently the following Trigger types: - [cronTrigger](https://trigger.dev/docs/sdk/crontrigger) - [intervalTrigger](https://trigger.dev/docs/sdk/intervaltrigger) - [eventTrigger](https://trigger.dev/docs/sdk/eventtrigger) - [DynamicTrigger](https://trigger.dev/docs/sdk/dynamictrigger) - [DynamicSchedule](https://trigger.dev/docs/sdk/dynamicschedule) - integration Triggers, like webhooks. See the [integrations](https://trigger.dev/docs/integrations) page for more information. */ trigger: TTrigger; /** The `logLevel` property is an optional property that specifies the level of logging for the Job. The level is inherited from the client if you omit this property. */ logLevel?: LogLevel; /** Imports the specified integrations into the Job. The integrations will be available on the `io` object in the `run()` function with the same name as the key. For example: ```ts client.defineJob({ //... other options integrations: { slack, gh: github, }, run: async (payload, io, ctx) => { //slack is available on io.slack io.slack.postMessage(...); //github is available on io.gh io.gh.addIssueLabels(...); } }); ``` */ integrations?: TIntegrations; /** * The `concurrencyLimit` property is used to limit the number of concurrent run executions of a job. * Can be a number which represents the limit or a `ConcurrencyLimit` instance which can be used to * group together multiple jobs to share the same concurrency limit. * * If undefined the job will be limited only by the server's global concurrency limit, or if you are using the * Trigger.dev Cloud service, the concurrency limit of your plan. */ concurrencyLimit?: number | ConcurrencyLimit; /** The `enabled` property is used to enable or disable the Job. If you disable a Job, it will not run. */ enabled?: boolean; /** This function gets called automatically when a Run is Triggered. * This is where you put the code you want to run for a Job. You can use normal code in here and you can also use Tasks. You can return a value from this function and it will be sent back to the Trigger API. * @param payload The payload of the event * @param io An object that contains the integrations that you specified in the `integrations` property and other useful functions like delays and running Tasks. * @param context An object that contains information about the Organization, Job, Run and more. */ run: (payload: TriggerEventType, io: IOWithIntegrations, context: TriggerContext) => Promise; onSuccess?: (notification: SuccessfulRunNotification>) => void; onFailure?: (notification: FailedRunNotification>) => void; }; export type JobPayload = TJob extends Job>, any> ? TEvent : never; export type JobIO = TJob extends Job ? IOWithIntegrations : never; /** A [Job](https://trigger.dev/docs/documentation/concepts/jobs) is used to define the [Trigger](https://trigger.dev/docs/documentation/concepts/triggers), metadata, and what happens when it runs. */ export declare class Job>, TIntegrations extends Record = {}, TOutput extends any = any> { #private; readonly options: JobOptions; client?: TriggerClient; constructor(options: JobOptions); /** * Attaches the job to a client. This is called automatically when you define a job using `client.defineJob()`. */ attachToClient(client: TriggerClient): this; get id(): string; get enabled(): boolean; get name(): string; get trigger(): TTrigger; get version(): string; get logLevel(): LogLevel | undefined; get integrations(): Record; toJSON(): JobMetadata; invoke(cacheKey: string, payload: TriggerInvokeType, options?: InvokeOptions): Promise<{ id: string; }>; invoke(payload: TriggerInvokeType, options?: InvokeOptions): Promise<{ id: string; }>; invokeAndWaitForCompletion(cacheKey: string | string[], payload: TriggerInvokeType, timeoutInSeconds?: number, // 1 hour options?: Prettify>): Promise>; batchInvokeAndWaitForCompletion(cacheKey: string | string[], batch: Array<{ payload: TriggerInvokeType; timeoutInSeconds?: number; options?: Prettify>; }>): Promise>>; } //# sourceMappingURL=job.d.ts.map