UNPKG

typed-tasks

Version:

A type-safe abstraction for Google Cloud Tasks

20 lines 1.01 kB
import type { CloudTasksClient } from "@google-cloud/tasks"; import type { z } from "zod"; import type { TaskRegistry } from "./task-registry"; import type { ExtractSchema, TaskDefinitionRecord } from "./types"; /** * Creates a factory function that produces type-safe task schedulers for * specific tasks * * @param tasksClient - Google Cloud Tasks client * @param projectId - Google Cloud project ID * @param region - GCP region for the Cloud Tasks * @param taskRegistry - Registry containing task configurations from task * definitions * @returns A factory function for creating task schedulers */ export declare function createSchedulerFactory<Defs extends TaskDefinitionRecord<string>>(tasksClient: CloudTasksClient, projectId: string, region: string, taskRegistry: TaskRegistry): <T extends keyof Defs & string>(queueName: T) => (data: z.infer<ExtractSchema<Defs[T]>>, options?: { taskName?: string; delaySeconds?: number; }) => Promise<void>; //# sourceMappingURL=scheduler.d.ts.map