feat: add support for indicating workplaceTypes (#296)

This commit is contained in:
Ryan Foote
2026-03-21 20:43:43 +00:00
committed by GitHub
parent 8274ec4e14
commit 0b22c08d7d
25 changed files with 497 additions and 5 deletions
+3
View File
@@ -32,6 +32,9 @@ export const manifest: ExtractorManifest = {
? parseInt(context.settings.jobspyResultsWanted, 10)
: undefined,
countryIndeed: context.settings.jobspyCountryIndeed,
workplaceTypes: context.settings.workplaceTypes
? JSON.parse(context.settings.workplaceTypes)
: undefined,
onProgress: (event) => {
if (context.shouldCancel?.()) return;
+13 -1
View File
@@ -128,6 +128,7 @@ export interface RunJobSpyOptions {
searchTerms?: string[];
location?: string;
locations?: string[];
workplaceTypes?: Array<"remote" | "hybrid" | "onsite">;
resultsWanted?: number;
hoursOld?: number;
countryIndeed?: string;
@@ -142,6 +143,14 @@ export interface JobSpyResult {
error?: string;
}
export function deriveIsRemoteFlag(
workplaceTypes: Array<"remote" | "hybrid" | "onsite"> | undefined,
): boolean | undefined {
return workplaceTypes?.length === 1 && workplaceTypes[0] === "remote"
? true
: undefined;
}
export async function runJobSpy(
options: RunJobSpyOptions = {},
): Promise<JobSpyResult> {
@@ -224,7 +233,10 @@ export async function runJobSpy(
"1",
),
JOBSPY_IS_REMOTE: String(
options.isRemote ?? process.env.JOBSPY_IS_REMOTE ?? "0",
options.isRemote ??
deriveIsRemoteFlag(options.workplaceTypes) ??
process.env.JOBSPY_IS_REMOTE ??
"0",
),
JOBSPY_OUTPUT_CSV: outputCsv,
JOBSPY_OUTPUT_JSON: outputJson,
+12 -1
View File
@@ -1,5 +1,5 @@
import { describe, expect, it } from "vitest";
import { parseJobSpyProgressLine } from "../src/run";
import { deriveIsRemoteFlag, parseJobSpyProgressLine } from "../src/run";
describe("parseJobSpyProgressLine", () => {
it("parses term_start progress lines", () => {
@@ -37,4 +37,15 @@ describe("parseJobSpyProgressLine", () => {
it("returns null for non-progress lines", () => {
expect(parseJobSpyProgressLine("Found 20 jobs")).toBeNull();
});
it("maps remote-only workplace types to isRemote", () => {
expect(deriveIsRemoteFlag(["remote"])).toBe(true);
});
it("does not force JobSpy remote filtering for hybrid or onsite selections", () => {
expect(deriveIsRemoteFlag(["hybrid"])).toBeUndefined();
expect(deriveIsRemoteFlag(["onsite"])).toBeUndefined();
expect(deriveIsRemoteFlag(["remote", "hybrid"])).toBeUndefined();
expect(deriveIsRemoteFlag(["remote", "hybrid", "onsite"])).toBeUndefined();
});
});