Skip to content

Job application tracker and AI-powered job search assistant. Helps job seekers manage their search journey with AI resume review, job matching, task logging, and application analytics, all while keeping your data private.

feat(scraper): add the Ashby fetch adapter and mapper, and register Ashby across the model, schema, ATS registry and board URLs

Khuram Niaz3982e0592a6d
diff --git a/__tests__/ashby-fetch.spec.ts b/__tests__/ashby-fetch.spec.ts
new file mode 100644
index 0000000..7c80fd5
--- /dev/null
+++ b/__tests__/ashby-fetch.spec.ts
@@ -0,0 +1,195 @@
+import { fetchAshbyBoardJobs, searchAshbyJobs } from "@/lib/scraper/ashby";
+import { mapAshbyJob } from "@/lib/scraper/ashby/mapper";
+import type { AshbyJob } from "@/lib/scraper/ashby/types";
+
+function posting(overrides: Partial<AshbyJob> = {}): AshbyJob {
+ return {
+ id: "job-1",
+ title: "Backend Engineer",
+ jobUrl: "https://jobs.ashbyhq.com/acme/job-1",
+ ...overrides,
+ };
+}
+
+describe("mapAshbyJob", () => {
+ it("carries the company name from the caller (absent in the payload)", () => {
+ expect(mapAshbyJob(posting(), "Acme").company).toBe("Acme");
+ });
+
+ it("trims the leading whitespace Ashby ships on some titles", () => {
+ const job = mapAshbyJob(posting({ title: " Security Engineer" }), "Acme");
+ expect(job.title).toBe("Security Engineer");
+ });
+
+ it("joins the primary and secondary locations, deduped", () => {
+ const job = mapAshbyJob(
+ posting({
+ location: "New York, NY",
+ secondaryLocations: [
+ { location: "Remote (US)" },
+ { location: "New York, NY" },
+ {},
+ ],
+ }),
+ "Acme",
+ );
+ expect(job.location).toBe("New York, NY, Remote (US)");
+ });
+
+ it("prefers descriptionHtml and does not decode it", () => {
+ const job = mapAshbyJob(
+ posting({
+ descriptionHtml: "<p>Build &amp; ship</p>",
+ descriptionPlain: "Build & ship",
+ }),
+ "Acme",
+ );
+ expect(job.description).toBe("<p>Build &amp; ship</p>");
+ });
+
+ it("falls back to descriptionPlain when the HTML body is empty", () => {
+ const job = mapAshbyJob(
+ posting({ descriptionHtml: "", descriptionPlain: "Plain body" }),
+ "Acme",
+ );
+ expect(job.description).toBe("Plain body");
+ });
+
+ it("maps workplaceType, including OnSite (no hyphen, unlike Lever)", () => {
+ expect(mapAshbyJob(posting({ workplaceType: "Remote" }), "A").workplaceType).toBe("REMOTE");
+ expect(mapAshbyJob(posting({ workplaceType: "Hybrid" }), "A").workplaceType).toBe("HYBRID");
+ expect(mapAshbyJob(posting({ workplaceType: "OnSite" }), "A").workplaceType).toBe("ONSITE");
+ });
+
+ it("leaves workplaceType undefined for an unknown value", () => {
+ const job = mapAshbyJob(posting({ workplaceType: "Flexible" }), "Acme");
+ expect(job.workplaceType).toBeUndefined();
+ });
+
+ it("passes publishedAt through as the ISO postedDate", () => {
+ const job = mapAshbyJob(
+ posting({ publishedAt: "2026-04-07T17:12:35.753+00:00" }),
+ "Acme",
+ );
+ expect(job.postedDate).toBe("2026-04-07T17:12:35.753+00:00");
+ });
+
+ it("passes employmentType through untouched for normalizeJobType", () => {
+ const job = mapAshbyJob(posting({ employmentType: "Temporary" }), "Acme");
+ expect(job.employmentType).toBe("Temporary");
+ });
+
+ // Ashby sets isRemote on hybrid/on-site postings that merely offer a remote
+ // office, so mapping it would mislabel them REMOTE downstream.
+ it("does not carry isRemote", () => {
+ const job = mapAshbyJob(
+ { ...posting({ workplaceType: "Hybrid" }), isRemote: true } as AshbyJob,
+ "Acme",
+ );
+ expect(job.isRemote).toBeUndefined();
+ expect(job.workplaceType).toBe("HYBRID");
+ });
+});
+
+function okJson(body: unknown, status = 200) {
+ return {
+ ok: status >= 200 && status < 300,
+ status,
+ json: async () => body,
+ } as Response;
+}
+
+describe("fetchAshbyBoardJobs", () => {
+ afterEach(() => vi.restoreAllMocks());
+
+ it("fetches the whole board in one call (no pagination)", async () => {
+ const spy = vi
+ .spyOn(global, "fetch")
+ .mockResolvedValue(okJson({ jobs: [posting(), posting({ id: "job-2" })] }));
+
+ const result = await fetchAshbyBoardJobs("Acme", "acme");
+
+ expect(spy).toHaveBeenCalledTimes(1);
+ expect(String(spy.mock.calls[0][0])).toBe(
+ "https://api.ashbyhq.com/posting-api/job-board/acme",
+ );
+ expect(result.success).toBe(true);
+ if (!result.success) return;
+ expect(result.data).toHaveLength(2);
+ expect(result.data[0].company).toBe("Acme");
+ });
+
+ it("drops postings flagged isListed: false", async () => {
+ vi.spyOn(global, "fetch").mockResolvedValue(
+ okJson({
+ jobs: [posting({ isListed: true }), posting({ id: "j2", isListed: false })],
+ }),
+ );
+
+ const result = await fetchAshbyBoardJobs("Acme", "acme");
+ expect(result.success).toBe(true);
+ if (!result.success) return;
+ expect(result.data).toHaveLength(1);
+ });
+
+ it("returns a network error naming the token on 404", async () => {
+ vi.spyOn(global, "fetch").mockResolvedValue(okJson(null, 404));
+
+ const result = await fetchAshbyBoardJobs("Acme", "nope");
+ expect(result.success).toBe(false);
+ if (result.success) return;
+ expect(result.error.type).toBe("network");
+ expect(result.error).toMatchObject({ message: expect.stringContaining("nope") });
+ });
+
+ it("maps 429 to rate_limited, not a generic network error", async () => {
+ vi.spyOn(global, "fetch").mockResolvedValue(okJson(null, 429));
+
+ const result = await fetchAshbyBoardJobs("Acme", "acme");
+ expect(result.success).toBe(false);
+ if (result.success) return;
+ expect(result.error.type).toBe("rate_limited");
+ });
+
+ it("returns a parse error when jobs is not an array", async () => {
+ vi.spyOn(global, "fetch").mockResolvedValue(okJson({ jobs: "nope" }));
+
+ const result = await fetchAshbyBoardJobs("Acme", "acme");
+ expect(result.success).toBe(false);
+ if (result.success) return;
+ expect(result.error.type).toBe("parse");
+ });
+
+ it("reports a timeout as a network error", async () => {
+ const abort = Object.assign(new Error("aborted"), { name: "AbortError" });
+ vi.spyOn(global, "fetch").mockRejectedValue(abort);
+
+ const result = await fetchAshbyBoardJobs("Acme", "acme");
+ expect(result.success).toBe(false);
+ if (result.success) return;
+ expect(result.error).toMatchObject({ message: expect.stringContaining("timed out") });
+ });
+});
+
+describe("searchAshbyJobs", () => {
+ afterEach(() => vi.restoreAllMocks());
+
+ it("isolates a failing board: good jobs returned, bad token recorded", async () => {
+ vi.spyOn(global, "fetch").mockImplementation((input) =>
+ Promise.resolve(
+ String(input).endsWith("/bad")
+ ? okJson(null, 404)
+ : okJson({ jobs: [posting()] }),
+ ),
+ );
+
+ const { jobs, errors } = await searchAshbyJobs([
+ { name: "Good", token: "good" },
+ { name: "Bad", token: "bad" },
+ ]);
+
+ expect(jobs).toHaveLength(1);
+ expect(jobs[0].company).toBe("Good");
+ expect(errors).toEqual([{ token: "bad", reason: expect.stringContaining("bad") }]);
+ });
+});
diff --git a/__tests__/atsBoardUrl.spec.ts b/__tests__/atsBoardUrl.spec.ts
index d050d26..8779078 100644
--- a/__tests__/atsBoardUrl.spec.ts
+++ b/__tests__/atsBoardUrl.spec.ts
@@ -32,4 +32,16 @@ describe("companyBoardUrl", () => {
companyBoardUrl("greenhouse", { token: "acme", host: "eu" }),
).toBe(`${APP_CONSTANTS.GREENHOUSE_BOARD_URL}/acme`);
});
+
+ it("builds an Ashby board URL from the token", () => {
+ expect(companyBoardUrl("ashby", { token: "ramp" })).toBe(
+ `${APP_CONSTANTS.ASHBY_JOB_URL}/ramp`,
+ );
+ });
+
+ it("ignores host for Ashby boards (single global host)", () => {
+ expect(companyBoardUrl("ashby", { token: "ramp", host: "eu" })).toBe(
+ `${APP_CONSTANTS.ASHBY_JOB_URL}/ramp`,
+ );
+ });
});
diff --git a/__tests__/automationSourceConfig.schema.spec.ts b/__tests__/automationSourceConfig.schema.spec.ts
index c04b26d..154bcb4 100644
--- a/__tests__/automationSourceConfig.schema.spec.ts
+++ b/__tests__/automationSourceConfig.schema.spec.ts
@@ -83,4 +83,24 @@ describe("CreateAutomationSchema conditional validation", () => {
});
expect(result.success).toBe(false);
});
+
+ it("ashby requires at least one company", () => {
+ const result = CreateAutomationSchema.safeParse({
+ ...base,
+ jobBoard: "ashby",
+ sourceConfig: { ashby: { companies: [] } },
+ });
+ expect(result.success).toBe(false);
+ });
+
+ it("ashby passes with one company", () => {
+ const result = CreateAutomationSchema.safeParse({
+ ...base,
+ jobBoard: "ashby",
+ sourceConfig: {
+ ashby: { companies: [{ name: "Ramp", token: "ramp" }] },
+ },
+ });
+ expect(result.success).toBe(true);
+ });
});
diff --git a/src/components/automations/automation-wizard/wizardConfig.ts b/src/components/automations/automation-wizard/wizardConfig.ts
index 93a0cc3..6a8d63a 100644
--- a/src/components/automations/automation-wizard/wizardConfig.ts
+++ b/src/components/automations/automation-wizard/wizardConfig.ts
@@ -2,7 +2,7 @@ import { APP_CONSTANTS } from "@/lib/constants";
import type { CreateAutomationInput } from "@/models/automation.schema";
import type { AtsConfigValue } from "../AtsSearchStep";
-export type AtsKey = "greenhouse" | "lever";
+export type AtsKey = "greenhouse" | "lever" | "ashby";
export const EMPTY_ATS: AtsConfigValue = {
companies: [],
diff --git a/src/lib/atsBoardUrl.ts b/src/lib/atsBoardUrl.ts
index 0d360cc..c21067a 100644
--- a/src/lib/atsBoardUrl.ts
+++ b/src/lib/atsBoardUrl.ts
@@ -15,5 +15,8 @@ export function companyBoardUrl(
: APP_CONSTANTS.LEVER_JOB_URL;
return `${base}/${company.token}`;
}
+ if (jobBoard === "ashby") {
+ return `${APP_CONSTANTS.ASHBY_JOB_URL}/${company.token}`;
+ }
return `${APP_CONSTANTS.GREENHOUSE_BOARD_URL}/${company.token}`;
}
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
index 731110f..ad82295 100644
--- a/src/lib/constants.ts
+++ b/src/lib/constants.ts
@@ -123,6 +123,12 @@ export const APP_CONSTANTS = {
LEVER_FETCH_TIMEOUT_MS: 25_000, // wraps the WHOLE paginated loop per board
LEVER_FETCH_CONCURRENCY: 5,
+ // Ashby (public posting API — unauthenticated, whole board in one call)
+ ASHBY_BASE_URL: "https://api.ashbyhq.com/posting-api/job-board",
+ ASHBY_JOB_URL: "https://jobs.ashbyhq.com", // public board page (not API)
+ ASHBY_FETCH_TIMEOUT_MS: 25_000, // per-board AbortController timeout
+ ASHBY_FETCH_CONCURRENCY: 5,
+
// MCP server settings
MCP_DUPLICATE_WINDOW_DAYS: 30,
MCP_TOKEN_EXPIRY_PRESETS: [30, 90, 365] as const,
diff --git a/src/lib/scraper/ashby/index.ts b/src/lib/scraper/ashby/index.ts
new file mode 100644
index 0000000..f116773
--- /dev/null
+++ b/src/lib/scraper/ashby/index.ts
@@ -0,0 +1,98 @@
+import pLimit from "p-limit";
+import { APP_CONSTANTS } from "@/lib/constants";
+import type { JobDetails, ScraperResult } from "../types";
+import { errorReason } from "../utils";
+import type { AshbyBoardResponse } from "./types";
+import { mapAshbyJob } from "./mapper";
+
+// Fetch every listed posting for one board. Ashby returns the whole board in a
+// single response, so there is no pagination loop (unlike Lever).
+export async function fetchAshbyBoardJobs(
+ name: string,
+ token: string,
+): Promise<ScraperResult<JobDetails[]>> {
+ const controller = new AbortController();
+ const timer = setTimeout(
+ () => controller.abort(),
+ APP_CONSTANTS.ASHBY_FETCH_TIMEOUT_MS,
+ );
+
+ try {
+ const url = `${APP_CONSTANTS.ASHBY_BASE_URL}/${encodeURIComponent(token)}`;
+ const response = await fetch(url, { signal: controller.signal });
+
+ // 429 is distinct so the run surfaces the existing "rate limited" label.
+ if (response.status === 429) {
+ return { success: false, error: { type: "rate_limited" } };
+ }
+ if (!response.ok) {
+ return {
+ success: false,
+ error: {
+ type: "network",
+ message: `Board '${token}' returned ${response.status}`,
+ },
+ };
+ }
+
+ const data: AshbyBoardResponse = await response.json();
+ if (data.jobs !== undefined && !Array.isArray(data.jobs)) {
+ return {
+ success: false,
+ error: { type: "parse", message: `Board '${token}' malformed payload` },
+ };
+ }
+
+ // Company name isn't in the payload — carry it from the seed/user.
+ const jobs = (data.jobs ?? [])
+ .filter((job) => job.isListed !== false)
+ .map((job) => mapAshbyJob(job, name));
+
+ return { success: true, data: jobs };
+ } catch (error) {
+ if (error instanceof Error && error.name === "AbortError") {
+ return {
+ success: false,
+ error: { type: "network", message: `Board '${token}' timed out` },
+ };
+ }
+ const message = error instanceof Error ? error.message : "Unknown error";
+ return { success: false, error: { type: "network", message } };
+ } finally {
+ clearTimeout(timer);
+ }
+}
+
+// Fetch a watchlist in parallel (bounded concurrency) with per-token isolation.
+// Mirrors searchGreenhouseJobs / searchLeverJobs.
+export async function searchAshbyJobs(
+ companies: { name: string; token: string }[],
+): Promise<{ jobs: JobDetails[]; errors: { token: string; reason: string }[] }> {
+ const limit = pLimit(APP_CONSTANTS.ASHBY_FETCH_CONCURRENCY);
+
+ const settled = await Promise.allSettled(
+ companies.map(({ name, token }) =>
+ limit(() => fetchAshbyBoardJobs(name, token)),
+ ),
+ );
+
+ const jobs: JobDetails[] = [];
+ const errors: { token: string; reason: string }[] = [];
+
+ settled.forEach((result, index) => {
+ const token = companies[index].token;
+ if (result.status === "fulfilled") {
+ if (result.value.success) {
+ jobs.push(...result.value.data);
+ } else {
+ errors.push({ token, reason: errorReason(result.value.error) });
+ }
+ } else {
+ const reason =
+ result.reason instanceof Error ? result.reason.message : "Unknown error";
+ errors.push({ token, reason });
+ }
+ });
+
+ return { jobs, errors };
+}
diff --git a/src/lib/scraper/ashby/mapper.ts b/src/lib/scraper/ashby/mapper.ts
new file mode 100644
index 0000000..10600b8
--- /dev/null
+++ b/src/lib/scraper/ashby/mapper.ts
@@ -0,0 +1,44 @@
+import type { JobDetails } from "../types";
+import type { AshbyJob } from "./types";
+
+// Ashby's workplaceType → WORKPLACE_TYPES enum key. "OnSite" has no hyphen
+// here (Lever sends "on-site"), so the two adapters can't share one map.
+function mapAshbyWorkplace(raw?: string): string | undefined {
+ switch (raw?.toLowerCase()) {
+ case "remote":
+ return "REMOTE";
+ case "hybrid":
+ return "HYBRID";
+ case "onsite":
+ return "ONSITE";
+ default:
+ return undefined;
+ }
+}
+
+export function mapAshbyJob(job: AshbyJob, companyName: string): JobDetails {
+ // Join every office a posting is listed under so the strict-location gate
+ // can match any of them, not just the primary.
+ const locations = [
+ job.location,
+ ...(job.secondaryLocations ?? []).map((entry) => entry.location),
+ ]
+ .map((value) => value?.trim())
+ .filter((value): value is string => Boolean(value));
+
+ return {
+ title: (job.title ?? "").trim(),
+ company: companyName, // not in the payload
+ location: Array.from(new Set(locations)).join(", "),
+ // descriptionHtml is already real HTML (no entity pass), matching what
+ // Greenhouse stores post-decode, so the display path is unchanged.
+ description:
+ job.descriptionHtml?.trim() || job.descriptionPlain?.trim() || "",
+ url: job.jobUrl,
+ postedDate: job.publishedAt,
+ employmentType: job.employmentType,
+ // isRemote is deliberately unmapped: Ashby sets it true whenever a remote
+ // office is offered, so hybrid/on-site roles carry it too.
+ workplaceType: mapAshbyWorkplace(job.workplaceType),
+ };
+}
diff --git a/src/lib/scraper/ashby/types.ts b/src/lib/scraper/ashby/types.ts
new file mode 100644
index 0000000..3e17609
--- /dev/null
+++ b/src/lib/scraper/ashby/types.ts
@@ -0,0 +1,29 @@
+export interface AshbyJob {
+ id: string;
+ title?: string;
+ department?: string;
+ team?: string;
+ employmentType?: string; // FullTime | PartTime | Intern | Contract | Temporary
+ location?: string;
+ // Extra offices a posting is listed under; each carries its own location.
+ secondaryLocations?: { location?: string }[];
+ publishedAt?: string; // ISO 8601
+ isListed?: boolean;
+ // Note: the payload also carries `isRemote`, deliberately omitted — it is
+ // true on hybrid/on-site postings too. workplaceType is the remote signal.
+ workplaceType?: string; // Remote | Hybrid | OnSite
+ jobUrl: string;
+ applyUrl?: string;
+ descriptionHtml?: string; // already-decoded HTML, no entity pass needed
+ descriptionPlain?: string;
+}
+
+export interface AshbyBoardResponse {
+ jobs?: AshbyJob[];
+ apiVersion?: string;
+}
+
+export interface AshbyCompany {
+ name: string;
+ token: string;
+}
diff --git a/src/lib/scraper/ats/registry.ts b/src/lib/scraper/ats/registry.ts
index caa4d4a..83dd1a0 100644
--- a/src/lib/scraper/ats/registry.ts
+++ b/src/lib/scraper/ats/registry.ts
@@ -1,6 +1,7 @@
import type { JobBoard } from "@/models/automation.model";
import { searchGreenhouseJobs } from "../greenhouse";
import { searchLeverJobs } from "../lever";
+import { searchAshbyJobs } from "../ashby";
import type { AtsProvider } from "./types";
// Server-only: imports the real network-calling search fns (fetch, p-limit).
@@ -13,4 +14,5 @@ export const ATS_PROVIDERS: Partial<Record<JobBoard, AtsProvider>> = {
search: searchGreenhouseJobs,
},
lever: { id: "lever", label: "Lever", search: searchLeverJobs },
+ ashby: { id: "ashby", label: "Ashby", search: searchAshbyJobs },
};
diff --git a/src/lib/scraper/ats/types.ts b/src/lib/scraper/ats/types.ts
index 83035d2..26e64ae 100644
--- a/src/lib/scraper/ats/types.ts
+++ b/src/lib/scraper/ats/types.ts
@@ -6,8 +6,8 @@ import type { JobDetails } from "../types";
export type AtsHost = "default" | "eu";
export interface AtsProvider {
- id: JobBoard; // "greenhouse" | "lever"
- label: string; // "Greenhouse" | "Lever"
+ id: JobBoard;
+ label: string; // display name shown in the wizard/detail UI
// Fetch a watchlist with bounded concurrency + per-token isolation.
search(
companies: { name: string; token: string; host?: AtsHost }[],
diff --git a/src/lib/scraper/index.ts b/src/lib/scraper/index.ts
index a2d0000..9c737b7 100644
--- a/src/lib/scraper/index.ts
+++ b/src/lib/scraper/index.ts
@@ -7,6 +7,9 @@ export { flattenHtml, decodeHtml } from "./html";
export { fetchLeverBoardJobs, searchLeverJobs } from "./lever";
export { mapLeverJob } from "./lever/mapper";
export type { LeverPosting, LeverCompany, LeverHost } from "./lever/types";
+export { fetchAshbyBoardJobs, searchAshbyJobs } from "./ashby";
+export { mapAshbyJob } from "./ashby/mapper";
+export type { AshbyJob, AshbyCompany } from "./ashby/types";
export { ATS_PROVIDERS } from "./ats/registry";
export type { AtsProvider, AtsHost } from "./ats/types";
export { scoreJob, passesFloor, locationMatches } from "./ats/rank";
diff --git a/src/lib/scraper/utils.ts b/src/lib/scraper/utils.ts
index 3248f0a..803b0e1 100644
--- a/src/lib/scraper/utils.ts
+++ b/src/lib/scraper/utils.ts
@@ -1,7 +1,7 @@
import type { ScraperError } from "./types";
import { canonicalizeEntityValue } from "@/lib/jobs/canonicalize";
-// Allowlist for ATS board tokens (shared by Greenhouse + Lever). Rejects
+// Allowlist for ATS board tokens (shared by every ATS provider). Rejects
// path/query injection before the token is interpolated into a fetch URL.
export const ATS_TOKEN_REGEX = /^[a-z0-9][a-z0-9_-]{1,79}$/;
@@ -95,7 +95,7 @@ export function jobDedupeKey(job: DedupableJob): string {
}
// Removes jobs already saved (existingKeys) and collapses duplicates within the
-// batch itself. Both ATS source paths (Greenhouse, Lever) run through here.
+// batch itself. Every ATS source path runs through here.
// Accepts any key lookup with `.has` so callers can pass a Set or the
// getExistingJobDedupeMap Map directly.
export function dedupeJobs<T extends DedupableJob>(
diff --git a/src/models/automation.model.ts b/src/models/automation.model.ts
index 13d69cd..aa1d70b 100644
--- a/src/models/automation.model.ts
+++ b/src/models/automation.model.ts
@@ -11,7 +11,7 @@ export type AutomationRunStatus =
| "rate_limited"
| "cancelled";
export type DiscoveryStatus = "new" | "accepted" | "dismissed";
-export type JobBoard = "greenhouse" | "lever";
+export type JobBoard = "greenhouse" | "lever" | "ashby";
export interface GreenhouseCompany {
name: string;
@@ -42,15 +42,28 @@ export interface LeverSourceConfig
companies: LeverCompany[];
}
+// Ashby has a single global host, so its company entries are the plain
+// {name, token} shape — no `host`, unlike Lever.
+export interface AshbyCompany {
+ name: string;
+ token: string;
+}
+
+export interface AshbySourceConfig
+ extends Omit<GreenhouseSourceConfig, "companies"> {
+ companies: AshbyCompany[];
+}
+
export interface SourceConfig {
greenhouse?: GreenhouseSourceConfig;
lever?: LeverSourceConfig;
+ ashby?: AshbySourceConfig;
}
// Plain, dependency-free board list. Do NOT import this from ats/registry.ts
// (that pulls the network-calling search fns into client bundles). Both the
// client-imported schema and the scheduler import it here.
-export const ATS_BOARDS: JobBoard[] = ["greenhouse", "lever"];
+export const ATS_BOARDS: JobBoard[] = ["greenhouse", "lever", "ashby"];
// Boards that used to exist and were removed. Their Automation rows stay in
// the database; the UI marks them retired and only offers pause/delete.
diff --git a/src/models/automation.schema.ts b/src/models/automation.schema.ts
index 627f1a1..47f5157 100644
--- a/src/models/automation.schema.ts
+++ b/src/models/automation.schema.ts
@@ -4,7 +4,7 @@ import { APP_CONSTANTS } from "@/lib/constants";
// network code into the client bundle via this file's client consumers.
import { ATS_TOKEN_REGEX } from "@/lib/scraper/utils";
-export const JobBoardSchema = z.enum(["greenhouse", "lever"]);
+export const JobBoardSchema = z.enum(["greenhouse", "lever", "ashby"]);
export const AutomationStatusSchema = z.enum(["active", "paused"]);
@@ -50,9 +50,22 @@ export const LeverSourceConfigSchema = GreenhouseSourceConfigSchema.extend({
.max(APP_CONSTANTS.ATS_MAX_COMPANIES),
});
+// Same token allowlist as Lever (rejects path/query injection at the save
+// boundary); no `host` — Ashby is single-host.
+export const AshbyCompanySchema = GreenhouseCompanySchema.extend({
+ token: z.string().regex(ATS_TOKEN_REGEX),
+});
+
+export const AshbySourceConfigSchema = GreenhouseSourceConfigSchema.extend({
+ companies: z
+ .array(AshbyCompanySchema)
+ .max(APP_CONSTANTS.ATS_MAX_COMPANIES),
+});
+
export const SourceConfigSchema = z.object({
greenhouse: GreenhouseSourceConfigSchema.optional(),
lever: LeverSourceConfigSchema.optional(),
+ ashby: AshbySourceConfigSchema.optional(),
});
export const CreateAutomationSchema = z