linkedin-relay-mcp 3.10.1 → 3.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/skills/linkedin-relay/SKILL.md +19 -9
- package/dist/cli.js +244 -84
- package/dist/cli.js.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/dist/mcp-shim.js +251 -88
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
|
@@ -59,20 +59,27 @@ Out-of-network people come back as `name: "LinkedIn Member"` with a `/headless`
|
|
|
59
59
|
LinkedIn behaviour, not a bug — LinkedIn will not name them to this account. Say so rather than
|
|
60
60
|
presenting it as a data problem.
|
|
61
61
|
|
|
62
|
-
### `jobs` — 1 job-search call per
|
|
62
|
+
### `jobs` — 1 job-search call per 100 results. Job search with every filter.
|
|
63
63
|
```
|
|
64
|
-
jobs keywords:"<terms>" [location:"<place>" | geoId:"<id>"] [distance:<miles>]
|
|
64
|
+
jobs keywords:"<terms>" | ["<terms>", "<terms>", …] [location:"<place>" | geoId:"<id>"] [distance:<miles>]
|
|
65
65
|
[posted:"24h|week|month|<N>h|<N>d"] [experience:[internship|entry|associate|mid-senior|director|executive]]
|
|
66
66
|
[type:[full-time|part-time|contract|temporary|volunteer|internship|other]]
|
|
67
67
|
[workplace:[on-site|remote|hybrid]] [easyApply] [under10] [verified] [inNetwork] [fairChance]
|
|
68
68
|
[company|industry|function|title|place:[ids]] [filter:["key=v1,v2"]] [sort:recent|relevant]
|
|
69
|
-
[limit:1-
|
|
69
|
+
[limit:1-1000 per keyword set] [start:N] [details] [description] [compact]
|
|
70
70
|
```
|
|
71
71
|
Each item: `id`, `title`, `company`, `location`, `workplace`, `listed` (YYYY-MM-DD), `easyApply`,
|
|
72
72
|
`promoted`, `salary` (when the card shows one), `insights`, `url`. `compact` gives one line per job.
|
|
73
73
|
|
|
74
|
-
- **
|
|
75
|
-
|
|
74
|
+
- **Several keyword sets in one call.** Pass `keywords` as a list: each set is searched with the
|
|
75
|
+
same filters, and the results are merged by job id. A job found by several sets comes back once,
|
|
76
|
+
with `matched` naming them; the most-matched come first. Treat that order as a hint, not a
|
|
77
|
+
ranking: LinkedIn matches keywords loosely ("AI agent developer" returns plain frontend jobs),
|
|
78
|
+
so a generic job can match every set. Rank on title and company.
|
|
79
|
+
`meta.searches` has each set's total, count, state and `next`; `meta.duplicates` is how many
|
|
80
|
+
repeats were merged. One set failing leaves the others, with `state: "failed"` in its entry.
|
|
81
|
+
- **Rank on the rows, then read the finalists with `job`.** `details` reads every row in full, 100
|
|
82
|
+
per job read, to add the apply link, applicants and employment type.
|
|
76
83
|
- **Check `data.location`.** A typed location is resolved by LinkedIn, and the place it chose is
|
|
77
84
|
reported there. "Vienna, Austria" resolved to one district of Vienna. Pass `geoId` for an exact
|
|
78
85
|
place; ids are in `job_filters` under `populatedPlace`.
|
|
@@ -80,13 +87,16 @@ Each item: `id`, `title`, `company`, `location`, `workplace`, `listed` (YYYY-MM-
|
|
|
80
87
|
batch, and `meta.state` is `complete` only when the results ran out. LinkedIn serves at most 1000
|
|
81
88
|
per search; narrow the query rather than paging deep.
|
|
82
89
|
- Job hunting has its own budget: 150 job-search calls and 60 job reads a day, apart from the
|
|
83
|
-
people and company `search`.
|
|
84
|
-
|
|
90
|
+
people and company `search`. A search call returns 100 jobs, so ten keyword sets of a few
|
|
91
|
+
hundred results each take about 30 calls. Reposts and recruiter copies of one role carry
|
|
92
|
+
different ids, so they are not merged: judge those by company, title and description.
|
|
85
93
|
|
|
86
|
-
### `job` — 1 job read.
|
|
94
|
+
### `job` — 1 job read per 100 jobs. Jobs, in full.
|
|
87
95
|
```
|
|
88
|
-
job job:"<id | /jobs/view/ URL | ?currentJobId= URL>"
|
|
96
|
+
job job:"<id | /jobs/view/ URL | ?currentJobId= URL>" or job job:["<id>", "<id>", …]
|
|
89
97
|
```
|
|
98
|
+
One id returns the job; a list returns `{items, meta}`, read 100 per call, so pass all your finalists
|
|
99
|
+
at once rather than one call each. `meta.unread` lists ids LinkedIn did not return.
|
|
90
100
|
`description`, `apply: {type: "external" | "easy-apply", url}`, `company`, `companyUrl`,
|
|
91
101
|
`location`, `workplace`, `employmentType`, `experienceLevel`, `industries`, `functions`, `listed`,
|
|
92
102
|
`expires`, `state` (`LISTED` or `CLOSED`), `applicants`, `ats` (the employer's applicant tracking
|
package/dist/cli.js
CHANGED
|
@@ -2907,7 +2907,8 @@ function contract(name) {
|
|
|
2907
2907
|
if (c?.decorationId === void 0) throw new Error(`job contract '${name}' is missing`);
|
|
2908
2908
|
return { path: c.path, decorationId: c.decorationId };
|
|
2909
2909
|
}
|
|
2910
|
-
var PAGE_SIZE2 =
|
|
2910
|
+
var PAGE_SIZE2 = 100;
|
|
2911
|
+
var BATCH_SIZE = 100;
|
|
2911
2912
|
function queryTuple(q2) {
|
|
2912
2913
|
const locationUnion = q2.geoId !== void 0 ? { geoId: q2.geoId } : q2.location !== void 0 ? { seoLocation: { location: q2.location } } : void 0;
|
|
2913
2914
|
const selected = Object.entries(q2.filters).filter(([, v]) => v.length > 0);
|
|
@@ -2931,6 +2932,10 @@ function jobDetailUrl(id) {
|
|
|
2931
2932
|
const c = contract("jobPosting");
|
|
2932
2933
|
return `${c.path}/${id}?decorationId=${c.decorationId}`;
|
|
2933
2934
|
}
|
|
2935
|
+
function jobBatchUrl(ids) {
|
|
2936
|
+
const c = contract("jobPosting");
|
|
2937
|
+
return `${c.path}?ids=List(${ids.join(",")})&decorationId=${c.decorationId}`;
|
|
2938
|
+
}
|
|
2934
2939
|
function jobIdOf(input) {
|
|
2935
2940
|
const s = input.trim();
|
|
2936
2941
|
if (/^\d+$/.test(s)) return s;
|
|
@@ -3039,7 +3044,7 @@ function parseJobCards(json) {
|
|
|
3039
3044
|
return { ok: true, jobs, total, start, ...resolvedGeo(included), unknownTypes };
|
|
3040
3045
|
}
|
|
3041
3046
|
var WORKPLACE_URN = { "1": "on-site", "2": "remote", "3": "hybrid" };
|
|
3042
|
-
function applyOf(method) {
|
|
3047
|
+
function applyOf(method, id) {
|
|
3043
3048
|
const m = method;
|
|
3044
3049
|
if (m === null || m === void 0) return void 0;
|
|
3045
3050
|
const type = String(m.$type ?? "");
|
|
@@ -3048,19 +3053,15 @@ function applyOf(method) {
|
|
|
3048
3053
|
return defined2({ type: "external", url });
|
|
3049
3054
|
}
|
|
3050
3055
|
if (type.endsWith("OnsiteApply")) {
|
|
3051
|
-
const url = typeof m.easyApplyUrl === "string" ? m.easyApplyUrl :
|
|
3052
|
-
return
|
|
3056
|
+
const url = typeof m.easyApplyUrl === "string" ? m.easyApplyUrl : viewUrl(id);
|
|
3057
|
+
return { type: "easy-apply", url };
|
|
3053
3058
|
}
|
|
3054
3059
|
return void 0;
|
|
3055
3060
|
}
|
|
3056
|
-
function
|
|
3057
|
-
const
|
|
3058
|
-
const d = root?.data;
|
|
3059
|
-
const rawId = d?.jobPostingId ?? d?.entityUrn;
|
|
3061
|
+
function postingToJob(d, included) {
|
|
3062
|
+
const rawId = d.jobPostingId ?? d.entityUrn;
|
|
3060
3063
|
const id = rawId === void 0 ? void 0 : jobIdOf(String(rawId));
|
|
3061
|
-
if (
|
|
3062
|
-
return drift2("the job response carried no posting");
|
|
3063
|
-
const included = root?.included ?? [];
|
|
3064
|
+
if (id === void 0 || typeof d.title !== "string") return void 0;
|
|
3064
3065
|
const find = (urn) => typeof urn === "string" ? included.find((n) => n.entityUrn === urn) : void 0;
|
|
3065
3066
|
const details = d.companyDetails ?? {};
|
|
3066
3067
|
const company = find(details.company ?? details["*companyResolutionResult"]);
|
|
@@ -3070,31 +3071,53 @@ function parseJobDetail(json) {
|
|
|
3070
3071
|
const applying = find(d["*applyingInfo"]);
|
|
3071
3072
|
const saving = find(d["*savingInfo"]);
|
|
3072
3073
|
const list2 = (v) => Array.isArray(v) && v.length > 0 ? v.filter((x) => typeof x === "string") : void 0;
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
|
|
3078
|
-
|
|
3079
|
-
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3074
|
+
const nonEmpty = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
3075
|
+
return defined2({
|
|
3076
|
+
id,
|
|
3077
|
+
title: d.title,
|
|
3078
|
+
company: companyName,
|
|
3079
|
+
companyUrl: typeof company?.url === "string" ? company.url : void 0,
|
|
3080
|
+
location: nonEmpty(d.formattedLocation),
|
|
3081
|
+
workplace: workplace ?? (d.workRemoteAllowed === true ? "remote" : void 0),
|
|
3082
|
+
employmentType: nonEmpty(d.formattedEmploymentStatus),
|
|
3083
|
+
experienceLevel: nonEmpty(d.formattedExperienceLevel),
|
|
3084
|
+
industries: list2(d.formattedIndustries),
|
|
3085
|
+
functions: list2(d.formattedJobFunctions),
|
|
3086
|
+
listed: day(d.listedAt),
|
|
3087
|
+
expires: day(d.expireAt),
|
|
3088
|
+
state: nonEmpty(d.jobState),
|
|
3089
|
+
applicants: typeof d.applies === "number" && d.applies > 0 ? d.applies : void 0,
|
|
3090
|
+
apply: applyOf(d.applyMethod, id),
|
|
3091
|
+
ats: nonEmpty(d.applicantTrackingSystem),
|
|
3092
|
+
applied: typeof applying?.applied === "boolean" ? applying.applied : void 0,
|
|
3093
|
+
saved: typeof saving?.saved === "boolean" ? saving.saved : void 0,
|
|
3094
|
+
description: text2(d.description),
|
|
3095
|
+
url: viewUrl(id)
|
|
3096
|
+
});
|
|
3097
|
+
}
|
|
3098
|
+
function parseJobDetail(json) {
|
|
3099
|
+
const root = json;
|
|
3100
|
+
const job = root?.data === void 0 ? void 0 : postingToJob(root.data, root.included ?? []);
|
|
3101
|
+
return job === void 0 ? drift2("the job response carried no posting") : { ok: true, job };
|
|
3102
|
+
}
|
|
3103
|
+
function parseJobBatch(json) {
|
|
3104
|
+
const root = json;
|
|
3105
|
+
const results = root?.data?.results;
|
|
3106
|
+
if (results === null || typeof results !== "object")
|
|
3107
|
+
return drift2("the batch job response carried no results");
|
|
3108
|
+
const included = root?.included ?? [];
|
|
3109
|
+
const byUrn = new Map(included.map((n) => [n.entityUrn, n]));
|
|
3110
|
+
const jobs = [];
|
|
3111
|
+
for (const ref of Object.values(results)) {
|
|
3112
|
+
const node = typeof ref === "string" ? byUrn.get(ref) : ref;
|
|
3113
|
+
const job = node === void 0 ? void 0 : postingToJob(node, included);
|
|
3114
|
+
if (job !== void 0) jobs.push(job);
|
|
3115
|
+
}
|
|
3116
|
+
const claimed = Object.keys(results).length;
|
|
3117
|
+
if (claimed > 0 && jobs.length === 0)
|
|
3118
|
+
return drift2(`the batch listed ${claimed} jobs but none could be read`);
|
|
3119
|
+
const errors = root?.data?.errors ?? {};
|
|
3120
|
+
return { ok: true, jobs, missing: Object.keys(errors).map((k) => k.replace(/^\*/, "")) };
|
|
3098
3121
|
}
|
|
3099
3122
|
function parseJobFilters(json) {
|
|
3100
3123
|
const elements = json?.data?.elements;
|
|
@@ -3256,6 +3279,7 @@ function compactJob(j) {
|
|
|
3256
3279
|
if (j.promoted) parts.push("promoted");
|
|
3257
3280
|
parts.push(j.salary);
|
|
3258
3281
|
if (j.apply?.url !== void 0) parts.push(`apply: ${j.apply.url}`);
|
|
3282
|
+
if (j.matched !== void 0) parts.push(`matched: ${j.matched.join(" + ")}`);
|
|
3259
3283
|
return parts.filter((p) => p !== void 0 && p !== "").map((p) => p.replaceAll(" | ", " / ")).join(" | ");
|
|
3260
3284
|
}
|
|
3261
3285
|
function shape(rows, opts, line) {
|
|
@@ -3264,9 +3288,17 @@ function shape(rows, opts, line) {
|
|
|
3264
3288
|
return project(rows, opts.fields);
|
|
3265
3289
|
return rows;
|
|
3266
3290
|
}
|
|
3267
|
-
function
|
|
3291
|
+
function keywordSets(keywords) {
|
|
3292
|
+
const given = keywords === void 0 ? [] : Array.isArray(keywords) ? keywords : [keywords];
|
|
3293
|
+
const out = [];
|
|
3294
|
+
for (const k of given.map((g) => g.trim())) {
|
|
3295
|
+
if (k !== "" && !out.some((o) => o.toLowerCase() === k.toLowerCase())) out.push(k);
|
|
3296
|
+
}
|
|
3297
|
+
return out;
|
|
3298
|
+
}
|
|
3299
|
+
function queryOf(req, filters, keywords) {
|
|
3268
3300
|
return {
|
|
3269
|
-
...
|
|
3301
|
+
...keywords ? { keywords } : {},
|
|
3270
3302
|
...req.location ? { location: req.location } : {},
|
|
3271
3303
|
...req.geoId ? { geoId: req.geoId } : {},
|
|
3272
3304
|
filters
|
|
@@ -3287,7 +3319,9 @@ async function collect(get, query, first, want) {
|
|
|
3287
3319
|
for (const [k, n] of Object.entries(page.unknownTypes))
|
|
3288
3320
|
out.unknownTypes[k] = (out.unknownTypes[k] ?? 0) + n;
|
|
3289
3321
|
const fresh = page.jobs.filter((j) => !out.jobs.some((x) => x.id === j.id));
|
|
3290
|
-
|
|
3322
|
+
const room = want - out.jobs.length;
|
|
3323
|
+
out.jobs.push(...fresh.slice(0, room));
|
|
3324
|
+
if (fresh.length > room) break;
|
|
3291
3325
|
if (page.jobs.length === 0 || out.total !== void 0 && start + PAGE_SIZE2 >= out.total) {
|
|
3292
3326
|
out.exhausted = true;
|
|
3293
3327
|
break;
|
|
@@ -3295,24 +3329,111 @@ async function collect(get, query, first, want) {
|
|
|
3295
3329
|
}
|
|
3296
3330
|
return out;
|
|
3297
3331
|
}
|
|
3298
|
-
async function
|
|
3332
|
+
async function readJobs(get, ids) {
|
|
3333
|
+
const jobs = /* @__PURE__ */ new Map();
|
|
3334
|
+
for (let at = 0; at < ids.length; at += BATCH_SIZE) {
|
|
3335
|
+
const res = await get(jobBatchUrl(ids.slice(at, at + BATCH_SIZE)), "jobRead");
|
|
3336
|
+
const batch = res.ok ? parseJobBatch(res.json) : res;
|
|
3337
|
+
if (!batch.ok) return { jobs, stoppedBy: batch.code };
|
|
3338
|
+
for (const job of batch.jobs) if (ids.includes(job.id)) jobs.set(job.id, job);
|
|
3339
|
+
}
|
|
3340
|
+
return { jobs };
|
|
3341
|
+
}
|
|
3342
|
+
async function addDetails(get, rows, withDescription) {
|
|
3343
|
+
const read = await readJobs(
|
|
3344
|
+
get,
|
|
3345
|
+
rows.map((r) => r.id)
|
|
3346
|
+
);
|
|
3347
|
+
for (const row of rows) {
|
|
3348
|
+
const detail = read.jobs.get(row.id);
|
|
3349
|
+
if (detail === void 0) continue;
|
|
3350
|
+
const { description, id: _id, url: _url, ...rest } = detail;
|
|
3351
|
+
Object.assign(row, rest, withDescription ? { description } : {});
|
|
3352
|
+
}
|
|
3353
|
+
const unread = rows.filter((r) => !read.jobs.has(r.id)).length;
|
|
3354
|
+
return read.stoppedBy === void 0 ? { unread } : { unread, stoppedBy: read.stoppedBy };
|
|
3355
|
+
}
|
|
3356
|
+
function reportOf(keywords, found, first) {
|
|
3357
|
+
const report = {
|
|
3358
|
+
...keywords !== void 0 ? { keywords } : {},
|
|
3359
|
+
claimedCount: found.total,
|
|
3360
|
+
returnedCount: found.jobs.length,
|
|
3361
|
+
state: found.stoppedBy === void 0 && found.exhausted ? "complete" : "partial"
|
|
3362
|
+
};
|
|
3363
|
+
if (!found.exhausted) report.next = first + found.jobs.length;
|
|
3364
|
+
if (found.stoppedBy !== void 0) report.stoppedBy = found.stoppedBy;
|
|
3365
|
+
return report;
|
|
3366
|
+
}
|
|
3367
|
+
function mergeInto(out, byId, jobs, keywords) {
|
|
3299
3368
|
for (const job of jobs) {
|
|
3300
|
-
const
|
|
3301
|
-
|
|
3302
|
-
|
|
3303
|
-
|
|
3304
|
-
|
|
3369
|
+
const seen = byId.get(job.id);
|
|
3370
|
+
if (seen !== void 0) {
|
|
3371
|
+
out.duplicates++;
|
|
3372
|
+
if (keywords !== void 0) seen.matched?.push(keywords);
|
|
3373
|
+
continue;
|
|
3374
|
+
}
|
|
3375
|
+
const row = keywords !== void 0 ? { ...job, matched: [keywords] } : job;
|
|
3376
|
+
byId.set(job.id, row);
|
|
3377
|
+
out.rows.push(row);
|
|
3378
|
+
}
|
|
3379
|
+
}
|
|
3380
|
+
async function searchAll(get, sets, base, first, want) {
|
|
3381
|
+
const out = { rows: [], searches: [], duplicates: 0, unknownTypes: {} };
|
|
3382
|
+
const byId = /* @__PURE__ */ new Map();
|
|
3383
|
+
for (const keywords of sets) {
|
|
3384
|
+
const found = await collect(get, { ...base, ...keywords ? { keywords } : {} }, first, want);
|
|
3385
|
+
if ("ok" in found) {
|
|
3386
|
+
out.failure = out.failure ?? found;
|
|
3387
|
+
out.searches.push({
|
|
3388
|
+
...keywords !== void 0 ? { keywords } : {},
|
|
3389
|
+
returnedCount: 0,
|
|
3390
|
+
state: "failed",
|
|
3391
|
+
stoppedBy: found.code
|
|
3392
|
+
});
|
|
3393
|
+
continue;
|
|
3394
|
+
}
|
|
3395
|
+
out.searches.push(reportOf(keywords, found, first));
|
|
3396
|
+
out.resolved = out.resolved ?? found.resolved;
|
|
3397
|
+
for (const [k, n] of Object.entries(found.unknownTypes))
|
|
3398
|
+
out.unknownTypes[k] = (out.unknownTypes[k] ?? 0) + n;
|
|
3399
|
+
mergeInto(out, byId, found.jobs, sets.length > 1 ? keywords : void 0);
|
|
3305
3400
|
}
|
|
3306
|
-
|
|
3401
|
+
if (sets.length > 1) out.rows.sort((x, y) => (y.matched?.length ?? 0) - (x.matched?.length ?? 0));
|
|
3402
|
+
return out;
|
|
3403
|
+
}
|
|
3404
|
+
function metaOf(merged, single, first, unread, readStop) {
|
|
3405
|
+
const searched = merged.searches;
|
|
3406
|
+
const allComplete = searched.every((r) => r.state === "complete");
|
|
3407
|
+
const meta = {
|
|
3408
|
+
state: allComplete && unread === 0 && readStop === void 0 ? "complete" : "partial",
|
|
3409
|
+
operation: "jobs"
|
|
3410
|
+
};
|
|
3411
|
+
if (single) {
|
|
3412
|
+
const { keywords: _k, state: _s, ...report } = searched[0];
|
|
3413
|
+
Object.assign(meta, report, { start: first });
|
|
3414
|
+
if (readStop !== void 0) meta.stoppedBy = meta.stoppedBy ?? readStop;
|
|
3415
|
+
} else {
|
|
3416
|
+
Object.assign(meta, {
|
|
3417
|
+
returnedCount: merged.rows.length,
|
|
3418
|
+
duplicates: merged.duplicates,
|
|
3419
|
+
start: first,
|
|
3420
|
+
searches: searched,
|
|
3421
|
+
...readStop !== void 0 ? { stoppedBy: readStop } : {}
|
|
3422
|
+
});
|
|
3423
|
+
}
|
|
3424
|
+
if (unread > 0) meta.unread = unread;
|
|
3425
|
+
if (Object.keys(merged.unknownTypes).length > 0) meta.unknownTypes = merged.unknownTypes;
|
|
3426
|
+
return meta;
|
|
3307
3427
|
}
|
|
3308
3428
|
async function runJobs(req, opts = {}, fetch2) {
|
|
3309
|
-
const
|
|
3429
|
+
const sets = keywordSets(req.keywords);
|
|
3430
|
+
const hasQuery = sets.length > 0 || [req.location, req.geoId].some((v) => v !== void 0 && v !== "");
|
|
3310
3431
|
if (!hasQuery) {
|
|
3311
3432
|
return err(
|
|
3312
3433
|
"jobs",
|
|
3313
3434
|
"INVALID_INPUT",
|
|
3314
3435
|
"give keywords, a location, or both",
|
|
3315
|
-
'lnrelay jobs "<keywords>" [--location "<place>" | --geo <id>] [filters]'
|
|
3436
|
+
'lnrelay jobs "<keywords>" ["<more keywords>" ...] [--location "<place>" | --geo <id>] [filters]'
|
|
3316
3437
|
);
|
|
3317
3438
|
}
|
|
3318
3439
|
const selection2 = jobFilterSelection(req.filter ?? {});
|
|
@@ -3322,49 +3443,89 @@ async function runJobs(req, opts = {}, fetch2) {
|
|
|
3322
3443
|
if (typeof get !== "function") return get;
|
|
3323
3444
|
const first = Math.max(0, req.start ?? 0);
|
|
3324
3445
|
const want = Math.max(1, Math.min(req.limit, MAX_RESULTS - first));
|
|
3325
|
-
const
|
|
3326
|
-
const
|
|
3327
|
-
if (
|
|
3446
|
+
const base = queryOf(req, selection2.filters);
|
|
3447
|
+
const merged = await searchAll(get, sets.length > 0 ? sets : [void 0], base, first, want);
|
|
3448
|
+
if (merged.rows.length === 0 && merged.failure !== void 0) {
|
|
3449
|
+
const f = merged.failure;
|
|
3450
|
+
return err("jobs", f.code, f.message, f.hint);
|
|
3451
|
+
}
|
|
3452
|
+
let unread = 0;
|
|
3453
|
+
let readStop;
|
|
3328
3454
|
if (req.details === true) {
|
|
3329
|
-
const
|
|
3330
|
-
|
|
3455
|
+
const added = await addDetails(get, merged.rows, req.description === true);
|
|
3456
|
+
unread = added.unread;
|
|
3457
|
+
readStop = added.stoppedBy;
|
|
3331
3458
|
}
|
|
3332
|
-
const
|
|
3459
|
+
const single = sets.length <= 1;
|
|
3460
|
+
const meta = metaOf(merged, single, first, unread, readStop);
|
|
3333
3461
|
return ok("jobs", {
|
|
3334
|
-
query,
|
|
3335
|
-
...
|
|
3336
|
-
items: shape(
|
|
3337
|
-
meta
|
|
3338
|
-
state: stoppedBy === void 0 && exhausted ? "complete" : "partial",
|
|
3339
|
-
operation: "jobs",
|
|
3340
|
-
claimedCount: found.total,
|
|
3341
|
-
returnedCount: jobs.length,
|
|
3342
|
-
start: first,
|
|
3343
|
-
next: exhausted ? void 0 : first + jobs.length,
|
|
3344
|
-
...stoppedBy !== void 0 ? { stoppedBy } : {},
|
|
3345
|
-
...Object.keys(unknownTypes).length > 0 ? { unknownTypes } : {}
|
|
3346
|
-
}
|
|
3462
|
+
query: { ...base, ...sets.length > 0 ? { keywords: single ? sets[0] : sets } : {} },
|
|
3463
|
+
...merged.resolved !== void 0 ? { location: merged.resolved } : {},
|
|
3464
|
+
items: shape(merged.rows, opts, compactJob),
|
|
3465
|
+
meta
|
|
3347
3466
|
});
|
|
3348
3467
|
}
|
|
3349
3468
|
async function runJob(input, opts = {}, fetch2) {
|
|
3350
|
-
const
|
|
3351
|
-
|
|
3352
|
-
|
|
3469
|
+
const given = input === void 0 ? [] : Array.isArray(input) ? input : [input];
|
|
3470
|
+
const ids = [...new Set(given.map(jobIdOf))];
|
|
3471
|
+
if (ids.length === 0 || ids.some((id) => id === void 0)) {
|
|
3472
|
+
const bad = given.filter((g) => jobIdOf(g) === void 0);
|
|
3473
|
+
return err(
|
|
3474
|
+
"job",
|
|
3475
|
+
"INVALID_INPUT",
|
|
3476
|
+
bad.length > 0 ? `not a job id or URL: ${bad.join(", ")}` : "a job id or job URL is required",
|
|
3477
|
+
"lnrelay job <id|url> [<id|url> ...]"
|
|
3478
|
+
);
|
|
3353
3479
|
}
|
|
3354
3480
|
const get = fetch2 ?? liveFetch("job", opts.quiet === true);
|
|
3355
3481
|
if (typeof get !== "function") return get;
|
|
3356
|
-
const
|
|
3357
|
-
if (
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3482
|
+
const wanted = ids;
|
|
3483
|
+
if (wanted.length === 1) {
|
|
3484
|
+
const res = await get(jobDetailUrl(wanted[0]), "jobRead");
|
|
3485
|
+
if (!res.ok) return err("job", res.code, res.message, res.hint);
|
|
3486
|
+
const detail = parseJobDetail(res.json);
|
|
3487
|
+
if (!detail.ok) return err("job", detail.code, detail.message, detail.hint);
|
|
3488
|
+
return ok("job", detail.job);
|
|
3489
|
+
}
|
|
3490
|
+
const read = await readJobs(get, wanted);
|
|
3491
|
+
if (read.jobs.size === 0 && read.stoppedBy !== void 0)
|
|
3492
|
+
return err("job", read.stoppedBy, "no job could be read");
|
|
3493
|
+
const unread = wanted.filter((id) => !read.jobs.has(id));
|
|
3494
|
+
const jobs = wanted.flatMap((id) => read.jobs.get(id) ?? []);
|
|
3495
|
+
return ok("job", {
|
|
3496
|
+
items: shape(
|
|
3497
|
+
jobs,
|
|
3498
|
+
opts,
|
|
3499
|
+
(j) => compactJob({ ...j, easyApply: j.apply?.type === "easy-apply", promoted: false })
|
|
3500
|
+
),
|
|
3501
|
+
meta: {
|
|
3502
|
+
state: unread.length === 0 ? "complete" : "partial",
|
|
3503
|
+
operation: "job",
|
|
3504
|
+
returnedCount: jobs.length,
|
|
3505
|
+
...unread.length > 0 ? { unread } : {},
|
|
3506
|
+
...read.stoppedBy !== void 0 ? { stoppedBy: read.stoppedBy } : {}
|
|
3507
|
+
}
|
|
3508
|
+
});
|
|
3361
3509
|
}
|
|
3362
3510
|
async function runJobFilters(req, opts = {}, fetch2) {
|
|
3511
|
+
const sets = keywordSets(req.keywords);
|
|
3512
|
+
if (sets.length > 1) {
|
|
3513
|
+
return err(
|
|
3514
|
+
"job-filters",
|
|
3515
|
+
"INVALID_INPUT",
|
|
3516
|
+
"job-filters takes one keyword set: its counts belong to that one query",
|
|
3517
|
+
'lnrelay job-filters "<keywords>" [filters]'
|
|
3518
|
+
);
|
|
3519
|
+
}
|
|
3363
3520
|
const selection2 = jobFilterSelection(req.filter ?? {});
|
|
3364
3521
|
if (!selection2.ok) return err("job-filters", selection2.code, selection2.message);
|
|
3365
3522
|
const get = fetch2 ?? liveFetch("job-filters", opts.quiet === true);
|
|
3366
3523
|
if (typeof get !== "function") return get;
|
|
3367
|
-
const url = jobFiltersUrl({
|
|
3524
|
+
const url = jobFiltersUrl({
|
|
3525
|
+
...queryOf(req, selection2.filters, sets[0]),
|
|
3526
|
+
start: 0,
|
|
3527
|
+
count: PAGE_SIZE2
|
|
3528
|
+
});
|
|
3368
3529
|
const res = await get(url, "jobSearch");
|
|
3369
3530
|
const parsed = res.ok ? parseJobFilters(res.json) : res;
|
|
3370
3531
|
if (!parsed.ok) return err("job-filters", parsed.code, parsed.message, parsed.hint);
|
|
@@ -4049,18 +4210,18 @@ var COMMANDS = [
|
|
|
4049
4210
|
},
|
|
4050
4211
|
{
|
|
4051
4212
|
name: "jobs",
|
|
4052
|
-
cost: "1 job-search call per
|
|
4213
|
+
cost: "1 job-search call per 100 jobs; --details adds 1 job read per 100 jobs",
|
|
4053
4214
|
summary: "Job search with every filter the jobs page has. Cards carry id, title, company, place, workplace, listed date, Easy Apply. Read finalists with `job`.",
|
|
4054
|
-
usage: 'lnrelay jobs "<keywords>" [--location "<place>" | --geo <id>]
|
|
4215
|
+
usage: 'lnrelay jobs "<keywords>" ["<more keywords>" ...] [--location "<place>" | --geo <id>]\n [--distance <miles>]\n [--posted 24h|week|month|<N>h|<N>d] [--experience internship,entry,associate,\n mid-senior,director,executive] [--type full-time,part-time,contract,temporary,\n volunteer,internship,other] [--workplace on-site,remote,hybrid] [--easy-apply]\n [--under-10] [--verified] [--in-network] [--fair-chance] [--company <ids>]\n [--industry <ids>] [--function <codes>] [--title <ids>] [--place <geo-ids>]\n [--filter key=v1,v2 ...] [--sort recent|relevant] [--limit N] [--start N]\n [--details [--description]] [--compact | --fields a,b,c]\n Ids for --company/--industry/--title/--place/--filter come from `job-filters`.\n The resolved place is in data.location: check it, "Vienna" may resolve narrow.',
|
|
4055
4216
|
audience: ["cli", "mcp"],
|
|
4056
4217
|
risk: "read",
|
|
4057
4218
|
implemented: true
|
|
4058
4219
|
},
|
|
4059
4220
|
{
|
|
4060
4221
|
name: "job",
|
|
4061
|
-
cost: "1 job read",
|
|
4062
|
-
summary: "
|
|
4063
|
-
usage: "lnrelay job <id|job-url>",
|
|
4222
|
+
cost: "1 job read per 100 jobs",
|
|
4223
|
+
summary: "Jobs in full: description, apply link (external or Easy Apply), applicants, state. Several ids are read together, 100 a call.",
|
|
4224
|
+
usage: "lnrelay job <id|job-url> [<id|job-url> ...] [--compact | --fields a,b,c]",
|
|
4064
4225
|
audience: ["cli", "mcp"],
|
|
4065
4226
|
risk: "read",
|
|
4066
4227
|
implemented: true
|
|
@@ -6606,8 +6767,7 @@ function jobsRequest(args) {
|
|
|
6606
6767
|
const sort = str(args, "sort");
|
|
6607
6768
|
if (sort !== void 0) filter.sort = sort;
|
|
6608
6769
|
const req = { limit: num(args, "limit") ?? 25, filter };
|
|
6609
|
-
|
|
6610
|
-
if (keywords !== void 0) req.keywords = keywords;
|
|
6770
|
+
if (args.positionals.length > 0) req.keywords = [...args.positionals];
|
|
6611
6771
|
const location = str(args, "location");
|
|
6612
6772
|
if (location !== void 0) req.location = location;
|
|
6613
6773
|
const geo = str(args, "geo");
|
|
@@ -6731,7 +6891,7 @@ async function dispatch(argv, now) {
|
|
|
6731
6891
|
case "jobs":
|
|
6732
6892
|
return runJobs(jobsRequest(args), output(args));
|
|
6733
6893
|
case "job":
|
|
6734
|
-
return runJob(args.positionals
|
|
6894
|
+
return runJob(args.positionals, output(args));
|
|
6735
6895
|
case "job-filters":
|
|
6736
6896
|
return runJobFilters(jobsRequest(args), output(args));
|
|
6737
6897
|
case "search":
|