import { type ApiClientConfiguration, RealtimeRunSkipColumns } from "@trigger.dev/core/v3"; /** * Register the global API client configuration. Alternatively, you can set the `TRIGGER_SECRET_KEY` and `TRIGGER_API_URL` environment variables. * @param options The API client configuration. * @param options.baseURL The base URL of the Trigger API. (default: `https://api.trigger.dev`) * @param options.accessToken The accessToken to authenticate with the Trigger API. (default: `process.env.TRIGGER_SECRET_KEY`) This can be found in your Trigger.dev project "API Keys" settings. * * @example * * ```typescript * import { configure } from "@trigger.dev/sdk/v3"; * * configure({ * baseURL: "https://api.trigger.dev", * accessToken: "tr_dev_1234567890" * }); * ``` */ export declare function configure(options: ApiClientConfiguration): void; export declare const auth: { configure: typeof configure; createPublicToken: typeof createPublicToken; createTriggerPublicToken: typeof createTriggerPublicToken; createBatchTriggerPublicToken: typeof createBatchTriggerPublicToken; withAuth: typeof withAuth; withPublicToken: typeof withPublicToken; withTriggerPublicToken: typeof withTriggerPublicToken; withBatchTriggerPublicToken: typeof withBatchTriggerPublicToken; }; type PublicTokenPermissionProperties = { /** * Grant access to specific tasks */ tasks?: string | string[]; /** * Grant access to specific run tags */ tags?: string | string[]; /** * Grant access to specific runs */ runs?: string | string[] | true; /** * Grant access to specific batch runs */ batch?: string | string[]; /** * Grant access to specific waitpoints */ waitpoints?: string | string[]; /** * Grant access to send data to input streams on specific runs */ inputStreams?: string | string[]; }; export type PublicTokenPermissions = { read?: PublicTokenPermissionProperties; write?: PublicTokenPermissionProperties; /** * Use auth.createTriggerPublicToken */ trigger?: { tasks: string | string[]; }; /** * Use auth.createBatchTriggerPublicToken */ batchTrigger?: { tasks: string | string[]; }; }; export type CreatePublicTokenOptions = { /** * A collection of permission scopes to be granted to the token. * * @example * * ```typescript * scopes: { * read: { * tags: ["file:1234"] * } * } * ``` */ scopes?: PublicTokenPermissions; /** * The expiration time for the token. This can be a number representing the time in milliseconds, a `Date` object, or a string. * * @example * * ```typescript * expirationTime: "1h" * ``` */ expirationTime?: number | Date | string; realtime?: { /** * Skip columns from the subscription. * * @default [] * * @example * ```ts * auth.createPublicToken({ * realtime: { * skipColumns: ["payload", "output"] * } * }); * ``` */ skipColumns?: RealtimeRunSkipColumns; }; }; /** * Creates a public token using the provided options. * * @param options - Optional parameters for creating the public token. * @param options.scopes - An array of permission scopes to be included in the token. * @param options.expirationTime - The expiration time for the token. * @param options.realtime - Options for realtime subscriptions. * @param options.realtime.skipColumns - Skip columns from the subscription. * @returns A promise that resolves to a string representing the generated public token. * * @example * * ```typescript * import { auth } from "@trigger.dev/sdk/v3"; * * const publicToken = await auth.createPublicToken({ * scopes: { * read: { * tags: ["file:1234"] * } * }); * ``` */ declare function createPublicToken(options?: CreatePublicTokenOptions): Promise; /** * Executes a function with a public token, providing temporary access permissions. * * @param options - Options for creating the public token. * @param fn - The asynchronous function to be executed with the public token. */ declare function withPublicToken(options: CreatePublicTokenOptions, fn: () => Promise): Promise; export type CreateTriggerTokenOptions = { /** * The expiration time for the token. This can be a number representing the time in milliseconds, a `Date` object, or a string. * * @example * * ```typescript * expirationTime: "1h" * ``` */ expirationTime?: number | Date | string; /** * Whether the token can be used multiple times. By default trigger tokens are one-time use. * @default false */ multipleUse?: boolean; realtime?: { /** * Skip columns from the subscription. * * @default [] * * @example * ```ts * auth.createTriggerPublicToken("my-task", { * realtime: { * skipColumns: ["payload", "output"] * } * }); * ``` */ skipColumns?: RealtimeRunSkipColumns; }; }; /** * Creates a one-time use token to trigger a specific task. * * @param task - The task ID or an array of task IDs that the token should allow triggering. * @param options - Options for creating the one-time use token. * @returns A promise that resolves to a string representing the generated one-time use token. * * @example * Create a one-time use public token that allows triggering a specific task: * * ```ts * import { auth } from "@trigger.dev/sdk/v3"; * * const token = await auth.createTriggerPublicToken("my-task"); * ``` * * @example You can also create a one-time use token that allows triggering multiple tasks: * * ```ts * import { auth } from "@trigger.dev/sdk/v3"; * * const token = await auth.createTriggerPublicToken(["task1", "task2"]); * ``` * * @example You can also create a one-time use token that allows triggering a task with a specific expiration time: * * ```ts * import { auth } from "@trigger.dev/sdk/v3"; * * const token = await auth.createTriggerPublicToken("my-task", { expirationTime: "1h" }); * ``` */ declare function createTriggerPublicToken(task: string | string[], options?: CreateTriggerTokenOptions): Promise; /** * Executes a function with a one-time use token that allows triggering a specific task. * * @param task - The task ID or an array of task IDs that the token should allow triggering. * @param options - Options for creating the one-time use token. * @param fn - The asynchronous function to be executed with the one-time use token. */ declare function withTriggerPublicToken(task: string | string[], options: CreateTriggerTokenOptions | undefined, fn: () => Promise): Promise; /** * Creates a one-time use token to batch trigger a specific task or tasks. * * @param task - The task ID or an array of task IDs that the token should allow triggering. * @param options - Options for creating the one-time use token. * @returns A promise that resolves to a string representing the generated one-time use token. * * @example * * ```ts * import { auth } from "@trigger.dev/sdk/v3"; * * const token = await auth.createBatchTriggerPublicToken("my-task"); * ``` * * @example You can also create a one-time use token that allows batch triggering multiple tasks: * * ```ts * import { auth } from "@trigger.dev/sdk/v3"; * * const token = await auth.createBatchTriggerPublicToken(["task1", "task2"]); * ``` * * @example You can also create a one-time use token that allows batch triggering a task with a specific expiration time: * * ```ts * import { auth } from "@trigger.dev/sdk/v3"; * * const token = await auth.createBatchTriggerPublicToken("my-task", { expirationTime: "1h" }); * ``` */ declare function createBatchTriggerPublicToken(task: string | string[], options?: CreateTriggerTokenOptions): Promise; /** * Executes a function with a one-time use token that allows triggering a specific task. * * @param task - The task ID or an array of task IDs that the token should allow triggering. * @param options - Options for creating the one-time use token. * @param fn - The asynchronous function to be executed with the one-time use token. */ declare function withBatchTriggerPublicToken(task: string | string[], options: CreateTriggerTokenOptions | undefined, fn: () => Promise): Promise; /** * Executes a provided asynchronous function with a specified API client configuration. * * @template R - The type of the asynchronous function to be executed. * @param {ApiClientConfiguration} config - The configuration for the API client. * @param {R} fn - The asynchronous function to be executed. * @returns {Promise>} A promise that resolves to the return type of the provided function. */ declare function withAuth Promise>(config: ApiClientConfiguration, fn: R): Promise>; export {};