Skip to content

Commit

Permalink
identifier/payload type for DbJobSpec
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Jan 17, 2024
1 parent b050c84 commit 68c5d9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion __tests__/runner.helpers.getTaskName.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Pool, PoolClient } from "pg";

import { DbJobSpec, Job, Runner, RunnerOptions } from "../src/interfaces";
import { DbJobSpec, Runner, RunnerOptions } from "../src/interfaces";
import { run } from "../src/runner";
import {
ESCAPED_GRAPHILE_WORKER_SCHEMA,
Expand Down
10 changes: 7 additions & 3 deletions src/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -526,9 +526,13 @@ export interface TaskSpec {
}

/** Equivalent of graphile_worker.job_spec DB type */
export interface DbJobSpec {
identifier: string;
payload?: Record<string, any>;
export interface DbJobSpec<
TIdentifier extends keyof GraphileWorker.Tasks | (string & {}) = string,
> {
identifier: TIdentifier;
payload: TIdentifier extends keyof GraphileWorker.Tasks
? GraphileWorker.Tasks[TIdentifier]
: unknown;
queue_name?: string | null;
run_at?: string | null;
max_attempts?: number | null;
Expand Down

0 comments on commit 68c5d9f

Please sign in to comment.