linkedin-relay-mcp 3.8.0 → 3.10.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 +49 -1
- package/dist/cli.js +1023 -150
- package/dist/cli.js.map +1 -1
- package/dist/index.js +46 -10
- package/dist/index.js.map +1 -1
- package/dist/mcp-shim.js +837 -75
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1380,15 +1380,33 @@ var CONTRACTS = {
|
|
|
1380
1380
|
provenance: "discovered",
|
|
1381
1381
|
capturedAt: "2026-08-02"
|
|
1382
1382
|
},
|
|
1383
|
-
//
|
|
1384
|
-
//
|
|
1383
|
+
// Job search, captured 2026-10-14. The jobs page itself now opens an SDUI
|
|
1384
|
+
// "AI job search" that drops filters it does not support; these are the
|
|
1385
|
+
// classic Voyager resources still behind /jobs/search/, which take them all.
|
|
1386
|
+
// See engine/jobs.ts.
|
|
1385
1387
|
jobCards: {
|
|
1386
1388
|
name: "jobCards",
|
|
1387
|
-
transport: "voyager-
|
|
1388
|
-
path: `${VOYAGER}/
|
|
1389
|
-
|
|
1390
|
-
provenance: "
|
|
1391
|
-
capturedAt: "2026-
|
|
1389
|
+
transport: "voyager-restli",
|
|
1390
|
+
path: `${VOYAGER}/voyagerJobsDashJobCards`,
|
|
1391
|
+
decorationId: "com.linkedin.voyager.dash.deco.jobs.search.JobSearchCardsCollection-220",
|
|
1392
|
+
provenance: "verified",
|
|
1393
|
+
capturedAt: "2026-10-14"
|
|
1394
|
+
},
|
|
1395
|
+
jobFilters: {
|
|
1396
|
+
name: "jobFilters",
|
|
1397
|
+
transport: "voyager-restli",
|
|
1398
|
+
path: `${VOYAGER}/voyagerJobsDashSearchFilterClustersResource`,
|
|
1399
|
+
decorationId: "com.linkedin.voyager.dash.deco.search.SearchFilterCluster-44",
|
|
1400
|
+
provenance: "verified",
|
|
1401
|
+
capturedAt: "2026-10-14"
|
|
1402
|
+
},
|
|
1403
|
+
jobPosting: {
|
|
1404
|
+
name: "jobPosting",
|
|
1405
|
+
transport: "voyager-restli",
|
|
1406
|
+
path: `${VOYAGER}/jobs/jobPostings`,
|
|
1407
|
+
decorationId: "com.linkedin.voyager.deco.jobs.web.shared.WebFullJobPosting-65",
|
|
1408
|
+
provenance: "verified",
|
|
1409
|
+
capturedAt: "2026-10-14"
|
|
1392
1410
|
}
|
|
1393
1411
|
};
|
|
1394
1412
|
var RETIRED = {
|
|
@@ -1639,10 +1657,10 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1639
1657
|
const client = createLiveClient(session, deps, quiet);
|
|
1640
1658
|
return {
|
|
1641
1659
|
async whoami() {
|
|
1642
|
-
const
|
|
1643
|
-
if (
|
|
1660
|
+
const contract2 = contractFor("me");
|
|
1661
|
+
if (contract2 === void 0) return missingContract("me");
|
|
1644
1662
|
const res = await client.request({
|
|
1645
|
-
url:
|
|
1663
|
+
url: contract2.path,
|
|
1646
1664
|
spendClass: "profile",
|
|
1647
1665
|
operation: "me"
|
|
1648
1666
|
});
|
|
@@ -1650,10 +1668,10 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1650
1668
|
return { ok: true, value: parseSingle(res.json) };
|
|
1651
1669
|
},
|
|
1652
1670
|
async profile(memberId) {
|
|
1653
|
-
const
|
|
1654
|
-
if (
|
|
1671
|
+
const contract2 = contractFor("profile");
|
|
1672
|
+
if (contract2 === void 0) return missingContract("profile");
|
|
1655
1673
|
const variables = encodeVariables({ memberIdentity: memberId });
|
|
1656
|
-
const url = `${
|
|
1674
|
+
const url = `${contract2.path}?includeWebMetadata=true&variables=${variables}&queryId=${contract2.queryId}`;
|
|
1657
1675
|
const res = await client.request({ url, spendClass: "profile", operation: "profile" });
|
|
1658
1676
|
if (!res.ok) return res;
|
|
1659
1677
|
const envelope = res.json;
|
|
@@ -1665,9 +1683,9 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1665
1683
|
return { ok: true, value: { profile, index } };
|
|
1666
1684
|
},
|
|
1667
1685
|
async feed(limit) {
|
|
1668
|
-
const
|
|
1669
|
-
if (
|
|
1670
|
-
const url = `${
|
|
1686
|
+
const contract2 = contractFor("feed");
|
|
1687
|
+
if (contract2 === void 0) return missingContract("feed");
|
|
1688
|
+
const url = `${contract2.path}?q=chronFeed&count=${limit}&start=0`;
|
|
1671
1689
|
const res = await client.request({ url, spendClass: "page", operation: "feed" });
|
|
1672
1690
|
if (!res.ok) return res;
|
|
1673
1691
|
const envelope = res.json;
|
|
@@ -1676,21 +1694,21 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1676
1694
|
value: {
|
|
1677
1695
|
parsed: parseCollection(res.json, {
|
|
1678
1696
|
operation: "feed",
|
|
1679
|
-
contractCapturedAt:
|
|
1697
|
+
contractCapturedAt: contract2.capturedAt
|
|
1680
1698
|
}),
|
|
1681
1699
|
index: indexIncluded(envelope.included)
|
|
1682
1700
|
}
|
|
1683
1701
|
};
|
|
1684
1702
|
},
|
|
1685
1703
|
async myPosts(profileUrn, limit) {
|
|
1686
|
-
const
|
|
1687
|
-
if (
|
|
1704
|
+
const contract2 = contractFor("myPosts");
|
|
1705
|
+
if (contract2 === void 0) return missingContract("myPosts");
|
|
1688
1706
|
const variables = encodeVariables({
|
|
1689
1707
|
count: Math.min(limit, 100),
|
|
1690
1708
|
start: 0,
|
|
1691
1709
|
profileUrn: canonicalUrn(profileUrn)
|
|
1692
1710
|
});
|
|
1693
|
-
const url = `${
|
|
1711
|
+
const url = `${contract2.path}?includeWebMetadata=true&variables=${variables}&queryId=${contract2.queryId}`;
|
|
1694
1712
|
const res = await client.request({ url, spendClass: "page", operation: "myPosts" });
|
|
1695
1713
|
if (!res.ok) return res;
|
|
1696
1714
|
const envelope = res.json;
|
|
@@ -1699,7 +1717,7 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1699
1717
|
value: {
|
|
1700
1718
|
parsed: parseCollection(res.json, {
|
|
1701
1719
|
operation: "myPosts",
|
|
1702
|
-
contractCapturedAt:
|
|
1720
|
+
contractCapturedAt: contract2.capturedAt,
|
|
1703
1721
|
truncated: true
|
|
1704
1722
|
}),
|
|
1705
1723
|
index: indexIncluded(envelope.included)
|
|
@@ -1712,8 +1730,8 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1712
1730
|
* snapshot and diffs, rather than pretending a watermark exists.
|
|
1713
1731
|
*/
|
|
1714
1732
|
async connections(limit) {
|
|
1715
|
-
const
|
|
1716
|
-
if (
|
|
1733
|
+
const contract2 = contractFor("search");
|
|
1734
|
+
if (contract2 === void 0) return missingContract("search");
|
|
1717
1735
|
const variables = encodeVariables({
|
|
1718
1736
|
start: 0,
|
|
1719
1737
|
origin: "FACETED_SEARCH",
|
|
@@ -1726,12 +1744,12 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1726
1744
|
includeFiltersInResponse: false
|
|
1727
1745
|
}
|
|
1728
1746
|
});
|
|
1729
|
-
const url = `${
|
|
1747
|
+
const url = `${contract2.path}?variables=${variables}&queryId=${contract2.queryId}`;
|
|
1730
1748
|
const res = await client.request({ url, spendClass: "search", operation: "connections" });
|
|
1731
1749
|
if (!res.ok) return res;
|
|
1732
1750
|
const parsed = parseCollection(res.json, {
|
|
1733
1751
|
operation: "connections",
|
|
1734
|
-
contractCapturedAt:
|
|
1752
|
+
contractCapturedAt: contract2.capturedAt,
|
|
1735
1753
|
claimedCount: totalResultCount(res.json),
|
|
1736
1754
|
truncated: true
|
|
1737
1755
|
});
|
|
@@ -1741,8 +1759,8 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1741
1759
|
return { ok: true, value: { parsed, index: indexIncluded(envelope.included) } };
|
|
1742
1760
|
},
|
|
1743
1761
|
async post(postUrn2, limit) {
|
|
1744
|
-
const
|
|
1745
|
-
if (
|
|
1762
|
+
const contract2 = contractFor("comments");
|
|
1763
|
+
if (contract2 === void 0) return missingContract("comments");
|
|
1746
1764
|
const variables = encodeVariables({
|
|
1747
1765
|
count: Math.min(limit, 100),
|
|
1748
1766
|
numReplies: 1,
|
|
@@ -1750,12 +1768,12 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1750
1768
|
sortOrder: "RELEVANCE",
|
|
1751
1769
|
start: 0
|
|
1752
1770
|
});
|
|
1753
|
-
const url = `${
|
|
1771
|
+
const url = `${contract2.path}?includeWebMetadata=true&variables=${variables}&queryId=${contract2.queryId}`;
|
|
1754
1772
|
const res = await client.request({ url, spendClass: "page", operation: "comments" });
|
|
1755
1773
|
if (!res.ok) return res;
|
|
1756
1774
|
const parsed = parseCollection(res.json, {
|
|
1757
1775
|
operation: "comments",
|
|
1758
|
-
contractCapturedAt:
|
|
1776
|
+
contractCapturedAt: contract2.capturedAt,
|
|
1759
1777
|
// A page of many; we follow no cursor yet, so never claim exhaustion.
|
|
1760
1778
|
truncated: true
|
|
1761
1779
|
});
|
|
@@ -1763,27 +1781,27 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1763
1781
|
return { ok: true, value: { parsed, index: indexIncluded(envelope.included) } };
|
|
1764
1782
|
},
|
|
1765
1783
|
async reactions(postUrn2, limit) {
|
|
1766
|
-
const
|
|
1767
|
-
if (
|
|
1784
|
+
const contract2 = contractFor("reactions");
|
|
1785
|
+
if (contract2 === void 0) return missingContract("reactions");
|
|
1768
1786
|
const variables = encodeVariables({
|
|
1769
1787
|
count: Math.min(limit, 100),
|
|
1770
1788
|
start: 0,
|
|
1771
1789
|
threadUrn: postUrn2
|
|
1772
1790
|
});
|
|
1773
|
-
const url = `${
|
|
1791
|
+
const url = `${contract2.path}?includeWebMetadata=true&variables=${variables}&queryId=${contract2.queryId}`;
|
|
1774
1792
|
const res = await client.request({ url, spendClass: "page", operation: "reactions" });
|
|
1775
1793
|
if (!res.ok) return res;
|
|
1776
1794
|
const parsed = parseCollection(res.json, {
|
|
1777
1795
|
operation: "reactions",
|
|
1778
|
-
contractCapturedAt:
|
|
1796
|
+
contractCapturedAt: contract2.capturedAt,
|
|
1779
1797
|
truncated: true
|
|
1780
1798
|
});
|
|
1781
1799
|
const envelope = res.json;
|
|
1782
1800
|
return { ok: true, value: { parsed, index: indexIncluded(envelope.included) } };
|
|
1783
1801
|
},
|
|
1784
1802
|
async search(kind, query, limit) {
|
|
1785
|
-
const
|
|
1786
|
-
if (
|
|
1803
|
+
const contract2 = contractFor("search");
|
|
1804
|
+
if (contract2 === void 0) return missingContract("search");
|
|
1787
1805
|
const variables = encodeVariables({
|
|
1788
1806
|
start: 0,
|
|
1789
1807
|
origin: "GLOBAL_SEARCH_HEADER",
|
|
@@ -1794,12 +1812,12 @@ function createEngine(session, deps, quiet = false) {
|
|
|
1794
1812
|
includeFiltersInResponse: false
|
|
1795
1813
|
}
|
|
1796
1814
|
});
|
|
1797
|
-
const url = `${
|
|
1815
|
+
const url = `${contract2.path}?variables=${variables}&queryId=${contract2.queryId}`;
|
|
1798
1816
|
const res = await client.request({ url, spendClass: "search", operation: "search" });
|
|
1799
1817
|
if (!res.ok) return res;
|
|
1800
1818
|
const parsed = parseCollection(res.json, {
|
|
1801
1819
|
operation: "search",
|
|
1802
|
-
contractCapturedAt:
|
|
1820
|
+
contractCapturedAt: contract2.capturedAt,
|
|
1803
1821
|
claimedCount: totalResultCount(res.json),
|
|
1804
1822
|
truncated: true
|
|
1805
1823
|
// one page of many; we never claim exhaustion
|
|
@@ -1993,7 +2011,7 @@ async function fetchCommentMenu(ref, trackingId, client) {
|
|
|
1993
2011
|
const stream = result.classification.raw ?? "";
|
|
1994
2012
|
return { ok: true, stream };
|
|
1995
2013
|
}
|
|
1996
|
-
function textStates(payload,
|
|
2014
|
+
function textStates(payload, text3) {
|
|
1997
2015
|
const keyOf = (...names) => {
|
|
1998
2016
|
for (const n of names) {
|
|
1999
2017
|
const slot = payload[n];
|
|
@@ -2012,12 +2030,12 @@ function textStates(payload, text2) {
|
|
|
2012
2030
|
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: key } }
|
|
2013
2031
|
});
|
|
2014
2032
|
return [
|
|
2015
|
-
entry2(plain2,
|
|
2016
|
-
entry2(rich, { text:
|
|
2033
|
+
entry2(plain2, text3, "stringValue"),
|
|
2034
|
+
entry2(rich, { text: text3, attribute: [], $type: "TextModel", source: "local" }, "textModelForWrite")
|
|
2017
2035
|
];
|
|
2018
2036
|
}
|
|
2019
|
-
function editStates(payload,
|
|
2020
|
-
return textStates(payload,
|
|
2037
|
+
function editStates(payload, text3) {
|
|
2038
|
+
return textStates(payload, text3);
|
|
2021
2039
|
}
|
|
2022
2040
|
async function runCommentAction(ref, operation, trackingId, client, newText) {
|
|
2023
2041
|
const menu = await fetchCommentMenu(ref, trackingId, client);
|
|
@@ -2356,12 +2374,12 @@ var CATEGORY = {
|
|
|
2356
2374
|
VIDEO: "VIDEO",
|
|
2357
2375
|
DOCUMENT: "NATIVE_DOCUMENT"
|
|
2358
2376
|
};
|
|
2359
|
-
function sharePayload(
|
|
2377
|
+
function sharePayload(text3, visibility, media = [], scheduledAt) {
|
|
2360
2378
|
const schedule = scheduledAt === void 0 ? { postState: "PUBLISHED" } : { postState: "SCHEDULED", scheduledAt };
|
|
2361
2379
|
return {
|
|
2362
2380
|
visibleToConnectionsOnly: visibility === "CONNECTIONS",
|
|
2363
2381
|
externalAudienceProviders: [],
|
|
2364
|
-
commentaryV2: { text:
|
|
2382
|
+
commentaryV2: { text: text3, attributes: [] },
|
|
2365
2383
|
origin: "FEED",
|
|
2366
2384
|
allowedCommentersScope: "ALL",
|
|
2367
2385
|
...schedule,
|
|
@@ -2475,15 +2493,15 @@ async function share(confirmed, client, bytes) {
|
|
|
2475
2493
|
note: "LinkedIn accepted the post but the response carried no recognisable urn. Run `lnrelay sync my-posts && lnrelay my-posts` to confirm what actually landed \u2014 and do NOT re-run this command on the assumption it failed, or you will post twice."
|
|
2476
2494
|
} : { ok: true, id };
|
|
2477
2495
|
}
|
|
2478
|
-
function editPostBody(
|
|
2479
|
-
return { patch: { $set: { commentaryV2: { text:
|
|
2496
|
+
function editPostBody(text3) {
|
|
2497
|
+
return { patch: { $set: { commentaryV2: { text: text3, attributes: [] } } } };
|
|
2480
2498
|
}
|
|
2481
2499
|
async function editPost(confirmed, client) {
|
|
2482
|
-
const { urn, text:
|
|
2500
|
+
const { urn, text: text3 } = confirmed.payload;
|
|
2483
2501
|
const result = await client.request({
|
|
2484
2502
|
url: deleteUrl(urn),
|
|
2485
2503
|
method: "POST",
|
|
2486
|
-
body: editPostBody(
|
|
2504
|
+
body: editPostBody(text3),
|
|
2487
2505
|
spendClass: "write",
|
|
2488
2506
|
operation: "edit-post"
|
|
2489
2507
|
});
|
|
@@ -2493,7 +2511,7 @@ async function editPost(confirmed, client) {
|
|
|
2493
2511
|
return out;
|
|
2494
2512
|
}
|
|
2495
2513
|
const held = result.json?.data?.commentary?.text;
|
|
2496
|
-
if (held !==
|
|
2514
|
+
if (held !== text3) {
|
|
2497
2515
|
return {
|
|
2498
2516
|
ok: false,
|
|
2499
2517
|
code: "SCHEMA_DRIFT",
|
|
@@ -2522,14 +2540,14 @@ function pollUrnOf(json) {
|
|
|
2522
2540
|
return JSON.stringify(json ?? null).match(/urn:li:fsd_pollSummary:\d+/)?.[0] ?? null;
|
|
2523
2541
|
}
|
|
2524
2542
|
async function createPoll(poll, client) {
|
|
2525
|
-
const
|
|
2526
|
-
if (
|
|
2543
|
+
const contract2 = contractFor("createPoll");
|
|
2544
|
+
if (contract2?.queryId === void 0) {
|
|
2527
2545
|
return { ok: false, code: "NOT_IMPLEMENTED", message: "no verified poll contract" };
|
|
2528
2546
|
}
|
|
2529
2547
|
const result = await client.request({
|
|
2530
|
-
url: `${
|
|
2548
|
+
url: `${contract2.path}?action=execute&queryId=${contract2.queryId}`,
|
|
2531
2549
|
method: "POST",
|
|
2532
|
-
body: { variables: { poll }, queryId:
|
|
2550
|
+
body: { variables: { poll }, queryId: contract2.queryId, includeWebMetadata: true },
|
|
2533
2551
|
spendClass: "write",
|
|
2534
2552
|
operation: "create-poll"
|
|
2535
2553
|
});
|
|
@@ -2554,16 +2572,16 @@ async function createPoll(poll, client) {
|
|
|
2554
2572
|
}
|
|
2555
2573
|
return { ok: true, urn };
|
|
2556
2574
|
}
|
|
2557
|
-
function firstUrl(
|
|
2558
|
-
const found =
|
|
2575
|
+
function firstUrl(text3) {
|
|
2576
|
+
const found = text3.match(/https?:\/\/[^\s<>"]+/)?.[0];
|
|
2559
2577
|
if (found === void 0) return null;
|
|
2560
2578
|
let url = found.replace(/[.,;:!?'"]+$/, "");
|
|
2561
2579
|
if (url.endsWith(")") && !url.includes("(")) url = url.slice(0, -1);
|
|
2562
2580
|
return url;
|
|
2563
2581
|
}
|
|
2564
2582
|
function urlPreviewUrl(url) {
|
|
2565
|
-
const
|
|
2566
|
-
return `${
|
|
2583
|
+
const contract2 = contractFor("urlPreview");
|
|
2584
|
+
return `${contract2?.path}?includeWebMetadata=true&variables=(url:${encodeURIComponent(url)})&queryId=${contract2?.queryId}`;
|
|
2567
2585
|
}
|
|
2568
2586
|
function parseUrlPreview(json) {
|
|
2569
2587
|
const error = gqlError(json);
|
|
@@ -2719,8 +2737,8 @@ function previewLines2(post) {
|
|
|
2719
2737
|
" about to delete, or that it is yours."
|
|
2720
2738
|
];
|
|
2721
2739
|
}
|
|
2722
|
-
const
|
|
2723
|
-
const shown =
|
|
2740
|
+
const text3 = typeof post.text === "string" ? post.text : "(no text \u2014 media-only post?)";
|
|
2741
|
+
const shown = text3.length > PREVIEW_CHARS ? `${text3.slice(0, PREVIEW_CHARS)}\u2026` : text3;
|
|
2724
2742
|
const lines = [`content "${shown.replace(/\n/g, " ")}"`];
|
|
2725
2743
|
if (typeof post.scheduledAt === "string") {
|
|
2726
2744
|
lines.push(`status scheduled, publishes ${post.scheduledAt} unless cancelled`);
|
|
@@ -2866,6 +2884,483 @@ async function runDelete(urn, now = Date.now(), deps, quiet = false) {
|
|
|
2866
2884
|
return ok("delete", { deleted: urn, verified: post !== void 0, evictedFromCache: evicted });
|
|
2867
2885
|
}
|
|
2868
2886
|
|
|
2887
|
+
// src/engine/jobs.ts
|
|
2888
|
+
function contract(name) {
|
|
2889
|
+
const c = CONTRACTS[name];
|
|
2890
|
+
if (c?.decorationId === void 0) throw new Error(`job contract '${name}' is missing`);
|
|
2891
|
+
return { path: c.path, decorationId: c.decorationId };
|
|
2892
|
+
}
|
|
2893
|
+
var PAGE_SIZE2 = 25;
|
|
2894
|
+
function queryTuple(q2) {
|
|
2895
|
+
const locationUnion = q2.geoId !== void 0 ? { geoId: q2.geoId } : q2.location !== void 0 ? { seoLocation: { location: q2.location } } : void 0;
|
|
2896
|
+
const selected = Object.entries(q2.filters).filter(([, v]) => v.length > 0);
|
|
2897
|
+
return encodeVariables({
|
|
2898
|
+
origin: "JOB_SEARCH_PAGE_JOB_FILTER",
|
|
2899
|
+
keywords: q2.keywords,
|
|
2900
|
+
locationUnion,
|
|
2901
|
+
selectedFilters: selected.length > 0 ? Object.fromEntries(selected) : void 0,
|
|
2902
|
+
spellCorrectionEnabled: true
|
|
2903
|
+
});
|
|
2904
|
+
}
|
|
2905
|
+
function jobSearchUrl(q2) {
|
|
2906
|
+
const c = contract("jobCards");
|
|
2907
|
+
return `${c.path}?decorationId=${c.decorationId}&count=${q2.count}&q=jobSearch&query=${queryTuple(q2)}&start=${q2.start}`;
|
|
2908
|
+
}
|
|
2909
|
+
function jobFiltersUrl(q2) {
|
|
2910
|
+
const c = contract("jobFilters");
|
|
2911
|
+
return `${c.path}?decorationId=${c.decorationId}&q=filters&query=${queryTuple(q2)}`;
|
|
2912
|
+
}
|
|
2913
|
+
function jobDetailUrl(id) {
|
|
2914
|
+
const c = contract("jobPosting");
|
|
2915
|
+
return `${c.path}/${id}?decorationId=${c.decorationId}`;
|
|
2916
|
+
}
|
|
2917
|
+
function jobIdOf(input) {
|
|
2918
|
+
const s = input.trim();
|
|
2919
|
+
if (/^\d+$/.test(s)) return s;
|
|
2920
|
+
const found = s.match(/\/jobs\/view\/(?:[^/?#]*-)?(\d+)/) ?? s.match(/[?&]currentJobId=(\d+)/) ?? s.match(/urn:li:(?:fsd_|fs_normalized_)?jobPosting:(\d+)/);
|
|
2921
|
+
return found?.[1];
|
|
2922
|
+
}
|
|
2923
|
+
var viewUrl = (id) => `https://www.linkedin.com/jobs/view/${id}/`;
|
|
2924
|
+
var day = (ms) => typeof ms === "number" ? new Date(ms).toISOString().slice(0, 10) : void 0;
|
|
2925
|
+
var text2 = (v) => {
|
|
2926
|
+
const t = v?.text;
|
|
2927
|
+
return typeof t === "string" && t.trim() !== "" ? t.trim() : void 0;
|
|
2928
|
+
};
|
|
2929
|
+
function defined2(obj) {
|
|
2930
|
+
for (const k of Object.keys(obj)) if (obj[k] === void 0) delete obj[k];
|
|
2931
|
+
return obj;
|
|
2932
|
+
}
|
|
2933
|
+
var WORKPLACE_SUFFIX = {
|
|
2934
|
+
remote: "remote",
|
|
2935
|
+
hybrid: "hybrid",
|
|
2936
|
+
"on-site": "on-site"
|
|
2937
|
+
};
|
|
2938
|
+
function splitLocation(line) {
|
|
2939
|
+
if (line === void 0) return {};
|
|
2940
|
+
const m = line.match(/^(.*?)\s*\(([^()]+)\)$/);
|
|
2941
|
+
const kind = m?.[2] === void 0 ? void 0 : WORKPLACE_SUFFIX[m[2].toLowerCase()];
|
|
2942
|
+
return kind === void 0 || m?.[1] === void 0 ? { location: line } : { location: m[1], workplace: kind };
|
|
2943
|
+
}
|
|
2944
|
+
function cardToJob(card) {
|
|
2945
|
+
const urn = card.jobPostingUrn ?? card["*jobPosting"];
|
|
2946
|
+
const id = typeof urn === "string" ? jobIdOf(urn) : void 0;
|
|
2947
|
+
const title = typeof card.jobPostingTitle === "string" ? card.jobPostingTitle : text2(card.title);
|
|
2948
|
+
if (id === void 0 || title === void 0) return void 0;
|
|
2949
|
+
const footer = Array.isArray(card.footerItems) ? card.footerItems : [];
|
|
2950
|
+
const listed2 = footer.find((f) => f.type === "LISTED_DATE");
|
|
2951
|
+
const insights = footer.filter((f) => !["LISTED_DATE", "PROMOTED", "EASY_APPLY_TEXT"].includes(String(f.type))).map((f) => text2(f.text)).filter((t) => t !== void 0);
|
|
2952
|
+
const insight = text2(card.relevanceInsight?.text);
|
|
2953
|
+
if (insight !== void 0) insights.push(insight);
|
|
2954
|
+
return defined2({
|
|
2955
|
+
id,
|
|
2956
|
+
title,
|
|
2957
|
+
company: text2(card.primaryDescription),
|
|
2958
|
+
...splitLocation(text2(card.secondaryDescription)),
|
|
2959
|
+
listed: day(listed2?.timeAt),
|
|
2960
|
+
easyApply: footer.some((f) => f.type === "EASY_APPLY_TEXT"),
|
|
2961
|
+
promoted: footer.some((f) => f.type === "PROMOTED"),
|
|
2962
|
+
salary: text2(card.tertiaryDescription),
|
|
2963
|
+
insights: insights.length > 0 ? insights : void 0,
|
|
2964
|
+
url: viewUrl(id)
|
|
2965
|
+
});
|
|
2966
|
+
}
|
|
2967
|
+
var drift2 = (message) => ({
|
|
2968
|
+
ok: false,
|
|
2969
|
+
code: "SCHEMA_DRIFT",
|
|
2970
|
+
message,
|
|
2971
|
+
hint: "the job search response changed shape; re-capture it"
|
|
2972
|
+
});
|
|
2973
|
+
function readCards(elements, included) {
|
|
2974
|
+
const byUrn = /* @__PURE__ */ new Map();
|
|
2975
|
+
for (const node of included) {
|
|
2976
|
+
if (typeof node.entityUrn === "string") byUrn.set(node.entityUrn, node);
|
|
2977
|
+
}
|
|
2978
|
+
const jobs = [];
|
|
2979
|
+
const unknownTypes = {};
|
|
2980
|
+
let unresolved = 0;
|
|
2981
|
+
for (const el of elements) {
|
|
2982
|
+
const union = el.jobCardUnion ?? {};
|
|
2983
|
+
const ref = union["*jobPostingCard"];
|
|
2984
|
+
if (typeof ref !== "string") {
|
|
2985
|
+
for (const kind of Object.keys(union)) unknownTypes[kind] = (unknownTypes[kind] ?? 0) + 1;
|
|
2986
|
+
continue;
|
|
2987
|
+
}
|
|
2988
|
+
const card = byUrn.get(ref);
|
|
2989
|
+
const job = card === void 0 ? void 0 : cardToJob(card);
|
|
2990
|
+
if (job === void 0) unresolved++;
|
|
2991
|
+
else if (!jobs.some((j) => j.id === job.id)) jobs.push(job);
|
|
2992
|
+
}
|
|
2993
|
+
return { jobs, unknownTypes, unresolved };
|
|
2994
|
+
}
|
|
2995
|
+
function resolvedGeo(included) {
|
|
2996
|
+
const geo = included.find((n) => typeof n.$type === "string" && n.$type.endsWith(".common.Geo"));
|
|
2997
|
+
const geoId = typeof geo?.entityUrn === "string" ? geo.entityUrn.split(":").pop() : void 0;
|
|
2998
|
+
const name = typeof geo?.fullLocalizedName === "string" ? geo.fullLocalizedName : void 0;
|
|
2999
|
+
return geoId !== void 0 && name !== void 0 ? { location: { geoId, name } } : {};
|
|
3000
|
+
}
|
|
3001
|
+
function parseJobCards(json) {
|
|
3002
|
+
const root = json;
|
|
3003
|
+
const data = root?.data;
|
|
3004
|
+
const elements = data?.elements;
|
|
3005
|
+
if (data === void 0 || !Array.isArray(elements))
|
|
3006
|
+
return drift2("the job search returned no result list");
|
|
3007
|
+
const paging = data.paging ?? {};
|
|
3008
|
+
const total = typeof paging.total === "number" ? paging.total : void 0;
|
|
3009
|
+
const start = typeof paging.start === "number" ? paging.start : 0;
|
|
3010
|
+
const included = root?.included ?? [];
|
|
3011
|
+
const { jobs, unknownTypes, unresolved } = readCards(elements, included);
|
|
3012
|
+
if (unresolved > 0 && jobs.length === 0)
|
|
3013
|
+
return drift2(`${unresolved} job cards were listed but none could be read`);
|
|
3014
|
+
if (elements.length === 0 && total !== void 0 && total > start) {
|
|
3015
|
+
return {
|
|
3016
|
+
ok: false,
|
|
3017
|
+
code: "SCHEMA_DRIFT",
|
|
3018
|
+
message: `LinkedIn claims ${total} jobs but returned none from ${start}`,
|
|
3019
|
+
hint: 'a failed fetch, not an empty search; do not report "no jobs"'
|
|
3020
|
+
};
|
|
3021
|
+
}
|
|
3022
|
+
return { ok: true, jobs, total, start, ...resolvedGeo(included), unknownTypes };
|
|
3023
|
+
}
|
|
3024
|
+
var WORKPLACE_URN = { "1": "on-site", "2": "remote", "3": "hybrid" };
|
|
3025
|
+
function applyOf(method) {
|
|
3026
|
+
const m = method;
|
|
3027
|
+
if (m === null || m === void 0) return void 0;
|
|
3028
|
+
const type = String(m.$type ?? "");
|
|
3029
|
+
if (type.endsWith("OffsiteApply")) {
|
|
3030
|
+
const url = typeof m.companyApplyUrl === "string" ? m.companyApplyUrl : void 0;
|
|
3031
|
+
return defined2({ type: "external", url });
|
|
3032
|
+
}
|
|
3033
|
+
if (type.endsWith("OnsiteApply")) {
|
|
3034
|
+
const url = typeof m.easyApplyUrl === "string" ? m.easyApplyUrl : void 0;
|
|
3035
|
+
return defined2({ type: "easy-apply", url });
|
|
3036
|
+
}
|
|
3037
|
+
return void 0;
|
|
3038
|
+
}
|
|
3039
|
+
function parseJobDetail(json) {
|
|
3040
|
+
const root = json;
|
|
3041
|
+
const d = root?.data;
|
|
3042
|
+
const rawId = d?.jobPostingId ?? d?.entityUrn;
|
|
3043
|
+
const id = rawId === void 0 ? void 0 : jobIdOf(String(rawId));
|
|
3044
|
+
if (d === void 0 || id === void 0 || typeof d.title !== "string")
|
|
3045
|
+
return drift2("the job response carried no posting");
|
|
3046
|
+
const included = root?.included ?? [];
|
|
3047
|
+
const find = (urn) => typeof urn === "string" ? included.find((n) => n.entityUrn === urn) : void 0;
|
|
3048
|
+
const details = d.companyDetails ?? {};
|
|
3049
|
+
const company = find(details.company ?? details["*companyResolutionResult"]);
|
|
3050
|
+
const companyName = typeof company?.name === "string" ? company.name : typeof details.companyName === "string" ? details.companyName : void 0;
|
|
3051
|
+
const workplaces = Array.isArray(d.workplaceTypes) ? d.workplaceTypes : [];
|
|
3052
|
+
const workplace = WORKPLACE_URN[String(workplaces[0]?.split(":").pop())];
|
|
3053
|
+
const applying = find(d["*applyingInfo"]);
|
|
3054
|
+
const saving = find(d["*savingInfo"]);
|
|
3055
|
+
const list2 = (v) => Array.isArray(v) && v.length > 0 ? v.filter((x) => typeof x === "string") : void 0;
|
|
3056
|
+
return {
|
|
3057
|
+
ok: true,
|
|
3058
|
+
job: defined2({
|
|
3059
|
+
id,
|
|
3060
|
+
title: d.title,
|
|
3061
|
+
company: companyName,
|
|
3062
|
+
companyUrl: typeof company?.url === "string" ? company.url : void 0,
|
|
3063
|
+
location: typeof d.formattedLocation === "string" ? d.formattedLocation : void 0,
|
|
3064
|
+
workplace: workplace ?? (d.workRemoteAllowed === true ? "remote" : void 0),
|
|
3065
|
+
employmentType: typeof d.formattedEmploymentStatus === "string" && d.formattedEmploymentStatus !== "" ? d.formattedEmploymentStatus : void 0,
|
|
3066
|
+
experienceLevel: typeof d.formattedExperienceLevel === "string" && d.formattedExperienceLevel !== "" ? d.formattedExperienceLevel : void 0,
|
|
3067
|
+
industries: list2(d.formattedIndustries),
|
|
3068
|
+
functions: list2(d.formattedJobFunctions),
|
|
3069
|
+
listed: day(d.listedAt),
|
|
3070
|
+
expires: day(d.expireAt),
|
|
3071
|
+
state: typeof d.jobState === "string" ? d.jobState : void 0,
|
|
3072
|
+
applicants: typeof d.applies === "number" && d.applies > 0 ? d.applies : void 0,
|
|
3073
|
+
apply: applyOf(d.applyMethod),
|
|
3074
|
+
ats: typeof d.applicantTrackingSystem === "string" ? d.applicantTrackingSystem : void 0,
|
|
3075
|
+
applied: typeof applying?.applied === "boolean" ? applying.applied : void 0,
|
|
3076
|
+
saved: typeof saving?.saved === "boolean" ? saving.saved : void 0,
|
|
3077
|
+
description: text2(d.description),
|
|
3078
|
+
url: viewUrl(id)
|
|
3079
|
+
})
|
|
3080
|
+
};
|
|
3081
|
+
}
|
|
3082
|
+
function parseJobFilters(json) {
|
|
3083
|
+
const elements = json?.data?.elements;
|
|
3084
|
+
if (!Array.isArray(elements)) return drift2("the job filter list was missing");
|
|
3085
|
+
const filters = [];
|
|
3086
|
+
for (const el of elements) {
|
|
3087
|
+
const groups = [
|
|
3088
|
+
...el.secondaryFilterGroups ?? [],
|
|
3089
|
+
...el.primaryFilterGroups ?? []
|
|
3090
|
+
];
|
|
3091
|
+
for (const group of groups) {
|
|
3092
|
+
for (const f of group.filters ?? []) {
|
|
3093
|
+
const key = f.parameterName;
|
|
3094
|
+
if (typeof key !== "string" || filters.some((x) => x.key === key)) continue;
|
|
3095
|
+
const values = [
|
|
3096
|
+
...f.secondaryFilterValues ?? [],
|
|
3097
|
+
...f.primaryFilterValues ?? []
|
|
3098
|
+
];
|
|
3099
|
+
const options = values.filter((v) => typeof v.value === "string").map(
|
|
3100
|
+
(v) => defined2({
|
|
3101
|
+
value: v.value,
|
|
3102
|
+
label: text2(v.displayName) ?? (typeof v.displayName === "string" ? v.displayName : String(v.value)),
|
|
3103
|
+
count: typeof v.count === "number" ? v.count : void 0
|
|
3104
|
+
})
|
|
3105
|
+
);
|
|
3106
|
+
if (options.length === 0) continue;
|
|
3107
|
+
filters.push({ key, label: text2(f.displayName) ?? key, options });
|
|
3108
|
+
}
|
|
3109
|
+
}
|
|
3110
|
+
}
|
|
3111
|
+
if (filters.length === 0) return drift2("the job filter list was empty");
|
|
3112
|
+
return { ok: true, filters };
|
|
3113
|
+
}
|
|
3114
|
+
var NAMED = {
|
|
3115
|
+
experience: {
|
|
3116
|
+
param: "experience",
|
|
3117
|
+
values: {
|
|
3118
|
+
internship: "1",
|
|
3119
|
+
entry: "2",
|
|
3120
|
+
associate: "3",
|
|
3121
|
+
"mid-senior": "4",
|
|
3122
|
+
senior: "4",
|
|
3123
|
+
director: "5",
|
|
3124
|
+
executive: "6"
|
|
3125
|
+
}
|
|
3126
|
+
},
|
|
3127
|
+
type: {
|
|
3128
|
+
param: "jobType",
|
|
3129
|
+
values: {
|
|
3130
|
+
"full-time": "F",
|
|
3131
|
+
"part-time": "P",
|
|
3132
|
+
contract: "C",
|
|
3133
|
+
temporary: "T",
|
|
3134
|
+
volunteer: "V",
|
|
3135
|
+
internship: "I",
|
|
3136
|
+
other: "O"
|
|
3137
|
+
}
|
|
3138
|
+
},
|
|
3139
|
+
workplace: {
|
|
3140
|
+
param: "workplaceType",
|
|
3141
|
+
values: { "on-site": "1", onsite: "1", remote: "2", hybrid: "3" }
|
|
3142
|
+
}
|
|
3143
|
+
};
|
|
3144
|
+
var POSTED = {
|
|
3145
|
+
day: 86400,
|
|
3146
|
+
"24h": 86400,
|
|
3147
|
+
week: 604800,
|
|
3148
|
+
month: 2592e3
|
|
3149
|
+
};
|
|
3150
|
+
var Refused = class extends Error {
|
|
3151
|
+
};
|
|
3152
|
+
function postedRange(given) {
|
|
3153
|
+
const p = given.toLowerCase();
|
|
3154
|
+
const n = p.match(/^(\d+)([hd])$/);
|
|
3155
|
+
const seconds = POSTED[p] ?? (n ? Number(n[1]) * (n[2] === "h" ? 3600 : 86400) : void 0);
|
|
3156
|
+
if (seconds === void 0)
|
|
3157
|
+
throw new Refused(`--posted '${given}' is not one of: 24h, week, month, or <N>h / <N>d`);
|
|
3158
|
+
return `r${seconds}`;
|
|
3159
|
+
}
|
|
3160
|
+
function named(name, given) {
|
|
3161
|
+
const { values } = NAMED[name];
|
|
3162
|
+
const out = [];
|
|
3163
|
+
for (const v of given) {
|
|
3164
|
+
const mapped = values[v.toLowerCase()] ?? (Object.values(values).includes(v) ? v : void 0);
|
|
3165
|
+
if (mapped === void 0)
|
|
3166
|
+
throw new Refused(`--${name} '${v}' is not one of: ${Object.keys(values).join(", ")}`);
|
|
3167
|
+
if (!out.includes(mapped)) out.push(mapped);
|
|
3168
|
+
}
|
|
3169
|
+
return out;
|
|
3170
|
+
}
|
|
3171
|
+
function rawFilter(r) {
|
|
3172
|
+
const m = r.match(/^([A-Za-z_]+)=(.+)$/);
|
|
3173
|
+
if (m?.[1] === void 0 || m[2] === void 0)
|
|
3174
|
+
throw new Refused(`--filter '${r}' is not key=value[,value]`);
|
|
3175
|
+
const values = m[2].split(",").map((v) => v.trim()).filter((v) => v !== "");
|
|
3176
|
+
return [m[1], values];
|
|
3177
|
+
}
|
|
3178
|
+
function selection(o) {
|
|
3179
|
+
const filters = {};
|
|
3180
|
+
if (o.posted !== void 0) filters.timePostedRange = [postedRange(o.posted)];
|
|
3181
|
+
for (const name of ["experience", "type", "workplace"]) {
|
|
3182
|
+
const given = o[name];
|
|
3183
|
+
if (given !== void 0 && given.length > 0)
|
|
3184
|
+
filters[NAMED[name].param] = named(name, given);
|
|
3185
|
+
}
|
|
3186
|
+
const flags = [
|
|
3187
|
+
[o.easyApply, "applyWithLinkedin"],
|
|
3188
|
+
[o.under10, "earlyApplicant"],
|
|
3189
|
+
[o.verified, "verifiedJob"],
|
|
3190
|
+
[o.inNetwork, "jobInYourNetwork"],
|
|
3191
|
+
[o.fairChance, "fairChanceEmployer"]
|
|
3192
|
+
];
|
|
3193
|
+
for (const [on, param] of flags) if (on === true) filters[param] = ["true"];
|
|
3194
|
+
const ids = [
|
|
3195
|
+
[o.company, "company"],
|
|
3196
|
+
[o.industry, "industry"],
|
|
3197
|
+
[o.function, "function"],
|
|
3198
|
+
[o.title, "title"],
|
|
3199
|
+
[o.place, "populatedPlace"]
|
|
3200
|
+
];
|
|
3201
|
+
for (const [given, param] of ids)
|
|
3202
|
+
if (given !== void 0 && given.length > 0) filters[param] = given;
|
|
3203
|
+
if (o.sort !== void 0) {
|
|
3204
|
+
const sort = { recent: "DD", relevant: "R" }[o.sort.toLowerCase()];
|
|
3205
|
+
if (sort === void 0) throw new Refused(`--sort '${o.sort}' is not one of: recent, relevant`);
|
|
3206
|
+
filters.sortBy = [sort];
|
|
3207
|
+
}
|
|
3208
|
+
if (o.distance !== void 0) filters.distance = [String(o.distance)];
|
|
3209
|
+
for (const r of o.raw ?? []) {
|
|
3210
|
+
const [key, values] = rawFilter(r);
|
|
3211
|
+
filters[key] = values;
|
|
3212
|
+
}
|
|
3213
|
+
return filters;
|
|
3214
|
+
}
|
|
3215
|
+
function jobFilterSelection(o) {
|
|
3216
|
+
try {
|
|
3217
|
+
return { ok: true, filters: selection(o) };
|
|
3218
|
+
} catch (e) {
|
|
3219
|
+
if (e instanceof Refused) return { ok: false, code: "INVALID_INPUT", message: e.message };
|
|
3220
|
+
throw e;
|
|
3221
|
+
}
|
|
3222
|
+
}
|
|
3223
|
+
|
|
3224
|
+
// src/commands/jobs.ts
|
|
3225
|
+
function liveFetch(command, quiet) {
|
|
3226
|
+
const session = loadSession();
|
|
3227
|
+
if (session.state !== "ok")
|
|
3228
|
+
return err(command, "AUTH_FAILED", "no LinkedIn session \u2014 run `lnrelay login`");
|
|
3229
|
+
const client = createLiveClient(session.session, void 0, quiet);
|
|
3230
|
+
return async (url, spendClass) => {
|
|
3231
|
+
const r = await client.request({ url, spendClass, operation: command });
|
|
3232
|
+
return r.ok ? { ok: true, json: r.json } : r;
|
|
3233
|
+
};
|
|
3234
|
+
}
|
|
3235
|
+
var MAX_RESULTS = 1e3;
|
|
3236
|
+
function compactJob(j) {
|
|
3237
|
+
const parts = [j.id, j.title, j.company, j.location, j.workplace, j.listed];
|
|
3238
|
+
if (j.easyApply) parts.push("easy apply");
|
|
3239
|
+
if (j.promoted) parts.push("promoted");
|
|
3240
|
+
parts.push(j.salary);
|
|
3241
|
+
if (j.apply?.url !== void 0) parts.push(`apply: ${j.apply.url}`);
|
|
3242
|
+
return parts.filter((p) => p !== void 0 && p !== "").map((p) => p.replaceAll(" | ", " / ")).join(" | ");
|
|
3243
|
+
}
|
|
3244
|
+
function shape(rows, opts, line) {
|
|
3245
|
+
if (opts.compact === true) return rows.map(line);
|
|
3246
|
+
if (opts.fields !== void 0 && opts.fields !== "")
|
|
3247
|
+
return project(rows, opts.fields);
|
|
3248
|
+
return rows;
|
|
3249
|
+
}
|
|
3250
|
+
function queryOf(req, filters) {
|
|
3251
|
+
return {
|
|
3252
|
+
...req.keywords ? { keywords: req.keywords } : {},
|
|
3253
|
+
...req.location ? { location: req.location } : {},
|
|
3254
|
+
...req.geoId ? { geoId: req.geoId } : {},
|
|
3255
|
+
filters
|
|
3256
|
+
};
|
|
3257
|
+
}
|
|
3258
|
+
async function collect(get, query, first, want) {
|
|
3259
|
+
const out = { jobs: [], exhausted: false, unknownTypes: {} };
|
|
3260
|
+
for (let start = first; out.jobs.length < want && start < MAX_RESULTS; start += PAGE_SIZE2) {
|
|
3261
|
+
const res = await get(jobSearchUrl({ ...query, start, count: PAGE_SIZE2 }), "search");
|
|
3262
|
+
const page = res.ok ? parseJobCards(res.json) : res;
|
|
3263
|
+
if (!page.ok) {
|
|
3264
|
+
if (out.jobs.length === 0) return page;
|
|
3265
|
+
out.stoppedBy = page.code;
|
|
3266
|
+
break;
|
|
3267
|
+
}
|
|
3268
|
+
out.total = page.total ?? out.total;
|
|
3269
|
+
out.resolved = page.location ?? out.resolved;
|
|
3270
|
+
for (const [k, n] of Object.entries(page.unknownTypes))
|
|
3271
|
+
out.unknownTypes[k] = (out.unknownTypes[k] ?? 0) + n;
|
|
3272
|
+
const fresh = page.jobs.filter((j) => !out.jobs.some((x) => x.id === j.id));
|
|
3273
|
+
out.jobs.push(...fresh.slice(0, want - out.jobs.length));
|
|
3274
|
+
if (page.jobs.length === 0 || out.total !== void 0 && start + PAGE_SIZE2 >= out.total) {
|
|
3275
|
+
out.exhausted = true;
|
|
3276
|
+
break;
|
|
3277
|
+
}
|
|
3278
|
+
}
|
|
3279
|
+
return out;
|
|
3280
|
+
}
|
|
3281
|
+
async function addDetails(get, jobs, withDescription) {
|
|
3282
|
+
for (const job of jobs) {
|
|
3283
|
+
const res = await get(jobDetailUrl(job.id), "profile");
|
|
3284
|
+
const detail = res.ok ? parseJobDetail(res.json) : res;
|
|
3285
|
+
if (!detail.ok) return detail.code;
|
|
3286
|
+
const { description, id: _id, url: _url, ...rest } = detail.job;
|
|
3287
|
+
Object.assign(job, rest, withDescription ? { description } : {});
|
|
3288
|
+
}
|
|
3289
|
+
return void 0;
|
|
3290
|
+
}
|
|
3291
|
+
async function runJobs(req, opts = {}, fetch2) {
|
|
3292
|
+
const hasQuery = [req.keywords, req.location, req.geoId].some((v) => v !== void 0 && v !== "");
|
|
3293
|
+
if (!hasQuery) {
|
|
3294
|
+
return err(
|
|
3295
|
+
"jobs",
|
|
3296
|
+
"INVALID_INPUT",
|
|
3297
|
+
"give keywords, a location, or both",
|
|
3298
|
+
'lnrelay jobs "<keywords>" [--location "<place>" | --geo <id>] [filters]'
|
|
3299
|
+
);
|
|
3300
|
+
}
|
|
3301
|
+
const selection2 = jobFilterSelection(req.filter ?? {});
|
|
3302
|
+
if (!selection2.ok)
|
|
3303
|
+
return err("jobs", selection2.code, selection2.message, "see `lnrelay help jobs`");
|
|
3304
|
+
const get = fetch2 ?? liveFetch("jobs", opts.quiet === true);
|
|
3305
|
+
if (typeof get !== "function") return get;
|
|
3306
|
+
const first = Math.max(0, req.start ?? 0);
|
|
3307
|
+
const want = Math.max(1, Math.min(req.limit, MAX_RESULTS - first));
|
|
3308
|
+
const query = queryOf(req, selection2.filters);
|
|
3309
|
+
const found = await collect(get, query, first, want);
|
|
3310
|
+
if ("ok" in found) return err("jobs", found.code, found.message, found.hint);
|
|
3311
|
+
if (req.details === true) {
|
|
3312
|
+
const stopped = await addDetails(get, found.jobs, req.description === true);
|
|
3313
|
+
found.stoppedBy = found.stoppedBy ?? stopped;
|
|
3314
|
+
}
|
|
3315
|
+
const { jobs, stoppedBy, exhausted, unknownTypes } = found;
|
|
3316
|
+
return ok("jobs", {
|
|
3317
|
+
query,
|
|
3318
|
+
...found.resolved !== void 0 ? { location: found.resolved } : {},
|
|
3319
|
+
items: shape(jobs, opts, compactJob),
|
|
3320
|
+
meta: {
|
|
3321
|
+
state: stoppedBy === void 0 && exhausted ? "complete" : "partial",
|
|
3322
|
+
operation: "jobs",
|
|
3323
|
+
claimedCount: found.total,
|
|
3324
|
+
returnedCount: jobs.length,
|
|
3325
|
+
start: first,
|
|
3326
|
+
next: exhausted ? void 0 : first + jobs.length,
|
|
3327
|
+
...stoppedBy !== void 0 ? { stoppedBy } : {},
|
|
3328
|
+
...Object.keys(unknownTypes).length > 0 ? { unknownTypes } : {}
|
|
3329
|
+
}
|
|
3330
|
+
});
|
|
3331
|
+
}
|
|
3332
|
+
async function runJob(input, opts = {}, fetch2) {
|
|
3333
|
+
const id = input === void 0 ? void 0 : jobIdOf(input);
|
|
3334
|
+
if (id === void 0) {
|
|
3335
|
+
return err("job", "INVALID_INPUT", "a job id or job URL is required", "lnrelay job <id|url>");
|
|
3336
|
+
}
|
|
3337
|
+
const get = fetch2 ?? liveFetch("job", opts.quiet === true);
|
|
3338
|
+
if (typeof get !== "function") return get;
|
|
3339
|
+
const res = await get(jobDetailUrl(id), "profile");
|
|
3340
|
+
if (!res.ok) return err("job", res.code, res.message, res.hint);
|
|
3341
|
+
const detail = parseJobDetail(res.json);
|
|
3342
|
+
if (!detail.ok) return err("job", detail.code, detail.message, detail.hint);
|
|
3343
|
+
return ok("job", detail.job);
|
|
3344
|
+
}
|
|
3345
|
+
async function runJobFilters(req, opts = {}, fetch2) {
|
|
3346
|
+
const selection2 = jobFilterSelection(req.filter ?? {});
|
|
3347
|
+
if (!selection2.ok) return err("job-filters", selection2.code, selection2.message);
|
|
3348
|
+
const get = fetch2 ?? liveFetch("job-filters", opts.quiet === true);
|
|
3349
|
+
if (typeof get !== "function") return get;
|
|
3350
|
+
const url = jobFiltersUrl({ ...queryOf(req, selection2.filters), start: 0, count: PAGE_SIZE2 });
|
|
3351
|
+
const res = await get(url, "search");
|
|
3352
|
+
const parsed = res.ok ? parseJobFilters(res.json) : res;
|
|
3353
|
+
if (!parsed.ok) return err("job-filters", parsed.code, parsed.message, parsed.hint);
|
|
3354
|
+
return ok("job-filters", {
|
|
3355
|
+
items: shape(
|
|
3356
|
+
parsed.filters,
|
|
3357
|
+
opts,
|
|
3358
|
+
(f) => `${f.key}: ${f.options.map((o) => `${o.value}=${o.label}${o.count !== void 0 ? ` (${o.count})` : ""}`).join(", ")}`
|
|
3359
|
+
),
|
|
3360
|
+
meta: { state: "complete", operation: "job-filters", returnedCount: parsed.filters.length }
|
|
3361
|
+
});
|
|
3362
|
+
}
|
|
3363
|
+
|
|
2869
3364
|
// src/commands/live.ts
|
|
2870
3365
|
function withSession(command, quiet = false) {
|
|
2871
3366
|
const loaded = sessionFor(command);
|
|
@@ -3215,18 +3710,18 @@ async function exchange(code, config, deps) {
|
|
|
3215
3710
|
} catch (e) {
|
|
3216
3711
|
return { ok: false, message: `could not reach LinkedIn: ${e.message}` };
|
|
3217
3712
|
}
|
|
3218
|
-
const
|
|
3713
|
+
const text3 = await res.text();
|
|
3219
3714
|
if (res.status !== 200) {
|
|
3220
3715
|
return {
|
|
3221
3716
|
ok: false,
|
|
3222
3717
|
message: `LinkedIn rejected the code exchange (${res.status})`,
|
|
3223
3718
|
// The most common causes, in the order they actually happen.
|
|
3224
|
-
hint: `Check that the app has BOTH products added, and that its Auth tab lists exactly ${REDIRECT_URI} as an authorized redirect URL. Response: ${
|
|
3719
|
+
hint: `Check that the app has BOTH products added, and that its Auth tab lists exactly ${REDIRECT_URI} as an authorized redirect URL. Response: ${text3.slice(0, 200)}`
|
|
3225
3720
|
};
|
|
3226
3721
|
}
|
|
3227
3722
|
let parsed;
|
|
3228
3723
|
try {
|
|
3229
|
-
parsed = JSON.parse(
|
|
3724
|
+
parsed = JSON.parse(text3);
|
|
3230
3725
|
} catch {
|
|
3231
3726
|
return { ok: false, message: "token response was not JSON" };
|
|
3232
3727
|
}
|
|
@@ -3522,7 +4017,34 @@ var COMMANDS = [
|
|
|
3522
4017
|
name: "search",
|
|
3523
4018
|
cost: "cheap \u2014 the net",
|
|
3524
4019
|
summary: "Search people, companies or jobs. Cast wide, then deep-read the finalists.",
|
|
3525
|
-
usage: 'lnrelay search people|companies|jobs "<query>" [--limit N]\n [--compact | --fields a,b,c] [--retain] [--raw]',
|
|
4020
|
+
usage: 'lnrelay search people|companies|jobs "<query>" [--limit N] (jobs: see `jobs`)\n [--compact | --fields a,b,c] [--retain] [--raw]',
|
|
4021
|
+
audience: ["cli", "mcp"],
|
|
4022
|
+
risk: "read",
|
|
4023
|
+
implemented: true
|
|
4024
|
+
},
|
|
4025
|
+
{
|
|
4026
|
+
name: "jobs",
|
|
4027
|
+
cost: "1 search call per 25 jobs; --details adds 1 profile call per job",
|
|
4028
|
+
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`.",
|
|
4029
|
+
usage: 'lnrelay jobs "<keywords>" [--location "<place>" | --geo <id>] [--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.',
|
|
4030
|
+
audience: ["cli", "mcp"],
|
|
4031
|
+
risk: "read",
|
|
4032
|
+
implemented: true
|
|
4033
|
+
},
|
|
4034
|
+
{
|
|
4035
|
+
name: "job",
|
|
4036
|
+
cost: "1 profile call",
|
|
4037
|
+
summary: "One job: description, apply link (external or Easy Apply), applicants, state.",
|
|
4038
|
+
usage: "lnrelay job <id|job-url>",
|
|
4039
|
+
audience: ["cli", "mcp"],
|
|
4040
|
+
risk: "read",
|
|
4041
|
+
implemented: true
|
|
4042
|
+
},
|
|
4043
|
+
{
|
|
4044
|
+
name: "job-filters",
|
|
4045
|
+
cost: "1 search call",
|
|
4046
|
+
summary: "Every job filter for a query, with option ids and live counts: what `jobs --filter` and --company/--industry/--title/--place take.",
|
|
4047
|
+
usage: 'lnrelay job-filters "<keywords>" [--location "<place>" | --geo <id>] [jobs filters]',
|
|
3526
4048
|
audience: ["cli", "mcp"],
|
|
3527
4049
|
risk: "read",
|
|
3528
4050
|
implemented: true
|
|
@@ -3554,15 +4076,6 @@ var COMMANDS = [
|
|
|
3554
4076
|
risk: "read",
|
|
3555
4077
|
implemented: false
|
|
3556
4078
|
},
|
|
3557
|
-
{
|
|
3558
|
-
name: "job",
|
|
3559
|
-
cost: "1 call",
|
|
3560
|
-
summary: "A job posting detail.",
|
|
3561
|
-
usage: "lnrelay job <job-id|url>",
|
|
3562
|
-
audience: ["cli", "mcp"],
|
|
3563
|
-
risk: "read",
|
|
3564
|
-
implemented: false
|
|
3565
|
-
},
|
|
3566
4079
|
{
|
|
3567
4080
|
name: "feed",
|
|
3568
4081
|
cost: "medium",
|
|
@@ -3618,6 +4131,15 @@ var COMMANDS = [
|
|
|
3618
4131
|
risk: "read",
|
|
3619
4132
|
implemented: true
|
|
3620
4133
|
},
|
|
4134
|
+
{
|
|
4135
|
+
name: "skills",
|
|
4136
|
+
cost: "3 calls",
|
|
4137
|
+
summary: "The skills on your own profile, with the skill id `skill remove` takes.",
|
|
4138
|
+
usage: "lnrelay skills",
|
|
4139
|
+
audience: ["cli", "mcp"],
|
|
4140
|
+
risk: "read",
|
|
4141
|
+
implemented: true
|
|
4142
|
+
},
|
|
3621
4143
|
{
|
|
3622
4144
|
name: "local",
|
|
3623
4145
|
cost: "free \u2014 local cache",
|
|
@@ -3718,6 +4240,15 @@ var COMMANDS = [
|
|
|
3718
4240
|
risk: "write",
|
|
3719
4241
|
implemented: true
|
|
3720
4242
|
},
|
|
4243
|
+
{
|
|
4244
|
+
name: "skill",
|
|
4245
|
+
cost: "4-5 reads + 1 write",
|
|
4246
|
+
summary: "Add a skill to your profile, or remove one.",
|
|
4247
|
+
usage: 'lnrelay skill add "<name>"\n lnrelay skill remove <skill-id>\n Skill ids come from `lnrelay skills`. A skill is added as free text, linked to no role,\n school or project. Removing a skill removes its endorsements with it.',
|
|
4248
|
+
audience: ["cli"],
|
|
4249
|
+
risk: "write",
|
|
4250
|
+
implemented: true
|
|
4251
|
+
},
|
|
3721
4252
|
{
|
|
3722
4253
|
name: "react",
|
|
3723
4254
|
cost: "1 call \u2014 write",
|
|
@@ -3765,10 +4296,10 @@ function balanced(s, start) {
|
|
|
3765
4296
|
return null;
|
|
3766
4297
|
}
|
|
3767
4298
|
function parseAt(s, start) {
|
|
3768
|
-
const
|
|
3769
|
-
if (
|
|
4299
|
+
const text3 = start < 0 ? null : balanced(s, start);
|
|
4300
|
+
if (text3 === null) return null;
|
|
3770
4301
|
try {
|
|
3771
|
-
return JSON.parse(
|
|
4302
|
+
return JSON.parse(text3);
|
|
3772
4303
|
} catch {
|
|
3773
4304
|
return null;
|
|
3774
4305
|
}
|
|
@@ -3939,7 +4470,7 @@ var PROFILE_FIELDS = {
|
|
|
3939
4470
|
maxLength: 2600
|
|
3940
4471
|
}
|
|
3941
4472
|
};
|
|
3942
|
-
var
|
|
4473
|
+
var drift3 = (message) => ({
|
|
3943
4474
|
ok: false,
|
|
3944
4475
|
code: "SCHEMA_DRIFT",
|
|
3945
4476
|
message,
|
|
@@ -3947,10 +4478,10 @@ var drift2 = (message) => ({
|
|
|
3947
4478
|
});
|
|
3948
4479
|
function readForm(stream, field) {
|
|
3949
4480
|
const states2 = readModel(stream);
|
|
3950
|
-
if (states2 === null) return
|
|
4481
|
+
if (states2 === null) return drift3("the profile form carried no initial values");
|
|
3951
4482
|
const args = findRequest(stream, field.save);
|
|
3952
4483
|
if (args === null)
|
|
3953
|
-
return
|
|
4484
|
+
return drift3(`the profile form carried no ${field.save.split(".").pop()} action`);
|
|
3954
4485
|
return { ok: true, args, states: states2, screen: field.screen, save: field.save };
|
|
3955
4486
|
}
|
|
3956
4487
|
function boundKey(form, property) {
|
|
@@ -3966,7 +4497,7 @@ function topSkills(form) {
|
|
|
3966
4497
|
return (key) => {
|
|
3967
4498
|
if (!key.endsWith("ReorderableSkillsFormBindingsskillIdsBinding")) return void 0;
|
|
3968
4499
|
const initial = [...form.states.entries()].find(([k]) => k.startsWith("initialSkills"))?.[1];
|
|
3969
|
-
if (initial === void 0) return
|
|
4500
|
+
if (initial === void 0) return drift3("the About form carried no initial top skills");
|
|
3970
4501
|
if (!Array.isArray(initial.value) || initial.value.length > 0) {
|
|
3971
4502
|
return {
|
|
3972
4503
|
ok: false,
|
|
@@ -3989,7 +4520,7 @@ function saveBody(form, field, value) {
|
|
|
3989
4520
|
const target = boundKey(form, field.binding);
|
|
3990
4521
|
const current = target === void 0 ? void 0 : form.states.get(target);
|
|
3991
4522
|
if (target === void 0 || current === void 0) {
|
|
3992
|
-
return
|
|
4523
|
+
return drift3(`the profile form has no ${field.name} field`);
|
|
3993
4524
|
}
|
|
3994
4525
|
const model = new Map(form.states);
|
|
3995
4526
|
model.set(target, { ...current, value });
|
|
@@ -4058,7 +4589,7 @@ var POSITION = {
|
|
|
4058
4589
|
var EDIT_NAV = `{"$type":"proto.sdui.actions.core.NavigateToScreen","screenId":"${POSITION.editScreen}"`;
|
|
4059
4590
|
function listPositions(stream) {
|
|
4060
4591
|
if (readModel(stream) === null && !stream.includes(EDIT_NAV) && !stream.includes('"rows"')) {
|
|
4061
|
-
return
|
|
4592
|
+
return drift3("the Experience screen could not be read");
|
|
4062
4593
|
}
|
|
4063
4594
|
const positions = [];
|
|
4064
4595
|
const seen = /* @__PURE__ */ new Set();
|
|
@@ -4066,27 +4597,27 @@ function listPositions(stream) {
|
|
|
4066
4597
|
for (; ; ) {
|
|
4067
4598
|
i = stream.indexOf(EDIT_NAV, i);
|
|
4068
4599
|
if (i === -1) break;
|
|
4069
|
-
const
|
|
4600
|
+
const text3 = balanced(stream, i);
|
|
4070
4601
|
i += EDIT_NAV.length;
|
|
4071
|
-
if (
|
|
4072
|
-
const payload = JSON.parse(
|
|
4602
|
+
if (text3 === null) continue;
|
|
4603
|
+
const payload = JSON.parse(text3).requestedArguments?.payload;
|
|
4073
4604
|
const id = payload?.positionId;
|
|
4074
4605
|
if (typeof id !== "string" || seen.has(id) || payload === void 0) continue;
|
|
4075
4606
|
seen.add(id);
|
|
4076
4607
|
positions.push({ positionId: id, title: String(payload.title ?? ""), payload });
|
|
4077
4608
|
}
|
|
4078
4609
|
if (positions.length === 0 && !stream.includes('"rows"') && !stream.includes("Experience")) {
|
|
4079
|
-
return
|
|
4610
|
+
return drift3("the Experience screen listed no roles and did not look like one");
|
|
4080
4611
|
}
|
|
4081
4612
|
return { ok: true, positions };
|
|
4082
4613
|
}
|
|
4083
4614
|
function readPositionForm(stream) {
|
|
4084
4615
|
const model = readModel(stream);
|
|
4085
|
-
if (model === null) return
|
|
4616
|
+
if (model === null) return drift3("the position form carried no initial values");
|
|
4086
4617
|
const media = findRequest(stream, POSITION.media);
|
|
4087
4618
|
const prefix = media?.payload.formIdPrefix;
|
|
4088
4619
|
if (media === null || typeof prefix !== "string") {
|
|
4089
|
-
return
|
|
4620
|
+
return drift3("the position form carried no save step (uploadPositionMedia)");
|
|
4090
4621
|
}
|
|
4091
4622
|
const del = findRequest(stream, POSITION.delete);
|
|
4092
4623
|
return {
|
|
@@ -4137,7 +4668,7 @@ function applyChanges(form, changes) {
|
|
|
4137
4668
|
}
|
|
4138
4669
|
need("dynamicallyCreateHeadline", false);
|
|
4139
4670
|
need("allowProfileEditBroadcasts", changes.notify === true);
|
|
4140
|
-
if (missing.length > 0) return
|
|
4671
|
+
if (missing.length > 0) return drift3(`the position form has no ${missing.join(", ")} field`);
|
|
4141
4672
|
const s = roleSummary(model);
|
|
4142
4673
|
if (!s.current && s.start !== null && s.end !== null && s.end < s.start) {
|
|
4143
4674
|
return {
|
|
@@ -4182,7 +4713,7 @@ function mediaBody(form, model) {
|
|
|
4182
4713
|
}
|
|
4183
4714
|
function saveFromReply(reply) {
|
|
4184
4715
|
const args = findRequest(reply, POSITION.save);
|
|
4185
|
-
return args === null ?
|
|
4716
|
+
return args === null ? drift3("the media step did not hand back the save action") : { ok: true, args };
|
|
4186
4717
|
}
|
|
4187
4718
|
function positionSaveBody(save, model, screen) {
|
|
4188
4719
|
const sending = new Map(model);
|
|
@@ -4194,7 +4725,7 @@ function positionSaveBody(save, model, screen) {
|
|
|
4194
4725
|
}
|
|
4195
4726
|
function deleteBody(form) {
|
|
4196
4727
|
if (form.del === null)
|
|
4197
|
-
return
|
|
4728
|
+
return drift3("this form has no delete action (it is not an existing role)");
|
|
4198
4729
|
const states2 = wireStates(keysOf(form.del), form.model, resolver);
|
|
4199
4730
|
if (!Array.isArray(states2)) return states2;
|
|
4200
4731
|
return { ok: true, body: requestBody(POSITION.delete, form.del, states2, form.screen) };
|
|
@@ -4272,9 +4803,9 @@ async function send(url, body, token, deps) {
|
|
|
4272
4803
|
} catch (e) {
|
|
4273
4804
|
return { ok: false, code: "FETCH_FAILED", message: e.message };
|
|
4274
4805
|
}
|
|
4275
|
-
const
|
|
4806
|
+
const text3 = await res.text();
|
|
4276
4807
|
if (res.status === 201 || res.status === 200) {
|
|
4277
|
-
const id = res.headers.get("x-restli-id") ?? extractId(
|
|
4808
|
+
const id = res.headers.get("x-restli-id") ?? extractId(text3);
|
|
4278
4809
|
return {
|
|
4279
4810
|
ok: true,
|
|
4280
4811
|
id: id ?? "(unknown)",
|
|
@@ -4301,7 +4832,7 @@ async function send(url, body, token, deps) {
|
|
|
4301
4832
|
ok: false,
|
|
4302
4833
|
code: "FETCH_FAILED",
|
|
4303
4834
|
message: `write failed (${res.status})`,
|
|
4304
|
-
hint:
|
|
4835
|
+
hint: text3.slice(0, 300)
|
|
4305
4836
|
};
|
|
4306
4837
|
}
|
|
4307
4838
|
function extractId(body) {
|
|
@@ -4349,7 +4880,7 @@ function feedTypeFor(bindingKey) {
|
|
|
4349
4880
|
function stateKey(prefix, body) {
|
|
4350
4881
|
return `${prefix}-${body}`;
|
|
4351
4882
|
}
|
|
4352
|
-
function states(
|
|
4883
|
+
function states(text3, body) {
|
|
4353
4884
|
return STATE_PREFIXES.map((prefix) => {
|
|
4354
4885
|
const key = stateKey(prefix, body);
|
|
4355
4886
|
const base = {
|
|
@@ -4358,19 +4889,19 @@ function states(text2, body) {
|
|
|
4358
4889
|
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: key } }
|
|
4359
4890
|
};
|
|
4360
4891
|
if (prefix === "commentBoxText") {
|
|
4361
|
-
return { ...base, value:
|
|
4892
|
+
return { ...base, value: text3, originalProtoCase: "stringValue" };
|
|
4362
4893
|
}
|
|
4363
4894
|
if (prefix === "richCommentBoxText") {
|
|
4364
4895
|
return {
|
|
4365
4896
|
...base,
|
|
4366
|
-
value: { text:
|
|
4897
|
+
value: { text: text3, attribute: [], $type: "TextModel", source: "local" },
|
|
4367
4898
|
originalProtoCase: "textModelForWrite"
|
|
4368
4899
|
};
|
|
4369
4900
|
}
|
|
4370
4901
|
return { ...base, value: "", originalProtoCase: "stringValue" };
|
|
4371
4902
|
});
|
|
4372
4903
|
}
|
|
4373
|
-
function commentBody(activityId,
|
|
4904
|
+
function commentBody(activityId, text3, tokens, feedType) {
|
|
4374
4905
|
const body = keyBody(tokens.bindingKey);
|
|
4375
4906
|
const activityUrn = { activityUrn: { activityId } };
|
|
4376
4907
|
const binding = (prefix) => ({
|
|
@@ -4417,17 +4948,17 @@ function commentBody(activityId, text2, tokens, feedType) {
|
|
|
4417
4948
|
isStreaming: false,
|
|
4418
4949
|
rumPageKey: ""
|
|
4419
4950
|
},
|
|
4420
|
-
states: states(
|
|
4951
|
+
states: states(text3, body),
|
|
4421
4952
|
requestedArguments: {
|
|
4422
4953
|
...args,
|
|
4423
|
-
states: states(
|
|
4954
|
+
states: states(text3, body),
|
|
4424
4955
|
screenId: SCREEN_ID3,
|
|
4425
4956
|
knownTemplateIds: []
|
|
4426
4957
|
}
|
|
4427
4958
|
};
|
|
4428
4959
|
}
|
|
4429
4960
|
async function comment(confirmed, client) {
|
|
4430
|
-
const { activityId, text:
|
|
4961
|
+
const { activityId, text: text3, tokens } = confirmed.payload;
|
|
4431
4962
|
if (!keyMatchesPost(tokens.bindingKey, activityId)) {
|
|
4432
4963
|
return {
|
|
4433
4964
|
ok: false,
|
|
@@ -4448,7 +4979,7 @@ async function comment(confirmed, client) {
|
|
|
4448
4979
|
const result = await client.request({
|
|
4449
4980
|
url: COMMENT_URL,
|
|
4450
4981
|
method: "POST",
|
|
4451
|
-
body: commentBody(activityId,
|
|
4982
|
+
body: commentBody(activityId, text3, tokens, feedType),
|
|
4452
4983
|
spendClass: "write",
|
|
4453
4984
|
operation: "comment.create"
|
|
4454
4985
|
});
|
|
@@ -4572,10 +5103,10 @@ var REPLY_URL = `https://www.linkedin.com/voyager/api/voyagerSocialDashNormComme
|
|
|
4572
5103
|
function parentThreadUrn(ref) {
|
|
4573
5104
|
return `urn:li:comment:(${ref.threadType}:${ref.activityId},${ref.commentId})`;
|
|
4574
5105
|
}
|
|
4575
|
-
function replyBody(ref,
|
|
5106
|
+
function replyBody(ref, text3) {
|
|
4576
5107
|
return {
|
|
4577
5108
|
commentary: {
|
|
4578
|
-
text:
|
|
5109
|
+
text: text3,
|
|
4579
5110
|
// The captured reply carried a profileMention, because LinkedIn's UI
|
|
4580
5111
|
// pre-fills "@Author " into the box. We send none: an @mention notifies a
|
|
4581
5112
|
// real person, and inventing one would put words — and a notification —
|
|
@@ -4587,11 +5118,11 @@ function replyBody(ref, text2) {
|
|
|
4587
5118
|
};
|
|
4588
5119
|
}
|
|
4589
5120
|
async function replyToComment(confirmed, client) {
|
|
4590
|
-
const { ref, text:
|
|
5121
|
+
const { ref, text: text3 } = confirmed.payload;
|
|
4591
5122
|
const result = await client.request({
|
|
4592
5123
|
url: REPLY_URL,
|
|
4593
5124
|
method: "POST",
|
|
4594
|
-
body: replyBody(ref,
|
|
5125
|
+
body: replyBody(ref, text3),
|
|
4595
5126
|
spendClass: "write",
|
|
4596
5127
|
operation: "reply"
|
|
4597
5128
|
});
|
|
@@ -4953,8 +5484,8 @@ function whenLine(at, now) {
|
|
|
4953
5484
|
const away = hours < 48 ? `in ${hours} h` : `in ${Math.round(hours / 24)} days`;
|
|
4954
5485
|
return `when ${local} (${zone}) \u2014 ${away}`;
|
|
4955
5486
|
}
|
|
4956
|
-
async function runShare(
|
|
4957
|
-
if (
|
|
5487
|
+
async function runShare(text3, visibility, now = Date.now(), deps = terminalDeps(), via2, media, at, poll, link = {}) {
|
|
5488
|
+
if (text3 === void 0 || text3.trim() === "") {
|
|
4958
5489
|
return err("share", "INVALID_INPUT", "text is required", 'lnrelay share "<text>"');
|
|
4959
5490
|
}
|
|
4960
5491
|
const vis = visibility === "connections" ? "CONNECTIONS" : "PUBLIC";
|
|
@@ -4969,7 +5500,7 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
|
|
|
4969
5500
|
via: via2
|
|
4970
5501
|
});
|
|
4971
5502
|
if (pollSpec !== void 0 && "ok" in pollSpec) return pollSpec;
|
|
4972
|
-
const cardUrl = link.card !== false && loaded === void 0 && pollSpec === void 0 && via2 !== "oauth" ? firstUrl(
|
|
5503
|
+
const cardUrl = link.card !== false && loaded === void 0 && pollSpec === void 0 && via2 !== "oauth" ? firstUrl(text3) : null;
|
|
4973
5504
|
const needs = shareNeeds(loaded?.approved.length, scheduledAt, pollSpec, cardUrl);
|
|
4974
5505
|
const ctx = prepare("share", now, needs.voyagerOnly ? "voyager" : via2, needs.calls);
|
|
4975
5506
|
if ("ok" in ctx) return ctx;
|
|
@@ -4978,7 +5509,7 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
|
|
|
4978
5509
|
const plan = sharePlan({
|
|
4979
5510
|
author: authorLine(ctx.transport),
|
|
4980
5511
|
transport: ctx.transport.kind,
|
|
4981
|
-
text:
|
|
5512
|
+
text: text3,
|
|
4982
5513
|
visibility: vis,
|
|
4983
5514
|
media: loaded?.approved,
|
|
4984
5515
|
scheduledAt,
|
|
@@ -5001,7 +5532,7 @@ async function runShare(text2, visibility, now = Date.now(), deps = terminalDeps
|
|
|
5001
5532
|
note: "note" in result ? result.note : ctx.note
|
|
5002
5533
|
});
|
|
5003
5534
|
}
|
|
5004
|
-
async function runEditPost(urn,
|
|
5535
|
+
async function runEditPost(urn, text3, now, deps) {
|
|
5005
5536
|
const unapprovable = refuseUnapprovable("edit", "editing", deps);
|
|
5006
5537
|
if (unapprovable !== null) return unapprovable;
|
|
5007
5538
|
const ctx = prepare("edit", now, "voyager");
|
|
@@ -5016,12 +5547,12 @@ async function runEditPost(urn, text2, now, deps) {
|
|
|
5016
5547
|
const before = await lookup(urn, true);
|
|
5017
5548
|
const plan = {
|
|
5018
5549
|
action: "edit your post",
|
|
5019
|
-
payload: { urn, text:
|
|
5550
|
+
payload: { urn, text: text3 },
|
|
5020
5551
|
summary: [
|
|
5021
5552
|
authorLine(ctx.transport),
|
|
5022
5553
|
`post ${urn}`,
|
|
5023
5554
|
...previewLines2(before).map((l) => l.replace(/^content /, "was ")),
|
|
5024
|
-
`new text "${
|
|
5555
|
+
`new text "${text3}"`
|
|
5025
5556
|
],
|
|
5026
5557
|
reversibility: "editable again, but the previous text is NOT kept here, LinkedIn marks the post as edited, and an @mention in the old text is not carried over",
|
|
5027
5558
|
transport: "voyager"
|
|
@@ -5045,7 +5576,7 @@ function liveProfile(session) {
|
|
|
5045
5576
|
};
|
|
5046
5577
|
}
|
|
5047
5578
|
var PROFILE_HINT = `profile fields: ${Object.keys(PROFILE_FIELDS).join(", ")}`;
|
|
5048
|
-
async function runEditProfile(name,
|
|
5579
|
+
async function runEditProfile(name, text3, now = Date.now(), deps = terminalDeps(), surface) {
|
|
5049
5580
|
const field = PROFILE_FIELDS[name];
|
|
5050
5581
|
if (field === void 0) {
|
|
5051
5582
|
return err(
|
|
@@ -5055,7 +5586,7 @@ async function runEditProfile(name, text2, now = Date.now(), deps = terminalDeps
|
|
|
5055
5586
|
PROFILE_HINT
|
|
5056
5587
|
);
|
|
5057
5588
|
}
|
|
5058
|
-
if (
|
|
5589
|
+
if (text3 === void 0 || text3.trim() === "") {
|
|
5059
5590
|
return err(
|
|
5060
5591
|
"edit",
|
|
5061
5592
|
"INVALID_INPUT",
|
|
@@ -5063,11 +5594,11 @@ async function runEditProfile(name, text2, now = Date.now(), deps = terminalDeps
|
|
|
5063
5594
|
`lnrelay edit ${name} "<text>"`
|
|
5064
5595
|
);
|
|
5065
5596
|
}
|
|
5066
|
-
if (
|
|
5597
|
+
if (text3.length > field.maxLength) {
|
|
5067
5598
|
return err(
|
|
5068
5599
|
"edit",
|
|
5069
5600
|
"INVALID_INPUT",
|
|
5070
|
-
`the ${name} is ${
|
|
5601
|
+
`the ${name} is ${text3.length} characters; LinkedIn allows ${field.maxLength}`
|
|
5071
5602
|
);
|
|
5072
5603
|
}
|
|
5073
5604
|
const unapprovable = refuseUnapprovable("edit", "editing", deps);
|
|
@@ -5083,19 +5614,19 @@ async function runEditProfile(name, text2, now = Date.now(), deps = terminalDeps
|
|
|
5083
5614
|
const form = await profile.open(field, me.vanity);
|
|
5084
5615
|
if (!form.ok) return err("edit", form.code, form.message, form.hint);
|
|
5085
5616
|
const was = currentValue(form, field) ?? "";
|
|
5086
|
-
if (was ===
|
|
5617
|
+
if (was === text3) {
|
|
5087
5618
|
return err("edit", "INVALID_INPUT", `your ${name} already reads exactly that; nothing to save`);
|
|
5088
5619
|
}
|
|
5089
|
-
const built = saveBody(form, field,
|
|
5620
|
+
const built = saveBody(form, field, text3);
|
|
5090
5621
|
if (!built.ok) return err("edit", built.code, built.message, built.hint);
|
|
5091
5622
|
const plan = {
|
|
5092
5623
|
action: `change your ${name}`,
|
|
5093
|
-
payload: { field: name, was, text:
|
|
5624
|
+
payload: { field: name, was, text: text3 },
|
|
5094
5625
|
summary: [
|
|
5095
5626
|
authorLine(ctx.transport),
|
|
5096
5627
|
`field ${name}`,
|
|
5097
5628
|
`was "${was}"`,
|
|
5098
|
-
`new "${
|
|
5629
|
+
`new "${text3}"`
|
|
5099
5630
|
],
|
|
5100
5631
|
reversibility: "editable again, but the old text is kept only in this preview and the audit log (~/.lnrelay/writes.jsonl). Every other profile field is sent back as LinkedIn holds it.",
|
|
5101
5632
|
transport: "voyager"
|
|
@@ -5106,7 +5637,7 @@ async function runEditProfile(name, text2, now = Date.now(), deps = terminalDeps
|
|
|
5106
5637
|
if (!sent.ok) return err("edit", sent.code, sent.message, sent.hint);
|
|
5107
5638
|
const after = await profile.open(field, me.vanity);
|
|
5108
5639
|
const reads = after.ok ? currentValue(after, field) : void 0;
|
|
5109
|
-
if (reads !==
|
|
5640
|
+
if (reads !== text3) {
|
|
5110
5641
|
return err(
|
|
5111
5642
|
"edit",
|
|
5112
5643
|
"SCHEMA_DRIFT",
|
|
@@ -5145,8 +5676,8 @@ async function harvest(activityId, session, now) {
|
|
|
5145
5676
|
if (!found.ok) return err("comment", "SCHEMA_DRIFT", found.message, found.hint);
|
|
5146
5677
|
return { ok: true, tokens: { bindingKey: found.bindingKey, trackingId: found.trackingId } };
|
|
5147
5678
|
}
|
|
5148
|
-
async function runComment(postUrn2,
|
|
5149
|
-
if (postUrn2 === void 0 ||
|
|
5679
|
+
async function runComment(postUrn2, text3, now = Date.now(), deps = terminalDeps()) {
|
|
5680
|
+
if (postUrn2 === void 0 || text3 === void 0 || text3.trim() === "") {
|
|
5150
5681
|
return err(
|
|
5151
5682
|
"comment",
|
|
5152
5683
|
"INVALID_INPUT",
|
|
@@ -5183,11 +5714,11 @@ async function runComment(postUrn2, text2, now = Date.now(), deps = terminalDeps
|
|
|
5183
5714
|
if (!("tokens" in harvested)) return harvested;
|
|
5184
5715
|
const plan = {
|
|
5185
5716
|
action: "comment on a post",
|
|
5186
|
-
payload: { activityId, text:
|
|
5717
|
+
payload: { activityId, text: text3, tokens: harvested.tokens },
|
|
5187
5718
|
// The harvested trackingId changes on every render, so --plan and --confirm
|
|
5188
5719
|
// would never agree on a token derived from it. The intent is what's approved.
|
|
5189
|
-
tokenBasis: { activityId, text:
|
|
5190
|
-
summary: [authorLine(ctx.transport), `on ${postUrn2}`, `content "${
|
|
5720
|
+
tokenBasis: { activityId, text: text3 },
|
|
5721
|
+
summary: [authorLine(ctx.transport), `on ${postUrn2}`, `content "${text3}"`],
|
|
5191
5722
|
reversibility: "deletable with `lnrelay delete <comment-urn>`; the author is notified immediately",
|
|
5192
5723
|
transport: "voyager"
|
|
5193
5724
|
};
|
|
@@ -5199,8 +5730,8 @@ async function runComment(postUrn2, text2, now = Date.now(), deps = terminalDeps
|
|
|
5199
5730
|
);
|
|
5200
5731
|
return result.ok ? ok("comment", { on: postUrn2 }) : err("comment", result.code, result.message, result.hint);
|
|
5201
5732
|
}
|
|
5202
|
-
async function runEdit(commentUrn,
|
|
5203
|
-
if (commentUrn === void 0 ||
|
|
5733
|
+
async function runEdit(commentUrn, text3, now = Date.now(), deps = terminalDeps()) {
|
|
5734
|
+
if (commentUrn === void 0 || text3 === void 0 || text3.trim() === "") {
|
|
5204
5735
|
return err(
|
|
5205
5736
|
"edit",
|
|
5206
5737
|
"INVALID_INPUT",
|
|
@@ -5210,11 +5741,11 @@ async function runEdit(commentUrn, text2, now = Date.now(), deps = terminalDeps(
|
|
|
5210
5741
|
}
|
|
5211
5742
|
const ref = parseCommentUrn(commentUrn);
|
|
5212
5743
|
if (ref === null && !commentUrn.startsWith("urn:")) {
|
|
5213
|
-
return runEditProfile(commentUrn,
|
|
5744
|
+
return runEditProfile(commentUrn, text3, now, deps);
|
|
5214
5745
|
}
|
|
5215
5746
|
if (ref === null) {
|
|
5216
5747
|
if (/^urn:li:(share|ugcPost):\d+$/.test(commentUrn)) {
|
|
5217
|
-
return runEditPost(commentUrn,
|
|
5748
|
+
return runEditPost(commentUrn, text3, now, deps);
|
|
5218
5749
|
}
|
|
5219
5750
|
return err(
|
|
5220
5751
|
"edit",
|
|
@@ -5234,8 +5765,8 @@ async function runEdit(commentUrn, text2, now = Date.now(), deps = terminalDeps(
|
|
|
5234
5765
|
if (!("tokens" in harvested)) return harvested;
|
|
5235
5766
|
const plan = {
|
|
5236
5767
|
action: "edit your comment",
|
|
5237
|
-
payload: { urn: commentUrn, text:
|
|
5238
|
-
summary: [authorLine(ctx.transport), `comment ${commentUrn}`, `new text "${
|
|
5768
|
+
payload: { urn: commentUrn, text: text3 },
|
|
5769
|
+
summary: [authorLine(ctx.transport), `comment ${commentUrn}`, `new text "${text3}"`],
|
|
5239
5770
|
reversibility: "editable again, but the previous text is NOT recoverable here and LinkedIn marks the comment as edited",
|
|
5240
5771
|
transport: "voyager"
|
|
5241
5772
|
};
|
|
@@ -5246,7 +5777,7 @@ async function runEdit(commentUrn, text2, now = Date.now(), deps = terminalDeps(
|
|
|
5246
5777
|
UPDATE_OP,
|
|
5247
5778
|
harvested.tokens.trackingId,
|
|
5248
5779
|
createLiveClient(ctx.transport.session),
|
|
5249
|
-
|
|
5780
|
+
text3
|
|
5250
5781
|
);
|
|
5251
5782
|
return result.ok ? ok("edit", { edited: commentUrn }) : err("edit", result.code, result.message, result.hint);
|
|
5252
5783
|
}
|
|
@@ -5290,8 +5821,8 @@ async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps(),
|
|
|
5290
5821
|
const result = await react(gated.confirmed, createLiveClient(ctx.transport.session));
|
|
5291
5822
|
return result.ok ? ok("react", { id: result.id, removed: remove }) : err("react", result.code, result.message, result.hint);
|
|
5292
5823
|
}
|
|
5293
|
-
async function runReply(commentUrn,
|
|
5294
|
-
if (commentUrn === void 0 ||
|
|
5824
|
+
async function runReply(commentUrn, text3, now = Date.now(), deps = terminalDeps()) {
|
|
5825
|
+
if (commentUrn === void 0 || text3 === void 0 || text3.trim() === "") {
|
|
5295
5826
|
return err(
|
|
5296
5827
|
"reply",
|
|
5297
5828
|
"INVALID_INPUT",
|
|
@@ -5317,8 +5848,8 @@ async function runReply(commentUrn, text2, now = Date.now(), deps = terminalDeps
|
|
|
5317
5848
|
}
|
|
5318
5849
|
const plan = {
|
|
5319
5850
|
action: "reply to a comment",
|
|
5320
|
-
payload: { ref: parent, text:
|
|
5321
|
-
summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${
|
|
5851
|
+
payload: { ref: parent, text: text3 },
|
|
5852
|
+
summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${text3}"`],
|
|
5322
5853
|
reversibility: "deletable with `lnrelay delete <the reply urn>`; the comment author is notified immediately",
|
|
5323
5854
|
transport: "voyager"
|
|
5324
5855
|
};
|
|
@@ -5459,16 +5990,16 @@ async function runRole(sub, target, req, now = Date.now(), deps = terminalDeps()
|
|
|
5459
5990
|
const roles = surface ?? liveRoles(ctx.transport.session);
|
|
5460
5991
|
const me = await roles.vanity();
|
|
5461
5992
|
if (!me.ok) return err("role", me.code, me.message, me.hint);
|
|
5462
|
-
const
|
|
5463
|
-
if (!
|
|
5464
|
-
if (sub === "add") return addRole(changes, me.vanity,
|
|
5465
|
-
const position =
|
|
5993
|
+
const listed2 = await roles.list(me.vanity);
|
|
5994
|
+
if (!listed2.ok) return err("role", listed2.code, listed2.message, listed2.hint);
|
|
5995
|
+
if (sub === "add") return addRole(changes, me.vanity, listed2.positions, roles, ctx, deps);
|
|
5996
|
+
const position = listed2.positions.find((p) => p.positionId === target);
|
|
5466
5997
|
if (position === void 0) {
|
|
5467
5998
|
return err(
|
|
5468
5999
|
"role",
|
|
5469
6000
|
"NOT_FOUND",
|
|
5470
6001
|
`no role ${target} on your profile`,
|
|
5471
|
-
`your roles: ${
|
|
6002
|
+
`your roles: ${listed2.positions.map((p) => `${p.positionId} (${p.title})`).join(", ") || "none"}`
|
|
5472
6003
|
);
|
|
5473
6004
|
}
|
|
5474
6005
|
const form = await roles.open({ ...position.payload, vanityName: me.vanity }, true);
|
|
@@ -5569,11 +6100,289 @@ async function runExperience(quiet = false) {
|
|
|
5569
6100
|
const roles = liveRoles(session.session, quiet);
|
|
5570
6101
|
const me = await roles.vanity();
|
|
5571
6102
|
if (!me.ok) return err("experience", me.code, me.message, me.hint);
|
|
5572
|
-
const
|
|
5573
|
-
if (!
|
|
6103
|
+
const listed2 = await roles.list(me.vanity);
|
|
6104
|
+
if (!listed2.ok) return err("experience", listed2.code, listed2.message, listed2.hint);
|
|
5574
6105
|
return ok("experience", {
|
|
5575
|
-
items:
|
|
5576
|
-
meta: { state: "complete", returnedCount:
|
|
6106
|
+
items: listed2.positions.map((p) => ({ positionId: p.positionId, title: p.title })),
|
|
6107
|
+
meta: { state: "complete", returnedCount: listed2.positions.length }
|
|
6108
|
+
});
|
|
6109
|
+
}
|
|
6110
|
+
|
|
6111
|
+
// src/engine/sdui-skill.ts
|
|
6112
|
+
var SKILL = {
|
|
6113
|
+
addScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillAddForm",
|
|
6114
|
+
editScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillDetailsEditForm",
|
|
6115
|
+
listScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillDetails",
|
|
6116
|
+
pager: "com.linkedin.sdui.pagers.profile.details.skills",
|
|
6117
|
+
save: "com.linkedin.sdui.requests.profile.saveProfileSkillForm",
|
|
6118
|
+
delete: "com.linkedin.sdui.requests.profile.deleteProfileSkillForm"
|
|
6119
|
+
};
|
|
6120
|
+
var EDIT_NAV2 = `{"$type":"proto.sdui.actions.core.NavigateToScreen","screenId":"${SKILL.editScreen}"`;
|
|
6121
|
+
var TEXT2 = /"children":\["((?:[^"\\]|\\.)*)"\]/g;
|
|
6122
|
+
function skillsFromPage(stream) {
|
|
6123
|
+
if (!stream.includes(SKILL.pager) && !stream.includes(EDIT_NAV2) && !stream.includes("isPartialPage")) {
|
|
6124
|
+
return drift3("the skills page could not be read");
|
|
6125
|
+
}
|
|
6126
|
+
const skills = [];
|
|
6127
|
+
let from = 0;
|
|
6128
|
+
let i = 0;
|
|
6129
|
+
for (; ; ) {
|
|
6130
|
+
i = stream.indexOf(EDIT_NAV2, i);
|
|
6131
|
+
if (i === -1) break;
|
|
6132
|
+
const text3 = balanced(stream, i);
|
|
6133
|
+
const end = i;
|
|
6134
|
+
i += EDIT_NAV2.length;
|
|
6135
|
+
if (text3 === null) continue;
|
|
6136
|
+
const payload = JSON.parse(text3).requestedArguments?.payload;
|
|
6137
|
+
const id = payload?.skillId;
|
|
6138
|
+
if (typeof id !== "string" || payload === void 0 || skills.some((s) => s.skillId === id))
|
|
6139
|
+
continue;
|
|
6140
|
+
const names = [...stream.slice(from, end).matchAll(TEXT2)].map(
|
|
6141
|
+
(m) => JSON.parse(`"${m[1]}"`)
|
|
6142
|
+
);
|
|
6143
|
+
skills.push({ skillId: id, name: names.length === 1 ? names[0] ?? null : null, payload });
|
|
6144
|
+
from = end + text3.length;
|
|
6145
|
+
}
|
|
6146
|
+
return { ok: true, skills };
|
|
6147
|
+
}
|
|
6148
|
+
function pagerFrom(payload, start) {
|
|
6149
|
+
const args = {
|
|
6150
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
6151
|
+
requestedStateKeys: [],
|
|
6152
|
+
payload: { ...payload, start },
|
|
6153
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
6154
|
+
};
|
|
6155
|
+
return {
|
|
6156
|
+
pagerId: SKILL.pager,
|
|
6157
|
+
clientArguments: { ...args, states: [], screenId: SKILL.listScreen, knownTemplateIds: [] },
|
|
6158
|
+
paginationRequest: {
|
|
6159
|
+
$type: "proto.sdui.actions.requests.PaginationRequest",
|
|
6160
|
+
pagerId: SKILL.pager,
|
|
6161
|
+
retryCount: 0,
|
|
6162
|
+
requestedArguments: args
|
|
6163
|
+
}
|
|
6164
|
+
};
|
|
6165
|
+
}
|
|
6166
|
+
function readSkillForm(stream) {
|
|
6167
|
+
const model = readModel(stream);
|
|
6168
|
+
if (model === null) return drift3("the skill form carried no initial values");
|
|
6169
|
+
const save = findRequest(stream, SKILL.save);
|
|
6170
|
+
const del = findRequest(stream, SKILL.delete);
|
|
6171
|
+
if (save === null && del === null)
|
|
6172
|
+
return drift3("the skill form carried neither a save nor a delete");
|
|
6173
|
+
return { ok: true, model, save, del, screen: del === null ? SKILL.addScreen : SKILL.editScreen };
|
|
6174
|
+
}
|
|
6175
|
+
var nameKey = (model) => [...model.keys()].find((k) => k.startsWith("addSkillsTypeaheadSkillName"));
|
|
6176
|
+
function skillNameOf(form) {
|
|
6177
|
+
const key = nameKey(form.model);
|
|
6178
|
+
const v = key === void 0 ? void 0 : form.model.get(key)?.value;
|
|
6179
|
+
return typeof v === "string" ? v : null;
|
|
6180
|
+
}
|
|
6181
|
+
function addSkillBody(form, name) {
|
|
6182
|
+
if (name.trim() === "")
|
|
6183
|
+
return { ok: false, code: "INVALID_INPUT", message: "a skill needs a name" };
|
|
6184
|
+
if (form.save === null) return drift3("this form has no save action (it is not the add form)");
|
|
6185
|
+
const key = nameKey(form.model);
|
|
6186
|
+
const current = key === void 0 ? void 0 : form.model.get(key);
|
|
6187
|
+
if (key === void 0 || current === void 0) return drift3("the skill form has no name field");
|
|
6188
|
+
const model = new Map(form.model);
|
|
6189
|
+
model.set(key, { ...current, value: name.trim() });
|
|
6190
|
+
const states2 = wireStates(keysOf(form.save), model, () => void 0);
|
|
6191
|
+
if (!Array.isArray(states2)) return states2;
|
|
6192
|
+
return { ok: true, body: requestBody(SKILL.save, form.save, states2, form.screen) };
|
|
6193
|
+
}
|
|
6194
|
+
function removeSkillBody(form) {
|
|
6195
|
+
if (form.del === null)
|
|
6196
|
+
return drift3("this form has no delete action (it is not an existing skill)");
|
|
6197
|
+
const states2 = wireStates(keysOf(form.del), form.model, () => void 0);
|
|
6198
|
+
if (!Array.isArray(states2)) return states2;
|
|
6199
|
+
return { ok: true, body: requestBody(SKILL.delete, form.del, states2, form.screen) };
|
|
6200
|
+
}
|
|
6201
|
+
var PAGER_URL2 = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${SKILL.pager}`;
|
|
6202
|
+
var MAX_PAGES2 = 10;
|
|
6203
|
+
async function fetchSkills(vanityName, client) {
|
|
6204
|
+
const screen = await openForm(
|
|
6205
|
+
SKILL.listScreen,
|
|
6206
|
+
{ vanityName, isVanityNameResolved: true },
|
|
6207
|
+
client,
|
|
6208
|
+
"skills-screen"
|
|
6209
|
+
);
|
|
6210
|
+
if (typeof screen !== "string") return screen;
|
|
6211
|
+
const at = screen.indexOf('"filter":"ProfileSkillCategory_ALL"');
|
|
6212
|
+
const open = at === -1 ? -1 : screen.lastIndexOf('"payload":{', at);
|
|
6213
|
+
const text3 = open === -1 ? null : balanced(screen, open + '"payload":'.length);
|
|
6214
|
+
if (text3 === null) return drift3("the Skills screen carried no list request");
|
|
6215
|
+
const payload = JSON.parse(text3);
|
|
6216
|
+
const count2 = typeof payload.count === "number" ? payload.count : 10;
|
|
6217
|
+
const skills = [];
|
|
6218
|
+
for (let page = 0; page < MAX_PAGES2; page++) {
|
|
6219
|
+
const result = await client.request({
|
|
6220
|
+
url: PAGER_URL2,
|
|
6221
|
+
method: "POST",
|
|
6222
|
+
body: pagerFrom(payload, skills.length),
|
|
6223
|
+
spendClass: "page",
|
|
6224
|
+
operation: "skills"
|
|
6225
|
+
});
|
|
6226
|
+
if (!result.ok) return { ok: false, code: result.code, message: result.message };
|
|
6227
|
+
const parsed = skillsFromPage(result.classification.raw ?? "");
|
|
6228
|
+
if (!parsed.ok) return parsed;
|
|
6229
|
+
const fresh = parsed.skills.filter((s) => !skills.some((k) => k.skillId === s.skillId));
|
|
6230
|
+
skills.push(...fresh);
|
|
6231
|
+
if (parsed.skills.length < count2 || fresh.length === 0) break;
|
|
6232
|
+
}
|
|
6233
|
+
return { ok: true, skills };
|
|
6234
|
+
}
|
|
6235
|
+
async function openSkillForm(payload, client, edit2) {
|
|
6236
|
+
const stream = await openForm(
|
|
6237
|
+
edit2 ? SKILL.editScreen : SKILL.addScreen,
|
|
6238
|
+
{ ...payload, isVanityNameResolved: true },
|
|
6239
|
+
client,
|
|
6240
|
+
edit2 ? "skill-edit-form" : "skill-add-form"
|
|
6241
|
+
);
|
|
6242
|
+
return typeof stream === "string" ? readSkillForm(stream) : stream;
|
|
6243
|
+
}
|
|
6244
|
+
async function sendSkill(body, requestId, client) {
|
|
6245
|
+
const sent = await sendAction(
|
|
6246
|
+
requestId,
|
|
6247
|
+
body,
|
|
6248
|
+
client,
|
|
6249
|
+
requestId === SKILL.save ? "skill-add" : "skill-remove"
|
|
6250
|
+
);
|
|
6251
|
+
return typeof sent === "string" ? { ok: true } : sent;
|
|
6252
|
+
}
|
|
6253
|
+
|
|
6254
|
+
// src/commands/skill.ts
|
|
6255
|
+
function liveSkills(session, quiet = false) {
|
|
6256
|
+
const client = createLiveClient(session, void 0, quiet);
|
|
6257
|
+
return {
|
|
6258
|
+
vanity: async () => {
|
|
6259
|
+
const me = await createEngine(session, void 0, quiet).whoami();
|
|
6260
|
+
if (!me.ok) return me;
|
|
6261
|
+
const id = me.value?.publicIdentifier;
|
|
6262
|
+
return typeof id === "string" && id !== "" ? { ok: true, vanity: id } : { ok: false, code: "SCHEMA_DRIFT", message: "whoami returned no public profile id" };
|
|
6263
|
+
},
|
|
6264
|
+
list: (vanity) => fetchSkills(vanity, client),
|
|
6265
|
+
open: (payload, edit2) => openSkillForm(payload, client, edit2),
|
|
6266
|
+
send: (body, requestId) => sendSkill(body, requestId, client)
|
|
6267
|
+
};
|
|
6268
|
+
}
|
|
6269
|
+
var listed = (skills) => skills.map((s) => `${s.skillId} (${s.name ?? "?"})`).join(", ") || "none";
|
|
6270
|
+
async function runSkill(sub, arg, now = Date.now(), deps = terminalDeps(), surface) {
|
|
6271
|
+
if (sub !== "add" && sub !== "remove") {
|
|
6272
|
+
return err(
|
|
6273
|
+
"skill",
|
|
6274
|
+
"INVALID_INPUT",
|
|
6275
|
+
`unknown skill subcommand '${sub ?? ""}'`,
|
|
6276
|
+
'lnrelay skill add "<name>" | lnrelay skill remove <skill-id>'
|
|
6277
|
+
);
|
|
6278
|
+
}
|
|
6279
|
+
if (arg === void 0 || arg.trim() === "") {
|
|
6280
|
+
return err(
|
|
6281
|
+
"skill",
|
|
6282
|
+
"INVALID_INPUT",
|
|
6283
|
+
sub === "add" ? "the skill name is required" : "the skill id is required",
|
|
6284
|
+
"ids come from `lnrelay skills`"
|
|
6285
|
+
);
|
|
6286
|
+
}
|
|
6287
|
+
const unapprovable = refuseUnapprovable("skill", "changing your skills", deps);
|
|
6288
|
+
if (unapprovable !== null) return unapprovable;
|
|
6289
|
+
const ctx = prepare("skill", now, "voyager");
|
|
6290
|
+
if ("ok" in ctx) return ctx;
|
|
6291
|
+
if (ctx.transport.kind !== "voyager")
|
|
6292
|
+
return err("skill", "NOT_IMPLEMENTED", "skill changes go over the browser session only");
|
|
6293
|
+
const skills = surface ?? liveSkills(ctx.transport.session);
|
|
6294
|
+
const me = await skills.vanity();
|
|
6295
|
+
if (!me.ok) return err("skill", me.code, me.message, me.hint);
|
|
6296
|
+
const before = await skills.list(me.vanity);
|
|
6297
|
+
if (!before.ok) return err("skill", before.code, before.message, before.hint);
|
|
6298
|
+
return sub === "add" ? addSkill(arg.trim(), before.skills, me.vanity, skills, ctx, deps) : removeSkill(arg, before.skills, me.vanity, skills, ctx, deps);
|
|
6299
|
+
}
|
|
6300
|
+
async function addSkill(name, current, vanity, skills, ctx, deps) {
|
|
6301
|
+
const dup = current.find((s) => s.name?.toLowerCase() === name.toLowerCase());
|
|
6302
|
+
if (dup !== void 0)
|
|
6303
|
+
return err(
|
|
6304
|
+
"skill",
|
|
6305
|
+
"INVALID_INPUT",
|
|
6306
|
+
`"${dup.name}" is already on your profile (${dup.skillId})`
|
|
6307
|
+
);
|
|
6308
|
+
const form = await skills.open({ vanityName: vanity }, false);
|
|
6309
|
+
if (!form.ok) return err("skill", form.code, form.message, form.hint);
|
|
6310
|
+
const body = addSkillBody(form, name);
|
|
6311
|
+
if (!body.ok) return err("skill", body.code, body.message, body.hint);
|
|
6312
|
+
const plan = {
|
|
6313
|
+
action: "add a skill to your profile",
|
|
6314
|
+
payload: { name },
|
|
6315
|
+
summary: [
|
|
6316
|
+
authorLine(ctx.transport),
|
|
6317
|
+
`skill "${name}"`,
|
|
6318
|
+
"linked to nothing (no roles, schools or projects)"
|
|
6319
|
+
],
|
|
6320
|
+
reversibility: "removable with `lnrelay skill remove <skill-id>`",
|
|
6321
|
+
transport: "voyager"
|
|
6322
|
+
};
|
|
6323
|
+
const gated = await gate("skill", plan, ctx, deps);
|
|
6324
|
+
if ("ok" in gated) return gated;
|
|
6325
|
+
const sent = await skills.send(body.body, SKILL.save);
|
|
6326
|
+
if (!sent.ok) return err("skill", sent.code, sent.message, sent.hint);
|
|
6327
|
+
const after = await skills.list(vanity);
|
|
6328
|
+
const known = new Set(current.map((s) => s.skillId));
|
|
6329
|
+
const added = after.ok ? after.skills.find((s) => !known.has(s.skillId)) : void 0;
|
|
6330
|
+
if (added === void 0)
|
|
6331
|
+
return err(
|
|
6332
|
+
"skill",
|
|
6333
|
+
"SCHEMA_DRIFT",
|
|
6334
|
+
"LinkedIn accepted the skill, but it does not appear on your profile"
|
|
6335
|
+
);
|
|
6336
|
+
return ok("skill", { added: added.skillId, name: added.name, verified: true });
|
|
6337
|
+
}
|
|
6338
|
+
async function removeSkill(arg, current, vanity, skills, ctx, deps) {
|
|
6339
|
+
const target = current.find((s) => s.skillId === arg);
|
|
6340
|
+
if (target === void 0)
|
|
6341
|
+
return err(
|
|
6342
|
+
"skill",
|
|
6343
|
+
"NOT_FOUND",
|
|
6344
|
+
`no skill ${arg} on your profile`,
|
|
6345
|
+
`your skills: ${listed(current)}`
|
|
6346
|
+
);
|
|
6347
|
+
const form = await skills.open({ ...target.payload, vanityName: vanity }, true);
|
|
6348
|
+
if (!form.ok) return err("skill", form.code, form.message, form.hint);
|
|
6349
|
+
const body = removeSkillBody(form);
|
|
6350
|
+
if (!body.ok) return err("skill", body.code, body.message, body.hint);
|
|
6351
|
+
const name = skillNameOf(form) ?? target.name ?? "?";
|
|
6352
|
+
const plan = {
|
|
6353
|
+
action: "remove a skill from your profile",
|
|
6354
|
+
payload: { skillId: target.skillId, name },
|
|
6355
|
+
summary: [authorLine(ctx.transport), `skill "${name}" (${target.skillId})`],
|
|
6356
|
+
reversibility: "NONE for its endorsements, which go with it; the skill itself can be added again",
|
|
6357
|
+
transport: "voyager"
|
|
6358
|
+
};
|
|
6359
|
+
const gated = await gate("skill", plan, ctx, deps);
|
|
6360
|
+
if ("ok" in gated) return gated;
|
|
6361
|
+
const sent = await skills.send(body.body, SKILL.delete);
|
|
6362
|
+
if (!sent.ok) return err("skill", sent.code, sent.message, sent.hint);
|
|
6363
|
+
const after = await skills.list(vanity);
|
|
6364
|
+
if (!after.ok || after.skills.some((s) => s.skillId === target.skillId)) {
|
|
6365
|
+
return err(
|
|
6366
|
+
"skill",
|
|
6367
|
+
"SCHEMA_DRIFT",
|
|
6368
|
+
"LinkedIn accepted the removal, but the skill is still listed"
|
|
6369
|
+
);
|
|
6370
|
+
}
|
|
6371
|
+
return ok("skill", { removed: target.skillId, verified: true });
|
|
6372
|
+
}
|
|
6373
|
+
async function runSkills(quiet = false) {
|
|
6374
|
+
const session = loadSession();
|
|
6375
|
+
if (session.state !== "ok")
|
|
6376
|
+
return err("skills", "AUTH_FAILED", "no LinkedIn session \u2014 run `lnrelay login`");
|
|
6377
|
+
const skills = liveSkills(session.session, quiet);
|
|
6378
|
+
const me = await skills.vanity();
|
|
6379
|
+
if (!me.ok) return err("skills", me.code, me.message, me.hint);
|
|
6380
|
+
const listedSkills = await skills.list(me.vanity);
|
|
6381
|
+
if (!listedSkills.ok)
|
|
6382
|
+
return err("skills", listedSkills.code, listedSkills.message, listedSkills.hint);
|
|
6383
|
+
return ok("skills", {
|
|
6384
|
+
items: listedSkills.skills.map((s) => ({ skillId: s.skillId, name: s.name })),
|
|
6385
|
+
meta: { state: "complete", returnedCount: listedSkills.skills.length }
|
|
5577
6386
|
});
|
|
5578
6387
|
}
|
|
5579
6388
|
|
|
@@ -5736,6 +6545,54 @@ function output(args) {
|
|
|
5736
6545
|
if (fields !== void 0) opts.fields = fields;
|
|
5737
6546
|
return opts;
|
|
5738
6547
|
}
|
|
6548
|
+
function many(args, name) {
|
|
6549
|
+
return list(args, name).flatMap((v) => v.split(",")).map((v) => v.trim()).filter((v) => v !== "");
|
|
6550
|
+
}
|
|
6551
|
+
function jobsRequest(args) {
|
|
6552
|
+
const filter = {};
|
|
6553
|
+
const distance = num(args, "distance");
|
|
6554
|
+
if (distance !== void 0) filter.distance = distance;
|
|
6555
|
+
const posted = str(args, "posted");
|
|
6556
|
+
if (posted !== void 0) filter.posted = posted;
|
|
6557
|
+
const lists = [
|
|
6558
|
+
["experience", "experience"],
|
|
6559
|
+
["type", "type"],
|
|
6560
|
+
["workplace", "workplace"],
|
|
6561
|
+
["company", "company"],
|
|
6562
|
+
["industry", "industry"],
|
|
6563
|
+
["function", "function"],
|
|
6564
|
+
["title", "title"],
|
|
6565
|
+
["place", "place"]
|
|
6566
|
+
];
|
|
6567
|
+
for (const [flag, key] of lists) {
|
|
6568
|
+
const values = many(args, flag);
|
|
6569
|
+
if (values.length > 0) filter[key] = values;
|
|
6570
|
+
}
|
|
6571
|
+
const flags = [
|
|
6572
|
+
["easy-apply", "easyApply"],
|
|
6573
|
+
["under-10", "under10"],
|
|
6574
|
+
["verified", "verified"],
|
|
6575
|
+
["in-network", "inNetwork"],
|
|
6576
|
+
["fair-chance", "fairChance"]
|
|
6577
|
+
];
|
|
6578
|
+
for (const [flag, key] of flags) if (bool(args, flag)) filter[key] = true;
|
|
6579
|
+
const raw = list(args, "filter");
|
|
6580
|
+
if (raw.length > 0) filter.raw = raw;
|
|
6581
|
+
const sort = str(args, "sort");
|
|
6582
|
+
if (sort !== void 0) filter.sort = sort;
|
|
6583
|
+
const req = { limit: num(args, "limit") ?? 25, filter };
|
|
6584
|
+
const keywords = args.positionals[0];
|
|
6585
|
+
if (keywords !== void 0) req.keywords = keywords;
|
|
6586
|
+
const location = str(args, "location");
|
|
6587
|
+
if (location !== void 0) req.location = location;
|
|
6588
|
+
const geo = str(args, "geo");
|
|
6589
|
+
if (geo !== void 0) req.geoId = geo;
|
|
6590
|
+
const start = num(args, "start");
|
|
6591
|
+
if (start !== void 0) req.start = start;
|
|
6592
|
+
if (bool(args, "details")) req.details = true;
|
|
6593
|
+
if (bool(args, "description")) req.description = true;
|
|
6594
|
+
return req;
|
|
6595
|
+
}
|
|
5739
6596
|
function via(args) {
|
|
5740
6597
|
const value = str(args, "via");
|
|
5741
6598
|
if (value === void 0) return void 0;
|
|
@@ -5826,6 +6683,8 @@ async function dispatch(argv, now) {
|
|
|
5826
6683
|
);
|
|
5827
6684
|
case "experience":
|
|
5828
6685
|
return runExperience(bool(args, "quiet"));
|
|
6686
|
+
case "skills":
|
|
6687
|
+
return runSkills(bool(args, "quiet"));
|
|
5829
6688
|
case "scheduled":
|
|
5830
6689
|
return runScheduled(bool(args, "quiet"));
|
|
5831
6690
|
case "sync":
|
|
@@ -5844,7 +6703,18 @@ async function dispatch(argv, now) {
|
|
|
5844
6703
|
return runPost(args.positionals[0], num(args, "limit") ?? 20, output(args));
|
|
5845
6704
|
case "reactions":
|
|
5846
6705
|
return runReactions(args.positionals[0], num(args, "limit") ?? 20, output(args));
|
|
6706
|
+
case "jobs":
|
|
6707
|
+
return runJobs(jobsRequest(args), output(args));
|
|
6708
|
+
case "job":
|
|
6709
|
+
return runJob(args.positionals[0], output(args));
|
|
6710
|
+
case "job-filters":
|
|
6711
|
+
return runJobFilters(jobsRequest(args), output(args));
|
|
5847
6712
|
case "search":
|
|
6713
|
+
if (args.positionals[0] === "jobs")
|
|
6714
|
+
return runJobs(
|
|
6715
|
+
{ keywords: args.positionals[1] ?? "", limit: num(args, "limit") ?? 10, filter: {} },
|
|
6716
|
+
output(args)
|
|
6717
|
+
);
|
|
5848
6718
|
return runSearch(
|
|
5849
6719
|
args.positionals[0],
|
|
5850
6720
|
args.positionals[1],
|
|
@@ -5901,13 +6771,13 @@ function edit(args, now, deps) {
|
|
|
5901
6771
|
if (inline !== void 0) {
|
|
5902
6772
|
return err("edit", "INVALID_INPUT", "pass the new text inline or with --file, not both");
|
|
5903
6773
|
}
|
|
5904
|
-
let
|
|
6774
|
+
let text3;
|
|
5905
6775
|
try {
|
|
5906
|
-
|
|
6776
|
+
text3 = readFileSync3(file, "utf-8").replace(/\n$/, "");
|
|
5907
6777
|
} catch {
|
|
5908
6778
|
return err("edit", "INVALID_INPUT", `cannot read ${file}`);
|
|
5909
6779
|
}
|
|
5910
|
-
return runEdit(target,
|
|
6780
|
+
return runEdit(target, text3, now, deps);
|
|
5911
6781
|
}
|
|
5912
6782
|
function role(args, now, deps) {
|
|
5913
6783
|
const [sub, target] = args.positionals;
|
|
@@ -5960,6 +6830,8 @@ function runWrite(command, args, now, deps) {
|
|
|
5960
6830
|
return runDelete(first, now, deps, bool(args, "quiet"));
|
|
5961
6831
|
case "role":
|
|
5962
6832
|
return role(args, now, deps);
|
|
6833
|
+
case "skill":
|
|
6834
|
+
return runSkill(first, second, now, deps);
|
|
5963
6835
|
default:
|
|
5964
6836
|
return err(command, "NOT_IMPLEMENTED", `'${command}' has no write runner`);
|
|
5965
6837
|
}
|
|
@@ -6044,6 +6916,7 @@ function share3(args, now, deps) {
|
|
|
6044
6916
|
);
|
|
6045
6917
|
}
|
|
6046
6918
|
export {
|
|
6047
|
-
dispatch
|
|
6919
|
+
dispatch,
|
|
6920
|
+
jobsRequest
|
|
6048
6921
|
};
|
|
6049
6922
|
//# sourceMappingURL=cli.js.map
|