linkedin-relay-mcp 3.24.0 → 3.26.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 +51 -13
- package/README.md +5 -2
- package/dist/cli.js +1382 -717
- package/dist/cli.js.map +1 -1
- package/dist/index.js +18 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp-shim.js +1164 -487
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1026,6 +1026,17 @@ var CONTRACTS = {
|
|
|
1026
1026
|
provenance: "verified",
|
|
1027
1027
|
capturedAt: "2026-10-16"
|
|
1028
1028
|
},
|
|
1029
|
+
// The owner's notifications, probed 2026-10-29: the cards the bell opens,
|
|
1030
|
+
// newest first. The page itself also marks them seen; reading them here
|
|
1031
|
+
// does not. See engine/notifications.ts.
|
|
1032
|
+
notifications: {
|
|
1033
|
+
name: "notifications",
|
|
1034
|
+
transport: "voyager-restli",
|
|
1035
|
+
path: `${VOYAGER}/voyagerIdentityDashNotificationCards`,
|
|
1036
|
+
decorationId: "com.linkedin.voyager.dash.deco.identity.notifications.CardsCollectionWithInjectionsNoPills-25",
|
|
1037
|
+
provenance: "verified",
|
|
1038
|
+
capturedAt: "2026-10-29"
|
|
1039
|
+
},
|
|
1029
1040
|
// A company page, captured 2026-10-14. The GraphQL company query by
|
|
1030
1041
|
// universalName answers only the company's urn, so this is the REST
|
|
1031
1042
|
// resource: by id (`/<id>`) or by name (`q=universalName`). It carries the
|
|
@@ -1095,6 +1106,24 @@ var CONTRACTS = {
|
|
|
1095
1106
|
provenance: "verified",
|
|
1096
1107
|
capturedAt: "2026-10-14"
|
|
1097
1108
|
},
|
|
1109
|
+
// Premium job reads, captured 2026-11-22 from /jobs/collections/top-applicant/
|
|
1110
|
+
// and a job's detail pane. See engine/job-premium.ts.
|
|
1111
|
+
jobCollection: {
|
|
1112
|
+
name: "jobCollection",
|
|
1113
|
+
transport: "voyager-graphql",
|
|
1114
|
+
path: `${VOYAGER}/graphql`,
|
|
1115
|
+
queryId: "voyagerJobsDashJobCards.fc1f897bcf2dc9afd5184ef3e9ed589b",
|
|
1116
|
+
provenance: "verified",
|
|
1117
|
+
capturedAt: "2026-11-22"
|
|
1118
|
+
},
|
|
1119
|
+
jobDetailSections: {
|
|
1120
|
+
name: "jobDetailSections",
|
|
1121
|
+
transport: "voyager-graphql",
|
|
1122
|
+
path: `${VOYAGER}/graphql`,
|
|
1123
|
+
queryId: "voyagerJobsDashJobPostingDetailSections.bc2eee77d01abc6616b8c8855344dfd5",
|
|
1124
|
+
provenance: "verified",
|
|
1125
|
+
capturedAt: "2026-11-22"
|
|
1126
|
+
},
|
|
1098
1127
|
jobPosting: {
|
|
1099
1128
|
name: "jobPosting",
|
|
1100
1129
|
transport: "voyager-restli",
|
|
@@ -1169,25 +1198,25 @@ function parseCompany(json) {
|
|
|
1169
1198
|
const data = root?.data;
|
|
1170
1199
|
if (data === void 0 || data === null) return drift("the company answer carried no data");
|
|
1171
1200
|
const included = root?.included ?? [];
|
|
1172
|
-
const
|
|
1201
|
+
const byUrn2 = new Map(included.map((n) => [n.entityUrn, n]));
|
|
1173
1202
|
let c = data;
|
|
1174
1203
|
if (!String(data.$type ?? "").endsWith("organization.Company")) {
|
|
1175
1204
|
const listed2 = urns(data["*elements"]);
|
|
1176
1205
|
if (listed2.length === 0)
|
|
1177
1206
|
return { ok: false, code: "NOT_FOUND", message: "no company has that name on LinkedIn" };
|
|
1178
|
-
c =
|
|
1207
|
+
c = byUrn2.get(listed2[0]);
|
|
1179
1208
|
if (c === void 0) return drift("the company was listed but not sent");
|
|
1180
1209
|
}
|
|
1181
1210
|
const id = idOf(c.entityUrn);
|
|
1182
1211
|
const name = str2(c.name);
|
|
1183
1212
|
if (id === void 0 || name === void 0) return drift("the company carried no id or name");
|
|
1184
1213
|
const followersOf = (n) => {
|
|
1185
|
-
const f =
|
|
1214
|
+
const f = byUrn2.get(n["*followingInfo"]);
|
|
1186
1215
|
return typeof f?.followerCount === "number" ? f.followerCount : void 0;
|
|
1187
1216
|
};
|
|
1188
1217
|
const related = (list2) => {
|
|
1189
1218
|
const pages = urns(list2).flatMap((u) => {
|
|
1190
|
-
const p =
|
|
1219
|
+
const p = byUrn2.get(u);
|
|
1191
1220
|
const pid = idOf(u);
|
|
1192
1221
|
const pname = str2(p?.name);
|
|
1193
1222
|
if (p === void 0 || pid === void 0 || pname === void 0) return [];
|
|
@@ -1195,7 +1224,7 @@ function parseCompany(json) {
|
|
|
1195
1224
|
});
|
|
1196
1225
|
return pages.length > 0 ? pages : void 0;
|
|
1197
1226
|
};
|
|
1198
|
-
const industry = urns(c["*companyIndustries"]).map((u) => str2(
|
|
1227
|
+
const industry = urns(c["*companyIndustries"]).map((u) => str2(byUrn2.get(u)?.localizedName)).find((x) => x !== void 0);
|
|
1199
1228
|
const locations = (Array.isArray(c.confirmedLocations) ? c.confirmedLocations : []).map(address).filter((x) => x !== void 0);
|
|
1200
1229
|
const specialties = Array.isArray(c.specialities) ? c.specialities.filter((x) => typeof x === "string") : [];
|
|
1201
1230
|
const founded = c.foundedOn?.year;
|
|
@@ -1395,6 +1424,7 @@ function classifyRedirect(location) {
|
|
|
1395
1424
|
return fail("FETCH_FAILED", `unexpected redirect to ${location || "(none)"}`);
|
|
1396
1425
|
}
|
|
1397
1426
|
function challengeIn(body) {
|
|
1427
|
+
if (!/^\s*</.test(body)) return null;
|
|
1398
1428
|
if (!CHALLENGE_MARKERS.test(body.slice(0, 4e3))) return null;
|
|
1399
1429
|
return fail("CHALLENGE_DETECTED", "a challenge page was returned with status 200", {
|
|
1400
1430
|
cooldown: "CHALLENGE_DETECTED",
|
|
@@ -1714,9 +1744,9 @@ function findRefs(data) {
|
|
|
1714
1744
|
}
|
|
1715
1745
|
function parseSingle(payload) {
|
|
1716
1746
|
const envelope = payload ?? {};
|
|
1717
|
-
const
|
|
1718
|
-
if (
|
|
1719
|
-
return
|
|
1747
|
+
const nodes2 = [...new Set(indexIncluded(envelope.included).values())];
|
|
1748
|
+
if (nodes2.length === 0) return void 0;
|
|
1749
|
+
return nodes2.find((n) => !isNoise(n) && !isDecoration(n)) ?? nodes2[0];
|
|
1720
1750
|
}
|
|
1721
1751
|
function parseCollection(payload, opts) {
|
|
1722
1752
|
const envelope = payload ?? {};
|
|
@@ -2202,10 +2232,10 @@ function balanced(s, start) {
|
|
|
2202
2232
|
return null;
|
|
2203
2233
|
}
|
|
2204
2234
|
function parseAt(s, start) {
|
|
2205
|
-
const
|
|
2206
|
-
if (
|
|
2235
|
+
const text7 = start < 0 ? null : balanced(s, start);
|
|
2236
|
+
if (text7 === null) return null;
|
|
2207
2237
|
try {
|
|
2208
|
-
return JSON.parse(
|
|
2238
|
+
return JSON.parse(text7);
|
|
2209
2239
|
} catch {
|
|
2210
2240
|
return null;
|
|
2211
2241
|
}
|
|
@@ -2399,22 +2429,56 @@ function postsPagerBody(q2) {
|
|
|
2399
2429
|
}
|
|
2400
2430
|
};
|
|
2401
2431
|
}
|
|
2432
|
+
function unitsFor(stream, from, bytes) {
|
|
2433
|
+
let i = from;
|
|
2434
|
+
let left = bytes;
|
|
2435
|
+
while (left > 0 && i < stream.length) {
|
|
2436
|
+
const c = stream.codePointAt(i);
|
|
2437
|
+
left -= c < 128 ? 1 : c < 2048 ? 2 : c < 65536 ? 3 : 4;
|
|
2438
|
+
i += c > 65535 ? 2 : 1;
|
|
2439
|
+
}
|
|
2440
|
+
return i - from;
|
|
2441
|
+
}
|
|
2402
2442
|
var Rows = class {
|
|
2403
2443
|
constructor(stream) {
|
|
2404
2444
|
this.stream = stream;
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2445
|
+
const head = /([0-9a-f]+):(?:T([0-9a-f]+),)?/y;
|
|
2446
|
+
let pos = 0;
|
|
2447
|
+
while (pos < stream.length) {
|
|
2448
|
+
if (stream[pos] === "\n") {
|
|
2449
|
+
pos++;
|
|
2450
|
+
continue;
|
|
2451
|
+
}
|
|
2452
|
+
head.lastIndex = pos;
|
|
2453
|
+
const m = head.exec(stream);
|
|
2454
|
+
if (m === null) {
|
|
2455
|
+
const nl = stream.indexOf("\n", pos);
|
|
2456
|
+
pos = nl === -1 ? stream.length : nl + 1;
|
|
2457
|
+
continue;
|
|
2458
|
+
}
|
|
2459
|
+
const id = m[1];
|
|
2460
|
+
const body = pos + m[0].length;
|
|
2461
|
+
this.starts.push({ id, at: pos });
|
|
2462
|
+
let end;
|
|
2463
|
+
if (m[2] !== void 0) {
|
|
2464
|
+
end = body + unitsFor(stream, body, Number.parseInt(m[2], 16));
|
|
2465
|
+
this.texts.add(id);
|
|
2466
|
+
} else {
|
|
2467
|
+
const nl = stream.indexOf("\n", body);
|
|
2468
|
+
end = nl === -1 ? stream.length : nl;
|
|
2469
|
+
}
|
|
2470
|
+
this.byId.set(id, stream.slice(body, end));
|
|
2471
|
+
pos = end;
|
|
2413
2472
|
}
|
|
2414
2473
|
}
|
|
2415
2474
|
stream;
|
|
2416
2475
|
byId = /* @__PURE__ */ new Map();
|
|
2417
2476
|
starts = [];
|
|
2477
|
+
texts = /* @__PURE__ */ new Set();
|
|
2478
|
+
/** Whether a row is raw text (a `T` row) rather than JSON. */
|
|
2479
|
+
isText(id) {
|
|
2480
|
+
return this.texts.has(id);
|
|
2481
|
+
}
|
|
2418
2482
|
/** The row a stream position falls in. */
|
|
2419
2483
|
at(pos) {
|
|
2420
2484
|
let lo = 0;
|
|
@@ -2536,13 +2600,13 @@ function readPost(rows, top, model) {
|
|
|
2536
2600
|
const subRow = sub === void 0 ? "" : rows.byId.get(sub.row) ?? "";
|
|
2537
2601
|
const posted = sub === void 0 ? void 0 : texts(subRow, subRow.indexOf('"viewName":"feed-actor-sub-description"'))[0];
|
|
2538
2602
|
const said = commentary === void 0 ? void 0 : firstIn(rows, commentary.under, (row) => texts(row)[0]);
|
|
2539
|
-
const
|
|
2603
|
+
const text7 = said?.v;
|
|
2540
2604
|
const post = {
|
|
2541
2605
|
id,
|
|
2542
2606
|
url: `https://www.linkedin.com/feed/update/${id}/`,
|
|
2543
2607
|
...author.fields,
|
|
2544
2608
|
...posted !== void 0 ? { posted } : {},
|
|
2545
|
-
...
|
|
2609
|
+
...text7 !== void 0 ? { text: text7 } : {},
|
|
2546
2610
|
...reactions !== void 0 ? { reactions } : {}
|
|
2547
2611
|
};
|
|
2548
2612
|
const comments = n(`commentCount-${id}`);
|
|
@@ -2652,25 +2716,25 @@ function splitLocation(line2) {
|
|
|
2652
2716
|
const kind = m?.[2] === void 0 ? void 0 : WORKPLACE_SUFFIX[m[2].toLowerCase()];
|
|
2653
2717
|
return kind === void 0 || m?.[1] === void 0 ? { location: line2 } : { location: m[1], workplace: kind };
|
|
2654
2718
|
}
|
|
2655
|
-
function cardToJob(
|
|
2656
|
-
const urn =
|
|
2719
|
+
function cardToJob(card2) {
|
|
2720
|
+
const urn = card2.jobPostingUrn ?? card2["*jobPosting"];
|
|
2657
2721
|
const id = typeof urn === "string" ? jobIdOf(urn) : void 0;
|
|
2658
|
-
const title = typeof
|
|
2722
|
+
const title = typeof card2.jobPostingTitle === "string" ? card2.jobPostingTitle : text2(card2.title);
|
|
2659
2723
|
if (id === void 0 || title === void 0) return void 0;
|
|
2660
|
-
const footer = Array.isArray(
|
|
2724
|
+
const footer = Array.isArray(card2.footerItems) ? card2.footerItems : [];
|
|
2661
2725
|
const listed2 = footer.find((f) => f.type === "LISTED_DATE");
|
|
2662
2726
|
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);
|
|
2663
|
-
const insight2 = text2(
|
|
2727
|
+
const insight2 = text2(card2.relevanceInsight?.text);
|
|
2664
2728
|
if (insight2 !== void 0) insights.push(insight2);
|
|
2665
2729
|
return defined3({
|
|
2666
2730
|
id,
|
|
2667
2731
|
title,
|
|
2668
|
-
company: text2(
|
|
2669
|
-
...splitLocation(text2(
|
|
2732
|
+
company: text2(card2.primaryDescription),
|
|
2733
|
+
...splitLocation(text2(card2.secondaryDescription)),
|
|
2670
2734
|
listed: day(listed2?.timeAt),
|
|
2671
2735
|
easyApply: footer.some((f) => f.type === "EASY_APPLY_TEXT"),
|
|
2672
2736
|
promoted: footer.some((f) => f.type === "PROMOTED"),
|
|
2673
|
-
salary: text2(
|
|
2737
|
+
salary: text2(card2.tertiaryDescription),
|
|
2674
2738
|
insights: insights.length > 0 ? insights : void 0,
|
|
2675
2739
|
url: viewUrl(id)
|
|
2676
2740
|
});
|
|
@@ -2682,22 +2746,23 @@ var drift2 = (message) => ({
|
|
|
2682
2746
|
hint: "the job search response changed shape; re-capture it"
|
|
2683
2747
|
});
|
|
2684
2748
|
function readCards(elements, included) {
|
|
2685
|
-
const
|
|
2749
|
+
const byUrn2 = /* @__PURE__ */ new Map();
|
|
2686
2750
|
for (const node of included) {
|
|
2687
|
-
if (typeof node.entityUrn === "string")
|
|
2751
|
+
if (typeof node.entityUrn === "string") byUrn2.set(node.entityUrn, node);
|
|
2688
2752
|
}
|
|
2689
2753
|
const jobs = [];
|
|
2690
2754
|
const unknownTypes = {};
|
|
2691
2755
|
let unresolved = 0;
|
|
2692
2756
|
for (const el of elements) {
|
|
2693
|
-
const union = el.jobCardUnion ?? {};
|
|
2757
|
+
const union = el.jobCardUnion ?? el.jobCard ?? {};
|
|
2694
2758
|
const ref = union["*jobPostingCard"];
|
|
2695
2759
|
if (typeof ref !== "string") {
|
|
2696
|
-
for (const kind of Object.
|
|
2760
|
+
for (const [kind, v] of Object.entries(union))
|
|
2761
|
+
if (v !== null && !kind.startsWith("$")) unknownTypes[kind] = (unknownTypes[kind] ?? 0) + 1;
|
|
2697
2762
|
continue;
|
|
2698
2763
|
}
|
|
2699
|
-
const
|
|
2700
|
-
const job =
|
|
2764
|
+
const card2 = byUrn2.get(ref);
|
|
2765
|
+
const job = card2 === void 0 ? void 0 : cardToJob(card2);
|
|
2701
2766
|
if (job === void 0) unresolved++;
|
|
2702
2767
|
else if (!jobs.some((j) => j.id === job.id)) jobs.push(job);
|
|
2703
2768
|
}
|
|
@@ -2795,10 +2860,10 @@ function parseJobBatch(json) {
|
|
|
2795
2860
|
if (results === null || typeof results !== "object")
|
|
2796
2861
|
return drift2("the batch job response carried no results");
|
|
2797
2862
|
const included = root?.included ?? [];
|
|
2798
|
-
const
|
|
2863
|
+
const byUrn2 = new Map(included.map((n) => [n.entityUrn, n]));
|
|
2799
2864
|
const jobs = [];
|
|
2800
2865
|
for (const ref of Object.values(results)) {
|
|
2801
|
-
const node = typeof ref === "string" ?
|
|
2866
|
+
const node = typeof ref === "string" ? byUrn2.get(ref) : ref;
|
|
2802
2867
|
const job = node === void 0 ? void 0 : postingToJob(node, included);
|
|
2803
2868
|
if (job !== void 0) jobs.push(job);
|
|
2804
2869
|
}
|
|
@@ -2823,11 +2888,11 @@ function hiringTeamBody(jobId) {
|
|
|
2823
2888
|
};
|
|
2824
2889
|
}
|
|
2825
2890
|
var unquote = (s) => JSON.parse(`"${s}"`);
|
|
2826
|
-
function memberOf(
|
|
2827
|
-
const url =
|
|
2828
|
-
const name =
|
|
2891
|
+
function memberOf(card2, id) {
|
|
2892
|
+
const url = card2.match(/"url":"(https:\/\/www\.linkedin\.com\/in\/[^"/]+\/)"/)?.[1];
|
|
2893
|
+
const name = card2.match(/\[null,"((?:[^"\\]|\\.)+)"/)?.[1];
|
|
2829
2894
|
if (url === void 0 || name === void 0) return void 0;
|
|
2830
|
-
const lines = [...
|
|
2895
|
+
const lines = [...card2.matchAll(/"children":\["((?:[^"\\$]|\\.)(?:[^"\\]|\\.)*)"\]/g)].map(
|
|
2831
2896
|
(m) => unquote(m[1]).trim()
|
|
2832
2897
|
);
|
|
2833
2898
|
const degree = lines.find((l) => l.startsWith("\u2022"));
|
|
@@ -2839,7 +2904,7 @@ function memberOf(card, id) {
|
|
|
2839
2904
|
headline,
|
|
2840
2905
|
degree: degree?.replace(/^•\s*/, ""),
|
|
2841
2906
|
role: role3,
|
|
2842
|
-
verified: /"role":"img","aria-label"/.test(
|
|
2907
|
+
verified: /"role":"img","aria-label"/.test(card2) ? true : void 0
|
|
2843
2908
|
});
|
|
2844
2909
|
}
|
|
2845
2910
|
function parseHiringTeam(stream) {
|
|
@@ -2848,7 +2913,7 @@ function parseHiringTeam(stream) {
|
|
|
2848
2913
|
return drift2("the hiring team answer was not the hiring team component");
|
|
2849
2914
|
const rows = new Rows(stream);
|
|
2850
2915
|
const cards = [...rows.byId].filter(([, row]) => /linkedin\.com\\?\/in\\?\//.test(row));
|
|
2851
|
-
const at = (
|
|
2916
|
+
const at = (card2) => stream.indexOf(`"$L${card2}"`);
|
|
2852
2917
|
const placed = cards.map(([key]) => at(key)).sort((a, b) => a - b);
|
|
2853
2918
|
const members = [];
|
|
2854
2919
|
for (const [key, row] of cards) {
|
|
@@ -3099,7 +3164,7 @@ function classify2(item) {
|
|
|
3099
3164
|
return kinds.every((k) => FURNITURE.has(k)) ? "furniture" : kinds;
|
|
3100
3165
|
}
|
|
3101
3166
|
function readItems(c, included, toRow) {
|
|
3102
|
-
const
|
|
3167
|
+
const byUrn2 = new Map(included.map((n) => [n.entityUrn, n]));
|
|
3103
3168
|
const people = [];
|
|
3104
3169
|
const unknownTypes = {};
|
|
3105
3170
|
let excluded = 0;
|
|
@@ -3112,7 +3177,7 @@ function readItems(c, included, toRow) {
|
|
|
3112
3177
|
} else if (Array.isArray(kind)) {
|
|
3113
3178
|
for (const k of kind) unknownTypes[k] = (unknownTypes[k] ?? 0) + 1;
|
|
3114
3179
|
} else {
|
|
3115
|
-
const row =
|
|
3180
|
+
const row = byUrn2.get(kind.ref);
|
|
3116
3181
|
const person = row === void 0 ? void 0 : toRow(row);
|
|
3117
3182
|
if (person === void 0) unresolved++;
|
|
3118
3183
|
else if (!people.some((p) => p.id === person.id)) people.push(person);
|
|
@@ -3192,11 +3257,11 @@ function parseOrgHits(json) {
|
|
|
3192
3257
|
const c = clustersOf(json);
|
|
3193
3258
|
if (c === void 0) return drift3("the organisation search returned no result list");
|
|
3194
3259
|
const included = json.included ?? [];
|
|
3195
|
-
const
|
|
3260
|
+
const byUrn2 = new Map(included.map((n) => [n.entityUrn, n]));
|
|
3196
3261
|
const hits = [];
|
|
3197
3262
|
for (const el of c.elements ?? []) {
|
|
3198
3263
|
for (const { item } of el.items ?? []) {
|
|
3199
|
-
const row =
|
|
3264
|
+
const row = byUrn2.get(item?.["*entityResult"]);
|
|
3200
3265
|
const id = String(row?.entityUrn ?? "").match(/urn:li:fsd_company:(\d+)/)?.[1];
|
|
3201
3266
|
const name = text3(row?.title);
|
|
3202
3267
|
if (id !== void 0 && name !== void 0 && !hits.some((h) => h.id === id))
|
|
@@ -3603,13 +3668,13 @@ function compactPost(p) {
|
|
|
3603
3668
|
p.comments !== void 0 ? `${p.comments} comments` : void 0,
|
|
3604
3669
|
p.reposts !== void 0 ? `${p.reposts} reposts` : void 0
|
|
3605
3670
|
].filter(Boolean);
|
|
3606
|
-
const
|
|
3671
|
+
const text7 = p.text?.replace(/\s+/g, " ");
|
|
3607
3672
|
return line([
|
|
3608
3673
|
p.id,
|
|
3609
3674
|
p.author,
|
|
3610
3675
|
p.posted,
|
|
3611
3676
|
counts2.length > 0 ? counts2.join(" \xB7 ") : void 0,
|
|
3612
|
-
|
|
3677
|
+
text7 !== void 0 && text7.length > 160 ? `${text7.slice(0, 157)}\u2026` : text7,
|
|
3613
3678
|
p.url,
|
|
3614
3679
|
p.matched !== void 0 ? `matched: ${p.matched.join(" + ")}` : void 0
|
|
3615
3680
|
]);
|
|
@@ -3930,7 +3995,7 @@ async function fetchCommentMenu(ref, trackingId, client) {
|
|
|
3930
3995
|
const stream = result.classification.raw ?? "";
|
|
3931
3996
|
return { ok: true, stream };
|
|
3932
3997
|
}
|
|
3933
|
-
function textStates(payload,
|
|
3998
|
+
function textStates(payload, text7) {
|
|
3934
3999
|
const keyOf = (...names) => {
|
|
3935
4000
|
for (const n of names) {
|
|
3936
4001
|
const slot = payload[n];
|
|
@@ -3949,12 +4014,12 @@ function textStates(payload, text6) {
|
|
|
3949
4014
|
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: key } }
|
|
3950
4015
|
});
|
|
3951
4016
|
return [
|
|
3952
|
-
entry3(plain2,
|
|
3953
|
-
entry3(rich, { text:
|
|
4017
|
+
entry3(plain2, text7, "stringValue"),
|
|
4018
|
+
entry3(rich, { text: text7, attribute: [], $type: "TextModel", source: "local" }, "textModelForWrite")
|
|
3954
4019
|
];
|
|
3955
4020
|
}
|
|
3956
|
-
function editStates(payload,
|
|
3957
|
-
return textStates(payload,
|
|
4021
|
+
function editStates(payload, text7) {
|
|
4022
|
+
return textStates(payload, text7);
|
|
3958
4023
|
}
|
|
3959
4024
|
async function runCommentAction(ref, operation, trackingId, client, newText) {
|
|
3960
4025
|
const menu = await fetchCommentMenu(ref, trackingId, client);
|
|
@@ -4207,12 +4272,12 @@ var CATEGORY = {
|
|
|
4207
4272
|
VIDEO: "VIDEO",
|
|
4208
4273
|
DOCUMENT: "NATIVE_DOCUMENT"
|
|
4209
4274
|
};
|
|
4210
|
-
function sharePayload(
|
|
4275
|
+
function sharePayload(text7, visibility, media = [], scheduledAt) {
|
|
4211
4276
|
const schedule = scheduledAt === void 0 ? { postState: "PUBLISHED" } : { postState: "SCHEDULED", scheduledAt };
|
|
4212
4277
|
return {
|
|
4213
4278
|
visibleToConnectionsOnly: visibility === "CONNECTIONS",
|
|
4214
4279
|
externalAudienceProviders: [],
|
|
4215
|
-
commentaryV2: { text:
|
|
4280
|
+
commentaryV2: { text: text7, attributes: [] },
|
|
4216
4281
|
origin: "FEED",
|
|
4217
4282
|
allowedCommentersScope: "ALL",
|
|
4218
4283
|
...schedule,
|
|
@@ -4275,8 +4340,8 @@ async function share(confirmed, client, bytes) {
|
|
|
4275
4340
|
}
|
|
4276
4341
|
}
|
|
4277
4342
|
const media = [];
|
|
4278
|
-
const { card } = confirmed.payload;
|
|
4279
|
-
if (
|
|
4343
|
+
const { card: card2 } = confirmed.payload;
|
|
4344
|
+
if (card2 !== void 0) media.push({ category: "ARTICLE", urn: card2.urn });
|
|
4280
4345
|
const { poll } = confirmed.payload;
|
|
4281
4346
|
if (poll !== void 0) {
|
|
4282
4347
|
const created = await createPoll(poll, client);
|
|
@@ -4326,15 +4391,15 @@ async function share(confirmed, client, bytes) {
|
|
|
4326
4391
|
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."
|
|
4327
4392
|
} : { ok: true, id };
|
|
4328
4393
|
}
|
|
4329
|
-
function editPostBody(
|
|
4330
|
-
return { patch: { $set: { commentaryV2: { text:
|
|
4394
|
+
function editPostBody(text7) {
|
|
4395
|
+
return { patch: { $set: { commentaryV2: { text: text7, attributes: [] } } } };
|
|
4331
4396
|
}
|
|
4332
4397
|
async function editPost(confirmed, client) {
|
|
4333
|
-
const { urn, text:
|
|
4398
|
+
const { urn, text: text7 } = confirmed.payload;
|
|
4334
4399
|
const result = await client.request({
|
|
4335
4400
|
url: deleteUrl(urn),
|
|
4336
4401
|
method: "POST",
|
|
4337
|
-
body: editPostBody(
|
|
4402
|
+
body: editPostBody(text7),
|
|
4338
4403
|
spendClass: "write",
|
|
4339
4404
|
operation: "edit-post"
|
|
4340
4405
|
});
|
|
@@ -4344,7 +4409,7 @@ async function editPost(confirmed, client) {
|
|
|
4344
4409
|
return out;
|
|
4345
4410
|
}
|
|
4346
4411
|
const held = result.json?.data?.commentary?.text;
|
|
4347
|
-
if (held !==
|
|
4412
|
+
if (held !== text7) {
|
|
4348
4413
|
return {
|
|
4349
4414
|
ok: false,
|
|
4350
4415
|
code: "SCHEMA_DRIFT",
|
|
@@ -4405,8 +4470,8 @@ async function createPoll(poll, client) {
|
|
|
4405
4470
|
}
|
|
4406
4471
|
return { ok: true, urn };
|
|
4407
4472
|
}
|
|
4408
|
-
function firstUrl(
|
|
4409
|
-
const found =
|
|
4473
|
+
function firstUrl(text7) {
|
|
4474
|
+
const found = text7.match(/https?:\/\/[^\s<>"]+/)?.[0];
|
|
4410
4475
|
if (found === void 0) return null;
|
|
4411
4476
|
let url = found.replace(/[.,;:!?'"]+$/, "");
|
|
4412
4477
|
if (url.endsWith(")") && !url.includes("(")) url = url.slice(0, -1);
|
|
@@ -4570,8 +4635,8 @@ function previewLines2(post) {
|
|
|
4570
4635
|
" about to delete, or that it is yours."
|
|
4571
4636
|
];
|
|
4572
4637
|
}
|
|
4573
|
-
const
|
|
4574
|
-
const shown =
|
|
4638
|
+
const text7 = typeof post.text === "string" ? post.text : "(no text \u2014 media-only post?)";
|
|
4639
|
+
const shown = text7.length > PREVIEW_CHARS ? `${text7.slice(0, PREVIEW_CHARS)}\u2026` : text7;
|
|
4575
4640
|
const lines = [`content "${shown.replace(/\n/g, " ")}"`];
|
|
4576
4641
|
if (typeof post.scheduledAt === "string") {
|
|
4577
4642
|
lines.push(`status scheduled, publishes ${post.scheduledAt} unless cancelled`);
|
|
@@ -4822,14 +4887,14 @@ var txt = (v) => {
|
|
|
4822
4887
|
if (t !== null && typeof t === "object") return txt(t);
|
|
4823
4888
|
return typeof t === "string" && t.trim() !== "" ? t.trim() : void 0;
|
|
4824
4889
|
};
|
|
4825
|
-
function organizerOf(e,
|
|
4890
|
+
function organizerOf(e, byUrn2) {
|
|
4826
4891
|
const o = e.organizer ?? {};
|
|
4827
|
-
const company =
|
|
4892
|
+
const company = byUrn2.get(o["*organizingCompanyUrn"]);
|
|
4828
4893
|
if (typeof company?.name === "string") {
|
|
4829
4894
|
const id = String(company.entityUrn).split(":").pop();
|
|
4830
4895
|
return { name: company.name, kind: "company", url: `https://www.linkedin.com/company/${id}/` };
|
|
4831
4896
|
}
|
|
4832
|
-
const person =
|
|
4897
|
+
const person = byUrn2.get(o["*organizingProfileUrn"] ?? o.organizingProfileUrn);
|
|
4833
4898
|
const name = [person?.firstName, person?.lastName].filter((x) => typeof x === "string").join(" ");
|
|
4834
4899
|
if (name !== "") {
|
|
4835
4900
|
const vanity = person?.publicIdentifier;
|
|
@@ -4853,11 +4918,11 @@ function parseEvent(json) {
|
|
|
4853
4918
|
hint: "re-capture the event page"
|
|
4854
4919
|
};
|
|
4855
4920
|
}
|
|
4856
|
-
const
|
|
4921
|
+
const byUrn2 = new Map(included.map((n) => [n.entityUrn, n]));
|
|
4857
4922
|
const range2 = e.timeRange ?? {};
|
|
4858
4923
|
const address2 = e.address ?? null;
|
|
4859
4924
|
const place = address2 === null ? void 0 : [address2.city, address2.geographicArea, address2.country].filter((x) => typeof x === "string" && x !== "").join(", ");
|
|
4860
|
-
const status =
|
|
4925
|
+
const status = byUrn2.get(e["*viewerStatus"])?.scheduledContentViewerStatus;
|
|
4861
4926
|
const attendees = Number(
|
|
4862
4927
|
txt(e.socialProof)?.match(/^(\d[\d,.\s]*)/)?.[1]?.replace(/[,.\s]/g, "")
|
|
4863
4928
|
);
|
|
@@ -4880,7 +4945,7 @@ function parseEvent(json) {
|
|
|
4880
4945
|
set("state", typeof e.lifecycleState === "string" ? e.lifecycleState : void 0);
|
|
4881
4946
|
if (e.cancelled === true) out.cancelled = true;
|
|
4882
4947
|
set("attendees", Number.isFinite(attendees) ? attendees : void 0);
|
|
4883
|
-
set("organizer", organizerOf(e,
|
|
4948
|
+
set("organizer", organizerOf(e, byUrn2));
|
|
4884
4949
|
set("place", place);
|
|
4885
4950
|
set("site", typeof e.externalUrl === "string" ? e.externalUrl : void 0);
|
|
4886
4951
|
if (e.privateEvent === true) out.private = true;
|
|
@@ -4988,6 +5053,158 @@ async function runEvent(inputs, opts = {}, fetch2) {
|
|
|
4988
5053
|
});
|
|
4989
5054
|
}
|
|
4990
5055
|
|
|
5056
|
+
// src/engine/job-premium.ts
|
|
5057
|
+
function graphql(name) {
|
|
5058
|
+
const c = CONTRACTS[name];
|
|
5059
|
+
if (c?.queryId === void 0) throw new Error(`job contract '${name}' is missing`);
|
|
5060
|
+
return { path: c.path, queryId: c.queryId };
|
|
5061
|
+
}
|
|
5062
|
+
var COLLECTION_PAGE = 100;
|
|
5063
|
+
function jobCollectionUrl(slug, start, count3) {
|
|
5064
|
+
const c = graphql("jobCollection");
|
|
5065
|
+
const variables = `(count:${count3},jobCollectionSlug:${slug},query:(origin:GENERIC_JOB_COLLECTIONS_LANDING),start:${start})`;
|
|
5066
|
+
return `${c.path}?variables=${variables}&queryId=${c.queryId}`;
|
|
5067
|
+
}
|
|
5068
|
+
function jobInsightsUrl(id) {
|
|
5069
|
+
const c = graphql("jobDetailSections");
|
|
5070
|
+
const urn = encodeURIComponent(`urn:li:fsd_jobPosting:${id}`);
|
|
5071
|
+
const variables = `(cardSectionTypes:List(JOB_APPLICANT_INSIGHTS,COMPANY_INSIGHTS_CARD),jobPostingUrn:${urn},includeSecondaryActionsV2:true)`;
|
|
5072
|
+
return `${c.path}?includeWebMetadata=true&variables=${variables}&queryId=${c.queryId}`;
|
|
5073
|
+
}
|
|
5074
|
+
var drift5 = (message) => ({ ok: false, code: "SCHEMA_DRIFT", message });
|
|
5075
|
+
var text4 = (v) => {
|
|
5076
|
+
const t = v?.text;
|
|
5077
|
+
return typeof t === "string" && t.trim() !== "" ? t.trim() : void 0;
|
|
5078
|
+
};
|
|
5079
|
+
var nodes = (v) => Array.isArray(v) ? v : [];
|
|
5080
|
+
function defined5(obj) {
|
|
5081
|
+
for (const k of Object.keys(obj)) if (obj[k] === void 0) delete obj[k];
|
|
5082
|
+
return obj;
|
|
5083
|
+
}
|
|
5084
|
+
function parseJobCollection(json) {
|
|
5085
|
+
const root = json;
|
|
5086
|
+
const collection2 = root?.data?.data?.jobsDashJobCardsByJobCollections;
|
|
5087
|
+
if (collection2 === void 0 || collection2 === null) {
|
|
5088
|
+
const why = nodes(root?.data?.errors)[0]?.message;
|
|
5089
|
+
return drift5(`the job collection was not served${typeof why === "string" ? `: ${why}` : ""}`);
|
|
5090
|
+
}
|
|
5091
|
+
return parseJobCards({ data: collection2, included: root?.included ?? [] });
|
|
5092
|
+
}
|
|
5093
|
+
function byUrn(included) {
|
|
5094
|
+
const map = /* @__PURE__ */ new Map();
|
|
5095
|
+
for (const n of included) if (typeof n.entityUrn === "string") map.set(n.entityUrn, n);
|
|
5096
|
+
return map;
|
|
5097
|
+
}
|
|
5098
|
+
var nameOf = (urns2, urn) => {
|
|
5099
|
+
const n = typeof urn === "string" ? urns2.get(urn)?.name : void 0;
|
|
5100
|
+
return typeof n === "string" ? n : void 0;
|
|
5101
|
+
};
|
|
5102
|
+
function applicantsOf(a, urns2) {
|
|
5103
|
+
const seniority = nodes(a.seniorityDetails).flatMap((s) => {
|
|
5104
|
+
const level = nameOf(urns2, s["*seniority"]);
|
|
5105
|
+
return level === void 0 || typeof s.percentage !== "number" ? [] : [defined5({ level, share: s.percentage, count: s.count })];
|
|
5106
|
+
});
|
|
5107
|
+
const education = nodes(a.degreeDetails).flatMap((d) => {
|
|
5108
|
+
const degree = nameOf(urns2, d["*degree"]);
|
|
5109
|
+
return degree === void 0 || typeof d.percentage !== "number" ? [] : [{ degree, share: d.percentage }];
|
|
5110
|
+
});
|
|
5111
|
+
const skills = nodes(a.skillDetails);
|
|
5112
|
+
const locations = nodes(a.locationDetails);
|
|
5113
|
+
return defined5({
|
|
5114
|
+
total: a.applicantCount,
|
|
5115
|
+
lastDay: typeof a.applicantsInPastDay === "number" ? a.applicantsInPastDay : void 0,
|
|
5116
|
+
seniority: seniority.length > 0 ? seniority : void 0,
|
|
5117
|
+
education: education.length > 0 ? education : void 0,
|
|
5118
|
+
rankPercentile: typeof a.applicantRankPercentile === "number" ? a.applicantRankPercentile : void 0,
|
|
5119
|
+
skills: skills.length > 0 ? skills : void 0,
|
|
5120
|
+
locations: locations.length > 0 ? locations : void 0
|
|
5121
|
+
});
|
|
5122
|
+
}
|
|
5123
|
+
function headcountOf(growth) {
|
|
5124
|
+
const months = nodes(growth?.headcountGrowth).flatMap((m) => {
|
|
5125
|
+
const on = m.startedOn;
|
|
5126
|
+
return typeof m.employeeCount === "number" && on?.year !== void 0 && on.month !== void 0 ? [{ month: `${on.year}-${String(on.month).padStart(2, "0")}`, count: m.employeeCount }] : [];
|
|
5127
|
+
});
|
|
5128
|
+
const latest = months[0];
|
|
5129
|
+
if (latest === void 0) return void 0;
|
|
5130
|
+
const back = (n) => months[n]?.count;
|
|
5131
|
+
const yearAgo = back(12);
|
|
5132
|
+
return defined5({
|
|
5133
|
+
asOf: latest.month,
|
|
5134
|
+
now: latest.count,
|
|
5135
|
+
sixMonthsAgo: back(6),
|
|
5136
|
+
yearAgo,
|
|
5137
|
+
twoYearsAgo: back(24),
|
|
5138
|
+
growth1y: yearAgo !== void 0 && yearAgo > 0 ? Math.round((latest.count - yearAgo) / yearAgo * 1e3) / 10 : void 0
|
|
5139
|
+
});
|
|
5140
|
+
}
|
|
5141
|
+
var str4 = (v) => typeof v === "string" ? v : void 0;
|
|
5142
|
+
function trendOf(s, urns2) {
|
|
5143
|
+
const company = urns2.get(String(s["*company"]));
|
|
5144
|
+
const fn = str4(s.formattedJobFunction);
|
|
5145
|
+
return defined5({
|
|
5146
|
+
name: str4(company?.name),
|
|
5147
|
+
url: str4(company?.url),
|
|
5148
|
+
headcount: headcountOf(s.employeeGrowth),
|
|
5149
|
+
function: fn !== void 0 ? { name: fn, ...headcountOf(s.employeeGrowthForFunction) } : void 0,
|
|
5150
|
+
medianTenure: text4(s.employeeGrowth?.medianTenureYears)
|
|
5151
|
+
});
|
|
5152
|
+
}
|
|
5153
|
+
function landscapeOf(s) {
|
|
5154
|
+
const competitors = nodes(s.competitors).flatMap((c) => {
|
|
5155
|
+
const name = text4(c.title);
|
|
5156
|
+
return name === void 0 ? [] : [defined5({ name, industry: text4(c.subtitle), url: str4(c.navigationUrl) })];
|
|
5157
|
+
});
|
|
5158
|
+
return defined5({
|
|
5159
|
+
landscape: text4(s.aiqInsightsText),
|
|
5160
|
+
competitors: competitors.length > 0 ? competitors : void 0
|
|
5161
|
+
});
|
|
5162
|
+
}
|
|
5163
|
+
var SECTIONS = {
|
|
5164
|
+
jobPostingCompanyInsights: trendOf,
|
|
5165
|
+
headcountAIQInsights: (s) => defined5({ hiring: text4(s.aiqInsightsText) }),
|
|
5166
|
+
strategicPrioritiesAIQInsights: (s) => defined5({ priorities: text4(s.insightsText) }),
|
|
5167
|
+
competitiveLandscapeAIQInsights: landscapeOf
|
|
5168
|
+
};
|
|
5169
|
+
function companyOf(card2, urns2, unknown) {
|
|
5170
|
+
const out = {};
|
|
5171
|
+
for (const el of nodes(card2.elements)) {
|
|
5172
|
+
for (const [kind, section] of Object.entries(el.companyInsights ?? {})) {
|
|
5173
|
+
if (section === null || kind.startsWith("$")) continue;
|
|
5174
|
+
const read = SECTIONS[kind];
|
|
5175
|
+
if (read === void 0) unknown[kind] = (unknown[kind] ?? 0) + 1;
|
|
5176
|
+
else Object.assign(out, read(section, urns2));
|
|
5177
|
+
}
|
|
5178
|
+
}
|
|
5179
|
+
return out;
|
|
5180
|
+
}
|
|
5181
|
+
function parseJobInsights(json) {
|
|
5182
|
+
const root = json;
|
|
5183
|
+
const sections = root?.data?.data?.jobsDashJobPostingDetailSectionsByCardSectionTypes;
|
|
5184
|
+
if (sections === void 0 || sections === null || !Array.isArray(sections.elements))
|
|
5185
|
+
return drift5("the job detail sections were not in the answer");
|
|
5186
|
+
const urns2 = byUrn(root?.included ?? []);
|
|
5187
|
+
const unknownSections = {};
|
|
5188
|
+
let applicants;
|
|
5189
|
+
let company;
|
|
5190
|
+
for (const el of nodes(sections.elements)) {
|
|
5191
|
+
for (const part2 of nodes(el.jobPostingDetailSection)) {
|
|
5192
|
+
const a = urns2.get(String(part2["*jobApplicantInsightsUrn"]));
|
|
5193
|
+
if (a !== void 0 && typeof a.applicantCount === "number")
|
|
5194
|
+
applicants = applicantsOf(a, urns2);
|
|
5195
|
+
const posting = urns2.get(String(part2["*companyInsightsCard"]));
|
|
5196
|
+
const card2 = posting?.companyInsightsCard;
|
|
5197
|
+
if (card2 !== void 0 && card2 !== null) company = companyOf(card2, urns2, unknownSections);
|
|
5198
|
+
}
|
|
5199
|
+
}
|
|
5200
|
+
return {
|
|
5201
|
+
ok: true,
|
|
5202
|
+
...applicants !== void 0 ? { applicants } : {},
|
|
5203
|
+
...company !== void 0 && Object.keys(company).length > 0 ? { company } : {},
|
|
5204
|
+
unknownSections
|
|
5205
|
+
};
|
|
5206
|
+
}
|
|
5207
|
+
|
|
4991
5208
|
// src/commands/jobs.ts
|
|
4992
5209
|
function liveFetch5(command, quiet) {
|
|
4993
5210
|
const session = loadSession();
|
|
@@ -5064,6 +5281,7 @@ async function addDetails(get, rows, withDescription) {
|
|
|
5064
5281
|
return read.stoppedBy === void 0 ? { unread } : { unread, stoppedBy: read.stoppedBy };
|
|
5065
5282
|
}
|
|
5066
5283
|
async function runJobs(req, opts = {}, fetch2) {
|
|
5284
|
+
if (req.collection !== void 0) return runCollection(req, req.collection, opts, fetch2);
|
|
5067
5285
|
const sets = keywordSets(req.keywords);
|
|
5068
5286
|
const hasQuery = sets.length > 0 || [req.location, req.geoId].some((v) => v !== void 0 && v !== "");
|
|
5069
5287
|
if (!hasQuery) {
|
|
@@ -5130,6 +5348,65 @@ async function runJobs(req, opts = {}, fetch2) {
|
|
|
5130
5348
|
meta
|
|
5131
5349
|
});
|
|
5132
5350
|
}
|
|
5351
|
+
async function runCollection(req, collection2, opts, fetch2) {
|
|
5352
|
+
const searched = keywordSets(req.keywords).length > 0 || req.location || req.geoId;
|
|
5353
|
+
const selection3 = jobFilterSelection(req.filter ?? {});
|
|
5354
|
+
const filtered = !selection3.ok || Object.keys(selection3.filters).length > 0;
|
|
5355
|
+
if (searched || filtered)
|
|
5356
|
+
return err(
|
|
5357
|
+
"jobs",
|
|
5358
|
+
"INVALID_INPUT",
|
|
5359
|
+
`--${collection2} is LinkedIn's own list: it takes no keywords, location or filters`
|
|
5360
|
+
);
|
|
5361
|
+
const get = fetch2 ?? liveFetch5("jobs", opts.quiet === true);
|
|
5362
|
+
if (typeof get !== "function") return get;
|
|
5363
|
+
const first = Math.max(0, req.start ?? 0);
|
|
5364
|
+
const want = Math.max(1, Math.min(req.limit, PAGING3.max - first));
|
|
5365
|
+
const fetchPage = async (_keywords, start) => {
|
|
5366
|
+
const res = await get(jobCollectionUrl(collection2, start, COLLECTION_PAGE), "jobSearch");
|
|
5367
|
+
const page = res.ok ? parseJobCollection(res.json) : res;
|
|
5368
|
+
if (!page.ok) return page;
|
|
5369
|
+
return {
|
|
5370
|
+
ok: true,
|
|
5371
|
+
items: page.jobs,
|
|
5372
|
+
...page.total !== void 0 ? { total: page.total } : {},
|
|
5373
|
+
unknownTypes: page.unknownTypes
|
|
5374
|
+
};
|
|
5375
|
+
};
|
|
5376
|
+
const merged = await searchAll(fetchPage, [void 0], first, want, PAGING3);
|
|
5377
|
+
if (merged.rows.length === 0 && merged.failure !== void 0) {
|
|
5378
|
+
const f = merged.failure;
|
|
5379
|
+
return err("jobs", f.code, f.message, f.hint);
|
|
5380
|
+
}
|
|
5381
|
+
let extra = {};
|
|
5382
|
+
if (req.details === true) {
|
|
5383
|
+
const added = await addDetails(get, merged.rows, req.description === true);
|
|
5384
|
+
extra = {
|
|
5385
|
+
unread: added.unread,
|
|
5386
|
+
...added.stoppedBy !== void 0 ? { readStop: added.stoppedBy } : {}
|
|
5387
|
+
};
|
|
5388
|
+
}
|
|
5389
|
+
return ok("jobs", {
|
|
5390
|
+
collection: collection2,
|
|
5391
|
+
items: shape2(merged.rows, opts, compactJob),
|
|
5392
|
+
meta: metaOf("jobs", merged, true, first, { unread: 0, ...extra })
|
|
5393
|
+
});
|
|
5394
|
+
}
|
|
5395
|
+
async function addInsights(get, jobs) {
|
|
5396
|
+
for (const job of jobs) {
|
|
5397
|
+
const res = await get(jobInsightsUrl(job.id), "jobRead");
|
|
5398
|
+
const read = res.ok ? parseJobInsights(res.json) : res;
|
|
5399
|
+
if (!read.ok) {
|
|
5400
|
+
job.premiumError = `${read.code}: ${read.message}`;
|
|
5401
|
+
continue;
|
|
5402
|
+
}
|
|
5403
|
+
const { ok: _ok, unknownSections, ...insights } = read;
|
|
5404
|
+
job.premium = {
|
|
5405
|
+
...insights,
|
|
5406
|
+
...Object.keys(unknownSections).length > 0 ? { unknownSections } : {}
|
|
5407
|
+
};
|
|
5408
|
+
}
|
|
5409
|
+
}
|
|
5133
5410
|
async function addTeams(get, jobs) {
|
|
5134
5411
|
for (const job of jobs) {
|
|
5135
5412
|
const res = await get(HIRING_TEAM_URL, "page", hiringTeamBody(job.id));
|
|
@@ -5158,8 +5435,10 @@ async function runJob(input, opts = {}, fetch2, req = {}) {
|
|
|
5158
5435
|
if (!res.ok) return err("job", res.code, res.message, res.hint);
|
|
5159
5436
|
const detail = parseJobDetail(res.json);
|
|
5160
5437
|
if (!detail.ok) return err("job", detail.code, detail.message, detail.hint);
|
|
5161
|
-
|
|
5162
|
-
|
|
5438
|
+
const job = detail.job;
|
|
5439
|
+
if (req.team === true) await addTeams(get, [job]);
|
|
5440
|
+
if (req.insights === true) await addInsights(get, [job]);
|
|
5441
|
+
return ok("job", job);
|
|
5163
5442
|
}
|
|
5164
5443
|
const read = await readJobs(get, wanted);
|
|
5165
5444
|
if (read.jobs.size === 0 && read.stoppedBy !== void 0)
|
|
@@ -5167,6 +5446,7 @@ async function runJob(input, opts = {}, fetch2, req = {}) {
|
|
|
5167
5446
|
const unread = wanted.filter((id) => !read.jobs.has(id));
|
|
5168
5447
|
const jobs = wanted.flatMap((id) => read.jobs.get(id) ?? []);
|
|
5169
5448
|
if (req.team === true) await addTeams(get, jobs);
|
|
5449
|
+
if (req.insights === true) await addInsights(get, jobs);
|
|
5170
5450
|
return ok("job", {
|
|
5171
5451
|
items: shape2(
|
|
5172
5452
|
jobs,
|
|
@@ -5545,7 +5825,7 @@ var txt2 = (v) => {
|
|
|
5545
5825
|
return typeof t === "string" && t.trim() !== "" ? t.trim() : void 0;
|
|
5546
5826
|
};
|
|
5547
5827
|
var iso = (ms) => typeof ms === "number" ? new Date(ms).toISOString() : void 0;
|
|
5548
|
-
function
|
|
5828
|
+
function defined6(obj) {
|
|
5549
5829
|
for (const k of Object.keys(obj)) if (obj[k] === void 0) delete obj[k];
|
|
5550
5830
|
return obj;
|
|
5551
5831
|
}
|
|
@@ -5555,7 +5835,7 @@ function participantOf(p) {
|
|
|
5555
5835
|
const m = t.member;
|
|
5556
5836
|
const name = [txt2(m.firstName), txt2(m.lastName)].filter(Boolean).join(" ");
|
|
5557
5837
|
const url = typeof m.profileUrl === "string" ? `${m.profileUrl.replace(/\/$/, "")}/` : void 0;
|
|
5558
|
-
return
|
|
5838
|
+
return defined6({
|
|
5559
5839
|
name: name !== "" ? name : "LinkedIn Member",
|
|
5560
5840
|
kind: "person",
|
|
5561
5841
|
headline: txt2(m.headline),
|
|
@@ -5565,7 +5845,7 @@ function participantOf(p) {
|
|
|
5565
5845
|
}
|
|
5566
5846
|
if (t.organization) {
|
|
5567
5847
|
const o = t.organization;
|
|
5568
|
-
return
|
|
5848
|
+
return defined6({
|
|
5569
5849
|
name: txt2(o.name) ?? "an organization",
|
|
5570
5850
|
kind: "organization",
|
|
5571
5851
|
url: typeof o.pageUrl === "string" ? o.pageUrl : void 0
|
|
@@ -5575,12 +5855,12 @@ function participantOf(p) {
|
|
|
5575
5855
|
return void 0;
|
|
5576
5856
|
}
|
|
5577
5857
|
var isMe = (urn, mailbox2) => typeof urn === "string" && urn.includes(mailbox2);
|
|
5578
|
-
function messageOf(m,
|
|
5858
|
+
function messageOf(m, byUrn2, mailbox2) {
|
|
5579
5859
|
const sender = m["*sender"] ?? m["*actor"];
|
|
5580
5860
|
const fromMe = isMe(sender, mailbox2);
|
|
5581
|
-
const who = fromMe ? void 0 : participantOf(
|
|
5861
|
+
const who = fromMe ? void 0 : participantOf(byUrn2.get(sender));
|
|
5582
5862
|
const render2 = Array.isArray(m.renderContent) ? m.renderContent : [];
|
|
5583
|
-
return
|
|
5863
|
+
return defined6({
|
|
5584
5864
|
from: fromMe ? "you" : who?.name ?? "unknown",
|
|
5585
5865
|
fromMe,
|
|
5586
5866
|
at: iso(m.deliveredAt),
|
|
@@ -5589,7 +5869,7 @@ function messageOf(m, byUrn, mailbox2) {
|
|
|
5589
5869
|
sponsored: render2.some((r) => r.conversationAdsMessageContent) ? true : void 0
|
|
5590
5870
|
});
|
|
5591
5871
|
}
|
|
5592
|
-
var
|
|
5872
|
+
var drift6 = (message) => ({
|
|
5593
5873
|
ok: false,
|
|
5594
5874
|
code: "SCHEMA_DRIFT",
|
|
5595
5875
|
message,
|
|
@@ -5609,26 +5889,26 @@ function refsOf(top) {
|
|
|
5609
5889
|
function parseConversations(json, mailbox2) {
|
|
5610
5890
|
const top = collectionOf(json);
|
|
5611
5891
|
const refs = refsOf(top);
|
|
5612
|
-
if (refs === void 0) return
|
|
5892
|
+
if (refs === void 0) return drift6("the conversation list was missing");
|
|
5613
5893
|
const included = json.included ?? [];
|
|
5614
|
-
const
|
|
5894
|
+
const byUrn2 = new Map(included.map((n) => [n.entityUrn, n]));
|
|
5615
5895
|
const conversations = [];
|
|
5616
5896
|
for (const ref of refs) {
|
|
5617
|
-
const c =
|
|
5897
|
+
const c = byUrn2.get(ref);
|
|
5618
5898
|
if (c === void 0) continue;
|
|
5619
|
-
const parts = (c["*conversationParticipants"] ?? []).filter((u) => !isMe(u, mailbox2)).map((u) => participantOf(
|
|
5899
|
+
const parts = (c["*conversationParticipants"] ?? []).filter((u) => !isMe(u, mailbox2)).map((u) => participantOf(byUrn2.get(u))).filter((p) => p !== void 0);
|
|
5620
5900
|
const lastRef = c.messages?.["*elements"]?.[0];
|
|
5621
|
-
const last = lastRef === void 0 ? void 0 :
|
|
5901
|
+
const last = lastRef === void 0 ? void 0 : byUrn2.get(lastRef);
|
|
5622
5902
|
const categories = Array.isArray(c.categories) ? c.categories : [];
|
|
5623
5903
|
conversations.push(
|
|
5624
|
-
|
|
5904
|
+
defined6({
|
|
5625
5905
|
id: String(c.entityUrn),
|
|
5626
5906
|
url: typeof c.conversationUrl === "string" ? c.conversationUrl : void 0,
|
|
5627
5907
|
with: parts,
|
|
5628
5908
|
title: c.groupChat === true ? txt2(c.title) : void 0,
|
|
5629
5909
|
unread: typeof c.unreadCount === "number" ? c.unreadCount : 0,
|
|
5630
5910
|
lastActivity: iso(c.lastActivityAt),
|
|
5631
|
-
last: last === void 0 ? void 0 : messageOf(last,
|
|
5911
|
+
last: last === void 0 ? void 0 : messageOf(last, byUrn2, mailbox2),
|
|
5632
5912
|
// PRIMARY_INBOX sits inside INBOX; report the folder a person would name.
|
|
5633
5913
|
folders: categories.map((k) => FOLDER_OF[k]).filter(
|
|
5634
5914
|
(f) => f !== void 0 && !(f === "primary" && categories.includes("INBOX"))
|
|
@@ -5638,7 +5918,7 @@ function parseConversations(json, mailbox2) {
|
|
|
5638
5918
|
);
|
|
5639
5919
|
}
|
|
5640
5920
|
if (refs.length > 0 && conversations.length === 0)
|
|
5641
|
-
return
|
|
5921
|
+
return drift6(`${refs.length} conversations were listed but none were sent`);
|
|
5642
5922
|
const cursor = top?.metadata?.nextCursor;
|
|
5643
5923
|
return {
|
|
5644
5924
|
ok: true,
|
|
@@ -5649,17 +5929,17 @@ function parseConversations(json, mailbox2) {
|
|
|
5649
5929
|
function parseMessages(json, mailbox2) {
|
|
5650
5930
|
const top = collectionOf(json);
|
|
5651
5931
|
const refs = refsOf(top);
|
|
5652
|
-
if (refs === void 0) return
|
|
5932
|
+
if (refs === void 0) return drift6("the message list was missing");
|
|
5653
5933
|
const included = json.included ?? [];
|
|
5654
|
-
const
|
|
5934
|
+
const byUrn2 = new Map(included.map((n) => [n.entityUrn, n]));
|
|
5655
5935
|
const messages = [];
|
|
5656
5936
|
for (const ref of refs) {
|
|
5657
|
-
const m =
|
|
5937
|
+
const m = byUrn2.get(ref);
|
|
5658
5938
|
if (m === void 0 || typeof m.deliveredAt !== "number") continue;
|
|
5659
|
-
messages.push({ id: String(m.entityUrn), ...messageOf(m,
|
|
5939
|
+
messages.push({ id: String(m.entityUrn), ...messageOf(m, byUrn2, mailbox2) });
|
|
5660
5940
|
}
|
|
5661
5941
|
if (refs.length > 0 && messages.length === 0)
|
|
5662
|
-
return
|
|
5942
|
+
return drift6(`${refs.length} messages were listed but none were sent`);
|
|
5663
5943
|
messages.sort((a, b) => a.at.localeCompare(b.at));
|
|
5664
5944
|
return { ok: true, messages };
|
|
5665
5945
|
}
|
|
@@ -5814,8 +6094,8 @@ function loadDrafts() {
|
|
|
5814
6094
|
};
|
|
5815
6095
|
return Array.isArray(loaded.value) ? loaded.value : [];
|
|
5816
6096
|
}
|
|
5817
|
-
async function runDraft(conversation,
|
|
5818
|
-
const body =
|
|
6097
|
+
async function runDraft(conversation, text7, fetch2, opts = {}) {
|
|
6098
|
+
const body = text7?.trim() ?? "";
|
|
5819
6099
|
if (body === "")
|
|
5820
6100
|
return err(
|
|
5821
6101
|
"draft",
|
|
@@ -5858,8 +6138,8 @@ async function runDraft(conversation, text6, fetch2, opts = {}) {
|
|
|
5858
6138
|
notice: "Saved on this machine only. Nothing was sent: open the link, review, and send it yourself."
|
|
5859
6139
|
});
|
|
5860
6140
|
}
|
|
5861
|
-
function draftText(
|
|
5862
|
-
return file !== void 0 ? readFileSync2(file, "utf-8") :
|
|
6141
|
+
function draftText(text7, file) {
|
|
6142
|
+
return file !== void 0 ? readFileSync2(file, "utf-8") : text7;
|
|
5863
6143
|
}
|
|
5864
6144
|
function runDrafts(opts = {}) {
|
|
5865
6145
|
const drafts = loadDrafts();
|
|
@@ -5918,14 +6198,14 @@ function itemsUrl(list2, q2) {
|
|
|
5918
6198
|
});
|
|
5919
6199
|
return `${c.path}?variables=${variables}&queryId=${c.queryId}`;
|
|
5920
6200
|
}
|
|
5921
|
-
var
|
|
6201
|
+
var text5 = (v) => {
|
|
5922
6202
|
const t = v?.text;
|
|
5923
6203
|
return typeof t === "string" && t.trim() !== "" ? t.trim().replace(/\s+/g, " ") : void 0;
|
|
5924
6204
|
};
|
|
5925
6205
|
var inner = (urn) => String(urn ?? "").match(/\((urn:li:[A-Za-z_]+:[^,)]+)/)?.[1];
|
|
5926
6206
|
var clean = (url) => typeof url === "string" && url.startsWith("https://") ? url.split("?")[0] : void 0;
|
|
5927
|
-
var insight = (row) => (Array.isArray(row.insightsResolutionResults) ? row.insightsResolutionResults : []).map((i) =>
|
|
5928
|
-
function
|
|
6207
|
+
var insight = (row) => (Array.isArray(row.insightsResolutionResults) ? row.insightsResolutionResults : []).map((i) => text5(i.simpleInsight?.title)).find((t) => t !== void 0);
|
|
6208
|
+
function defined7(obj) {
|
|
5929
6209
|
for (const k of Object.keys(obj)) if (obj[k] === void 0) delete obj[k];
|
|
5930
6210
|
return obj;
|
|
5931
6211
|
}
|
|
@@ -5937,40 +6217,40 @@ var WORKPLACE = {
|
|
|
5937
6217
|
function postRow(row) {
|
|
5938
6218
|
const id = inner(row.entityUrn);
|
|
5939
6219
|
if (id === void 0 || !/^urn:li:(activity|ugcPost|share):/.test(id)) return void 0;
|
|
5940
|
-
const posted =
|
|
5941
|
-
return
|
|
6220
|
+
const posted = text5(row.secondarySubtitle)?.replace(/\s*•\s*$/, "");
|
|
6221
|
+
return defined7({
|
|
5942
6222
|
id,
|
|
5943
6223
|
url: `https://www.linkedin.com/feed/update/${id}/`,
|
|
5944
|
-
author:
|
|
5945
|
-
authorHeadline:
|
|
6224
|
+
author: text5(row.title),
|
|
6225
|
+
authorHeadline: text5(row.primarySubtitle),
|
|
5946
6226
|
posted,
|
|
5947
|
-
text:
|
|
6227
|
+
text: text5(row.summary)
|
|
5948
6228
|
});
|
|
5949
6229
|
}
|
|
5950
6230
|
function courseRow(row) {
|
|
5951
6231
|
const id = inner(row.entityUrn)?.split(":").pop();
|
|
5952
|
-
const name =
|
|
6232
|
+
const name = text5(row.title);
|
|
5953
6233
|
if (id === void 0 || name === void 0) return void 0;
|
|
5954
|
-
return
|
|
6234
|
+
return defined7({
|
|
5955
6235
|
id,
|
|
5956
6236
|
name,
|
|
5957
|
-
length:
|
|
5958
|
-
detail:
|
|
5959
|
-
progress:
|
|
6237
|
+
length: text5(row.primarySubtitle),
|
|
6238
|
+
detail: text5(row.secondarySubtitle),
|
|
6239
|
+
progress: text5(row.summary),
|
|
5960
6240
|
url: clean(row.navigationUrl)
|
|
5961
6241
|
});
|
|
5962
6242
|
}
|
|
5963
6243
|
function jobRow(row, stage) {
|
|
5964
6244
|
const id = inner(row.entityUrn)?.split(":").pop();
|
|
5965
|
-
const title =
|
|
6245
|
+
const title = text5(row.title);
|
|
5966
6246
|
if (id === void 0 || title === void 0) return void 0;
|
|
5967
|
-
const place =
|
|
6247
|
+
const place = text5(row.secondarySubtitle);
|
|
5968
6248
|
const m = place?.match(/^(.*?)\s*\(([^()]+)\)$/);
|
|
5969
6249
|
const workplace = m?.[2] === void 0 ? void 0 : WORKPLACE[m[2].toLowerCase()];
|
|
5970
|
-
return
|
|
6250
|
+
return defined7({
|
|
5971
6251
|
id,
|
|
5972
6252
|
title,
|
|
5973
|
-
company:
|
|
6253
|
+
company: text5(row.primarySubtitle),
|
|
5974
6254
|
location: workplace !== void 0 ? m?.[1] : place,
|
|
5975
6255
|
workplace,
|
|
5976
6256
|
stage,
|
|
@@ -6130,7 +6410,7 @@ function searchUrl(q2) {
|
|
|
6130
6410
|
kind: SEARCH_KINDS[q2.kind]
|
|
6131
6411
|
});
|
|
6132
6412
|
}
|
|
6133
|
-
var
|
|
6413
|
+
var text6 = (v) => {
|
|
6134
6414
|
const t = v?.text;
|
|
6135
6415
|
return typeof t === "string" && t.trim() !== "" ? t.trim().replace(/\s+/g, " ") : void 0;
|
|
6136
6416
|
};
|
|
@@ -6144,13 +6424,13 @@ function cleanUrl2(nav) {
|
|
|
6144
6424
|
}
|
|
6145
6425
|
function rowToFound(row) {
|
|
6146
6426
|
const id = idOf2(row.entityUrn);
|
|
6147
|
-
const name =
|
|
6427
|
+
const name = text6(row.title);
|
|
6148
6428
|
if (id === void 0 || name === void 0) return void 0;
|
|
6149
6429
|
const found = { id, name };
|
|
6150
6430
|
const fields = [
|
|
6151
|
-
["subtitle",
|
|
6152
|
-
["detail",
|
|
6153
|
-
["summary",
|
|
6431
|
+
["subtitle", text6(row.primarySubtitle)],
|
|
6432
|
+
["detail", text6(row.secondarySubtitle)],
|
|
6433
|
+
["summary", text6(row.summary)],
|
|
6154
6434
|
["url", cleanUrl2(row.navigationUrl)]
|
|
6155
6435
|
];
|
|
6156
6436
|
for (const [k, v] of fields)
|
|
@@ -6158,7 +6438,7 @@ function rowToFound(row) {
|
|
|
6158
6438
|
if (JSON.stringify(row.badgeIcon ?? null).includes("VERIFIED")) found.verified = true;
|
|
6159
6439
|
return found;
|
|
6160
6440
|
}
|
|
6161
|
-
var
|
|
6441
|
+
var drift7 = (message) => ({
|
|
6162
6442
|
ok: false,
|
|
6163
6443
|
code: "SCHEMA_DRIFT",
|
|
6164
6444
|
message,
|
|
@@ -6167,7 +6447,7 @@ var drift6 = (message) => ({
|
|
|
6167
6447
|
function parseResults(json) {
|
|
6168
6448
|
const c = clustersOf(json);
|
|
6169
6449
|
if (c === void 0 || !Array.isArray(c.elements))
|
|
6170
|
-
return
|
|
6450
|
+
return drift7("the search returned no result list");
|
|
6171
6451
|
const included = json.included ?? [];
|
|
6172
6452
|
const { people: items, unknownTypes, excluded, unresolved } = readItems(c, included, rowToFound);
|
|
6173
6453
|
const total = typeof c.paging?.total === "number" ? c.paging.total : void 0;
|
|
@@ -6175,7 +6455,7 @@ function parseResults(json) {
|
|
|
6175
6455
|
const claimedRaw = c.metadata?.totalResultCount;
|
|
6176
6456
|
const claimed = typeof claimedRaw === "number" ? claimedRaw : total;
|
|
6177
6457
|
if (unresolved > 0 && items.length === 0)
|
|
6178
|
-
return
|
|
6458
|
+
return drift7(`${unresolved} results were listed but none could be read`);
|
|
6179
6459
|
if (items.length === 0 && total !== void 0 && total > start) {
|
|
6180
6460
|
return {
|
|
6181
6461
|
ok: false,
|
|
@@ -6246,15 +6526,15 @@ function parseSentInvitations(json) {
|
|
|
6246
6526
|
if (!Array.isArray(refs))
|
|
6247
6527
|
return { ok: false, code: "SCHEMA_DRIFT", message: "the sent invitations list was missing" };
|
|
6248
6528
|
const included = json.included ?? [];
|
|
6249
|
-
const
|
|
6529
|
+
const byUrn2 = new Map(included.map((n) => [n.entityUrn, n]));
|
|
6250
6530
|
const invitations2 = [];
|
|
6251
6531
|
for (const ref of refs) {
|
|
6252
|
-
const view =
|
|
6253
|
-
const inv =
|
|
6532
|
+
const view = byUrn2.get(ref);
|
|
6533
|
+
const inv = byUrn2.get(view?.["*invitation"]) ?? included.find(
|
|
6254
6534
|
(n) => String(n.$type).endsWith(".Invitation") && typeof ref === "string" && ref.endsWith(String(n.entityUrn))
|
|
6255
6535
|
);
|
|
6256
6536
|
if (inv === void 0) continue;
|
|
6257
|
-
const who =
|
|
6537
|
+
const who = byUrn2.get(inv["*toMember"]);
|
|
6258
6538
|
const name = [who?.firstName, who?.lastName].filter((x) => typeof x === "string" && x !== "").join(" ");
|
|
6259
6539
|
const id = String(inv["*toMember"] ?? "").split(":").pop();
|
|
6260
6540
|
const note = typeof inv.message === "string" ? inv.message : inv.message?.text;
|
|
@@ -6389,6 +6669,106 @@ async function runNetwork(list2, req, opts = {}, fetch2) {
|
|
|
6389
6669
|
});
|
|
6390
6670
|
}
|
|
6391
6671
|
|
|
6672
|
+
// src/engine/notifications.ts
|
|
6673
|
+
function notificationsUrl(count3, start) {
|
|
6674
|
+
const c = CONTRACTS.notifications;
|
|
6675
|
+
if (c?.decorationId === void 0) throw new Error("the 'notifications' contract is missing");
|
|
6676
|
+
return `${c.path}?decorationId=${c.decorationId}&q=filterVanityName&count=${count3}&start=${start}`;
|
|
6677
|
+
}
|
|
6678
|
+
var drift8 = (message) => ({ ok: false, code: "SCHEMA_DRIFT", message });
|
|
6679
|
+
var textOf = (v) => {
|
|
6680
|
+
const t = v?.text;
|
|
6681
|
+
return typeof t === "string" && t.trim() !== "" ? t.trim() : void 0;
|
|
6682
|
+
};
|
|
6683
|
+
var absolute = (v) => typeof v === "string" && v !== "" ? v.startsWith("/") ? `https://www.linkedin.com${v}` : v : void 0;
|
|
6684
|
+
function card(n) {
|
|
6685
|
+
const text7 = textOf(n.headline);
|
|
6686
|
+
if (text7 === void 0) return void 0;
|
|
6687
|
+
const kind = String(n.entityUrn ?? "").match(/fsd_notificationCard:\(([^,]+),/)?.[1] ?? "UNKNOWN";
|
|
6688
|
+
const detail = [n.subHeadline, n.contentPrimaryText, n.contentSecondaryText, n.kickerText].map(textOf).filter((t) => t !== void 0).join(" \xB7 ");
|
|
6689
|
+
const at = typeof n.publishedAt === "number" ? new Date(n.publishedAt).toISOString() : void 0;
|
|
6690
|
+
const url = absolute(n.cardAction?.actionTarget);
|
|
6691
|
+
const from = absolute(n.headerImage?.actionTarget);
|
|
6692
|
+
return {
|
|
6693
|
+
kind,
|
|
6694
|
+
text: text7,
|
|
6695
|
+
...detail !== "" ? { detail } : {},
|
|
6696
|
+
...at !== void 0 ? { at } : {},
|
|
6697
|
+
read: n.read === true,
|
|
6698
|
+
...url !== void 0 ? { url } : {},
|
|
6699
|
+
...from !== void 0 ? { from } : {}
|
|
6700
|
+
};
|
|
6701
|
+
}
|
|
6702
|
+
function parseNotifications(json) {
|
|
6703
|
+
const root = json;
|
|
6704
|
+
const data = root?.data;
|
|
6705
|
+
const listed2 = data?.["*elements"] ?? data?.elements;
|
|
6706
|
+
if (!Array.isArray(listed2)) return drift8("the notifications answer carried no card list");
|
|
6707
|
+
const byUrn2 = new Map((root?.included ?? []).map((n) => [n.entityUrn, n]));
|
|
6708
|
+
const items = listed2.flatMap((u) => {
|
|
6709
|
+
const n = byUrn2.get(u);
|
|
6710
|
+
const c = n === void 0 ? void 0 : card(n);
|
|
6711
|
+
return c === void 0 ? [] : [c];
|
|
6712
|
+
});
|
|
6713
|
+
if (listed2.length > 0 && items.length === 0)
|
|
6714
|
+
return drift8(`${listed2.length} notifications were listed but none could be read`);
|
|
6715
|
+
const meta = data?.metadata ?? {};
|
|
6716
|
+
return {
|
|
6717
|
+
ok: true,
|
|
6718
|
+
items,
|
|
6719
|
+
...typeof meta.numUnseen === "number" ? { unseen: meta.numUnseen } : {},
|
|
6720
|
+
...typeof meta.nextStart === "number" ? { next: meta.nextStart } : {}
|
|
6721
|
+
};
|
|
6722
|
+
}
|
|
6723
|
+
|
|
6724
|
+
// src/commands/notifications.ts
|
|
6725
|
+
function liveFetch8(quiet) {
|
|
6726
|
+
const session = loadSession();
|
|
6727
|
+
if (session.state !== "ok")
|
|
6728
|
+
return err("notifications", "AUTH_FAILED", "no LinkedIn session \u2014 run `lnrelay login`");
|
|
6729
|
+
const client = createLiveClient(session.session, void 0, quiet);
|
|
6730
|
+
return async (url, spendClass) => {
|
|
6731
|
+
const r = await client.request({ url, spendClass, operation: "notifications" });
|
|
6732
|
+
return r.ok ? { ok: true, json: r.json } : r;
|
|
6733
|
+
};
|
|
6734
|
+
}
|
|
6735
|
+
var PAGE = 25;
|
|
6736
|
+
var compactNotification = (n) => line([n.read ? void 0 : "unread", n.at, n.kind, n.text, n.detail, n.url]);
|
|
6737
|
+
async function runNotifications(req, opts = {}, fetch2) {
|
|
6738
|
+
const get = fetch2 ?? liveFetch8(opts.quiet === true);
|
|
6739
|
+
if (typeof get !== "function") return get;
|
|
6740
|
+
const limit = Math.max(1, req.limit);
|
|
6741
|
+
const items = [];
|
|
6742
|
+
let unseen;
|
|
6743
|
+
let start = 0;
|
|
6744
|
+
let stoppedBy;
|
|
6745
|
+
while (start !== void 0 && items.length < limit) {
|
|
6746
|
+
const res = await get(notificationsUrl(PAGE, start), "page");
|
|
6747
|
+
const page = res.ok ? parseNotifications(res.json) : res;
|
|
6748
|
+
if (!page.ok) {
|
|
6749
|
+
if (items.length === 0 && start === 0)
|
|
6750
|
+
return err("notifications", page.code, page.message, page.hint);
|
|
6751
|
+
stoppedBy = page.code;
|
|
6752
|
+
break;
|
|
6753
|
+
}
|
|
6754
|
+
unseen ??= page.unseen;
|
|
6755
|
+
items.push(...page.items.filter((n) => req.unread !== true || !n.read));
|
|
6756
|
+
start = page.next !== void 0 && page.next > start ? page.next : void 0;
|
|
6757
|
+
}
|
|
6758
|
+
const kept = items.slice(0, limit);
|
|
6759
|
+
const state2 = stoppedBy !== void 0 || start !== void 0 && kept.length === limit ? "partial" : "complete";
|
|
6760
|
+
return ok("notifications", {
|
|
6761
|
+
...unseen !== void 0 ? { unseen } : {},
|
|
6762
|
+
items: shape(kept, opts, compactNotification),
|
|
6763
|
+
meta: {
|
|
6764
|
+
state: state2,
|
|
6765
|
+
operation: "notifications",
|
|
6766
|
+
returnedCount: kept.length,
|
|
6767
|
+
...stoppedBy !== void 0 ? { stoppedBy } : {}
|
|
6768
|
+
}
|
|
6769
|
+
});
|
|
6770
|
+
}
|
|
6771
|
+
|
|
6392
6772
|
// src/commands/oauth.ts
|
|
6393
6773
|
import { spawn } from "child_process";
|
|
6394
6774
|
import { createServer } from "http";
|
|
@@ -6429,18 +6809,18 @@ async function exchange(code, config, deps) {
|
|
|
6429
6809
|
} catch (e) {
|
|
6430
6810
|
return { ok: false, message: `could not reach LinkedIn: ${e.message}` };
|
|
6431
6811
|
}
|
|
6432
|
-
const
|
|
6812
|
+
const text7 = await res.text();
|
|
6433
6813
|
if (res.status !== 200) {
|
|
6434
6814
|
return {
|
|
6435
6815
|
ok: false,
|
|
6436
6816
|
message: `LinkedIn rejected the code exchange (${res.status})`,
|
|
6437
6817
|
// The most common causes, in the order they actually happen.
|
|
6438
|
-
hint: `Check that the app has BOTH products added, and that its Auth tab lists exactly ${REDIRECT_URI} as an authorized redirect URL. Response: ${
|
|
6818
|
+
hint: `Check that the app has BOTH products added, and that its Auth tab lists exactly ${REDIRECT_URI} as an authorized redirect URL. Response: ${text7.slice(0, 200)}`
|
|
6439
6819
|
};
|
|
6440
6820
|
}
|
|
6441
6821
|
let parsed;
|
|
6442
6822
|
try {
|
|
6443
|
-
parsed = JSON.parse(
|
|
6823
|
+
parsed = JSON.parse(text7);
|
|
6444
6824
|
} catch {
|
|
6445
6825
|
return { ok: false, message: "token response was not JSON" };
|
|
6446
6826
|
}
|
|
@@ -6695,7 +7075,7 @@ function contactInfoBody(publicId, firstName, lastName) {
|
|
|
6695
7075
|
isModal: true
|
|
6696
7076
|
};
|
|
6697
7077
|
}
|
|
6698
|
-
var
|
|
7078
|
+
var drift9 = (message) => ({ ok: false, code: "SCHEMA_DRIFT", message });
|
|
6699
7079
|
var unquote2 = (s) => JSON.parse(`"${s}"`);
|
|
6700
7080
|
var LABEL = /\["\$","p",null,\{"className":"[^"]*","children":\["((?:[^"\\]|\\.)+)"\]\}\]/g;
|
|
6701
7081
|
var VIEW = /"viewName":"contact-([a-z-]+)"/g;
|
|
@@ -6733,13 +7113,13 @@ function fieldsOf(stream) {
|
|
|
6733
7113
|
}
|
|
6734
7114
|
var camel = (s) => s.replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
6735
7115
|
function put(contact, f) {
|
|
6736
|
-
const
|
|
7116
|
+
const text7 = f.texts.join(", ");
|
|
6737
7117
|
switch (f.view) {
|
|
6738
7118
|
case "your-profile":
|
|
6739
7119
|
return;
|
|
6740
7120
|
// `profile` already has the profile URL.
|
|
6741
7121
|
case "email":
|
|
6742
|
-
contact.email = f.links[0] ??
|
|
7122
|
+
contact.email = f.links[0] ?? text7;
|
|
6743
7123
|
return;
|
|
6744
7124
|
case "website":
|
|
6745
7125
|
contact.websites = [
|
|
@@ -6757,18 +7137,18 @@ function put(contact, f) {
|
|
|
6757
7137
|
contact.twitter = [...contact.twitter ?? [], ...f.texts];
|
|
6758
7138
|
return;
|
|
6759
7139
|
case void 0:
|
|
6760
|
-
if (/^connected since$/i.test(f.label)) contact.connectedSince =
|
|
6761
|
-
else contact.other = { ...contact.other, [f.label]:
|
|
7140
|
+
if (/^connected since$/i.test(f.label)) contact.connectedSince = text7;
|
|
7141
|
+
else contact.other = { ...contact.other, [f.label]: text7 };
|
|
6762
7142
|
return;
|
|
6763
7143
|
default:
|
|
6764
|
-
contact[camel(f.view)] =
|
|
7144
|
+
contact[camel(f.view)] = text7;
|
|
6765
7145
|
}
|
|
6766
7146
|
}
|
|
6767
7147
|
function parseContactInfo(stream) {
|
|
6768
7148
|
if (!stream.includes("profile-contact-info-details-view"))
|
|
6769
|
-
return
|
|
7149
|
+
return drift9("the contact info answer was not the contact info overlay");
|
|
6770
7150
|
const fields = fieldsOf(stream);
|
|
6771
|
-
if (fields.length === 0) return
|
|
7151
|
+
if (fields.length === 0) return drift9("the contact info overlay had no fields");
|
|
6772
7152
|
const contact = {};
|
|
6773
7153
|
for (const f of fields) put(contact, f);
|
|
6774
7154
|
return { ok: true, contact };
|
|
@@ -6789,10 +7169,10 @@ function positionsPageUrl(profileUrn, start) {
|
|
|
6789
7169
|
const c = contract3("profilePositions");
|
|
6790
7170
|
return `${c.path}?q=viewee&profileUrn=${encodeURIComponent(profileUrn)}&decorationId=${c.decorationId}&start=${start}&count=${POSITIONS_PAGE}`;
|
|
6791
7171
|
}
|
|
6792
|
-
var
|
|
6793
|
-
var
|
|
7172
|
+
var drift10 = (message) => ({ ok: false, code: "SCHEMA_DRIFT", message });
|
|
7173
|
+
var str5 = (v) => typeof v === "string" && v.trim() !== "" && v.trim() !== "-" ? v.trim() : void 0;
|
|
6794
7174
|
var idOf3 = (urn) => String(urn ?? "").match(/:(\d+)$/)?.[1];
|
|
6795
|
-
function
|
|
7175
|
+
function defined8(obj) {
|
|
6796
7176
|
for (const k of Object.keys(obj)) if (obj[k] === void 0) delete obj[k];
|
|
6797
7177
|
return obj;
|
|
6798
7178
|
}
|
|
@@ -6807,7 +7187,7 @@ function range(v) {
|
|
|
6807
7187
|
const r = v;
|
|
6808
7188
|
const start = date(r?.start);
|
|
6809
7189
|
const end = date(r?.end);
|
|
6810
|
-
return
|
|
7190
|
+
return defined8({
|
|
6811
7191
|
start,
|
|
6812
7192
|
end,
|
|
6813
7193
|
current: start !== void 0 && end === void 0 ? true : void 0
|
|
@@ -6830,21 +7210,21 @@ var Index = class {
|
|
|
6830
7210
|
collection(urn) {
|
|
6831
7211
|
const c = this.get(urn);
|
|
6832
7212
|
const refs = Array.isArray(c?.["*elements"]) ? c?.["*elements"] : [];
|
|
6833
|
-
const
|
|
7213
|
+
const nodes2 = refs.flatMap((r) => this.list(r));
|
|
6834
7214
|
const total = c?.paging?.total;
|
|
6835
|
-
return typeof total === "number" ? { nodes, total } : { nodes };
|
|
7215
|
+
return typeof total === "number" ? { nodes: nodes2, total } : { nodes: nodes2 };
|
|
6836
7216
|
}
|
|
6837
7217
|
};
|
|
6838
7218
|
function role(p, group, ix) {
|
|
6839
7219
|
const companyUrn = p.companyUrn ?? group?.companyUrn;
|
|
6840
|
-
return
|
|
6841
|
-
title:
|
|
6842
|
-
company:
|
|
7220
|
+
return defined8({
|
|
7221
|
+
title: str5(p.title),
|
|
7222
|
+
company: str5(p.companyName) ?? str5(group?.companyName),
|
|
6843
7223
|
companyId: idOf3(companyUrn),
|
|
6844
|
-
employmentType:
|
|
6845
|
-
location:
|
|
7224
|
+
employmentType: str5(ix.get(p["*employmentType"])?.name),
|
|
7225
|
+
location: str5(p.locationName) ?? str5(p.geoLocationName),
|
|
6846
7226
|
...range(p.dateRange),
|
|
6847
|
-
description:
|
|
7227
|
+
description: str5(p.description)
|
|
6848
7228
|
});
|
|
6849
7229
|
}
|
|
6850
7230
|
function rolesOf(groups, ix) {
|
|
@@ -6854,39 +7234,39 @@ function rolesOf(groups, ix) {
|
|
|
6854
7234
|
});
|
|
6855
7235
|
}
|
|
6856
7236
|
function school(e) {
|
|
6857
|
-
return
|
|
6858
|
-
school:
|
|
7237
|
+
return defined8({
|
|
7238
|
+
school: str5(e.schoolName),
|
|
6859
7239
|
schoolId: idOf3(e.schoolUrn),
|
|
6860
|
-
degree:
|
|
6861
|
-
field:
|
|
7240
|
+
degree: str5(e.degreeName),
|
|
7241
|
+
field: str5(e.fieldOfStudy),
|
|
6862
7242
|
...range(e.dateRange),
|
|
6863
|
-
grade:
|
|
6864
|
-
activities:
|
|
6865
|
-
description:
|
|
7243
|
+
grade: str5(e.grade),
|
|
7244
|
+
activities: str5(e.activities),
|
|
7245
|
+
description: str5(e.description)
|
|
6866
7246
|
});
|
|
6867
7247
|
}
|
|
6868
7248
|
function entry(n) {
|
|
6869
|
-
const proficiency =
|
|
6870
|
-
return
|
|
6871
|
-
name:
|
|
6872
|
-
title:
|
|
6873
|
-
role:
|
|
6874
|
-
organization:
|
|
6875
|
-
authority:
|
|
6876
|
-
issuer:
|
|
6877
|
-
publisher:
|
|
7249
|
+
const proficiency = str5(n.proficiency);
|
|
7250
|
+
return defined8({
|
|
7251
|
+
name: str5(n.name),
|
|
7252
|
+
title: str5(n.title),
|
|
7253
|
+
role: str5(n.role),
|
|
7254
|
+
organization: str5(n.companyName),
|
|
7255
|
+
authority: str5(n.authority),
|
|
7256
|
+
issuer: str5(n.issuer),
|
|
7257
|
+
publisher: str5(n.publisher),
|
|
6878
7258
|
proficiency: proficiency?.toLowerCase().replace(/_/g, " "),
|
|
6879
|
-
number:
|
|
6880
|
-
score:
|
|
6881
|
-
cause:
|
|
7259
|
+
number: str5(n.number) ?? str5(n.licenseNumber) ?? str5(n.patentNumber),
|
|
7260
|
+
score: str5(n.score),
|
|
7261
|
+
cause: str5(n.cause)?.toLowerCase().replace(/_/g, " "),
|
|
6882
7262
|
...range(n.dateRange),
|
|
6883
7263
|
issued: date(n.issuedOn),
|
|
6884
7264
|
published: date(n.publishedOn),
|
|
6885
|
-
url:
|
|
6886
|
-
description:
|
|
7265
|
+
url: str5(n.url),
|
|
7266
|
+
description: str5(n.description)
|
|
6887
7267
|
});
|
|
6888
7268
|
}
|
|
6889
|
-
var
|
|
7269
|
+
var SECTIONS2 = {
|
|
6890
7270
|
certifications: "*profileCertifications",
|
|
6891
7271
|
languages: "*profileLanguages",
|
|
6892
7272
|
honors: "*profileHonors",
|
|
@@ -6902,13 +7282,13 @@ var some = (xs) => xs.length > 0 ? xs : void 0;
|
|
|
6902
7282
|
function parseFullProfile(json) {
|
|
6903
7283
|
const root = json;
|
|
6904
7284
|
const listed2 = root?.data?.["*elements"];
|
|
6905
|
-
if (!Array.isArray(listed2)) return
|
|
7285
|
+
if (!Array.isArray(listed2)) return drift10("the profile answer carried no profile list");
|
|
6906
7286
|
if (listed2.length === 0)
|
|
6907
7287
|
return { ok: false, code: "NOT_FOUND", message: "no profile has that id on LinkedIn" };
|
|
6908
7288
|
const ix = new Index(root?.included ?? []);
|
|
6909
7289
|
const p = ix.get(listed2[0]);
|
|
6910
7290
|
const urn = typeof p?.entityUrn === "string" ? p.entityUrn : void 0;
|
|
6911
|
-
if (p === void 0 || urn === void 0) return
|
|
7291
|
+
if (p === void 0 || urn === void 0) return drift10("the profile was listed but not sent");
|
|
6912
7292
|
const counts2 = {};
|
|
6913
7293
|
const count3 = (key, shown, total) => {
|
|
6914
7294
|
if (total !== void 0 && total > shown) counts2[key] = { shown, total };
|
|
@@ -6920,32 +7300,32 @@ function parseFullProfile(json) {
|
|
|
6920
7300
|
const education = schools.nodes.map(school);
|
|
6921
7301
|
const skillNodes = ix.collection(p["*profileSkills"]);
|
|
6922
7302
|
count3("skills", skillNodes.nodes.length, skillNodes.total);
|
|
6923
|
-
const skills = skillNodes.nodes.flatMap((s) =>
|
|
7303
|
+
const skills = skillNodes.nodes.flatMap((s) => str5(s.name) ?? []);
|
|
6924
7304
|
const sections = {};
|
|
6925
|
-
for (const [key, field] of Object.entries(
|
|
7305
|
+
for (const [key, field] of Object.entries(SECTIONS2)) {
|
|
6926
7306
|
const c = ix.collection(p[field]);
|
|
6927
7307
|
count3(key, c.nodes.length, c.total);
|
|
6928
7308
|
const rows = c.nodes.map(entry);
|
|
6929
7309
|
if (rows.length > 0) sections[key] = rows;
|
|
6930
7310
|
}
|
|
6931
|
-
const publicId =
|
|
6932
|
-
const name = [
|
|
7311
|
+
const publicId = str5(p.publicIdentifier);
|
|
7312
|
+
const name = [str5(p.firstName), str5(p.lastName)].filter(Boolean).join(" ");
|
|
6933
7313
|
const geo = ix.get(p.geoLocation?.["*geo"]);
|
|
6934
7314
|
const bool3 = (v) => v === true ? true : void 0;
|
|
6935
7315
|
return {
|
|
6936
7316
|
ok: true,
|
|
6937
|
-
profile:
|
|
7317
|
+
profile: defined8({
|
|
6938
7318
|
id: urn.split(":").pop(),
|
|
6939
7319
|
urn,
|
|
6940
7320
|
publicId,
|
|
6941
7321
|
name: name === "" ? void 0 : name,
|
|
6942
|
-
firstName:
|
|
6943
|
-
lastName:
|
|
6944
|
-
headline:
|
|
7322
|
+
firstName: str5(p.firstName),
|
|
7323
|
+
lastName: str5(p.lastName),
|
|
7324
|
+
headline: str5(p.headline),
|
|
6945
7325
|
url: publicId === void 0 ? void 0 : `https://www.linkedin.com/in/${publicId}/`,
|
|
6946
|
-
location:
|
|
6947
|
-
industry:
|
|
6948
|
-
about:
|
|
7326
|
+
location: str5(geo?.defaultLocalizedName),
|
|
7327
|
+
industry: str5(ix.get(p["*industry"])?.name),
|
|
7328
|
+
about: str5(p.summary),
|
|
6949
7329
|
title: experience[0]?.title,
|
|
6950
7330
|
company: experience[0]?.company,
|
|
6951
7331
|
school: education[0]?.school,
|
|
@@ -6963,11 +7343,11 @@ function parseFullProfile(json) {
|
|
|
6963
7343
|
function parsePositionsPage(json) {
|
|
6964
7344
|
const root = json;
|
|
6965
7345
|
const refs = root?.data?.["*elements"];
|
|
6966
|
-
if (!Array.isArray(refs)) return
|
|
7346
|
+
if (!Array.isArray(refs)) return drift10("the experience page carried no position groups");
|
|
6967
7347
|
const ix = new Index(root?.included ?? []);
|
|
6968
7348
|
const groups = refs.flatMap((r) => ix.list(r));
|
|
6969
7349
|
if (refs.length > 0 && groups.length === 0)
|
|
6970
|
-
return
|
|
7350
|
+
return drift10(`${refs.length} position groups were listed but none sent`);
|
|
6971
7351
|
const total = root?.data?.paging?.total;
|
|
6972
7352
|
return {
|
|
6973
7353
|
ok: true,
|
|
@@ -6977,66 +7357,534 @@ function parsePositionsPage(json) {
|
|
|
6977
7357
|
};
|
|
6978
7358
|
}
|
|
6979
7359
|
|
|
6980
|
-
// src/
|
|
6981
|
-
|
|
6982
|
-
|
|
6983
|
-
|
|
6984
|
-
|
|
6985
|
-
|
|
6986
|
-
|
|
6987
|
-
|
|
6988
|
-
|
|
6989
|
-
|
|
6990
|
-
|
|
6991
|
-
|
|
6992
|
-
|
|
6993
|
-
|
|
6994
|
-
|
|
7360
|
+
// src/engine/recommendations.ts
|
|
7361
|
+
var PAGER = "com.linkedin.sdui.pagers.profile.details.recommendations";
|
|
7362
|
+
var SCREEN3 = "com.linkedin.sdui.flagshipnav.profile.ProfileRecommendationDetails";
|
|
7363
|
+
var RECOMMENDATIONS_URL = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${PAGER}`;
|
|
7364
|
+
var RECOMMENDATIONS_PAGE = 15;
|
|
7365
|
+
function recommendationsBody(kind, vanityName, profileId2, start) {
|
|
7366
|
+
const args = {
|
|
7367
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
7368
|
+
requestedStateKeys: [],
|
|
7369
|
+
payload: {
|
|
7370
|
+
type: kind === "received" ? "Received" : "Given",
|
|
7371
|
+
vanityName,
|
|
7372
|
+
profileId: profileId2,
|
|
7373
|
+
start,
|
|
7374
|
+
detailScreenTabIndex: kind === "received" ? "0" : "1",
|
|
7375
|
+
count: RECOMMENDATIONS_PAGE
|
|
7376
|
+
},
|
|
7377
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
6995
7378
|
};
|
|
6996
|
-
|
|
6997
|
-
|
|
6998
|
-
|
|
6999
|
-
|
|
7000
|
-
|
|
7001
|
-
|
|
7002
|
-
|
|
7003
|
-
|
|
7004
|
-
return slug;
|
|
7379
|
+
return {
|
|
7380
|
+
pagerId: PAGER,
|
|
7381
|
+
clientArguments: { ...args, states: [], screenId: SCREEN3, knownTemplateIds: [] },
|
|
7382
|
+
paginationRequest: {
|
|
7383
|
+
$type: "proto.sdui.actions.requests.PaginationRequest",
|
|
7384
|
+
pagerId: PAGER,
|
|
7385
|
+
retryCount: 2,
|
|
7386
|
+
requestedArguments: args
|
|
7005
7387
|
}
|
|
7006
|
-
}
|
|
7007
|
-
return s.match(/urn:li:fsd?_(?:mini)?[Pp]rofile:([^,)]+)/)?.[1] ?? s;
|
|
7388
|
+
};
|
|
7008
7389
|
}
|
|
7009
|
-
|
|
7010
|
-
|
|
7011
|
-
|
|
7012
|
-
|
|
7013
|
-
|
|
7014
|
-
|
|
7015
|
-
|
|
7016
|
-
|
|
7017
|
-
|
|
7018
|
-
|
|
7390
|
+
var drift11 = (message) => ({ ok: false, code: "SCHEMA_DRIFT", message });
|
|
7391
|
+
var unquote3 = (s) => JSON.parse(`"${s}"`);
|
|
7392
|
+
var STR = '((?:[^"\\\\]|\\\\.)+)';
|
|
7393
|
+
var loading = (id) => new RegExp(
|
|
7394
|
+
`"id":"${id}"\\}\\},"namespace":"LoadingNamespace"\\},"value":\\{"\\$case":"stringValue","stringValue":"${STR}"`
|
|
7395
|
+
);
|
|
7396
|
+
var NAME = loading("profile_name_loading_state");
|
|
7397
|
+
var HEADLINE = loading("profile_headline_loading_state");
|
|
7398
|
+
var PROFILE_URL = /"url":"(https:\/\/www\.linkedin\.com\/in\/[^"]+)"/;
|
|
7399
|
+
var TEXT3 = /"children":\["((?:[^"\\$]|\\.)(?:[^"\\]|\\.)*)"\]/g;
|
|
7400
|
+
var FRAGMENT = /\["\$","\$9","\d+",\{"children":\[(?:null|\["\$","br",null,\{\}\]),"((?:[^"\\]|\\.)*)"\]/g;
|
|
7401
|
+
var REF = /"\$L([0-9a-f]+)"/g;
|
|
7402
|
+
var ANY_REF = /"\$L?([0-9a-f]+)"/g;
|
|
7403
|
+
function header(rows, id) {
|
|
7404
|
+
const row = rows.byId.get(id) ?? "";
|
|
7405
|
+
const name = row.match(NAME)?.[1];
|
|
7406
|
+
if (name === void 0) return void 0;
|
|
7407
|
+
const headline = row.match(HEADLINE)?.[1];
|
|
7408
|
+
const all = rows.reach(id).map((r) => rows.byId.get(r) ?? "").join("\n");
|
|
7409
|
+
const texts3 = [...all.matchAll(TEXT3)].map((m) => unquote3(m[1]).trim());
|
|
7410
|
+
const degree = texts3.find((t) => t.startsWith("\xB7"));
|
|
7411
|
+
const shown = /* @__PURE__ */ new Set([unquote3(name), headline === void 0 ? "" : unquote3(headline)]);
|
|
7412
|
+
const context = texts3.filter((t) => t !== degree && !shown.has(t)).pop();
|
|
7413
|
+
const url = row.match(PROFILE_URL)?.[1];
|
|
7414
|
+
return {
|
|
7415
|
+
name: unquote3(name).trim(),
|
|
7416
|
+
...url !== void 0 ? { url } : {},
|
|
7417
|
+
...headline !== void 0 ? { headline: unquote3(headline).trim() } : {},
|
|
7418
|
+
...degree !== void 0 ? { degree: degree.replace(/^·\s*/, "") } : {},
|
|
7419
|
+
...context !== void 0 ? { context } : {}
|
|
7420
|
+
};
|
|
7421
|
+
}
|
|
7422
|
+
function inlined(rows, segment, depth = 0) {
|
|
7423
|
+
if (depth > 3) return segment;
|
|
7424
|
+
return segment.replace(ANY_REF, (ref, id) => {
|
|
7425
|
+
const row = rows.byId.get(id);
|
|
7426
|
+
if (row === void 0) return ref;
|
|
7427
|
+
if (rows.isText(id)) return JSON.stringify(row);
|
|
7428
|
+
return row.startsWith('["$","$9"') ? inlined(rows, row, depth + 1) : ref;
|
|
7429
|
+
});
|
|
7430
|
+
}
|
|
7431
|
+
function bodyOf(segment) {
|
|
7432
|
+
const fragments = [...segment.matchAll(FRAGMENT)].map((m) => unquote3(m[1]));
|
|
7433
|
+
const lines = fragments.length > 0 ? fragments : [...segment.matchAll(TEXT3)].map((m) => unquote3(m[1]));
|
|
7434
|
+
return lines.map((l) => l.replace(/\r/g, "").trimEnd()).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
7435
|
+
}
|
|
7436
|
+
function parseRecommendations(stream) {
|
|
7437
|
+
if (!stream.includes("isPartialPage") && !stream.includes(PAGER))
|
|
7438
|
+
return drift11("the recommendations answer was not the recommendations list");
|
|
7439
|
+
const rows = new Rows(stream);
|
|
7440
|
+
const headers2 = [...rows.byId].filter(([, row]) => NAME.test(row) && !row.startsWith('[["$"')).map(([id]) => id);
|
|
7441
|
+
const heads = new Set(headers2);
|
|
7442
|
+
const placed = headers2.flatMap((h) => {
|
|
7443
|
+
for (const [id, row] of rows.byId) {
|
|
7444
|
+
const at = row.indexOf(`"$L${h}"`);
|
|
7445
|
+
if (at !== -1) return [{ h, row: id, at }];
|
|
7019
7446
|
}
|
|
7020
|
-
|
|
7021
|
-
|
|
7022
|
-
|
|
7447
|
+
return [];
|
|
7448
|
+
});
|
|
7449
|
+
const holders = new Set(placed.map((p) => p.row));
|
|
7450
|
+
const items = [];
|
|
7451
|
+
for (const p of placed) {
|
|
7452
|
+
const row = rows.byId.get(p.row) ?? "";
|
|
7453
|
+
let end = row.length;
|
|
7454
|
+
for (const m of row.slice(p.at + 1).matchAll(REF)) {
|
|
7455
|
+
const id = m[1];
|
|
7456
|
+
if (heads.has(id) || holders.has(id) && id !== p.row) {
|
|
7457
|
+
end = p.at + 1 + (m.index ?? 0);
|
|
7458
|
+
break;
|
|
7459
|
+
}
|
|
7460
|
+
}
|
|
7461
|
+
const who = header(rows, p.h);
|
|
7462
|
+
const text7 = bodyOf(inlined(rows, row.slice(p.at, end)));
|
|
7463
|
+
if (who !== void 0 && text7 !== "") items.push({ ...who, text: text7 });
|
|
7023
7464
|
}
|
|
7024
|
-
|
|
7025
|
-
|
|
7026
|
-
|
|
7027
|
-
if (Object.keys(counts2).length > 0) p.counts = counts2;
|
|
7028
|
-
else delete p.counts;
|
|
7465
|
+
if (headers2.length > 0 && items.length === 0)
|
|
7466
|
+
return drift11(`${headers2.length} recommendations were shown but none could be read`);
|
|
7467
|
+
return { ok: true, items };
|
|
7029
7468
|
}
|
|
7030
|
-
|
|
7031
|
-
|
|
7032
|
-
|
|
7033
|
-
|
|
7034
|
-
|
|
7035
|
-
|
|
7036
|
-
|
|
7037
|
-
|
|
7038
|
-
|
|
7039
|
-
|
|
7469
|
+
|
|
7470
|
+
// src/engine/sdui-profile.ts
|
|
7471
|
+
var NAV_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/navigation";
|
|
7472
|
+
var ACTION_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
7473
|
+
var PROFILE_FIELDS = {
|
|
7474
|
+
headline: {
|
|
7475
|
+
name: "headline",
|
|
7476
|
+
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileEditIntroForm",
|
|
7477
|
+
save: "com.linkedin.sdui.requests.profile.saveProfileIntroForm",
|
|
7478
|
+
binding: "headline",
|
|
7479
|
+
// The web form refuses more ("Exceeded maximum length of 220 characters").
|
|
7480
|
+
maxLength: 220
|
|
7481
|
+
},
|
|
7482
|
+
about: {
|
|
7483
|
+
name: "about",
|
|
7484
|
+
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileAboutForm",
|
|
7485
|
+
save: "com.linkedin.sdui.requests.profile.saveProfileAboutForm",
|
|
7486
|
+
binding: "about",
|
|
7487
|
+
maxLength: 2600
|
|
7488
|
+
}
|
|
7489
|
+
};
|
|
7490
|
+
var drift12 = (message) => ({
|
|
7491
|
+
ok: false,
|
|
7492
|
+
code: "SCHEMA_DRIFT",
|
|
7493
|
+
message,
|
|
7494
|
+
hint: "Re-capture the profile form with scripts/observe-write.ts (edit one character, then revert)."
|
|
7495
|
+
});
|
|
7496
|
+
function readForm(stream, field) {
|
|
7497
|
+
const states2 = readModel(stream);
|
|
7498
|
+
if (states2 === null) return drift12("the profile form carried no initial values");
|
|
7499
|
+
const args = findRequest(stream, field.save);
|
|
7500
|
+
if (args === null)
|
|
7501
|
+
return drift12(`the profile form carried no ${field.save.split(".").pop()} action`);
|
|
7502
|
+
return { ok: true, args, states: states2, screen: field.screen, save: field.save };
|
|
7503
|
+
}
|
|
7504
|
+
function boundKey(form, property) {
|
|
7505
|
+
const ref = form.args.payload[property];
|
|
7506
|
+
return ref?.key;
|
|
7507
|
+
}
|
|
7508
|
+
function currentValue(form, field) {
|
|
7509
|
+
const key = boundKey(form, field.binding);
|
|
7510
|
+
const v = key === void 0 ? void 0 : form.states.get(key)?.value;
|
|
7511
|
+
return typeof v === "string" ? v : void 0;
|
|
7512
|
+
}
|
|
7513
|
+
function topSkills(form) {
|
|
7514
|
+
return (key) => {
|
|
7515
|
+
if (!key.endsWith("ReorderableSkillsFormBindingsskillIdsBinding")) return void 0;
|
|
7516
|
+
const initial = [...form.states.entries()].find(([k]) => k.startsWith("initialSkills"))?.[1];
|
|
7517
|
+
if (initial === void 0) return drift12("the About form carried no initial top skills");
|
|
7518
|
+
if (!Array.isArray(initial.value) || initial.value.length > 0) {
|
|
7519
|
+
return {
|
|
7520
|
+
ok: false,
|
|
7521
|
+
code: "NOT_IMPLEMENTED",
|
|
7522
|
+
message: "your About section has top skills, and saving it with them has not been verified",
|
|
7523
|
+
hint: "Edit About in the browser for now; nothing was changed."
|
|
7524
|
+
};
|
|
7525
|
+
}
|
|
7526
|
+
return { ok: true, value: [] };
|
|
7527
|
+
};
|
|
7528
|
+
}
|
|
7529
|
+
function saveBody(form, field, value) {
|
|
7530
|
+
if (value.length > field.maxLength) {
|
|
7531
|
+
return {
|
|
7532
|
+
ok: false,
|
|
7533
|
+
code: "INVALID_INPUT",
|
|
7534
|
+
message: `the ${field.name} is ${value.length} characters; LinkedIn allows ${field.maxLength}`
|
|
7535
|
+
};
|
|
7536
|
+
}
|
|
7537
|
+
const target2 = boundKey(form, field.binding);
|
|
7538
|
+
const current = target2 === void 0 ? void 0 : form.states.get(target2);
|
|
7539
|
+
if (target2 === void 0 || current === void 0) {
|
|
7540
|
+
return drift12(`the profile form has no ${field.name} field`);
|
|
7541
|
+
}
|
|
7542
|
+
const model = new Map(form.states);
|
|
7543
|
+
model.set(target2, { ...current, value });
|
|
7544
|
+
const states2 = wireStates(keysOf(form.args), model, topSkills(form));
|
|
7545
|
+
if (!Array.isArray(states2)) return states2;
|
|
7546
|
+
return { ok: true, body: requestBody(form.save, form.args, states2, form.screen) };
|
|
7547
|
+
}
|
|
7548
|
+
async function fetchProfileForm(field, vanityName, client) {
|
|
7549
|
+
const stream = await openForm(
|
|
7550
|
+
field.screen,
|
|
7551
|
+
{ vanityName, isVanityNameResolved: true },
|
|
7552
|
+
client,
|
|
7553
|
+
`profile-${field.name}-form`
|
|
7554
|
+
);
|
|
7555
|
+
return typeof stream === "string" ? readForm(stream, field) : stream;
|
|
7556
|
+
}
|
|
7557
|
+
async function openForm(screen, payload, client, operation) {
|
|
7558
|
+
const result = await client.request({
|
|
7559
|
+
url: `${NAV_URL}?screenId=${screen}&sduiid=${screen}`,
|
|
7560
|
+
method: "POST",
|
|
7561
|
+
body: navBody(screen, payload),
|
|
7562
|
+
spendClass: "page",
|
|
7563
|
+
operation
|
|
7564
|
+
});
|
|
7565
|
+
if (!result.ok) {
|
|
7566
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
7567
|
+
if (result.hint !== void 0) out.hint = result.hint;
|
|
7568
|
+
return out;
|
|
7569
|
+
}
|
|
7570
|
+
return result.classification.raw ?? "";
|
|
7571
|
+
}
|
|
7572
|
+
async function sendAction(requestId, body, client, operation, spendClass = "write") {
|
|
7573
|
+
const result = await client.request({
|
|
7574
|
+
url: `${ACTION_URL}?sduiid=${requestId}`,
|
|
7575
|
+
method: "POST",
|
|
7576
|
+
body,
|
|
7577
|
+
spendClass,
|
|
7578
|
+
operation
|
|
7579
|
+
});
|
|
7580
|
+
if (!result.ok) {
|
|
7581
|
+
const out = { ok: false, code: result.code, message: result.message };
|
|
7582
|
+
if (result.hint !== void 0) out.hint = result.hint;
|
|
7583
|
+
return out;
|
|
7584
|
+
}
|
|
7585
|
+
const raw = result.classification.raw ?? "";
|
|
7586
|
+
const errors = responseErrors(raw);
|
|
7587
|
+
if (errors !== null) {
|
|
7588
|
+
return { ok: false, code: "INVALID_INPUT", message: `LinkedIn refused it: ${errors}` };
|
|
7589
|
+
}
|
|
7590
|
+
return raw;
|
|
7591
|
+
}
|
|
7592
|
+
async function sendProfileSave(form, body, client) {
|
|
7593
|
+
const r = await sendAction(form.save, body, client, "profile-save");
|
|
7594
|
+
return typeof r === "string" ? { ok: true } : r;
|
|
7595
|
+
}
|
|
7596
|
+
|
|
7597
|
+
// src/engine/sdui-skill.ts
|
|
7598
|
+
var SKILL = {
|
|
7599
|
+
addScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillAddForm",
|
|
7600
|
+
editScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillDetailsEditForm",
|
|
7601
|
+
listScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillDetails",
|
|
7602
|
+
pager: "com.linkedin.sdui.pagers.profile.details.skills",
|
|
7603
|
+
save: "com.linkedin.sdui.requests.profile.saveProfileSkillForm",
|
|
7604
|
+
delete: "com.linkedin.sdui.requests.profile.deleteProfileSkillForm"
|
|
7605
|
+
};
|
|
7606
|
+
var EDIT_NAV = `{"$type":"proto.sdui.actions.core.NavigateToScreen","screenId":"${SKILL.editScreen}"`;
|
|
7607
|
+
var TEXT4 = /"children":\["((?:[^"\\]|\\.)*)"\]/g;
|
|
7608
|
+
function skillsFromPage(stream) {
|
|
7609
|
+
if (!stream.includes(SKILL.pager) && !stream.includes(EDIT_NAV) && !stream.includes("isPartialPage")) {
|
|
7610
|
+
return drift12("the skills page could not be read");
|
|
7611
|
+
}
|
|
7612
|
+
const skills = [];
|
|
7613
|
+
let from = 0;
|
|
7614
|
+
let i = 0;
|
|
7615
|
+
for (; ; ) {
|
|
7616
|
+
i = stream.indexOf(EDIT_NAV, i);
|
|
7617
|
+
if (i === -1) break;
|
|
7618
|
+
const text7 = balanced(stream, i);
|
|
7619
|
+
const end = i;
|
|
7620
|
+
i += EDIT_NAV.length;
|
|
7621
|
+
if (text7 === null) continue;
|
|
7622
|
+
const payload = JSON.parse(text7).requestedArguments?.payload;
|
|
7623
|
+
const id = payload?.skillId;
|
|
7624
|
+
if (typeof id !== "string" || payload === void 0 || skills.some((s) => s.skillId === id))
|
|
7625
|
+
continue;
|
|
7626
|
+
const names = [...stream.slice(from, end).matchAll(TEXT4)].map(
|
|
7627
|
+
(m) => JSON.parse(`"${m[1]}"`)
|
|
7628
|
+
);
|
|
7629
|
+
skills.push({ skillId: id, name: names.length === 1 ? names[0] ?? null : null, payload });
|
|
7630
|
+
from = end + text7.length;
|
|
7631
|
+
}
|
|
7632
|
+
return { ok: true, skills };
|
|
7633
|
+
}
|
|
7634
|
+
var SKILL_COMPONENT = /"componentKey":"com\.linkedin\.sdui\.profile\.skill\([^)]+\)","children":\["\$","\$L[0-9a-f]+","[^"]+",\{"componentKey":"[^"]+","initialContent":"\$L([0-9a-f]+)"/g;
|
|
7635
|
+
var SKILL_NAME = /"fontSize":"medium","fontStyle":"normal","fontWeight":"bold","lineHeight":"[^"]*","textAlign":"[^"]*","children":\["((?:[^"\\]|\\.)+)"\]/;
|
|
7636
|
+
function skillNamesOf(stream) {
|
|
7637
|
+
const rows = new Rows(stream);
|
|
7638
|
+
return [...stream.matchAll(SKILL_COMPONENT)].flatMap((m) => {
|
|
7639
|
+
const name = rows.reach(m[1]).map((r) => rows.byId.get(r)?.match(SKILL_NAME)?.[1]).find((n) => n !== void 0);
|
|
7640
|
+
return name === void 0 ? [] : [JSON.parse(`"${name}"`)];
|
|
7641
|
+
});
|
|
7642
|
+
}
|
|
7643
|
+
function skillRowsOf(stream) {
|
|
7644
|
+
return [...stream.matchAll(SKILL_COMPONENT)].length;
|
|
7645
|
+
}
|
|
7646
|
+
function listPayloadOf(screen) {
|
|
7647
|
+
const at = screen.indexOf('"filter":"ProfileSkillCategory_ALL"');
|
|
7648
|
+
const open = at === -1 ? -1 : screen.lastIndexOf('"payload":{', at);
|
|
7649
|
+
const text7 = open === -1 ? null : balanced(screen, open + '"payload":'.length);
|
|
7650
|
+
return text7 === null ? null : JSON.parse(text7);
|
|
7651
|
+
}
|
|
7652
|
+
function pagerFrom(payload, start) {
|
|
7653
|
+
const args = {
|
|
7654
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
7655
|
+
requestedStateKeys: [],
|
|
7656
|
+
payload: { ...payload, start },
|
|
7657
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
7658
|
+
};
|
|
7659
|
+
return {
|
|
7660
|
+
pagerId: SKILL.pager,
|
|
7661
|
+
clientArguments: { ...args, states: [], screenId: SKILL.listScreen, knownTemplateIds: [] },
|
|
7662
|
+
paginationRequest: {
|
|
7663
|
+
$type: "proto.sdui.actions.requests.PaginationRequest",
|
|
7664
|
+
pagerId: SKILL.pager,
|
|
7665
|
+
retryCount: 0,
|
|
7666
|
+
requestedArguments: args
|
|
7667
|
+
}
|
|
7668
|
+
};
|
|
7669
|
+
}
|
|
7670
|
+
function readSkillForm(stream) {
|
|
7671
|
+
const model = readModel(stream);
|
|
7672
|
+
if (model === null) return drift12("the skill form carried no initial values");
|
|
7673
|
+
const save = findRequest(stream, SKILL.save);
|
|
7674
|
+
const del = findRequest(stream, SKILL.delete);
|
|
7675
|
+
if (save === null && del === null)
|
|
7676
|
+
return drift12("the skill form carried neither a save nor a delete");
|
|
7677
|
+
return { ok: true, model, save, del, screen: del === null ? SKILL.addScreen : SKILL.editScreen };
|
|
7678
|
+
}
|
|
7679
|
+
var nameKey = (model) => [...model.keys()].find((k) => k.startsWith("addSkillsTypeaheadSkillName"));
|
|
7680
|
+
function skillNameOf(form) {
|
|
7681
|
+
const key = nameKey(form.model);
|
|
7682
|
+
const v = key === void 0 ? void 0 : form.model.get(key)?.value;
|
|
7683
|
+
return typeof v === "string" ? v : null;
|
|
7684
|
+
}
|
|
7685
|
+
function addSkillBody(form, name) {
|
|
7686
|
+
if (name.trim() === "")
|
|
7687
|
+
return { ok: false, code: "INVALID_INPUT", message: "a skill needs a name" };
|
|
7688
|
+
if (form.save === null) return drift12("this form has no save action (it is not the add form)");
|
|
7689
|
+
const key = nameKey(form.model);
|
|
7690
|
+
const current = key === void 0 ? void 0 : form.model.get(key);
|
|
7691
|
+
if (key === void 0 || current === void 0) return drift12("the skill form has no name field");
|
|
7692
|
+
const model = new Map(form.model);
|
|
7693
|
+
model.set(key, { ...current, value: name.trim() });
|
|
7694
|
+
const states2 = wireStates(keysOf(form.save), model, () => void 0);
|
|
7695
|
+
if (!Array.isArray(states2)) return states2;
|
|
7696
|
+
return { ok: true, body: requestBody(SKILL.save, form.save, states2, form.screen) };
|
|
7697
|
+
}
|
|
7698
|
+
function removeSkillBody(form) {
|
|
7699
|
+
if (form.del === null)
|
|
7700
|
+
return drift12("this form has no delete action (it is not an existing skill)");
|
|
7701
|
+
const states2 = wireStates(keysOf(form.del), form.model, () => void 0);
|
|
7702
|
+
if (!Array.isArray(states2)) return states2;
|
|
7703
|
+
return { ok: true, body: requestBody(SKILL.delete, form.del, states2, form.screen) };
|
|
7704
|
+
}
|
|
7705
|
+
var PAGER_URL2 = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${SKILL.pager}`;
|
|
7706
|
+
var MAX_PAGES2 = 10;
|
|
7707
|
+
async function fetchSkills(vanityName, client) {
|
|
7708
|
+
const screen = await openForm(
|
|
7709
|
+
SKILL.listScreen,
|
|
7710
|
+
{ vanityName, isVanityNameResolved: true },
|
|
7711
|
+
client,
|
|
7712
|
+
"skills-screen"
|
|
7713
|
+
);
|
|
7714
|
+
if (typeof screen !== "string") return screen;
|
|
7715
|
+
const payload = listPayloadOf(screen);
|
|
7716
|
+
if (payload === null) return drift12("the Skills screen carried no list request");
|
|
7717
|
+
const count3 = typeof payload.count === "number" ? payload.count : 10;
|
|
7718
|
+
const skills = [];
|
|
7719
|
+
for (let page = 0; page < MAX_PAGES2; page++) {
|
|
7720
|
+
const result = await client.request({
|
|
7721
|
+
url: PAGER_URL2,
|
|
7722
|
+
method: "POST",
|
|
7723
|
+
body: pagerFrom(payload, skills.length),
|
|
7724
|
+
spendClass: "page",
|
|
7725
|
+
operation: "skills"
|
|
7726
|
+
});
|
|
7727
|
+
if (!result.ok) return { ok: false, code: result.code, message: result.message };
|
|
7728
|
+
const parsed = skillsFromPage(result.classification.raw ?? "");
|
|
7729
|
+
if (!parsed.ok) return parsed;
|
|
7730
|
+
const fresh = parsed.skills.filter((s) => !skills.some((k) => k.skillId === s.skillId));
|
|
7731
|
+
skills.push(...fresh);
|
|
7732
|
+
if (parsed.skills.length < count3 || fresh.length === 0) break;
|
|
7733
|
+
}
|
|
7734
|
+
return { ok: true, skills };
|
|
7735
|
+
}
|
|
7736
|
+
async function openSkillForm(payload, client, edit2) {
|
|
7737
|
+
const stream = await openForm(
|
|
7738
|
+
edit2 ? SKILL.editScreen : SKILL.addScreen,
|
|
7739
|
+
{ ...payload, isVanityNameResolved: true },
|
|
7740
|
+
client,
|
|
7741
|
+
edit2 ? "skill-edit-form" : "skill-add-form"
|
|
7742
|
+
);
|
|
7743
|
+
return typeof stream === "string" ? readSkillForm(stream) : stream;
|
|
7744
|
+
}
|
|
7745
|
+
async function sendSkill(body, requestId, client) {
|
|
7746
|
+
const sent = await sendAction(
|
|
7747
|
+
requestId,
|
|
7748
|
+
body,
|
|
7749
|
+
client,
|
|
7750
|
+
requestId === SKILL.save ? "skill-add" : "skill-remove"
|
|
7751
|
+
);
|
|
7752
|
+
return typeof sent === "string" ? { ok: true } : sent;
|
|
7753
|
+
}
|
|
7754
|
+
|
|
7755
|
+
// src/commands/profile.ts
|
|
7756
|
+
function liveFetch9(quiet) {
|
|
7757
|
+
const session = loadSession();
|
|
7758
|
+
if (session.state !== "ok")
|
|
7759
|
+
return err("profile", "AUTH_FAILED", "no LinkedIn session \u2014 run `lnrelay login`");
|
|
7760
|
+
const client = createLiveClient(session.session, void 0, quiet);
|
|
7761
|
+
return async (url, spendClass, body) => {
|
|
7762
|
+
const r = await client.request({
|
|
7763
|
+
url,
|
|
7764
|
+
...body !== void 0 ? { method: "POST", body } : {},
|
|
7765
|
+
spendClass,
|
|
7766
|
+
operation: "profile"
|
|
7767
|
+
});
|
|
7768
|
+
if (!r.ok) return r;
|
|
7769
|
+
return { ok: true, json: r.json, raw: r.classification.raw ?? "" };
|
|
7770
|
+
};
|
|
7771
|
+
}
|
|
7772
|
+
function memberIdOf(input) {
|
|
7773
|
+
const s = input.trim();
|
|
7774
|
+
const slug = s.match(/linkedin\.com\/in\/([^/?#]+)/)?.[1];
|
|
7775
|
+
if (slug !== void 0) {
|
|
7776
|
+
try {
|
|
7777
|
+
return decodeURIComponent(slug);
|
|
7778
|
+
} catch {
|
|
7779
|
+
return slug;
|
|
7780
|
+
}
|
|
7781
|
+
}
|
|
7782
|
+
return s.match(/urn:li:fsd?_(?:mini)?[Pp]rofile:([^,)]+)/)?.[1] ?? s;
|
|
7783
|
+
}
|
|
7784
|
+
async function readRestOfExperience(get, p) {
|
|
7785
|
+
const want = p.counts?.experience;
|
|
7786
|
+
if (want === void 0) return;
|
|
7787
|
+
let start = want.shown;
|
|
7788
|
+
while (start < want.total) {
|
|
7789
|
+
const res = await get(positionsPageUrl(p.urn, start), "profile");
|
|
7790
|
+
const page = res.ok ? parsePositionsPage(res.json) : res;
|
|
7791
|
+
if (!page.ok) {
|
|
7792
|
+
p.experienceError = `${page.code}: ${page.message}`;
|
|
7793
|
+
return;
|
|
7794
|
+
}
|
|
7795
|
+
p.experience = [...p.experience ?? [], ...page.experience];
|
|
7796
|
+
start += page.groups;
|
|
7797
|
+
if (page.groups < POSITIONS_PAGE) break;
|
|
7798
|
+
}
|
|
7799
|
+
const counts2 = { ...p.counts };
|
|
7800
|
+
if (start >= want.total) delete counts2.experience;
|
|
7801
|
+
else counts2.experience = { shown: start, total: want.total };
|
|
7802
|
+
if (Object.keys(counts2).length > 0) p.counts = counts2;
|
|
7803
|
+
else delete p.counts;
|
|
7804
|
+
}
|
|
7805
|
+
async function readContact(get, p) {
|
|
7806
|
+
if (p.publicId === void 0 || p.firstName === void 0) {
|
|
7807
|
+
p.contactError = "NOT_FOUND: the profile has no public id or name to ask with";
|
|
7808
|
+
return;
|
|
7809
|
+
}
|
|
7810
|
+
const body = contactInfoBody(p.publicId, p.firstName, p.lastName ?? "");
|
|
7811
|
+
const res = await get(CONTACT_INFO_URL, "profile", body);
|
|
7812
|
+
const read = res.ok ? parseContactInfo(res.raw ?? "") : res;
|
|
7813
|
+
if (read.ok) p.contact = read.contact;
|
|
7814
|
+
else p.contactError = `${read.code}: ${read.message}`;
|
|
7815
|
+
}
|
|
7816
|
+
var SKILL_PAGES = 10;
|
|
7817
|
+
async function readAllSkills(get, p) {
|
|
7818
|
+
const fail2 = (code, message) => {
|
|
7819
|
+
p.skillsError = `${code}: ${message}`;
|
|
7820
|
+
};
|
|
7821
|
+
if (p.publicId === void 0)
|
|
7822
|
+
return fail2("NOT_FOUND", "the profile has no public id to ask with");
|
|
7823
|
+
const screen = SKILL.listScreen;
|
|
7824
|
+
const nav = await get(
|
|
7825
|
+
`${NAV_URL}?screenId=${screen}&sduiid=${screen}`,
|
|
7826
|
+
"page",
|
|
7827
|
+
navBody(screen, { vanityName: p.publicId, isVanityNameResolved: true })
|
|
7828
|
+
);
|
|
7829
|
+
if (!nav.ok) return fail2(nav.code, nav.message);
|
|
7830
|
+
const payload = listPayloadOf(nav.raw ?? "");
|
|
7831
|
+
if (payload === null) return fail2("SCHEMA_DRIFT", "the Skills screen carried no list request");
|
|
7832
|
+
const count3 = typeof payload.count === "number" ? payload.count : 10;
|
|
7833
|
+
const total = p.counts?.skills?.total;
|
|
7834
|
+
const skills = [];
|
|
7835
|
+
let start = 0;
|
|
7836
|
+
for (let page = 0; page < SKILL_PAGES; page++) {
|
|
7837
|
+
const res = await get(PAGER_URL2, "page", pagerFrom(payload, start));
|
|
7838
|
+
if (!res.ok) return fail2(res.code, res.message);
|
|
7839
|
+
const rows = skillRowsOf(res.raw ?? "");
|
|
7840
|
+
const names = skillNamesOf(res.raw ?? "");
|
|
7841
|
+
if (rows > names.length)
|
|
7842
|
+
return fail2("SCHEMA_DRIFT", `${rows} skills were shown, ${names.length} read`);
|
|
7843
|
+
skills.push(...names);
|
|
7844
|
+
start += rows;
|
|
7845
|
+
if (rows < count3 || total !== void 0 && start >= total) break;
|
|
7846
|
+
}
|
|
7847
|
+
if (skills.length === 0) return fail2("SCHEMA_DRIFT", "the skills list held no skills");
|
|
7848
|
+
p.skills = skills;
|
|
7849
|
+
const counts2 = { ...p.counts };
|
|
7850
|
+
if (total === void 0 || skills.length >= total) delete counts2.skills;
|
|
7851
|
+
else counts2.skills = { shown: skills.length, total };
|
|
7852
|
+
if (Object.keys(counts2).length > 0) p.counts = counts2;
|
|
7853
|
+
else delete p.counts;
|
|
7854
|
+
}
|
|
7855
|
+
var RECOMMENDATION_PAGES = 10;
|
|
7856
|
+
async function readRecommendations(get, p) {
|
|
7857
|
+
if (p.publicId === void 0) {
|
|
7858
|
+
p.recommendationsError = "NOT_FOUND: the profile has no public id to ask with";
|
|
7859
|
+
return;
|
|
7860
|
+
}
|
|
7861
|
+
const out = { received: [], given: [] };
|
|
7862
|
+
for (const kind of ["received", "given"]) {
|
|
7863
|
+
for (let page = 0; page < RECOMMENDATION_PAGES; page++) {
|
|
7864
|
+
const body = recommendationsBody(kind, p.publicId, p.id, out[kind].length);
|
|
7865
|
+
const res = await get(RECOMMENDATIONS_URL, "page", body);
|
|
7866
|
+
const read = res.ok ? parseRecommendations(res.raw ?? "") : res;
|
|
7867
|
+
if (!read.ok) {
|
|
7868
|
+
p.recommendationsError = `${read.code}: ${read.message}`;
|
|
7869
|
+
return;
|
|
7870
|
+
}
|
|
7871
|
+
out[kind].push(...read.items);
|
|
7872
|
+
if (read.items.length < RECOMMENDATIONS_PAGE) break;
|
|
7873
|
+
}
|
|
7874
|
+
}
|
|
7875
|
+
p.recommendations = out;
|
|
7876
|
+
}
|
|
7877
|
+
async function readPosts(get, p, n, compact2) {
|
|
7878
|
+
const r = await runPostsSearch(
|
|
7879
|
+
{ from: [p.id], sort: "recent", limit: n },
|
|
7880
|
+
compact2 ? { compact: true } : {},
|
|
7881
|
+
async (url, body) => {
|
|
7882
|
+
const res = await get(url, "search", body);
|
|
7883
|
+
return res.ok ? { ok: true, raw: res.raw ?? "" } : res;
|
|
7884
|
+
}
|
|
7885
|
+
);
|
|
7886
|
+
if (r.ok) p.posts = r.data.items;
|
|
7887
|
+
else p.postsError = `${r.error.code}: ${r.error.message}`;
|
|
7040
7888
|
}
|
|
7041
7889
|
var span = (x) => x.start === void 0 && x.end === void 0 ? void 0 : `${x.start ?? "?"} \u2013 ${x.current === true ? "now" : x.end ?? "?"}`;
|
|
7042
7890
|
var roleLine = (r) => line([r.title, r.company, span(r), r.employmentType, r.location]);
|
|
@@ -7077,7 +7925,7 @@ async function runProfile(input, opts = {}, fetch2, req = {}) {
|
|
|
7077
7925
|
"a public id, profile URL or urn is required",
|
|
7078
7926
|
"lnrelay profile <public-id|url|urn>"
|
|
7079
7927
|
);
|
|
7080
|
-
const get = fetch2 ??
|
|
7928
|
+
const get = fetch2 ?? liveFetch9(opts.quiet === true);
|
|
7081
7929
|
if (typeof get !== "function") return get;
|
|
7082
7930
|
const res = await get(fullProfileUrl(memberIdOf(input)), "profile");
|
|
7083
7931
|
if (!res.ok) return err("profile", res.code, res.message, res.hint);
|
|
@@ -7085,7 +7933,11 @@ async function runProfile(input, opts = {}, fetch2, req = {}) {
|
|
|
7085
7933
|
if (!parsed.ok) return err("profile", parsed.code, parsed.message, parsed.hint);
|
|
7086
7934
|
const p = parsed.profile;
|
|
7087
7935
|
await readRestOfExperience(get, p);
|
|
7936
|
+
if (req.skills === true) await readAllSkills(get, p);
|
|
7937
|
+
if (req.recommendations === true) await readRecommendations(get, p);
|
|
7088
7938
|
if (req.contact === true) await readContact(get, p);
|
|
7939
|
+
if (req.posts !== void 0 && req.posts > 0)
|
|
7940
|
+
await readPosts(get, p, req.posts, opts.compact === true);
|
|
7089
7941
|
if (opts.raw === true) return ok("profile", { ...p, raw: res.json });
|
|
7090
7942
|
if (opts.fields !== void 0 && opts.fields !== "")
|
|
7091
7943
|
return ok("profile", project([p], opts.fields)[0]);
|
|
@@ -7144,9 +7996,9 @@ var COMMANDS = [
|
|
|
7144
7996
|
},
|
|
7145
7997
|
{
|
|
7146
7998
|
name: "profile",
|
|
7147
|
-
cost: "1 profile read (+1 per 50 companies past the first 10; --contact +1)",
|
|
7148
|
-
summary: "A profile in full: name, headline, about, every role with dates and descriptions, education, skills, honors, publications, volunteering and the other sections. --contact adds contact info: email, websites, phone, birthday, connected since.",
|
|
7149
|
-
usage: "lnrelay profile <public-id|profile-id|urn|url> [--contact] [--compact | --fields a,b,c] [--raw]",
|
|
7999
|
+
cost: "1 profile read (+1 per 50 companies past the first 10; --contact +1; --posts +1 search; --skills +1 page per 10; --recommendations +2 pages)",
|
|
8000
|
+
summary: "A profile in full: name, headline, about, every role with dates and descriptions, education, skills, honors, publications, volunteering and the other sections. --contact adds contact info: email, websites, phone, birthday, connected since. --posts N adds their N newest posts; --skills reads every skill past the top 20; --recommendations adds those they received and gave.",
|
|
8001
|
+
usage: "lnrelay profile <public-id|profile-id|urn|url> [--contact] [--posts N] [--skills]\n [--recommendations]\n [--compact | --fields a,b,c] [--raw]",
|
|
7150
8002
|
audience: ["cli", "mcp"],
|
|
7151
8003
|
risk: "read",
|
|
7152
8004
|
implemented: true
|
|
@@ -7191,16 +8043,16 @@ var COMMANDS = [
|
|
|
7191
8043
|
name: "jobs",
|
|
7192
8044
|
cost: "1 job-search call per 100 jobs; --details adds 1 job read per 100 jobs",
|
|
7193
8045
|
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`.",
|
|
7194
|
-
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.',
|
|
8046
|
+
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.\nlnrelay jobs --top-applicant [--limit N] [--details] [--compact | --fields a,b,c]\n Premium: the jobs where LinkedIn says you would be a top applicant, 100 a call.',
|
|
7195
8047
|
audience: ["cli", "mcp"],
|
|
7196
8048
|
risk: "read",
|
|
7197
8049
|
implemented: true
|
|
7198
8050
|
},
|
|
7199
8051
|
{
|
|
7200
8052
|
name: "job",
|
|
7201
|
-
cost: "1 job read per 100 jobs; --team adds 1 page call per job",
|
|
7202
|
-
summary: "Jobs in full: description, apply link (external or Easy Apply), applicants, state. Several ids are read together, 100 a call. --team adds who posted it and who is hiring.",
|
|
7203
|
-
usage: "lnrelay job <id|job-url> [<id|job-url> ...] [--team] [--compact | --fields a,b,c]",
|
|
8053
|
+
cost: "1 job read per 100 jobs; --team adds 1 page call per job; --insights 1 job read per job",
|
|
8054
|
+
summary: "Jobs in full: description, apply link (external or Easy Apply), applicants, state. Several ids are read together, 100 a call. --team adds who posted it and who is hiring. --insights (Premium) adds who applied (count, last day, seniority, education) and the company's insights: headcount over two years, the job's function, tenure, competitors.",
|
|
8055
|
+
usage: "lnrelay job <id|job-url> [<id|job-url> ...] [--team] [--insights] [--compact | --fields a,b,c]",
|
|
7204
8056
|
audience: ["cli", "mcp"],
|
|
7205
8057
|
risk: "read",
|
|
7206
8058
|
implemented: true
|
|
@@ -7305,11 +8157,20 @@ var COMMANDS = [
|
|
|
7305
8157
|
risk: "read",
|
|
7306
8158
|
implemented: true
|
|
7307
8159
|
},
|
|
8160
|
+
{
|
|
8161
|
+
name: "notifications",
|
|
8162
|
+
cost: "1 page call per 25",
|
|
8163
|
+
summary: "Your notifications, newest first: what each says, when, read or not, where it goes and who it is about. Reading them here does not mark them seen.",
|
|
8164
|
+
usage: "lnrelay notifications [--unread] [--limit N] [--compact | --fields a,b,c]",
|
|
8165
|
+
audience: ["cli", "mcp"],
|
|
8166
|
+
risk: "read",
|
|
8167
|
+
implemented: true
|
|
8168
|
+
},
|
|
7308
8169
|
{
|
|
7309
8170
|
name: "viewers",
|
|
7310
8171
|
cost: "2 page calls",
|
|
7311
|
-
summary: "Who viewed your profile, as your profile-views page shows it: the total for the period, the viewers LinkedIn names (up to 3 on a free account), anonymous ones as LinkedIn describes them, and how many looked in private mode.",
|
|
7312
|
-
usage: "lnrelay viewers [--compact | --fields a,b,c]",
|
|
8172
|
+
summary: "Who viewed your profile, as your profile-views page shows it: the total for the period, the viewers LinkedIn names (up to 3 on a free account, all with Premium), anonymous ones as LinkedIn describes them, and how many looked in private mode. Premium adds a range and highlights: top location, industry and company, and the companies viewers work at.",
|
|
8173
|
+
usage: "lnrelay viewers [--days 7|14|28|90|365] [--compact | --fields a,b,c]",
|
|
7313
8174
|
audience: ["cli", "mcp"],
|
|
7314
8175
|
risk: "read",
|
|
7315
8176
|
implemented: true
|
|
@@ -7445,207 +8306,80 @@ var COMMANDS = [
|
|
|
7445
8306
|
name: "comment",
|
|
7446
8307
|
cost: "1 call \u2014 write",
|
|
7447
8308
|
summary: "Add a comment to a post. Harvests its binding tokens from the rendered page; no browser needed, but it costs one heavy read.",
|
|
7448
|
-
usage: 'lnrelay comment <activity-urn> "<text>"\n Fetches the post page (~2.8 MB) to harvest a binding key and trackingId, and proves\n the key belongs to that post before asking. To change a comment, see `edit`.',
|
|
7449
|
-
audience: ["cli"],
|
|
7450
|
-
risk: "write",
|
|
7451
|
-
implemented: true
|
|
7452
|
-
},
|
|
7453
|
-
{
|
|
7454
|
-
name: "delete",
|
|
7455
|
-
cost: "1 read + 1 write",
|
|
7456
|
-
summary: "Delete one of your own posts or comments. Reads a post back and shows its text first \u2014 this is the one action that cannot be undone.",
|
|
7457
|
-
usage: "lnrelay delete <activity-urn> # a post; shows you its text before destroying it\n lnrelay delete <comment-urn> # a comment; the server decides if you may",
|
|
7458
|
-
audience: ["cli"],
|
|
7459
|
-
risk: "write",
|
|
7460
|
-
implemented: true
|
|
7461
|
-
},
|
|
7462
|
-
{
|
|
7463
|
-
name: "reply",
|
|
7464
|
-
cost: "1 read + 1 write",
|
|
7465
|
-
summary: "Reply to a comment, nested under it. Goes over Voyager \u2014 a different endpoint from commenting, with the parent named in threadUrn.",
|
|
7466
|
-
usage: 'lnrelay reply <comment-urn> "<text>"',
|
|
7467
|
-
audience: ["cli"],
|
|
7468
|
-
risk: "write",
|
|
7469
|
-
implemented: true
|
|
7470
|
-
},
|
|
7471
|
-
{
|
|
7472
|
-
name: "edit",
|
|
7473
|
-
cost: "1 read + 1 write",
|
|
7474
|
-
summary: "Change the text of a comment or post you wrote, your profile headline or About, or your profile photo or cover image. Its own verb, so a comment urn can never be mistaken for something to comment ON.",
|
|
7475
|
-
usage: 'lnrelay edit <comment-urn | share-urn | ugcPost-urn> "<text>"\n lnrelay edit headline|about ("<text>" | --file <path>)\n lnrelay edit photo|banner <image.png|jpg> (photo square, banner 4:1, max 8 MB)\n A post is edited by the urn it was created as (`share` prints it; `my-posts` lists\n it as shareUrn), not its activity urn. The whole text is replaced. A profile edit\n shows the current text beside the new one, sends every other profile field back as\n LinkedIn holds it, and reads the profile back to confirm. Headline max 220 characters.\n An image is uploaded as it is, uncropped, and read back: it must be the one showing.',
|
|
7476
|
-
audience: ["cli"],
|
|
7477
|
-
risk: "write",
|
|
7478
|
-
implemented: true
|
|
7479
|
-
},
|
|
7480
|
-
{
|
|
7481
|
-
name: "role",
|
|
7482
|
-
cost: "3-4 reads + 1 write",
|
|
7483
|
-
summary: "Add, edit or remove a role in your Experience. Never rewrites your headline; notify network is off unless --notify.",
|
|
7484
|
-
usage: 'lnrelay role add --title "<t>" --company "<c>" --start YYYY-MM [--end YYYY-MM | --current]\n [--location "<l>"] [--description "<d>" | --description-file <path>] [--notify]\n lnrelay role edit <position-id> [any of the flags above]\n lnrelay role remove <position-id>\n Position ids come from `lnrelay experience`. The preview shows the role as it is and\n as it will be; the result is read back from the profile. A role with media attached\n is refused. The company is free text (not linked to a company page).',
|
|
7485
|
-
audience: ["cli"],
|
|
7486
|
-
risk: "write",
|
|
7487
|
-
implemented: true
|
|
7488
|
-
},
|
|
7489
|
-
{
|
|
7490
|
-
name: "skill",
|
|
7491
|
-
cost: "4-5 reads + 1 write",
|
|
7492
|
-
summary: "Add a skill to your profile, or remove one.",
|
|
7493
|
-
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.',
|
|
7494
|
-
audience: ["cli"],
|
|
7495
|
-
risk: "write",
|
|
7496
|
-
implemented: true
|
|
7497
|
-
},
|
|
7498
|
-
{
|
|
7499
|
-
name: "react",
|
|
7500
|
-
cost: "1 call \u2014 write",
|
|
7501
|
-
summary: "React to a post or comment, over LinkedIn's SDUI surface. Reversible with --remove.",
|
|
7502
|
-
usage: "lnrelay react <activity-urn | comment-urn> [--type LIKE|PRAISE|EMPATHY|INTEREST|APPRECIATION|ENTERTAINMENT]\n lnrelay react <urn> --remove # take the reaction back",
|
|
7503
|
-
audience: ["cli"],
|
|
7504
|
-
risk: "write",
|
|
7505
|
-
implemented: true
|
|
7506
|
-
}
|
|
7507
|
-
];
|
|
7508
|
-
var commandNames = COMMANDS.map((c) => c.name);
|
|
7509
|
-
function findCommand(name) {
|
|
7510
|
-
return COMMANDS.find((c) => c.name === name);
|
|
7511
|
-
}
|
|
7512
|
-
function helpText() {
|
|
7513
|
-
const lines = ["lnrelay \u2014 deep research over LinkedIn from your own account", "", "Commands:"];
|
|
7514
|
-
const width = Math.max(...commandNames.map((n) => n.length));
|
|
7515
|
-
for (const c of COMMANDS) {
|
|
7516
|
-
const flag = c.implemented ? " " : "\xB7";
|
|
7517
|
-
lines.push(` ${flag} ${c.name.padEnd(width)} ${c.summary} [${c.cost}]`);
|
|
7518
|
-
}
|
|
7519
|
-
lines.push("", " \xB7 = specified in docs/DESIGN.md, not yet implemented");
|
|
7520
|
-
lines.push("", "Run `lnrelay <command> --help` for usage.");
|
|
7521
|
-
return lines.join("\n");
|
|
7522
|
-
}
|
|
7523
|
-
|
|
7524
|
-
// src/engine/sdui-profile.ts
|
|
7525
|
-
var NAV_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/navigation";
|
|
7526
|
-
var ACTION_URL = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
7527
|
-
var PROFILE_FIELDS = {
|
|
7528
|
-
headline: {
|
|
7529
|
-
name: "headline",
|
|
7530
|
-
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileEditIntroForm",
|
|
7531
|
-
save: "com.linkedin.sdui.requests.profile.saveProfileIntroForm",
|
|
7532
|
-
binding: "headline",
|
|
7533
|
-
// The web form refuses more ("Exceeded maximum length of 220 characters").
|
|
7534
|
-
maxLength: 220
|
|
7535
|
-
},
|
|
7536
|
-
about: {
|
|
7537
|
-
name: "about",
|
|
7538
|
-
screen: "com.linkedin.sdui.flagshipnav.profile.ProfileAboutForm",
|
|
7539
|
-
save: "com.linkedin.sdui.requests.profile.saveProfileAboutForm",
|
|
7540
|
-
binding: "about",
|
|
7541
|
-
maxLength: 2600
|
|
7542
|
-
}
|
|
7543
|
-
};
|
|
7544
|
-
var drift9 = (message) => ({
|
|
7545
|
-
ok: false,
|
|
7546
|
-
code: "SCHEMA_DRIFT",
|
|
7547
|
-
message,
|
|
7548
|
-
hint: "Re-capture the profile form with scripts/observe-write.ts (edit one character, then revert)."
|
|
7549
|
-
});
|
|
7550
|
-
function readForm(stream, field) {
|
|
7551
|
-
const states2 = readModel(stream);
|
|
7552
|
-
if (states2 === null) return drift9("the profile form carried no initial values");
|
|
7553
|
-
const args = findRequest(stream, field.save);
|
|
7554
|
-
if (args === null)
|
|
7555
|
-
return drift9(`the profile form carried no ${field.save.split(".").pop()} action`);
|
|
7556
|
-
return { ok: true, args, states: states2, screen: field.screen, save: field.save };
|
|
7557
|
-
}
|
|
7558
|
-
function boundKey(form, property) {
|
|
7559
|
-
const ref = form.args.payload[property];
|
|
7560
|
-
return ref?.key;
|
|
7561
|
-
}
|
|
7562
|
-
function currentValue(form, field) {
|
|
7563
|
-
const key = boundKey(form, field.binding);
|
|
7564
|
-
const v = key === void 0 ? void 0 : form.states.get(key)?.value;
|
|
7565
|
-
return typeof v === "string" ? v : void 0;
|
|
7566
|
-
}
|
|
7567
|
-
function topSkills(form) {
|
|
7568
|
-
return (key) => {
|
|
7569
|
-
if (!key.endsWith("ReorderableSkillsFormBindingsskillIdsBinding")) return void 0;
|
|
7570
|
-
const initial = [...form.states.entries()].find(([k]) => k.startsWith("initialSkills"))?.[1];
|
|
7571
|
-
if (initial === void 0) return drift9("the About form carried no initial top skills");
|
|
7572
|
-
if (!Array.isArray(initial.value) || initial.value.length > 0) {
|
|
7573
|
-
return {
|
|
7574
|
-
ok: false,
|
|
7575
|
-
code: "NOT_IMPLEMENTED",
|
|
7576
|
-
message: "your About section has top skills, and saving it with them has not been verified",
|
|
7577
|
-
hint: "Edit About in the browser for now; nothing was changed."
|
|
7578
|
-
};
|
|
7579
|
-
}
|
|
7580
|
-
return { ok: true, value: [] };
|
|
7581
|
-
};
|
|
7582
|
-
}
|
|
7583
|
-
function saveBody(form, field, value) {
|
|
7584
|
-
if (value.length > field.maxLength) {
|
|
7585
|
-
return {
|
|
7586
|
-
ok: false,
|
|
7587
|
-
code: "INVALID_INPUT",
|
|
7588
|
-
message: `the ${field.name} is ${value.length} characters; LinkedIn allows ${field.maxLength}`
|
|
7589
|
-
};
|
|
7590
|
-
}
|
|
7591
|
-
const target2 = boundKey(form, field.binding);
|
|
7592
|
-
const current = target2 === void 0 ? void 0 : form.states.get(target2);
|
|
7593
|
-
if (target2 === void 0 || current === void 0) {
|
|
7594
|
-
return drift9(`the profile form has no ${field.name} field`);
|
|
7595
|
-
}
|
|
7596
|
-
const model = new Map(form.states);
|
|
7597
|
-
model.set(target2, { ...current, value });
|
|
7598
|
-
const states2 = wireStates(keysOf(form.args), model, topSkills(form));
|
|
7599
|
-
if (!Array.isArray(states2)) return states2;
|
|
7600
|
-
return { ok: true, body: requestBody(form.save, form.args, states2, form.screen) };
|
|
7601
|
-
}
|
|
7602
|
-
async function fetchProfileForm(field, vanityName, client) {
|
|
7603
|
-
const stream = await openForm(
|
|
7604
|
-
field.screen,
|
|
7605
|
-
{ vanityName, isVanityNameResolved: true },
|
|
7606
|
-
client,
|
|
7607
|
-
`profile-${field.name}-form`
|
|
7608
|
-
);
|
|
7609
|
-
return typeof stream === "string" ? readForm(stream, field) : stream;
|
|
7610
|
-
}
|
|
7611
|
-
async function openForm(screen, payload, client, operation) {
|
|
7612
|
-
const result = await client.request({
|
|
7613
|
-
url: `${NAV_URL}?screenId=${screen}&sduiid=${screen}`,
|
|
7614
|
-
method: "POST",
|
|
7615
|
-
body: navBody(screen, payload),
|
|
7616
|
-
spendClass: "page",
|
|
7617
|
-
operation
|
|
7618
|
-
});
|
|
7619
|
-
if (!result.ok) {
|
|
7620
|
-
const out = { ok: false, code: result.code, message: result.message };
|
|
7621
|
-
if (result.hint !== void 0) out.hint = result.hint;
|
|
7622
|
-
return out;
|
|
8309
|
+
usage: 'lnrelay comment <activity-urn> "<text>"\n Fetches the post page (~2.8 MB) to harvest a binding key and trackingId, and proves\n the key belongs to that post before asking. To change a comment, see `edit`.',
|
|
8310
|
+
audience: ["cli"],
|
|
8311
|
+
risk: "write",
|
|
8312
|
+
implemented: true
|
|
8313
|
+
},
|
|
8314
|
+
{
|
|
8315
|
+
name: "delete",
|
|
8316
|
+
cost: "1 read + 1 write",
|
|
8317
|
+
summary: "Delete one of your own posts or comments. Reads a post back and shows its text first \u2014 this is the one action that cannot be undone.",
|
|
8318
|
+
usage: "lnrelay delete <activity-urn> # a post; shows you its text before destroying it\n lnrelay delete <comment-urn> # a comment; the server decides if you may",
|
|
8319
|
+
audience: ["cli"],
|
|
8320
|
+
risk: "write",
|
|
8321
|
+
implemented: true
|
|
8322
|
+
},
|
|
8323
|
+
{
|
|
8324
|
+
name: "reply",
|
|
8325
|
+
cost: "1 read + 1 write",
|
|
8326
|
+
summary: "Reply to a comment, nested under it. Goes over Voyager \u2014 a different endpoint from commenting, with the parent named in threadUrn.",
|
|
8327
|
+
usage: 'lnrelay reply <comment-urn> "<text>"',
|
|
8328
|
+
audience: ["cli"],
|
|
8329
|
+
risk: "write",
|
|
8330
|
+
implemented: true
|
|
8331
|
+
},
|
|
8332
|
+
{
|
|
8333
|
+
name: "edit",
|
|
8334
|
+
cost: "1 read + 1 write",
|
|
8335
|
+
summary: "Change the text of a comment or post you wrote, your profile headline or About, or your profile photo or cover image. Its own verb, so a comment urn can never be mistaken for something to comment ON.",
|
|
8336
|
+
usage: 'lnrelay edit <comment-urn | share-urn | ugcPost-urn> "<text>"\n lnrelay edit headline|about ("<text>" | --file <path>)\n lnrelay edit photo|banner <image.png|jpg> (photo square, banner 4:1, max 8 MB)\n A post is edited by the urn it was created as (`share` prints it; `my-posts` lists\n it as shareUrn), not its activity urn. The whole text is replaced. A profile edit\n shows the current text beside the new one, sends every other profile field back as\n LinkedIn holds it, and reads the profile back to confirm. Headline max 220 characters.\n An image is uploaded as it is, uncropped, and read back: it must be the one showing.',
|
|
8337
|
+
audience: ["cli"],
|
|
8338
|
+
risk: "write",
|
|
8339
|
+
implemented: true
|
|
8340
|
+
},
|
|
8341
|
+
{
|
|
8342
|
+
name: "role",
|
|
8343
|
+
cost: "3-4 reads + 1 write",
|
|
8344
|
+
summary: "Add, edit or remove a role in your Experience. Never rewrites your headline; notify network is off unless --notify.",
|
|
8345
|
+
usage: 'lnrelay role add --title "<t>" --company "<c>" --start YYYY-MM [--end YYYY-MM | --current]\n [--location "<l>"] [--description "<d>" | --description-file <path>] [--notify]\n lnrelay role edit <position-id> [any of the flags above]\n lnrelay role remove <position-id>\n Position ids come from `lnrelay experience`. The preview shows the role as it is and\n as it will be; the result is read back from the profile. A role with media attached\n is refused. The company is free text (not linked to a company page).',
|
|
8346
|
+
audience: ["cli"],
|
|
8347
|
+
risk: "write",
|
|
8348
|
+
implemented: true
|
|
8349
|
+
},
|
|
8350
|
+
{
|
|
8351
|
+
name: "skill",
|
|
8352
|
+
cost: "4-5 reads + 1 write",
|
|
8353
|
+
summary: "Add a skill to your profile, or remove one.",
|
|
8354
|
+
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.',
|
|
8355
|
+
audience: ["cli"],
|
|
8356
|
+
risk: "write",
|
|
8357
|
+
implemented: true
|
|
8358
|
+
},
|
|
8359
|
+
{
|
|
8360
|
+
name: "react",
|
|
8361
|
+
cost: "1 call \u2014 write",
|
|
8362
|
+
summary: "React to a post or comment, over LinkedIn's SDUI surface. Reversible with --remove.",
|
|
8363
|
+
usage: "lnrelay react <activity-urn | comment-urn> [--type LIKE|PRAISE|EMPATHY|INTEREST|APPRECIATION|ENTERTAINMENT]\n lnrelay react <urn> --remove # take the reaction back",
|
|
8364
|
+
audience: ["cli"],
|
|
8365
|
+
risk: "write",
|
|
8366
|
+
implemented: true
|
|
7623
8367
|
}
|
|
7624
|
-
|
|
8368
|
+
];
|
|
8369
|
+
var commandNames = COMMANDS.map((c) => c.name);
|
|
8370
|
+
function findCommand(name) {
|
|
8371
|
+
return COMMANDS.find((c) => c.name === name);
|
|
7625
8372
|
}
|
|
7626
|
-
|
|
7627
|
-
const
|
|
7628
|
-
|
|
7629
|
-
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
operation
|
|
7633
|
-
});
|
|
7634
|
-
if (!result.ok) {
|
|
7635
|
-
const out = { ok: false, code: result.code, message: result.message };
|
|
7636
|
-
if (result.hint !== void 0) out.hint = result.hint;
|
|
7637
|
-
return out;
|
|
7638
|
-
}
|
|
7639
|
-
const raw = result.classification.raw ?? "";
|
|
7640
|
-
const errors = responseErrors(raw);
|
|
7641
|
-
if (errors !== null) {
|
|
7642
|
-
return { ok: false, code: "INVALID_INPUT", message: `LinkedIn refused it: ${errors}` };
|
|
8373
|
+
function helpText() {
|
|
8374
|
+
const lines = ["lnrelay \u2014 deep research over LinkedIn from your own account", "", "Commands:"];
|
|
8375
|
+
const width = Math.max(...commandNames.map((n) => n.length));
|
|
8376
|
+
for (const c of COMMANDS) {
|
|
8377
|
+
const flag = c.implemented ? " " : "\xB7";
|
|
8378
|
+
lines.push(` ${flag} ${c.name.padEnd(width)} ${c.summary} [${c.cost}]`);
|
|
7643
8379
|
}
|
|
7644
|
-
|
|
7645
|
-
|
|
7646
|
-
|
|
7647
|
-
const r = await sendAction(form.save, body, client, "profile-save");
|
|
7648
|
-
return typeof r === "string" ? { ok: true } : r;
|
|
8380
|
+
lines.push("", " \xB7 = specified in docs/DESIGN.md, not yet implemented");
|
|
8381
|
+
lines.push("", "Run `lnrelay <command> --help` for usage.");
|
|
8382
|
+
return lines.join("\n");
|
|
7649
8383
|
}
|
|
7650
8384
|
|
|
7651
8385
|
// src/engine/sdui-position.ts
|
|
@@ -7657,38 +8391,38 @@ var POSITION = {
|
|
|
7657
8391
|
save: "com.linkedin.sdui.requests.profile.saveProfilePositionForm",
|
|
7658
8392
|
delete: "com.linkedin.sdui.requests.profile.deleteProfilePositionForm"
|
|
7659
8393
|
};
|
|
7660
|
-
var
|
|
8394
|
+
var EDIT_NAV2 = `{"$type":"proto.sdui.actions.core.NavigateToScreen","screenId":"${POSITION.editScreen}"`;
|
|
7661
8395
|
function listPositions(stream) {
|
|
7662
|
-
if (readModel(stream) === null && !stream.includes(
|
|
7663
|
-
return
|
|
8396
|
+
if (readModel(stream) === null && !stream.includes(EDIT_NAV2) && !stream.includes('"rows"')) {
|
|
8397
|
+
return drift12("the Experience screen could not be read");
|
|
7664
8398
|
}
|
|
7665
8399
|
const positions = [];
|
|
7666
8400
|
const seen = /* @__PURE__ */ new Set();
|
|
7667
8401
|
let i = 0;
|
|
7668
8402
|
for (; ; ) {
|
|
7669
|
-
i = stream.indexOf(
|
|
8403
|
+
i = stream.indexOf(EDIT_NAV2, i);
|
|
7670
8404
|
if (i === -1) break;
|
|
7671
|
-
const
|
|
7672
|
-
i +=
|
|
7673
|
-
if (
|
|
7674
|
-
const payload = JSON.parse(
|
|
8405
|
+
const text7 = balanced(stream, i);
|
|
8406
|
+
i += EDIT_NAV2.length;
|
|
8407
|
+
if (text7 === null) continue;
|
|
8408
|
+
const payload = JSON.parse(text7).requestedArguments?.payload;
|
|
7675
8409
|
const id = payload?.positionId;
|
|
7676
8410
|
if (typeof id !== "string" || seen.has(id) || payload === void 0) continue;
|
|
7677
8411
|
seen.add(id);
|
|
7678
8412
|
positions.push({ positionId: id, title: String(payload.title ?? ""), payload });
|
|
7679
8413
|
}
|
|
7680
8414
|
if (positions.length === 0 && !stream.includes('"rows"') && !stream.includes("Experience")) {
|
|
7681
|
-
return
|
|
8415
|
+
return drift12("the Experience screen listed no roles and did not look like one");
|
|
7682
8416
|
}
|
|
7683
8417
|
return { ok: true, positions };
|
|
7684
8418
|
}
|
|
7685
8419
|
function readPositionForm(stream) {
|
|
7686
8420
|
const model = readModel(stream);
|
|
7687
|
-
if (model === null) return
|
|
8421
|
+
if (model === null) return drift12("the position form carried no initial values");
|
|
7688
8422
|
const media = findRequest(stream, POSITION.media);
|
|
7689
8423
|
const prefix = media?.payload.formIdPrefix;
|
|
7690
8424
|
if (media === null || typeof prefix !== "string") {
|
|
7691
|
-
return
|
|
8425
|
+
return drift12("the position form carried no save step (uploadPositionMedia)");
|
|
7692
8426
|
}
|
|
7693
8427
|
const del = findRequest(stream, POSITION.delete);
|
|
7694
8428
|
return {
|
|
@@ -7739,7 +8473,7 @@ function applyChanges(form, changes) {
|
|
|
7739
8473
|
}
|
|
7740
8474
|
need("dynamicallyCreateHeadline", false);
|
|
7741
8475
|
need("allowProfileEditBroadcasts", changes.notify === true);
|
|
7742
|
-
if (missing.length > 0) return
|
|
8476
|
+
if (missing.length > 0) return drift12(`the position form has no ${missing.join(", ")} field`);
|
|
7743
8477
|
const s = roleSummary(model);
|
|
7744
8478
|
if (!s.current && s.start !== null && s.end !== null && s.end < s.start) {
|
|
7745
8479
|
return {
|
|
@@ -7784,7 +8518,7 @@ function mediaBody(form, model) {
|
|
|
7784
8518
|
}
|
|
7785
8519
|
function saveFromReply(reply) {
|
|
7786
8520
|
const args = findRequest(reply, POSITION.save);
|
|
7787
|
-
return args === null ?
|
|
8521
|
+
return args === null ? drift12("the media step did not hand back the save action") : { ok: true, args };
|
|
7788
8522
|
}
|
|
7789
8523
|
function positionSaveBody(save, model, screen) {
|
|
7790
8524
|
const sending = new Map(model);
|
|
@@ -7796,7 +8530,7 @@ function positionSaveBody(save, model, screen) {
|
|
|
7796
8530
|
}
|
|
7797
8531
|
function deleteBody(form) {
|
|
7798
8532
|
if (form.del === null)
|
|
7799
|
-
return
|
|
8533
|
+
return drift12("this form has no delete action (it is not an existing role)");
|
|
7800
8534
|
const states2 = wireStates(keysOf(form.del), form.model, resolver);
|
|
7801
8535
|
if (!Array.isArray(states2)) return states2;
|
|
7802
8536
|
return { ok: true, body: requestBody(POSITION.delete, form.del, states2, form.screen) };
|
|
@@ -7874,9 +8608,9 @@ async function send(url, body, token, deps) {
|
|
|
7874
8608
|
} catch (e) {
|
|
7875
8609
|
return { ok: false, code: "FETCH_FAILED", message: e.message };
|
|
7876
8610
|
}
|
|
7877
|
-
const
|
|
8611
|
+
const text7 = await res.text();
|
|
7878
8612
|
if (res.status === 201 || res.status === 200) {
|
|
7879
|
-
const id = res.headers.get("x-restli-id") ?? extractId(
|
|
8613
|
+
const id = res.headers.get("x-restli-id") ?? extractId(text7);
|
|
7880
8614
|
return {
|
|
7881
8615
|
ok: true,
|
|
7882
8616
|
id: id ?? "(unknown)",
|
|
@@ -7903,7 +8637,7 @@ async function send(url, body, token, deps) {
|
|
|
7903
8637
|
ok: false,
|
|
7904
8638
|
code: "FETCH_FAILED",
|
|
7905
8639
|
message: `write failed (${res.status})`,
|
|
7906
|
-
hint:
|
|
8640
|
+
hint: text7.slice(0, 300)
|
|
7907
8641
|
};
|
|
7908
8642
|
}
|
|
7909
8643
|
function extractId(body) {
|
|
@@ -7951,7 +8685,7 @@ function feedTypeFor(bindingKey) {
|
|
|
7951
8685
|
function stateKey(prefix, body) {
|
|
7952
8686
|
return `${prefix}-${body}`;
|
|
7953
8687
|
}
|
|
7954
|
-
function states(
|
|
8688
|
+
function states(text7, body) {
|
|
7955
8689
|
return STATE_PREFIXES.map((prefix) => {
|
|
7956
8690
|
const key = stateKey(prefix, body);
|
|
7957
8691
|
const base = {
|
|
@@ -7960,19 +8694,19 @@ function states(text6, body) {
|
|
|
7960
8694
|
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: key } }
|
|
7961
8695
|
};
|
|
7962
8696
|
if (prefix === "commentBoxText") {
|
|
7963
|
-
return { ...base, value:
|
|
8697
|
+
return { ...base, value: text7, originalProtoCase: "stringValue" };
|
|
7964
8698
|
}
|
|
7965
8699
|
if (prefix === "richCommentBoxText") {
|
|
7966
8700
|
return {
|
|
7967
8701
|
...base,
|
|
7968
|
-
value: { text:
|
|
8702
|
+
value: { text: text7, attribute: [], $type: "TextModel", source: "local" },
|
|
7969
8703
|
originalProtoCase: "textModelForWrite"
|
|
7970
8704
|
};
|
|
7971
8705
|
}
|
|
7972
8706
|
return { ...base, value: "", originalProtoCase: "stringValue" };
|
|
7973
8707
|
});
|
|
7974
8708
|
}
|
|
7975
|
-
function commentBody(activityId,
|
|
8709
|
+
function commentBody(activityId, text7, tokens, feedType) {
|
|
7976
8710
|
const body = keyBody(tokens.bindingKey);
|
|
7977
8711
|
const activityUrn = { activityUrn: { activityId } };
|
|
7978
8712
|
const binding2 = (prefix) => ({
|
|
@@ -8019,17 +8753,17 @@ function commentBody(activityId, text6, tokens, feedType) {
|
|
|
8019
8753
|
isStreaming: false,
|
|
8020
8754
|
rumPageKey: ""
|
|
8021
8755
|
},
|
|
8022
|
-
states: states(
|
|
8756
|
+
states: states(text7, body),
|
|
8023
8757
|
requestedArguments: {
|
|
8024
8758
|
...args,
|
|
8025
|
-
states: states(
|
|
8759
|
+
states: states(text7, body),
|
|
8026
8760
|
screenId: SCREEN_ID3,
|
|
8027
8761
|
knownTemplateIds: []
|
|
8028
8762
|
}
|
|
8029
8763
|
};
|
|
8030
8764
|
}
|
|
8031
8765
|
async function comment(confirmed, client) {
|
|
8032
|
-
const { activityId, text:
|
|
8766
|
+
const { activityId, text: text7, tokens } = confirmed.payload;
|
|
8033
8767
|
if (!keyMatchesPost(tokens.bindingKey, activityId)) {
|
|
8034
8768
|
return {
|
|
8035
8769
|
ok: false,
|
|
@@ -8050,7 +8784,7 @@ async function comment(confirmed, client) {
|
|
|
8050
8784
|
const result = await client.request({
|
|
8051
8785
|
url: COMMENT_URL,
|
|
8052
8786
|
method: "POST",
|
|
8053
|
-
body: commentBody(activityId,
|
|
8787
|
+
body: commentBody(activityId, text7, tokens, feedType),
|
|
8054
8788
|
spendClass: "write",
|
|
8055
8789
|
operation: "comment.create"
|
|
8056
8790
|
});
|
|
@@ -8174,10 +8908,10 @@ var REPLY_URL = `https://www.linkedin.com/voyager/api/voyagerSocialDashNormComme
|
|
|
8174
8908
|
function parentThreadUrn(ref) {
|
|
8175
8909
|
return `urn:li:comment:(${ref.threadType}:${ref.activityId},${ref.commentId})`;
|
|
8176
8910
|
}
|
|
8177
|
-
function replyBody(ref,
|
|
8911
|
+
function replyBody(ref, text7) {
|
|
8178
8912
|
return {
|
|
8179
8913
|
commentary: {
|
|
8180
|
-
text:
|
|
8914
|
+
text: text7,
|
|
8181
8915
|
// The captured reply carried a profileMention, because LinkedIn's UI
|
|
8182
8916
|
// pre-fills "@Author " into the box. We send none: an @mention notifies a
|
|
8183
8917
|
// real person, and inventing one would put words — and a notification —
|
|
@@ -8189,11 +8923,11 @@ function replyBody(ref, text6) {
|
|
|
8189
8923
|
};
|
|
8190
8924
|
}
|
|
8191
8925
|
async function replyToComment(confirmed, client) {
|
|
8192
|
-
const { ref, text:
|
|
8926
|
+
const { ref, text: text7 } = confirmed.payload;
|
|
8193
8927
|
const result = await client.request({
|
|
8194
8928
|
url: REPLY_URL,
|
|
8195
8929
|
method: "POST",
|
|
8196
|
-
body: replyBody(ref,
|
|
8930
|
+
body: replyBody(ref, text7),
|
|
8197
8931
|
spendClass: "write",
|
|
8198
8932
|
operation: "reply"
|
|
8199
8933
|
});
|
|
@@ -8908,10 +9642,10 @@ function sharePlan(p) {
|
|
|
8908
9642
|
transport: p.transport
|
|
8909
9643
|
};
|
|
8910
9644
|
}
|
|
8911
|
-
function cardLines(
|
|
8912
|
-
if (
|
|
8913
|
-
if (
|
|
8914
|
-
return [`card "${
|
|
9645
|
+
function cardLines(card2) {
|
|
9646
|
+
if (card2 === void 0) return [];
|
|
9647
|
+
if (card2 === null) return ["card none \u2014 LinkedIn has no preview for this link"];
|
|
9648
|
+
return [`card "${card2.title}" (${card2.source})`];
|
|
8915
9649
|
}
|
|
8916
9650
|
var liveCardLookup = (url, session) => fetchLinkCard(url, createLiveClient(session));
|
|
8917
9651
|
function shareNeeds(files, scheduledAt, poll, cardUrl) {
|
|
@@ -9012,8 +9746,8 @@ function whenLine(at, now) {
|
|
|
9012
9746
|
const away = hours < 48 ? `in ${hours} h` : `in ${Math.round(hours / 24)} days`;
|
|
9013
9747
|
return `when ${local} (${zone}) \u2014 ${away}`;
|
|
9014
9748
|
}
|
|
9015
|
-
async function runShare(
|
|
9016
|
-
if (
|
|
9749
|
+
async function runShare(text7, visibility, now = Date.now(), deps = terminalDeps(), via2, media, at, poll, link = {}) {
|
|
9750
|
+
if (text7 === void 0 || text7.trim() === "") {
|
|
9017
9751
|
return err("share", "INVALID_INPUT", "text is required", 'lnrelay share "<text>"');
|
|
9018
9752
|
}
|
|
9019
9753
|
const vis = visibility === "connections" ? "CONNECTIONS" : "PUBLIC";
|
|
@@ -9028,21 +9762,21 @@ async function runShare(text6, visibility, now = Date.now(), deps = terminalDeps
|
|
|
9028
9762
|
via: via2
|
|
9029
9763
|
});
|
|
9030
9764
|
if (pollSpec !== void 0 && "ok" in pollSpec) return pollSpec;
|
|
9031
|
-
const cardUrl = link.card !== false && loaded === void 0 && pollSpec === void 0 && via2 !== "oauth" ? firstUrl(
|
|
9765
|
+
const cardUrl = link.card !== false && loaded === void 0 && pollSpec === void 0 && via2 !== "oauth" ? firstUrl(text7) : null;
|
|
9032
9766
|
const needs = shareNeeds(loaded?.approved.length, scheduledAt, pollSpec, cardUrl);
|
|
9033
9767
|
const ctx = prepare("share", now, needs.voyagerOnly ? "voyager" : via2, needs.calls);
|
|
9034
9768
|
if ("ok" in ctx) return ctx;
|
|
9035
|
-
const
|
|
9036
|
-
if (
|
|
9769
|
+
const card2 = await cardFor(cardUrl, ctx.transport, link);
|
|
9770
|
+
if (card2 !== void 0 && card2 !== null && "ok" in card2) return card2;
|
|
9037
9771
|
const plan = sharePlan({
|
|
9038
9772
|
author: authorLine(ctx.transport),
|
|
9039
9773
|
transport: ctx.transport.kind,
|
|
9040
|
-
text:
|
|
9774
|
+
text: text7,
|
|
9041
9775
|
visibility: vis,
|
|
9042
9776
|
media: loaded?.approved,
|
|
9043
9777
|
scheduledAt,
|
|
9044
9778
|
poll: pollSpec,
|
|
9045
|
-
...
|
|
9779
|
+
...card2 === void 0 ? {} : { card: card2 },
|
|
9046
9780
|
now
|
|
9047
9781
|
});
|
|
9048
9782
|
const gated = await gate("share", plan, ctx, deps);
|
|
@@ -9060,7 +9794,7 @@ async function runShare(text6, visibility, now = Date.now(), deps = terminalDeps
|
|
|
9060
9794
|
note: "note" in result ? result.note : ctx.note
|
|
9061
9795
|
});
|
|
9062
9796
|
}
|
|
9063
|
-
async function runEditPost(urn,
|
|
9797
|
+
async function runEditPost(urn, text7, now, deps) {
|
|
9064
9798
|
const unapprovable = refuseUnapprovable("edit", "editing", deps);
|
|
9065
9799
|
if (unapprovable !== null) return unapprovable;
|
|
9066
9800
|
const ctx = prepare("edit", now, "voyager");
|
|
@@ -9075,12 +9809,12 @@ async function runEditPost(urn, text6, now, deps) {
|
|
|
9075
9809
|
const before = await lookup(urn, true);
|
|
9076
9810
|
const plan = {
|
|
9077
9811
|
action: "edit your post",
|
|
9078
|
-
payload: { urn, text:
|
|
9812
|
+
payload: { urn, text: text7 },
|
|
9079
9813
|
summary: [
|
|
9080
9814
|
authorLine(ctx.transport),
|
|
9081
9815
|
`post ${urn}`,
|
|
9082
9816
|
...previewLines2(before).map((l) => l.replace(/^content /, "was ")),
|
|
9083
|
-
`new text "${
|
|
9817
|
+
`new text "${text7}"`
|
|
9084
9818
|
],
|
|
9085
9819
|
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",
|
|
9086
9820
|
transport: "voyager"
|
|
@@ -9104,7 +9838,7 @@ function liveProfile(session) {
|
|
|
9104
9838
|
};
|
|
9105
9839
|
}
|
|
9106
9840
|
var PROFILE_HINT = `profile fields: ${Object.keys(PROFILE_FIELDS).join(", ")}`;
|
|
9107
|
-
async function runEditProfile(name,
|
|
9841
|
+
async function runEditProfile(name, text7, now = Date.now(), deps = terminalDeps(), surface) {
|
|
9108
9842
|
const field = PROFILE_FIELDS[name];
|
|
9109
9843
|
if (field === void 0) {
|
|
9110
9844
|
return err(
|
|
@@ -9114,7 +9848,7 @@ async function runEditProfile(name, text6, now = Date.now(), deps = terminalDeps
|
|
|
9114
9848
|
PROFILE_HINT
|
|
9115
9849
|
);
|
|
9116
9850
|
}
|
|
9117
|
-
if (
|
|
9851
|
+
if (text7 === void 0 || text7.trim() === "") {
|
|
9118
9852
|
return err(
|
|
9119
9853
|
"edit",
|
|
9120
9854
|
"INVALID_INPUT",
|
|
@@ -9122,11 +9856,11 @@ async function runEditProfile(name, text6, now = Date.now(), deps = terminalDeps
|
|
|
9122
9856
|
`lnrelay edit ${name} "<text>"`
|
|
9123
9857
|
);
|
|
9124
9858
|
}
|
|
9125
|
-
if (
|
|
9859
|
+
if (text7.length > field.maxLength) {
|
|
9126
9860
|
return err(
|
|
9127
9861
|
"edit",
|
|
9128
9862
|
"INVALID_INPUT",
|
|
9129
|
-
`the ${name} is ${
|
|
9863
|
+
`the ${name} is ${text7.length} characters; LinkedIn allows ${field.maxLength}`
|
|
9130
9864
|
);
|
|
9131
9865
|
}
|
|
9132
9866
|
const unapprovable = refuseUnapprovable("edit", "editing", deps);
|
|
@@ -9142,19 +9876,19 @@ async function runEditProfile(name, text6, now = Date.now(), deps = terminalDeps
|
|
|
9142
9876
|
const form = await profile.open(field, me.vanity);
|
|
9143
9877
|
if (!form.ok) return err("edit", form.code, form.message, form.hint);
|
|
9144
9878
|
const was = currentValue(form, field) ?? "";
|
|
9145
|
-
if (was ===
|
|
9879
|
+
if (was === text7) {
|
|
9146
9880
|
return err("edit", "INVALID_INPUT", `your ${name} already reads exactly that; nothing to save`);
|
|
9147
9881
|
}
|
|
9148
|
-
const built = saveBody(form, field,
|
|
9882
|
+
const built = saveBody(form, field, text7);
|
|
9149
9883
|
if (!built.ok) return err("edit", built.code, built.message, built.hint);
|
|
9150
9884
|
const plan = {
|
|
9151
9885
|
action: `change your ${name}`,
|
|
9152
|
-
payload: { field: name, was, text:
|
|
9886
|
+
payload: { field: name, was, text: text7 },
|
|
9153
9887
|
summary: [
|
|
9154
9888
|
authorLine(ctx.transport),
|
|
9155
9889
|
`field ${name}`,
|
|
9156
9890
|
`was "${was}"`,
|
|
9157
|
-
`new "${
|
|
9891
|
+
`new "${text7}"`
|
|
9158
9892
|
],
|
|
9159
9893
|
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.",
|
|
9160
9894
|
transport: "voyager"
|
|
@@ -9165,7 +9899,7 @@ async function runEditProfile(name, text6, now = Date.now(), deps = terminalDeps
|
|
|
9165
9899
|
if (!sent.ok) return err("edit", sent.code, sent.message, sent.hint);
|
|
9166
9900
|
const after = await profile.open(field, me.vanity);
|
|
9167
9901
|
const reads = after.ok ? currentValue(after, field) : void 0;
|
|
9168
|
-
if (reads !==
|
|
9902
|
+
if (reads !== text7) {
|
|
9169
9903
|
return err(
|
|
9170
9904
|
"edit",
|
|
9171
9905
|
"SCHEMA_DRIFT",
|
|
@@ -9204,8 +9938,8 @@ async function harvest(activityId, session, now) {
|
|
|
9204
9938
|
if (!found.ok) return err("comment", "SCHEMA_DRIFT", found.message, found.hint);
|
|
9205
9939
|
return { ok: true, tokens: { bindingKey: found.bindingKey, trackingId: found.trackingId } };
|
|
9206
9940
|
}
|
|
9207
|
-
async function runComment(postUrn2,
|
|
9208
|
-
if (postUrn2 === void 0 ||
|
|
9941
|
+
async function runComment(postUrn2, text7, now = Date.now(), deps = terminalDeps()) {
|
|
9942
|
+
if (postUrn2 === void 0 || text7 === void 0 || text7.trim() === "") {
|
|
9209
9943
|
return err(
|
|
9210
9944
|
"comment",
|
|
9211
9945
|
"INVALID_INPUT",
|
|
@@ -9242,11 +9976,11 @@ async function runComment(postUrn2, text6, now = Date.now(), deps = terminalDeps
|
|
|
9242
9976
|
if (!("tokens" in harvested)) return harvested;
|
|
9243
9977
|
const plan = {
|
|
9244
9978
|
action: "comment on a post",
|
|
9245
|
-
payload: { activityId, text:
|
|
9979
|
+
payload: { activityId, text: text7, tokens: harvested.tokens },
|
|
9246
9980
|
// The harvested trackingId changes on every render, so --plan and --confirm
|
|
9247
9981
|
// would never agree on a token derived from it. The intent is what's approved.
|
|
9248
|
-
tokenBasis: { activityId, text:
|
|
9249
|
-
summary: [authorLine(ctx.transport), `on ${postUrn2}`, `content "${
|
|
9982
|
+
tokenBasis: { activityId, text: text7 },
|
|
9983
|
+
summary: [authorLine(ctx.transport), `on ${postUrn2}`, `content "${text7}"`],
|
|
9250
9984
|
reversibility: "deletable with `lnrelay delete <comment-urn>`; the author is notified immediately",
|
|
9251
9985
|
transport: "voyager"
|
|
9252
9986
|
};
|
|
@@ -9258,8 +9992,8 @@ async function runComment(postUrn2, text6, now = Date.now(), deps = terminalDeps
|
|
|
9258
9992
|
);
|
|
9259
9993
|
return result.ok ? ok("comment", { on: postUrn2 }) : err("comment", result.code, result.message, result.hint);
|
|
9260
9994
|
}
|
|
9261
|
-
async function runEdit(commentUrn,
|
|
9262
|
-
if (commentUrn === void 0 ||
|
|
9995
|
+
async function runEdit(commentUrn, text7, now = Date.now(), deps = terminalDeps()) {
|
|
9996
|
+
if (commentUrn === void 0 || text7 === void 0 || text7.trim() === "") {
|
|
9263
9997
|
return err(
|
|
9264
9998
|
"edit",
|
|
9265
9999
|
"INVALID_INPUT",
|
|
@@ -9268,15 +10002,15 @@ async function runEdit(commentUrn, text6, now = Date.now(), deps = terminalDeps(
|
|
|
9268
10002
|
);
|
|
9269
10003
|
}
|
|
9270
10004
|
if (commentUrn === "photo" || commentUrn === "banner") {
|
|
9271
|
-
return runEditImage(commentUrn,
|
|
10005
|
+
return runEditImage(commentUrn, text7, now, deps);
|
|
9272
10006
|
}
|
|
9273
10007
|
const ref = parseCommentUrn(commentUrn);
|
|
9274
10008
|
if (ref === null && !commentUrn.startsWith("urn:")) {
|
|
9275
|
-
return runEditProfile(commentUrn,
|
|
10009
|
+
return runEditProfile(commentUrn, text7, now, deps);
|
|
9276
10010
|
}
|
|
9277
10011
|
if (ref === null) {
|
|
9278
10012
|
if (/^urn:li:(share|ugcPost):\d+$/.test(commentUrn)) {
|
|
9279
|
-
return runEditPost(commentUrn,
|
|
10013
|
+
return runEditPost(commentUrn, text7, now, deps);
|
|
9280
10014
|
}
|
|
9281
10015
|
return err(
|
|
9282
10016
|
"edit",
|
|
@@ -9296,8 +10030,8 @@ async function runEdit(commentUrn, text6, now = Date.now(), deps = terminalDeps(
|
|
|
9296
10030
|
if (!("tokens" in harvested)) return harvested;
|
|
9297
10031
|
const plan = {
|
|
9298
10032
|
action: "edit your comment",
|
|
9299
|
-
payload: { urn: commentUrn, text:
|
|
9300
|
-
summary: [authorLine(ctx.transport), `comment ${commentUrn}`, `new text "${
|
|
10033
|
+
payload: { urn: commentUrn, text: text7 },
|
|
10034
|
+
summary: [authorLine(ctx.transport), `comment ${commentUrn}`, `new text "${text7}"`],
|
|
9301
10035
|
reversibility: "editable again, but the previous text is NOT recoverable here and LinkedIn marks the comment as edited",
|
|
9302
10036
|
transport: "voyager"
|
|
9303
10037
|
};
|
|
@@ -9308,7 +10042,7 @@ async function runEdit(commentUrn, text6, now = Date.now(), deps = terminalDeps(
|
|
|
9308
10042
|
UPDATE_OP,
|
|
9309
10043
|
harvested.tokens.trackingId,
|
|
9310
10044
|
createLiveClient(ctx.transport.session),
|
|
9311
|
-
|
|
10045
|
+
text7
|
|
9312
10046
|
);
|
|
9313
10047
|
return result.ok ? ok("edit", { edited: commentUrn }) : err("edit", result.code, result.message, result.hint);
|
|
9314
10048
|
}
|
|
@@ -9352,8 +10086,8 @@ async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps(),
|
|
|
9352
10086
|
const result = await react(gated.confirmed, createLiveClient(ctx.transport.session));
|
|
9353
10087
|
return result.ok ? ok("react", { id: result.id, removed: remove }) : err("react", result.code, result.message, result.hint);
|
|
9354
10088
|
}
|
|
9355
|
-
async function runReply(commentUrn,
|
|
9356
|
-
if (commentUrn === void 0 ||
|
|
10089
|
+
async function runReply(commentUrn, text7, now = Date.now(), deps = terminalDeps()) {
|
|
10090
|
+
if (commentUrn === void 0 || text7 === void 0 || text7.trim() === "") {
|
|
9357
10091
|
return err(
|
|
9358
10092
|
"reply",
|
|
9359
10093
|
"INVALID_INPUT",
|
|
@@ -9379,8 +10113,8 @@ async function runReply(commentUrn, text6, now = Date.now(), deps = terminalDeps
|
|
|
9379
10113
|
}
|
|
9380
10114
|
const plan = {
|
|
9381
10115
|
action: "reply to a comment",
|
|
9382
|
-
payload: { ref: parent, text:
|
|
9383
|
-
summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${
|
|
10116
|
+
payload: { ref: parent, text: text7 },
|
|
10117
|
+
summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${text7}"`],
|
|
9384
10118
|
reversibility: "deletable with `lnrelay delete <the reply urn>`; the comment author is notified immediately",
|
|
9385
10119
|
transport: "voyager"
|
|
9386
10120
|
};
|
|
@@ -9802,149 +10536,6 @@ async function runFindFilters(kind, req, opts = {}, fetch2) {
|
|
|
9802
10536
|
});
|
|
9803
10537
|
}
|
|
9804
10538
|
|
|
9805
|
-
// src/engine/sdui-skill.ts
|
|
9806
|
-
var SKILL = {
|
|
9807
|
-
addScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillAddForm",
|
|
9808
|
-
editScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillDetailsEditForm",
|
|
9809
|
-
listScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillDetails",
|
|
9810
|
-
pager: "com.linkedin.sdui.pagers.profile.details.skills",
|
|
9811
|
-
save: "com.linkedin.sdui.requests.profile.saveProfileSkillForm",
|
|
9812
|
-
delete: "com.linkedin.sdui.requests.profile.deleteProfileSkillForm"
|
|
9813
|
-
};
|
|
9814
|
-
var EDIT_NAV2 = `{"$type":"proto.sdui.actions.core.NavigateToScreen","screenId":"${SKILL.editScreen}"`;
|
|
9815
|
-
var TEXT3 = /"children":\["((?:[^"\\]|\\.)*)"\]/g;
|
|
9816
|
-
function skillsFromPage(stream) {
|
|
9817
|
-
if (!stream.includes(SKILL.pager) && !stream.includes(EDIT_NAV2) && !stream.includes("isPartialPage")) {
|
|
9818
|
-
return drift9("the skills page could not be read");
|
|
9819
|
-
}
|
|
9820
|
-
const skills = [];
|
|
9821
|
-
let from = 0;
|
|
9822
|
-
let i = 0;
|
|
9823
|
-
for (; ; ) {
|
|
9824
|
-
i = stream.indexOf(EDIT_NAV2, i);
|
|
9825
|
-
if (i === -1) break;
|
|
9826
|
-
const text6 = balanced(stream, i);
|
|
9827
|
-
const end = i;
|
|
9828
|
-
i += EDIT_NAV2.length;
|
|
9829
|
-
if (text6 === null) continue;
|
|
9830
|
-
const payload = JSON.parse(text6).requestedArguments?.payload;
|
|
9831
|
-
const id = payload?.skillId;
|
|
9832
|
-
if (typeof id !== "string" || payload === void 0 || skills.some((s) => s.skillId === id))
|
|
9833
|
-
continue;
|
|
9834
|
-
const names = [...stream.slice(from, end).matchAll(TEXT3)].map(
|
|
9835
|
-
(m) => JSON.parse(`"${m[1]}"`)
|
|
9836
|
-
);
|
|
9837
|
-
skills.push({ skillId: id, name: names.length === 1 ? names[0] ?? null : null, payload });
|
|
9838
|
-
from = end + text6.length;
|
|
9839
|
-
}
|
|
9840
|
-
return { ok: true, skills };
|
|
9841
|
-
}
|
|
9842
|
-
function pagerFrom(payload, start) {
|
|
9843
|
-
const args = {
|
|
9844
|
-
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
9845
|
-
requestedStateKeys: [],
|
|
9846
|
-
payload: { ...payload, start },
|
|
9847
|
-
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
9848
|
-
};
|
|
9849
|
-
return {
|
|
9850
|
-
pagerId: SKILL.pager,
|
|
9851
|
-
clientArguments: { ...args, states: [], screenId: SKILL.listScreen, knownTemplateIds: [] },
|
|
9852
|
-
paginationRequest: {
|
|
9853
|
-
$type: "proto.sdui.actions.requests.PaginationRequest",
|
|
9854
|
-
pagerId: SKILL.pager,
|
|
9855
|
-
retryCount: 0,
|
|
9856
|
-
requestedArguments: args
|
|
9857
|
-
}
|
|
9858
|
-
};
|
|
9859
|
-
}
|
|
9860
|
-
function readSkillForm(stream) {
|
|
9861
|
-
const model = readModel(stream);
|
|
9862
|
-
if (model === null) return drift9("the skill form carried no initial values");
|
|
9863
|
-
const save = findRequest(stream, SKILL.save);
|
|
9864
|
-
const del = findRequest(stream, SKILL.delete);
|
|
9865
|
-
if (save === null && del === null)
|
|
9866
|
-
return drift9("the skill form carried neither a save nor a delete");
|
|
9867
|
-
return { ok: true, model, save, del, screen: del === null ? SKILL.addScreen : SKILL.editScreen };
|
|
9868
|
-
}
|
|
9869
|
-
var nameKey = (model) => [...model.keys()].find((k) => k.startsWith("addSkillsTypeaheadSkillName"));
|
|
9870
|
-
function skillNameOf(form) {
|
|
9871
|
-
const key = nameKey(form.model);
|
|
9872
|
-
const v = key === void 0 ? void 0 : form.model.get(key)?.value;
|
|
9873
|
-
return typeof v === "string" ? v : null;
|
|
9874
|
-
}
|
|
9875
|
-
function addSkillBody(form, name) {
|
|
9876
|
-
if (name.trim() === "")
|
|
9877
|
-
return { ok: false, code: "INVALID_INPUT", message: "a skill needs a name" };
|
|
9878
|
-
if (form.save === null) return drift9("this form has no save action (it is not the add form)");
|
|
9879
|
-
const key = nameKey(form.model);
|
|
9880
|
-
const current = key === void 0 ? void 0 : form.model.get(key);
|
|
9881
|
-
if (key === void 0 || current === void 0) return drift9("the skill form has no name field");
|
|
9882
|
-
const model = new Map(form.model);
|
|
9883
|
-
model.set(key, { ...current, value: name.trim() });
|
|
9884
|
-
const states2 = wireStates(keysOf(form.save), model, () => void 0);
|
|
9885
|
-
if (!Array.isArray(states2)) return states2;
|
|
9886
|
-
return { ok: true, body: requestBody(SKILL.save, form.save, states2, form.screen) };
|
|
9887
|
-
}
|
|
9888
|
-
function removeSkillBody(form) {
|
|
9889
|
-
if (form.del === null)
|
|
9890
|
-
return drift9("this form has no delete action (it is not an existing skill)");
|
|
9891
|
-
const states2 = wireStates(keysOf(form.del), form.model, () => void 0);
|
|
9892
|
-
if (!Array.isArray(states2)) return states2;
|
|
9893
|
-
return { ok: true, body: requestBody(SKILL.delete, form.del, states2, form.screen) };
|
|
9894
|
-
}
|
|
9895
|
-
var PAGER_URL2 = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${SKILL.pager}`;
|
|
9896
|
-
var MAX_PAGES2 = 10;
|
|
9897
|
-
async function fetchSkills(vanityName, client) {
|
|
9898
|
-
const screen = await openForm(
|
|
9899
|
-
SKILL.listScreen,
|
|
9900
|
-
{ vanityName, isVanityNameResolved: true },
|
|
9901
|
-
client,
|
|
9902
|
-
"skills-screen"
|
|
9903
|
-
);
|
|
9904
|
-
if (typeof screen !== "string") return screen;
|
|
9905
|
-
const at = screen.indexOf('"filter":"ProfileSkillCategory_ALL"');
|
|
9906
|
-
const open = at === -1 ? -1 : screen.lastIndexOf('"payload":{', at);
|
|
9907
|
-
const text6 = open === -1 ? null : balanced(screen, open + '"payload":'.length);
|
|
9908
|
-
if (text6 === null) return drift9("the Skills screen carried no list request");
|
|
9909
|
-
const payload = JSON.parse(text6);
|
|
9910
|
-
const count3 = typeof payload.count === "number" ? payload.count : 10;
|
|
9911
|
-
const skills = [];
|
|
9912
|
-
for (let page = 0; page < MAX_PAGES2; page++) {
|
|
9913
|
-
const result = await client.request({
|
|
9914
|
-
url: PAGER_URL2,
|
|
9915
|
-
method: "POST",
|
|
9916
|
-
body: pagerFrom(payload, skills.length),
|
|
9917
|
-
spendClass: "page",
|
|
9918
|
-
operation: "skills"
|
|
9919
|
-
});
|
|
9920
|
-
if (!result.ok) return { ok: false, code: result.code, message: result.message };
|
|
9921
|
-
const parsed = skillsFromPage(result.classification.raw ?? "");
|
|
9922
|
-
if (!parsed.ok) return parsed;
|
|
9923
|
-
const fresh = parsed.skills.filter((s) => !skills.some((k) => k.skillId === s.skillId));
|
|
9924
|
-
skills.push(...fresh);
|
|
9925
|
-
if (parsed.skills.length < count3 || fresh.length === 0) break;
|
|
9926
|
-
}
|
|
9927
|
-
return { ok: true, skills };
|
|
9928
|
-
}
|
|
9929
|
-
async function openSkillForm(payload, client, edit2) {
|
|
9930
|
-
const stream = await openForm(
|
|
9931
|
-
edit2 ? SKILL.editScreen : SKILL.addScreen,
|
|
9932
|
-
{ ...payload, isVanityNameResolved: true },
|
|
9933
|
-
client,
|
|
9934
|
-
edit2 ? "skill-edit-form" : "skill-add-form"
|
|
9935
|
-
);
|
|
9936
|
-
return typeof stream === "string" ? readSkillForm(stream) : stream;
|
|
9937
|
-
}
|
|
9938
|
-
async function sendSkill(body, requestId, client) {
|
|
9939
|
-
const sent = await sendAction(
|
|
9940
|
-
requestId,
|
|
9941
|
-
body,
|
|
9942
|
-
client,
|
|
9943
|
-
requestId === SKILL.save ? "skill-add" : "skill-remove"
|
|
9944
|
-
);
|
|
9945
|
-
return typeof sent === "string" ? { ok: true } : sent;
|
|
9946
|
-
}
|
|
9947
|
-
|
|
9948
10539
|
// src/commands/skill.ts
|
|
9949
10540
|
function liveSkills(session, quiet = false) {
|
|
9950
10541
|
const client = createLiveClient(session, void 0, quiet);
|
|
@@ -10200,13 +10791,15 @@ async function runSync(source, limit, force, now = Date.now()) {
|
|
|
10200
10791
|
var SERVER_REQUEST = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
10201
10792
|
var VIEWERS_URL = `${SERVER_REQUEST}?sduiid=WvmpEntityList`;
|
|
10202
10793
|
var VIEW_TOTALS_URL = `${SERVER_REQUEST}?sduiid=WvmpAnalytics`;
|
|
10794
|
+
var VIEWERS_REFERER = "https://www.linkedin.com/analytics/profile-views/";
|
|
10795
|
+
var VIEW_RANGES = [7, 14, 28, 90, 365];
|
|
10203
10796
|
var RANGE = "WvmpSearchFilterType_DATE_RANGE";
|
|
10204
10797
|
var META2 = { $type: "proto.sdui.common.RequestMetadata" };
|
|
10205
|
-
function serverRequest2(requestId, stateKey3, payload) {
|
|
10798
|
+
function serverRequest2(requestId, stateKey3, payload, days) {
|
|
10206
10799
|
const state2 = {
|
|
10207
10800
|
key: stateKey3,
|
|
10208
10801
|
namespace: "MemoryNamespace",
|
|
10209
|
-
value: [],
|
|
10802
|
+
value: days === void 0 ? [] : [`WvmpSearchFilterTimeRange_LAST_${days}_DAYS`],
|
|
10210
10803
|
originalProtoCase: "stringListValue",
|
|
10211
10804
|
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: stateKey3 } }
|
|
10212
10805
|
};
|
|
@@ -10238,40 +10831,48 @@ function serverRequest2(requestId, stateKey3, payload) {
|
|
|
10238
10831
|
}
|
|
10239
10832
|
};
|
|
10240
10833
|
}
|
|
10241
|
-
function viewersBody() {
|
|
10242
|
-
return serverRequest2(
|
|
10243
|
-
|
|
10244
|
-
|
|
10834
|
+
function viewersBody(days) {
|
|
10835
|
+
return serverRequest2(
|
|
10836
|
+
"WvmpEntityList",
|
|
10837
|
+
`entityListQueryFilterPrefix${RANGE}`,
|
|
10838
|
+
{ sortType: "ProfileViewSortType_TIME_DESCENDING" },
|
|
10839
|
+
days
|
|
10840
|
+
);
|
|
10245
10841
|
}
|
|
10246
|
-
function viewTotalsBody() {
|
|
10247
|
-
return serverRequest2(
|
|
10248
|
-
|
|
10249
|
-
|
|
10250
|
-
|
|
10251
|
-
|
|
10252
|
-
|
|
10253
|
-
|
|
10254
|
-
|
|
10255
|
-
|
|
10256
|
-
|
|
10842
|
+
function viewTotalsBody(days) {
|
|
10843
|
+
return serverRequest2(
|
|
10844
|
+
"WvmpAnalytics",
|
|
10845
|
+
`analyticsFieldsFilterPrefix${RANGE}`,
|
|
10846
|
+
{
|
|
10847
|
+
highlightCardDimensions: [
|
|
10848
|
+
"DimensionType_LOCATION",
|
|
10849
|
+
"DimensionType_INDUSTRY",
|
|
10850
|
+
"DimensionType_ORGANIZATION"
|
|
10851
|
+
],
|
|
10852
|
+
detailsCardDimensions: ["DimensionType_ORGANIZATION"],
|
|
10853
|
+
highlightCardResultCount: 4,
|
|
10854
|
+
detailsCardResultCount: 23
|
|
10855
|
+
},
|
|
10856
|
+
days
|
|
10857
|
+
);
|
|
10257
10858
|
}
|
|
10258
|
-
var
|
|
10259
|
-
var
|
|
10260
|
-
var
|
|
10859
|
+
var drift13 = (message) => ({ ok: false, code: "SCHEMA_DRIFT", message });
|
|
10860
|
+
var unquote4 = (s) => JSON.parse(`"${s}"`);
|
|
10861
|
+
var STR2 = '((?:[^"\\\\]|\\\\.)+)';
|
|
10261
10862
|
var ITEM = /"viewName":"viewer-list-item"(?:,"impressionThresholds":\[[^\]]*\])?[^{}]*"semanticPosition"/;
|
|
10262
|
-
var TEXT_PROPS = /"textProps":\{"fontFamily":"[^"]*","fontSize":"(\w+)","fontStyle":"[^"]*","fontWeight":"(\w+)"
|
|
10263
|
-
var OWN_TEXT = new RegExp(`^\\["${
|
|
10264
|
-
var NESTED_TEXT = new RegExp(`\\[null,"${
|
|
10265
|
-
var LINK2 = new RegExp(`"urlValue":\\{"\\$case":"url","url":"${
|
|
10863
|
+
var TEXT_PROPS = /"textProps":\{"fontFamily":"[^"]*","fontSize":"(\w+)","fontStyle":"[^"]*","fontWeight":"(\w+)"(?:,"\w+":"[^"]*")*?,"children":/g;
|
|
10864
|
+
var OWN_TEXT = new RegExp(`^\\["${STR2}"\\]`);
|
|
10865
|
+
var NESTED_TEXT = new RegExp(`\\[null,"${STR2}"`);
|
|
10866
|
+
var LINK2 = new RegExp(`"urlValue":\\{"\\$case":"url","url":"${STR2}"`);
|
|
10266
10867
|
var PROFILE_ID2 = /ACoA[A-Za-z0-9_-]{10,}/;
|
|
10267
|
-
var PLAIN_TEXT = new RegExp(`"children":\\["${
|
|
10868
|
+
var PLAIN_TEXT = new RegExp(`"children":\\["${STR2}"\\]`, "g");
|
|
10268
10869
|
function textsOf(row) {
|
|
10269
10870
|
return [...row.matchAll(TEXT_PROPS)].flatMap((m) => {
|
|
10270
10871
|
const after = row.slice((m.index ?? 0) + m[0].length, (m.index ?? 0) + m[0].length + 600);
|
|
10271
10872
|
const raw = after.match(OWN_TEXT)?.[1] ?? after.match(NESTED_TEXT)?.[1];
|
|
10272
10873
|
if (raw === void 0) return [];
|
|
10273
|
-
const
|
|
10274
|
-
return
|
|
10874
|
+
const text7 = unquote4(raw).trim();
|
|
10875
|
+
return text7 === "" ? [] : [{ size: m[1], weight: m[2], text: text7 }];
|
|
10275
10876
|
});
|
|
10276
10877
|
}
|
|
10277
10878
|
function viewerOf(row, id) {
|
|
@@ -10284,7 +10885,7 @@ function viewerOf(row, id) {
|
|
|
10284
10885
|
const lines = rest.filter((t) => t !== degreeText);
|
|
10285
10886
|
const viewed = lines.at(-1);
|
|
10286
10887
|
const link = row.match(LINK2)?.[1];
|
|
10287
|
-
const url = link === void 0 ? void 0 :
|
|
10888
|
+
const url = link === void 0 ? void 0 : unquote4(link);
|
|
10288
10889
|
if (url === void 0 || !/linkedin\.com\/in\//.test(url)) {
|
|
10289
10890
|
const v = { anonymous: true, description: first };
|
|
10290
10891
|
if (viewed !== void 0) v.viewed = viewed;
|
|
@@ -10302,7 +10903,7 @@ function viewerOf(row, id) {
|
|
|
10302
10903
|
...viewed !== void 0 ? { viewed } : {}
|
|
10303
10904
|
};
|
|
10304
10905
|
}
|
|
10305
|
-
var
|
|
10906
|
+
var REF2 = /"\$[LQ]?([0-9a-f]+)"/g;
|
|
10306
10907
|
function idUnder(rows, ref, items) {
|
|
10307
10908
|
const seen = /* @__PURE__ */ new Set([ref]);
|
|
10308
10909
|
const queue = [ref];
|
|
@@ -10310,7 +10911,7 @@ function idUnder(rows, ref, items) {
|
|
|
10310
10911
|
const row = rows.byId.get(queue.shift()) ?? "";
|
|
10311
10912
|
const id = row.match(PROFILE_ID2)?.[0];
|
|
10312
10913
|
if (id !== void 0) return id;
|
|
10313
|
-
for (const m of row.matchAll(
|
|
10914
|
+
for (const m of row.matchAll(REF2)) {
|
|
10314
10915
|
const next = m[1];
|
|
10315
10916
|
if (!seen.has(next) && !items.has(next) && rows.byId.has(next)) {
|
|
10316
10917
|
seen.add(next);
|
|
@@ -10324,32 +10925,37 @@ function idsByViewer(rows, items) {
|
|
|
10324
10925
|
const ids = /* @__PURE__ */ new Map();
|
|
10325
10926
|
for (const row of rows.byId.values()) {
|
|
10326
10927
|
let current;
|
|
10327
|
-
|
|
10928
|
+
let from = 0;
|
|
10929
|
+
const settle = (id) => {
|
|
10930
|
+
if (current !== void 0 && id !== void 0 && !ids.has(current)) ids.set(current, id);
|
|
10931
|
+
};
|
|
10932
|
+
for (const m of row.matchAll(REF2)) {
|
|
10328
10933
|
const ref = m[1];
|
|
10934
|
+
const at = m.index ?? 0;
|
|
10935
|
+
settle(row.slice(from, at).match(PROFILE_ID2)?.[0]);
|
|
10936
|
+
from = at + m[0].length;
|
|
10329
10937
|
if (items.has(ref)) current = ref;
|
|
10330
|
-
else if (current !== void 0 && !ids.has(current))
|
|
10331
|
-
const id = idUnder(rows, ref, items);
|
|
10332
|
-
if (id !== void 0) ids.set(current, id);
|
|
10333
|
-
}
|
|
10938
|
+
else if (current !== void 0 && !ids.has(current)) settle(idUnder(rows, ref, items));
|
|
10334
10939
|
}
|
|
10940
|
+
settle(row.slice(from).match(PROFILE_ID2)?.[0]);
|
|
10335
10941
|
}
|
|
10336
10942
|
return ids;
|
|
10337
10943
|
}
|
|
10338
10944
|
function parseViewers(stream) {
|
|
10339
10945
|
if (!stream.includes('"viewName":"viewer-list"'))
|
|
10340
|
-
return
|
|
10946
|
+
return drift13("the profile viewers answer was not the viewer list");
|
|
10341
10947
|
const rows = new Rows(stream);
|
|
10342
10948
|
const items = new Set([...rows.byId].filter(([, row]) => ITEM.test(row)).map(([id]) => id));
|
|
10343
10949
|
const ids = idsByViewer(rows, items);
|
|
10344
10950
|
const viewers = [...items].flatMap((id) => viewerOf(rows.byId.get(id) ?? "", ids.get(id)) ?? []);
|
|
10345
10951
|
const shown = Math.max(items.size, (stream.match(new RegExp(ITEM, "g")) ?? []).length);
|
|
10346
10952
|
if (shown > 0 && viewers.length === 0)
|
|
10347
|
-
return
|
|
10953
|
+
return drift13(`${shown} profile viewers were shown but none could be read`);
|
|
10348
10954
|
let privateViewers;
|
|
10349
10955
|
for (const [id, row] of rows.byId) {
|
|
10350
10956
|
if (items.has(id) || privateViewers !== void 0) continue;
|
|
10351
10957
|
for (const m of row.matchAll(PLAIN_TEXT)) {
|
|
10352
|
-
const n =
|
|
10958
|
+
const n = unquote4(m[1]).match(/^(\d[\d.,\s]*)\s+\D/)?.[1];
|
|
10353
10959
|
if (n !== void 0) {
|
|
10354
10960
|
privateViewers = Number(n.replace(/\D/g, ""));
|
|
10355
10961
|
break;
|
|
@@ -10358,40 +10964,78 @@ function parseViewers(stream) {
|
|
|
10358
10964
|
}
|
|
10359
10965
|
return privateViewers === void 0 ? { ok: true, viewers } : { ok: true, viewers, privateViewers };
|
|
10360
10966
|
}
|
|
10967
|
+
var textsIn = (s) => [...s.matchAll(PLAIN_TEXT)].map((m) => unquote4(m[1]).trim());
|
|
10968
|
+
function highlightsOf(stream) {
|
|
10969
|
+
const from = stream.indexOf('"viewName":"highlights"');
|
|
10970
|
+
if (from === -1) return [];
|
|
10971
|
+
const to = stream.indexOf('"viewName":"details"', from);
|
|
10972
|
+
const texts3 = textsIn(stream.slice(from, to === -1 ? void 0 : to)).slice(1);
|
|
10973
|
+
const out = [];
|
|
10974
|
+
for (let i = 0; i + 1 < texts3.length; i += 2)
|
|
10975
|
+
out.push({ value: texts3[i], label: texts3[i + 1] });
|
|
10976
|
+
return out;
|
|
10977
|
+
}
|
|
10978
|
+
function companiesOf(texts3) {
|
|
10979
|
+
const seen = /* @__PURE__ */ new Map();
|
|
10980
|
+
texts3.forEach((t, i) => {
|
|
10981
|
+
const share4 = t.match(/^\((\d+)\s*%\)$/)?.[1];
|
|
10982
|
+
const name = texts3[i - 1];
|
|
10983
|
+
if (share4 !== void 0 && name !== void 0 && !seen.has(name)) seen.set(name, Number(share4));
|
|
10984
|
+
});
|
|
10985
|
+
return [...seen].map(([name, share4]) => ({ name, share: share4 }));
|
|
10986
|
+
}
|
|
10361
10987
|
function parseViewTotals(stream) {
|
|
10362
|
-
const texts3 =
|
|
10988
|
+
const texts3 = textsIn(stream);
|
|
10363
10989
|
const at = texts3.findIndex((t) => /^\d[\d.,\s]*$/.test(t));
|
|
10364
|
-
if (at === -1) return
|
|
10990
|
+
if (at === -1) return drift13("the profile view totals carried no number");
|
|
10365
10991
|
const total = Number(texts3[at].replace(/\D/g, ""));
|
|
10366
|
-
const
|
|
10367
|
-
|
|
10992
|
+
const label = texts3[at + 1];
|
|
10993
|
+
const highlights = highlightsOf(stream);
|
|
10994
|
+
const companies2 = companiesOf(texts3);
|
|
10995
|
+
return {
|
|
10996
|
+
ok: true,
|
|
10997
|
+
total,
|
|
10998
|
+
...label !== void 0 && /\d/.test(label) ? { period: label } : {},
|
|
10999
|
+
...highlights.length > 0 ? { highlights } : {},
|
|
11000
|
+
...companies2.length > 0 ? { companies: companies2 } : {}
|
|
11001
|
+
};
|
|
10368
11002
|
}
|
|
10369
11003
|
|
|
10370
11004
|
// src/commands/viewers.ts
|
|
10371
|
-
function
|
|
11005
|
+
function liveFetch10(quiet) {
|
|
10372
11006
|
const session = loadSession();
|
|
10373
11007
|
if (session.state !== "ok")
|
|
10374
11008
|
return err("viewers", "AUTH_FAILED", "no LinkedIn session \u2014 run `lnrelay login`");
|
|
10375
11009
|
const client = createLiveClient(session.session, void 0, quiet);
|
|
10376
11010
|
return async (url, body, spendClass) => {
|
|
10377
|
-
const r = await client.request({
|
|
11011
|
+
const r = await client.request({
|
|
11012
|
+
url,
|
|
11013
|
+
method: "POST",
|
|
11014
|
+
body,
|
|
11015
|
+
headers: { referer: VIEWERS_REFERER },
|
|
11016
|
+
spendClass,
|
|
11017
|
+
operation: "viewers"
|
|
11018
|
+
});
|
|
10378
11019
|
if (!r.ok) return r;
|
|
10379
11020
|
return { ok: true, raw: r.classification.raw ?? "" };
|
|
10380
11021
|
};
|
|
10381
11022
|
}
|
|
10382
11023
|
var compactViewer = (v) => "anonymous" in v ? line(["anonymous", v.description, v.viewed]) : line([v.name, v.degree, v.headline, v.viewed, v.url]);
|
|
10383
11024
|
async function runViewers(opts = {}, fetch2) {
|
|
10384
|
-
const get = fetch2 ??
|
|
11025
|
+
const get = fetch2 ?? liveFetch10(opts.quiet === true);
|
|
10385
11026
|
if (typeof get !== "function") return get;
|
|
10386
|
-
const totalsRes = await get(VIEW_TOTALS_URL, viewTotalsBody(), "page");
|
|
11027
|
+
const totalsRes = await get(VIEW_TOTALS_URL, viewTotalsBody(opts.days), "page");
|
|
10387
11028
|
const totals = totalsRes.ok ? parseViewTotals(totalsRes.raw) : totalsRes;
|
|
10388
|
-
const listRes = await get(VIEWERS_URL, viewersBody(), "page");
|
|
11029
|
+
const listRes = await get(VIEWERS_URL, viewersBody(opts.days), "page");
|
|
10389
11030
|
const list2 = listRes.ok ? parseViewers(listRes.raw) : listRes;
|
|
10390
11031
|
if (!list2.ok) return err("viewers", list2.code, list2.message, list2.hint);
|
|
10391
11032
|
const shown = list2.viewers.length;
|
|
10392
|
-
const
|
|
11033
|
+
const accounted = totals.ok && (totals.total <= shown || shown + (list2.privateViewers ?? 0) === totals.total);
|
|
11034
|
+
const state2 = !totals.ok ? "unknown" : accounted ? "complete" : "partial";
|
|
11035
|
+
const { ok: _ok, ...summary } = totals.ok ? totals : { ok: false };
|
|
10393
11036
|
return ok("viewers", {
|
|
10394
|
-
...
|
|
11037
|
+
...opts.days !== void 0 ? { days: opts.days } : {},
|
|
11038
|
+
...totals.ok ? summary : { totalError: `${totals.code}: ${totals.message}` },
|
|
10395
11039
|
...list2.privateViewers !== void 0 ? { privateViewers: list2.privateViewers } : {},
|
|
10396
11040
|
items: shape(list2.viewers, opts, compactViewer),
|
|
10397
11041
|
meta: { state: state2, operation: "viewers", returnedCount: shown }
|
|
@@ -10444,6 +11088,15 @@ function output(args) {
|
|
|
10444
11088
|
function many(args, name) {
|
|
10445
11089
|
return list(args, name).flatMap((v) => v.split(",")).map((v) => v.trim()).filter((v) => v !== "");
|
|
10446
11090
|
}
|
|
11091
|
+
function viewersCommand(args) {
|
|
11092
|
+
const days = num(args, "days");
|
|
11093
|
+
if (days !== void 0 && !VIEW_RANGES.includes(days))
|
|
11094
|
+
return err("viewers", "INVALID_INPUT", `--days takes ${VIEW_RANGES.join(", ")}`);
|
|
11095
|
+
return runViewers({
|
|
11096
|
+
...output(args),
|
|
11097
|
+
...days !== void 0 ? { days } : {}
|
|
11098
|
+
});
|
|
11099
|
+
}
|
|
10447
11100
|
function jobsRequest(args) {
|
|
10448
11101
|
const filter = {};
|
|
10449
11102
|
const distance = num(args, "distance");
|
|
@@ -10486,6 +11139,7 @@ function jobsRequest(args) {
|
|
|
10486
11139
|
if (start !== void 0) req.start = start;
|
|
10487
11140
|
if (bool(args, "details")) req.details = true;
|
|
10488
11141
|
if (bool(args, "description")) req.description = true;
|
|
11142
|
+
if (bool(args, "top-applicant")) req.collection = "top-applicant";
|
|
10489
11143
|
return req;
|
|
10490
11144
|
}
|
|
10491
11145
|
function orgs(args, name) {
|
|
@@ -10773,7 +11427,10 @@ async function dispatch(argv, now) {
|
|
|
10773
11427
|
return runWhoami(bool(args, "raw"));
|
|
10774
11428
|
case "profile":
|
|
10775
11429
|
return runProfile(args.positionals[0], output(args), void 0, {
|
|
10776
|
-
contact: bool(args, "contact")
|
|
11430
|
+
contact: bool(args, "contact"),
|
|
11431
|
+
skills: bool(args, "skills"),
|
|
11432
|
+
recommendations: bool(args, "recommendations"),
|
|
11433
|
+
...num(args, "posts") !== void 0 ? { posts: num(args, "posts") } : {}
|
|
10777
11434
|
});
|
|
10778
11435
|
case "feed":
|
|
10779
11436
|
return runFeed(num(args, "limit") ?? 10, output(args));
|
|
@@ -10784,7 +11441,10 @@ async function dispatch(argv, now) {
|
|
|
10784
11441
|
case "jobs":
|
|
10785
11442
|
return runJobs(jobsRequest(args), output(args));
|
|
10786
11443
|
case "job":
|
|
10787
|
-
return runJob(args.positionals, output(args), void 0, {
|
|
11444
|
+
return runJob(args.positionals, output(args), void 0, {
|
|
11445
|
+
team: bool(args, "team"),
|
|
11446
|
+
insights: bool(args, "insights")
|
|
11447
|
+
});
|
|
10788
11448
|
case "job-filters":
|
|
10789
11449
|
return runJobFilters(jobsRequest(args), output(args));
|
|
10790
11450
|
case "people":
|
|
@@ -10792,7 +11452,12 @@ async function dispatch(argv, now) {
|
|
|
10792
11452
|
case "people-filters":
|
|
10793
11453
|
return runPeopleFilters(peopleRequest(args), output(args));
|
|
10794
11454
|
case "viewers":
|
|
10795
|
-
return
|
|
11455
|
+
return viewersCommand(args);
|
|
11456
|
+
case "notifications":
|
|
11457
|
+
return runNotifications(
|
|
11458
|
+
{ limit: num(args, "limit") ?? 25, ...bool(args, "unread") ? { unread: true } : {} },
|
|
11459
|
+
output(args)
|
|
11460
|
+
);
|
|
10796
11461
|
case "events":
|
|
10797
11462
|
case "event":
|
|
10798
11463
|
case "company":
|
|
@@ -10859,13 +11524,13 @@ function edit(args, now, deps) {
|
|
|
10859
11524
|
if (inline !== void 0) {
|
|
10860
11525
|
return err("edit", "INVALID_INPUT", "pass the new text inline or with --file, not both");
|
|
10861
11526
|
}
|
|
10862
|
-
let
|
|
11527
|
+
let text7;
|
|
10863
11528
|
try {
|
|
10864
|
-
|
|
11529
|
+
text7 = readFileSync5(file, "utf-8").replace(/\n$/, "");
|
|
10865
11530
|
} catch {
|
|
10866
11531
|
return err("edit", "INVALID_INPUT", `cannot read ${file}`);
|
|
10867
11532
|
}
|
|
10868
|
-
return runEdit(target2,
|
|
11533
|
+
return runEdit(target2, text7, now, deps);
|
|
10869
11534
|
}
|
|
10870
11535
|
function role2(args, now, deps) {
|
|
10871
11536
|
const [sub, target2] = args.positionals;
|