linkedin-relay-mcp 3.13.0 → 3.14.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 +58 -20
- package/README.md +27 -2
- package/dist/cli.js +1099 -337
- package/dist/cli.js.map +1 -1
- package/dist/index.js +12 -3
- package/dist/index.js.map +1 -1
- package/dist/mcp-shim.js +1169 -412
- package/dist/mcp-shim.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -2028,7 +2028,7 @@ async function fetchCommentMenu(ref, trackingId, client) {
|
|
|
2028
2028
|
const stream = result.classification.raw ?? "";
|
|
2029
2029
|
return { ok: true, stream };
|
|
2030
2030
|
}
|
|
2031
|
-
function textStates(payload,
|
|
2031
|
+
function textStates(payload, text5) {
|
|
2032
2032
|
const keyOf = (...names) => {
|
|
2033
2033
|
for (const n of names) {
|
|
2034
2034
|
const slot = payload[n];
|
|
@@ -2047,12 +2047,12 @@ function textStates(payload, text4) {
|
|
|
2047
2047
|
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: key } }
|
|
2048
2048
|
});
|
|
2049
2049
|
return [
|
|
2050
|
-
entry2(plain2,
|
|
2051
|
-
entry2(rich, { text:
|
|
2050
|
+
entry2(plain2, text5, "stringValue"),
|
|
2051
|
+
entry2(rich, { text: text5, attribute: [], $type: "TextModel", source: "local" }, "textModelForWrite")
|
|
2052
2052
|
];
|
|
2053
2053
|
}
|
|
2054
|
-
function editStates(payload,
|
|
2055
|
-
return textStates(payload,
|
|
2054
|
+
function editStates(payload, text5) {
|
|
2055
|
+
return textStates(payload, text5);
|
|
2056
2056
|
}
|
|
2057
2057
|
async function runCommentAction(ref, operation, trackingId, client, newText) {
|
|
2058
2058
|
const menu = await fetchCommentMenu(ref, trackingId, client);
|
|
@@ -2158,10 +2158,10 @@ function parseScheduledPage(stream) {
|
|
|
2158
2158
|
if (claimedCount > 0 && posts.length === 0) {
|
|
2159
2159
|
return drift(`LinkedIn counts ${claimedCount} scheduled posts but no row could be read`);
|
|
2160
2160
|
}
|
|
2161
|
-
const
|
|
2162
|
-
if (
|
|
2161
|
+
const texts2 = [...stream.matchAll(TEXT)].map((m) => JSON.parse(`"${m[1]}"`));
|
|
2162
|
+
if (texts2.length === posts.length) {
|
|
2163
2163
|
posts.forEach((p, i) => {
|
|
2164
|
-
p.text =
|
|
2164
|
+
p.text = texts2[i] ?? null;
|
|
2165
2165
|
});
|
|
2166
2166
|
}
|
|
2167
2167
|
return { ok: true, claimedCount, posts };
|
|
@@ -2391,12 +2391,12 @@ var CATEGORY = {
|
|
|
2391
2391
|
VIDEO: "VIDEO",
|
|
2392
2392
|
DOCUMENT: "NATIVE_DOCUMENT"
|
|
2393
2393
|
};
|
|
2394
|
-
function sharePayload(
|
|
2394
|
+
function sharePayload(text5, visibility, media = [], scheduledAt) {
|
|
2395
2395
|
const schedule = scheduledAt === void 0 ? { postState: "PUBLISHED" } : { postState: "SCHEDULED", scheduledAt };
|
|
2396
2396
|
return {
|
|
2397
2397
|
visibleToConnectionsOnly: visibility === "CONNECTIONS",
|
|
2398
2398
|
externalAudienceProviders: [],
|
|
2399
|
-
commentaryV2: { text:
|
|
2399
|
+
commentaryV2: { text: text5, attributes: [] },
|
|
2400
2400
|
origin: "FEED",
|
|
2401
2401
|
allowedCommentersScope: "ALL",
|
|
2402
2402
|
...schedule,
|
|
@@ -2510,15 +2510,15 @@ async function share(confirmed, client, bytes) {
|
|
|
2510
2510
|
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."
|
|
2511
2511
|
} : { ok: true, id };
|
|
2512
2512
|
}
|
|
2513
|
-
function editPostBody(
|
|
2514
|
-
return { patch: { $set: { commentaryV2: { text:
|
|
2513
|
+
function editPostBody(text5) {
|
|
2514
|
+
return { patch: { $set: { commentaryV2: { text: text5, attributes: [] } } } };
|
|
2515
2515
|
}
|
|
2516
2516
|
async function editPost(confirmed, client) {
|
|
2517
|
-
const { urn, text:
|
|
2517
|
+
const { urn, text: text5 } = confirmed.payload;
|
|
2518
2518
|
const result = await client.request({
|
|
2519
2519
|
url: deleteUrl(urn),
|
|
2520
2520
|
method: "POST",
|
|
2521
|
-
body: editPostBody(
|
|
2521
|
+
body: editPostBody(text5),
|
|
2522
2522
|
spendClass: "write",
|
|
2523
2523
|
operation: "edit-post"
|
|
2524
2524
|
});
|
|
@@ -2528,7 +2528,7 @@ async function editPost(confirmed, client) {
|
|
|
2528
2528
|
return out;
|
|
2529
2529
|
}
|
|
2530
2530
|
const held = result.json?.data?.commentary?.text;
|
|
2531
|
-
if (held !==
|
|
2531
|
+
if (held !== text5) {
|
|
2532
2532
|
return {
|
|
2533
2533
|
ok: false,
|
|
2534
2534
|
code: "SCHEMA_DRIFT",
|
|
@@ -2589,8 +2589,8 @@ async function createPoll(poll, client) {
|
|
|
2589
2589
|
}
|
|
2590
2590
|
return { ok: true, urn };
|
|
2591
2591
|
}
|
|
2592
|
-
function firstUrl(
|
|
2593
|
-
const found =
|
|
2592
|
+
function firstUrl(text5) {
|
|
2593
|
+
const found = text5.match(/https?:\/\/[^\s<>"]+/)?.[0];
|
|
2594
2594
|
if (found === void 0) return null;
|
|
2595
2595
|
let url = found.replace(/[.,;:!?'"]+$/, "");
|
|
2596
2596
|
if (url.endsWith(")") && !url.includes("(")) url = url.slice(0, -1);
|
|
@@ -2754,8 +2754,8 @@ function previewLines2(post) {
|
|
|
2754
2754
|
" about to delete, or that it is yours."
|
|
2755
2755
|
];
|
|
2756
2756
|
}
|
|
2757
|
-
const
|
|
2758
|
-
const shown =
|
|
2757
|
+
const text5 = typeof post.text === "string" ? post.text : "(no text \u2014 media-only post?)";
|
|
2758
|
+
const shown = text5.length > PREVIEW_CHARS ? `${text5.slice(0, PREVIEW_CHARS)}\u2026` : text5;
|
|
2759
2759
|
const lines = [`content "${shown.replace(/\n/g, " ")}"`];
|
|
2760
2760
|
if (typeof post.scheduledAt === "string") {
|
|
2761
2761
|
lines.push(`status scheduled, publishes ${post.scheduledAt} unless cancelled`);
|
|
@@ -3661,24 +3661,6 @@ async function runFeed(limit, opts = {}) {
|
|
|
3661
3661
|
if (!result.ok) return toEnvelope("feed", result);
|
|
3662
3662
|
return ok("feed", collection(result.value, opts));
|
|
3663
3663
|
}
|
|
3664
|
-
async function runSearch(kind, query, limit, opts = {}) {
|
|
3665
|
-
if (kind === void 0 || !["people", "companies", "jobs"].includes(kind)) {
|
|
3666
|
-
return err(
|
|
3667
|
-
"search",
|
|
3668
|
-
"INVALID_INPUT",
|
|
3669
|
-
"kind must be people, companies or jobs",
|
|
3670
|
-
'lnrelay search people "<query>"'
|
|
3671
|
-
);
|
|
3672
|
-
}
|
|
3673
|
-
if (query === void 0 || query === "") {
|
|
3674
|
-
return err("search", "INVALID_INPUT", "a query is required", 'lnrelay search people "<query>"');
|
|
3675
|
-
}
|
|
3676
|
-
const ctx = withSession("search", opts.quiet === true);
|
|
3677
|
-
if ("ok" in ctx) return ctx;
|
|
3678
|
-
const result = await ctx.engine.search(kind, query, limit);
|
|
3679
|
-
if (!result.ok) return toEnvelope("search", result);
|
|
3680
|
-
return ok("search", { query, kind, ...collection(result.value, opts) });
|
|
3681
|
-
}
|
|
3682
3664
|
async function runPost(urn, limit, opts = {}) {
|
|
3683
3665
|
const postUrn2 = normalisePostUrn(urn);
|
|
3684
3666
|
if (postUrn2 === void 0) {
|
|
@@ -3938,18 +3920,18 @@ async function exchange(code, config, deps) {
|
|
|
3938
3920
|
} catch (e) {
|
|
3939
3921
|
return { ok: false, message: `could not reach LinkedIn: ${e.message}` };
|
|
3940
3922
|
}
|
|
3941
|
-
const
|
|
3923
|
+
const text5 = await res.text();
|
|
3942
3924
|
if (res.status !== 200) {
|
|
3943
3925
|
return {
|
|
3944
3926
|
ok: false,
|
|
3945
3927
|
message: `LinkedIn rejected the code exchange (${res.status})`,
|
|
3946
3928
|
// The most common causes, in the order they actually happen.
|
|
3947
|
-
hint: `Check that the app has BOTH products added, and that its Auth tab lists exactly ${REDIRECT_URI} as an authorized redirect URL. Response: ${
|
|
3929
|
+
hint: `Check that the app has BOTH products added, and that its Auth tab lists exactly ${REDIRECT_URI} as an authorized redirect URL. Response: ${text5.slice(0, 200)}`
|
|
3948
3930
|
};
|
|
3949
3931
|
}
|
|
3950
3932
|
let parsed;
|
|
3951
3933
|
try {
|
|
3952
|
-
parsed = JSON.parse(
|
|
3934
|
+
parsed = JSON.parse(text5);
|
|
3953
3935
|
} catch {
|
|
3954
3936
|
return { ok: false, message: "token response was not JSON" };
|
|
3955
3937
|
}
|
|
@@ -4257,14 +4239,22 @@ function clustersOf(json) {
|
|
|
4257
4239
|
const c = d?.searchDashClustersByAll;
|
|
4258
4240
|
return c !== null && typeof c === "object" ? c : void 0;
|
|
4259
4241
|
}
|
|
4260
|
-
var FURNITURE = /* @__PURE__ */ new Set([
|
|
4242
|
+
var FURNITURE = /* @__PURE__ */ new Set([
|
|
4243
|
+
"*feedbackCard",
|
|
4244
|
+
"*bannerCard",
|
|
4245
|
+
"*searchSuggestionCard",
|
|
4246
|
+
"*promoCard",
|
|
4247
|
+
"simpleText",
|
|
4248
|
+
"simpleTextV2",
|
|
4249
|
+
"*simpleText"
|
|
4250
|
+
]);
|
|
4261
4251
|
function classify2(item) {
|
|
4262
4252
|
const ref = item?.["*entityResult"];
|
|
4263
4253
|
if (typeof ref === "string") return { ref };
|
|
4264
4254
|
const kinds = Object.entries(item ?? {}).filter(([k, v]) => v !== null && !k.startsWith("$")).map(([k]) => k);
|
|
4265
4255
|
return kinds.every((k) => FURNITURE.has(k)) ? "furniture" : kinds;
|
|
4266
4256
|
}
|
|
4267
|
-
function readItems(c, included) {
|
|
4257
|
+
function readItems(c, included, toRow) {
|
|
4268
4258
|
const byUrn = new Map(included.map((n) => [n.entityUrn, n]));
|
|
4269
4259
|
const people = [];
|
|
4270
4260
|
const unknownTypes = {};
|
|
@@ -4279,7 +4269,7 @@ function readItems(c, included) {
|
|
|
4279
4269
|
for (const k of kind) unknownTypes[k] = (unknownTypes[k] ?? 0) + 1;
|
|
4280
4270
|
} else {
|
|
4281
4271
|
const row = byUrn.get(kind.ref);
|
|
4282
|
-
const person = row === void 0 ? void 0 :
|
|
4272
|
+
const person = row === void 0 ? void 0 : toRow(row);
|
|
4283
4273
|
if (person === void 0) unresolved++;
|
|
4284
4274
|
else if (!people.some((p) => p.id === person.id)) people.push(person);
|
|
4285
4275
|
}
|
|
@@ -4291,7 +4281,7 @@ function parsePeople(json) {
|
|
|
4291
4281
|
if (c === void 0 || !Array.isArray(c.elements))
|
|
4292
4282
|
return drift3("the people search returned no result list");
|
|
4293
4283
|
const included = json.included ?? [];
|
|
4294
|
-
const { people, unknownTypes, excluded, unresolved } = readItems(c, included);
|
|
4284
|
+
const { people, unknownTypes, excluded, unresolved } = readItems(c, included, rowToPerson);
|
|
4295
4285
|
const total = typeof c.paging?.total === "number" ? c.paging.total : void 0;
|
|
4296
4286
|
const start = typeof c.paging?.start === "number" ? c.paging.start : 0;
|
|
4297
4287
|
const claimedRaw = c.metadata?.totalResultCount;
|
|
@@ -4413,14 +4403,14 @@ function selection2(o) {
|
|
|
4413
4403
|
throw new Refused2(`${flag} takes a profile id (ACo\u2026) or urn, from a people row's \`id\``);
|
|
4414
4404
|
params[param] = [id];
|
|
4415
4405
|
}
|
|
4416
|
-
const
|
|
4406
|
+
const texts2 = [
|
|
4417
4407
|
[o.firstName, "firstName"],
|
|
4418
4408
|
[o.lastName, "lastName"],
|
|
4419
4409
|
[o.title, "title"],
|
|
4420
4410
|
[o.companyText, "company"],
|
|
4421
4411
|
[o.schoolText, "schoolFreetext"]
|
|
4422
4412
|
];
|
|
4423
|
-
for (const [given, param] of
|
|
4413
|
+
for (const [given, param] of texts2)
|
|
4424
4414
|
if (given !== void 0 && given.trim() !== "") params[param] = [given.trim()];
|
|
4425
4415
|
if (o.openToVolunteer === true) params.openToVolunteer = ["true"];
|
|
4426
4416
|
for (const r of o.raw ?? []) {
|
|
@@ -4636,6 +4626,617 @@ async function runPeopleFilters(req, opts = {}, fetch2) {
|
|
|
4636
4626
|
});
|
|
4637
4627
|
}
|
|
4638
4628
|
|
|
4629
|
+
// src/engine/sdui-form.ts
|
|
4630
|
+
function balanced(s, start) {
|
|
4631
|
+
const open = s[start];
|
|
4632
|
+
const close = open === "[" ? "]" : "}";
|
|
4633
|
+
let depth = 0;
|
|
4634
|
+
let inString = false;
|
|
4635
|
+
let escaped = false;
|
|
4636
|
+
for (let i = start; i < s.length; i++) {
|
|
4637
|
+
const ch = s[i];
|
|
4638
|
+
if (escaped) escaped = false;
|
|
4639
|
+
else if (ch === "\\") escaped = true;
|
|
4640
|
+
else if (ch === '"') inString = !inString;
|
|
4641
|
+
else if (!inString && ch === open) depth++;
|
|
4642
|
+
else if (!inString && ch === close) {
|
|
4643
|
+
depth--;
|
|
4644
|
+
if (depth === 0) return s.slice(start, i + 1);
|
|
4645
|
+
}
|
|
4646
|
+
}
|
|
4647
|
+
return null;
|
|
4648
|
+
}
|
|
4649
|
+
function parseAt(s, start) {
|
|
4650
|
+
const text5 = start < 0 ? null : balanced(s, start);
|
|
4651
|
+
if (text5 === null) return null;
|
|
4652
|
+
try {
|
|
4653
|
+
return JSON.parse(text5);
|
|
4654
|
+
} catch {
|
|
4655
|
+
return null;
|
|
4656
|
+
}
|
|
4657
|
+
}
|
|
4658
|
+
function plain(v) {
|
|
4659
|
+
const protoCase = String(v.$case);
|
|
4660
|
+
const raw = v[protoCase];
|
|
4661
|
+
if (protoCase === "stringListValue") {
|
|
4662
|
+
return { protoCase, value: raw?.stringValues ?? [] };
|
|
4663
|
+
}
|
|
4664
|
+
if (protoCase === "signedLongValue" && typeof raw === "string" && raw.startsWith("$n")) {
|
|
4665
|
+
return { protoCase, value: { type: "bigint", value: raw.slice(2) } };
|
|
4666
|
+
}
|
|
4667
|
+
return { protoCase, value: raw };
|
|
4668
|
+
}
|
|
4669
|
+
function readModel(stream) {
|
|
4670
|
+
const at = stream.indexOf('"modelStates":[');
|
|
4671
|
+
const entries = parseAt(stream, at === -1 ? -1 : stream.indexOf("[", at));
|
|
4672
|
+
if (entries === null) return null;
|
|
4673
|
+
const model = /* @__PURE__ */ new Map();
|
|
4674
|
+
for (const entry2 of entries) {
|
|
4675
|
+
const id = entry2.key?.key?.value?.id;
|
|
4676
|
+
if (id !== void 0 && entry2.value !== void 0 && !model.has(id)) {
|
|
4677
|
+
model.set(id, plain(entry2.value));
|
|
4678
|
+
}
|
|
4679
|
+
}
|
|
4680
|
+
return model;
|
|
4681
|
+
}
|
|
4682
|
+
function findRequest(stream, requestId) {
|
|
4683
|
+
const at = stream.indexOf(`"requestId":"${requestId}","requestedArguments":`);
|
|
4684
|
+
if (at === -1) return null;
|
|
4685
|
+
const args = parseAt(
|
|
4686
|
+
stream,
|
|
4687
|
+
stream.indexOf("{", stream.indexOf('"requestedArguments":', at))
|
|
4688
|
+
);
|
|
4689
|
+
return args !== null && Array.isArray(args.requestedStateKeys) && args.payload !== void 0 ? args : null;
|
|
4690
|
+
}
|
|
4691
|
+
var unknownExpression = (what) => ({
|
|
4692
|
+
ok: false,
|
|
4693
|
+
code: "SCHEMA_DRIFT",
|
|
4694
|
+
message: `the form computes a value with an expression this tool does not evaluate (${what})`,
|
|
4695
|
+
hint: "Nothing was sent. Re-capture the form to see what it has become."
|
|
4696
|
+
});
|
|
4697
|
+
function boundId(body) {
|
|
4698
|
+
return body?.key?.key?.value?.id;
|
|
4699
|
+
}
|
|
4700
|
+
function str2(node, model) {
|
|
4701
|
+
const e = node.expression;
|
|
4702
|
+
if (e?.$case === "stringValue") return String(e.stringValue);
|
|
4703
|
+
if (e?.$case === "bindableString") {
|
|
4704
|
+
const v = model.get(boundId(e.bindableString) ?? "")?.value;
|
|
4705
|
+
return typeof v === "string" ? v : "";
|
|
4706
|
+
}
|
|
4707
|
+
return null;
|
|
4708
|
+
}
|
|
4709
|
+
function bool2(node, model) {
|
|
4710
|
+
const e = node.expression;
|
|
4711
|
+
const body = e?.[e?.$case ?? ""];
|
|
4712
|
+
switch (e?.$case) {
|
|
4713
|
+
case "booleanExpression":
|
|
4714
|
+
return bool2(body, model);
|
|
4715
|
+
case "booleanValue":
|
|
4716
|
+
return e.booleanValue === true;
|
|
4717
|
+
case "bindableBoolean":
|
|
4718
|
+
return model.get(boundId(e.bindableBoolean) ?? "")?.value === true;
|
|
4719
|
+
case "notExpression": {
|
|
4720
|
+
const a = bool2(body?.a ?? {}, model);
|
|
4721
|
+
return a === null ? null : !a;
|
|
4722
|
+
}
|
|
4723
|
+
case "orExpression":
|
|
4724
|
+
case "andExpression": {
|
|
4725
|
+
const a = bool2(body?.a ?? {}, model);
|
|
4726
|
+
const b = bool2(body?.b ?? {}, model);
|
|
4727
|
+
if (a === null || b === null) return null;
|
|
4728
|
+
return e.$case === "orExpression" ? a || b : a && b;
|
|
4729
|
+
}
|
|
4730
|
+
case "stringEqualsExpression": {
|
|
4731
|
+
const a = str2(body?.a ?? {}, model);
|
|
4732
|
+
const b = str2(body?.b ?? {}, model);
|
|
4733
|
+
if (a === null || b === null) return null;
|
|
4734
|
+
return body.ignoreCase === true ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
4735
|
+
}
|
|
4736
|
+
default:
|
|
4737
|
+
return null;
|
|
4738
|
+
}
|
|
4739
|
+
}
|
|
4740
|
+
function evaluate(expression, model) {
|
|
4741
|
+
const value = bool2(expression, model);
|
|
4742
|
+
return value === null ? unknownExpression(JSON.stringify(expression).slice(0, 80)) : { ok: true, value };
|
|
4743
|
+
}
|
|
4744
|
+
function wireStates(keys, model, resolve) {
|
|
4745
|
+
const out = [];
|
|
4746
|
+
for (const id of keys) {
|
|
4747
|
+
const state = model.get(id);
|
|
4748
|
+
if (state === void 0) continue;
|
|
4749
|
+
let value = state.value;
|
|
4750
|
+
if (state.protoCase === "expression") {
|
|
4751
|
+
const r = resolve(id, state) ?? evaluate(state.value, model);
|
|
4752
|
+
if (!r.ok) return r;
|
|
4753
|
+
value = r.value;
|
|
4754
|
+
}
|
|
4755
|
+
out.push({
|
|
4756
|
+
key: id,
|
|
4757
|
+
namespace: "MemoryNamespace",
|
|
4758
|
+
value,
|
|
4759
|
+
originalProtoCase: state.protoCase,
|
|
4760
|
+
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id } }
|
|
4761
|
+
});
|
|
4762
|
+
}
|
|
4763
|
+
return out;
|
|
4764
|
+
}
|
|
4765
|
+
var keysOf = (args) => args.requestedStateKeys.map((k) => k.key.value.id);
|
|
4766
|
+
function requestBody(requestId, args, states2, screen) {
|
|
4767
|
+
const requestedArguments = {
|
|
4768
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
4769
|
+
requestedStateKeys: args.requestedStateKeys,
|
|
4770
|
+
payload: args.payload,
|
|
4771
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
4772
|
+
};
|
|
4773
|
+
return {
|
|
4774
|
+
requestId,
|
|
4775
|
+
serverRequest: {
|
|
4776
|
+
requestId,
|
|
4777
|
+
requestedArguments,
|
|
4778
|
+
isApfcEnabled: false,
|
|
4779
|
+
isStreaming: false,
|
|
4780
|
+
rumPageKey: ""
|
|
4781
|
+
},
|
|
4782
|
+
states: states2,
|
|
4783
|
+
requestedArguments: { ...requestedArguments, states: states2, screenId: screen, knownTemplateIds: [] }
|
|
4784
|
+
};
|
|
4785
|
+
}
|
|
4786
|
+
function navBody(screen, payload) {
|
|
4787
|
+
return {
|
|
4788
|
+
clientArguments: {
|
|
4789
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
4790
|
+
requestedStateKeys: [],
|
|
4791
|
+
payload,
|
|
4792
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" },
|
|
4793
|
+
states: [],
|
|
4794
|
+
screenId: screen,
|
|
4795
|
+
knownTemplateIds: []
|
|
4796
|
+
},
|
|
4797
|
+
isModal: true
|
|
4798
|
+
};
|
|
4799
|
+
}
|
|
4800
|
+
function responseErrors(raw) {
|
|
4801
|
+
return raw.match(/"errors":\[([^\]]+)\]/)?.[1]?.slice(0, 300) ?? null;
|
|
4802
|
+
}
|
|
4803
|
+
|
|
4804
|
+
// src/engine/posts.ts
|
|
4805
|
+
var POSTS_PAGER = "com.linkedin.sdui.search.contentSearchResults";
|
|
4806
|
+
var SCREEN = "com.linkedin.sdui.flagshipnav.search.SearchResultsContent";
|
|
4807
|
+
var POSTS_URL = `https://www.linkedin.com/flagship-web/rsc-action/actions/pagination?sduiid=${POSTS_PAGER}`;
|
|
4808
|
+
var POSTS_PAGE = 20;
|
|
4809
|
+
var POST_FILTERS = [
|
|
4810
|
+
"sortBy",
|
|
4811
|
+
"postedBy",
|
|
4812
|
+
"datePosted",
|
|
4813
|
+
"contentType",
|
|
4814
|
+
"fromMember",
|
|
4815
|
+
"mentionsOrganization",
|
|
4816
|
+
"mentionsMember",
|
|
4817
|
+
"fromOrganization",
|
|
4818
|
+
"authorCompany",
|
|
4819
|
+
"authorIndustry",
|
|
4820
|
+
"authorJobTitle"
|
|
4821
|
+
];
|
|
4822
|
+
function postsPagerBody(q2) {
|
|
4823
|
+
const payload = {
|
|
4824
|
+
startIndex: q2.start,
|
|
4825
|
+
keywords: q2.keywords ?? "",
|
|
4826
|
+
count: q2.count ?? POSTS_PAGE
|
|
4827
|
+
};
|
|
4828
|
+
for (const f of POST_FILTERS) payload[f] = q2.filters[f] ?? [];
|
|
4829
|
+
payload.spellCheckEnabled = true;
|
|
4830
|
+
const args = {
|
|
4831
|
+
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
4832
|
+
requestedStateKeys: [],
|
|
4833
|
+
payload,
|
|
4834
|
+
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
4835
|
+
};
|
|
4836
|
+
return {
|
|
4837
|
+
pagerId: POSTS_PAGER,
|
|
4838
|
+
clientArguments: { ...args, states: [], screenId: SCREEN, knownTemplateIds: [] },
|
|
4839
|
+
paginationRequest: {
|
|
4840
|
+
$type: "proto.sdui.actions.requests.PaginationRequest",
|
|
4841
|
+
pagerId: POSTS_PAGER,
|
|
4842
|
+
retryCount: 0,
|
|
4843
|
+
requestedArguments: args
|
|
4844
|
+
}
|
|
4845
|
+
};
|
|
4846
|
+
}
|
|
4847
|
+
var Rows = class {
|
|
4848
|
+
constructor(stream) {
|
|
4849
|
+
this.stream = stream;
|
|
4850
|
+
for (const m of stream.matchAll(/(?:^|\n)([0-9a-f]+):/g)) {
|
|
4851
|
+
const at = (m.index ?? 0) + (m[0].startsWith("\n") ? 1 : 0);
|
|
4852
|
+
this.starts.push({ id: m[1], at });
|
|
4853
|
+
}
|
|
4854
|
+
for (let i = 0; i < this.starts.length; i++) {
|
|
4855
|
+
const s = this.starts[i];
|
|
4856
|
+
const end = this.starts[i + 1]?.at ?? stream.length;
|
|
4857
|
+
this.byId.set(s.id, stream.slice(s.at + s.id.length + 1, end));
|
|
4858
|
+
}
|
|
4859
|
+
}
|
|
4860
|
+
stream;
|
|
4861
|
+
byId = /* @__PURE__ */ new Map();
|
|
4862
|
+
starts = [];
|
|
4863
|
+
/** The row a stream position falls in. */
|
|
4864
|
+
at(pos) {
|
|
4865
|
+
let lo = 0;
|
|
4866
|
+
let hi = this.starts.length - 1;
|
|
4867
|
+
while (lo < hi) {
|
|
4868
|
+
const mid = lo + hi + 1 >> 1;
|
|
4869
|
+
if (this.starts[mid].at <= pos) lo = mid;
|
|
4870
|
+
else hi = mid - 1;
|
|
4871
|
+
}
|
|
4872
|
+
return this.starts[lo]?.id;
|
|
4873
|
+
}
|
|
4874
|
+
/** Every row reachable from `id` through references, nearest first. */
|
|
4875
|
+
reach(id, limit = 400) {
|
|
4876
|
+
const seen = /* @__PURE__ */ new Set([id]);
|
|
4877
|
+
const queue = [id];
|
|
4878
|
+
while (queue.length > 0 && seen.size < limit) {
|
|
4879
|
+
const row = this.byId.get(queue.shift()) ?? "";
|
|
4880
|
+
for (const m of row.matchAll(/"\$L?([0-9a-f]+)(?::[^"]*)?"/g)) {
|
|
4881
|
+
const ref = m[1];
|
|
4882
|
+
if (!seen.has(ref) && this.byId.has(ref)) {
|
|
4883
|
+
seen.add(ref);
|
|
4884
|
+
queue.push(ref);
|
|
4885
|
+
}
|
|
4886
|
+
}
|
|
4887
|
+
}
|
|
4888
|
+
return [...seen];
|
|
4889
|
+
}
|
|
4890
|
+
};
|
|
4891
|
+
function strings(v, out = []) {
|
|
4892
|
+
if (typeof v === "string") {
|
|
4893
|
+
if (!v.startsWith("$")) out.push(v);
|
|
4894
|
+
} else if (Array.isArray(v)) {
|
|
4895
|
+
if (v[0] === "$" && v[1] === "br") out.push("\n");
|
|
4896
|
+
else if (v[0] === "$") strings(v[3], out);
|
|
4897
|
+
else for (const x of v) strings(x, out);
|
|
4898
|
+
} else if (v !== null && typeof v === "object" && "children" in v) {
|
|
4899
|
+
strings(v.children, out);
|
|
4900
|
+
}
|
|
4901
|
+
return out;
|
|
4902
|
+
}
|
|
4903
|
+
function texts(row, from = 0) {
|
|
4904
|
+
const part2 = row.slice(Math.max(0, from));
|
|
4905
|
+
const out = [];
|
|
4906
|
+
for (const m of part2.matchAll(/"textProps":/g)) {
|
|
4907
|
+
const obj = balanced(part2, part2.indexOf("{", m.index ?? 0));
|
|
4908
|
+
if (obj === null) continue;
|
|
4909
|
+
const t = strings(JSON.parse(obj)).join("").trim();
|
|
4910
|
+
if (t !== "") out.push(t);
|
|
4911
|
+
}
|
|
4912
|
+
return out;
|
|
4913
|
+
}
|
|
4914
|
+
var jsonString = (s) => JSON.parse(`"${s}"`);
|
|
4915
|
+
var REACTIONS = [
|
|
4916
|
+
"LIKE",
|
|
4917
|
+
"PRAISE",
|
|
4918
|
+
"EMPATHY",
|
|
4919
|
+
"INTEREST",
|
|
4920
|
+
"APPRECIATION",
|
|
4921
|
+
"ENTERTAINMENT",
|
|
4922
|
+
"SUPER_LIKE"
|
|
4923
|
+
];
|
|
4924
|
+
function part(rows, from, view, depth = 60) {
|
|
4925
|
+
const id = from.find((r) => rows.byId.get(r)?.includes(`"viewName":"${view}"`));
|
|
4926
|
+
return id === void 0 ? void 0 : { row: id, under: rows.reach(id, depth) };
|
|
4927
|
+
}
|
|
4928
|
+
function firstIn(rows, ids, find) {
|
|
4929
|
+
for (const id of ids) {
|
|
4930
|
+
const v = find(rows.byId.get(id) ?? "");
|
|
4931
|
+
if (v !== void 0) return { id, v };
|
|
4932
|
+
}
|
|
4933
|
+
return void 0;
|
|
4934
|
+
}
|
|
4935
|
+
function authorOf(rows, actor) {
|
|
4936
|
+
if (actor === void 0) return { fields: {}, used: [] };
|
|
4937
|
+
const state = (key) => (row) => {
|
|
4938
|
+
const m = row.match(new RegExp(`"${key}"[^]*?"stringValue":"((?:[^"\\\\]|\\\\.)*)"`));
|
|
4939
|
+
return m?.[1] === void 0 ? void 0 : jsonString(m[1]);
|
|
4940
|
+
};
|
|
4941
|
+
const link = firstIn(
|
|
4942
|
+
rows,
|
|
4943
|
+
actor.under,
|
|
4944
|
+
(row) => row.match(
|
|
4945
|
+
/"(?:https:\/\/www\.linkedin\.com)?(\/(?:in|company|school|showcase)\/[^"?/]+)/
|
|
4946
|
+
)?.[1]
|
|
4947
|
+
);
|
|
4948
|
+
const person = firstIn(rows, actor.under, state("profile_name_loading_state"));
|
|
4949
|
+
const headline = firstIn(rows, actor.under, state("profile_headline_loading_state"));
|
|
4950
|
+
const page = person !== void 0 ? void 0 : firstIn(rows, actor.under, (row) => {
|
|
4951
|
+
const labels = [...row.matchAll(/"aria-label":"((?:[^"\\]|\\.)+)"/g)].map(
|
|
4952
|
+
(m) => jsonString(m[1]).trim()
|
|
4953
|
+
);
|
|
4954
|
+
return texts(row).find((t) => labels.some((l) => l === t || l.startsWith(`${t} `)));
|
|
4955
|
+
});
|
|
4956
|
+
const named2 = person ?? page;
|
|
4957
|
+
return {
|
|
4958
|
+
fields: {
|
|
4959
|
+
...named2 !== void 0 ? { author: named2.v.trim() } : {},
|
|
4960
|
+
...headline !== void 0 ? { authorHeadline: headline.v } : {},
|
|
4961
|
+
...link !== void 0 ? { authorUrl: `https://www.linkedin.com${link.v}/` } : {}
|
|
4962
|
+
},
|
|
4963
|
+
used: [link?.id, named2?.id, headline?.id].filter((x) => x !== void 0)
|
|
4964
|
+
};
|
|
4965
|
+
}
|
|
4966
|
+
function readPost(rows, top, model) {
|
|
4967
|
+
const reach = rows.reach(top);
|
|
4968
|
+
const counted = reach.find((r) => /commentCount-urn:li:\w+:\d+/.test(rows.byId.get(r) ?? ""));
|
|
4969
|
+
const id = counted === void 0 ? void 0 : rows.byId.get(counted)?.match(/commentCount-(urn:li:\w+:\d+)/)?.[1];
|
|
4970
|
+
if (id === void 0) return { post: void 0, used: [top] };
|
|
4971
|
+
const actor = part(rows, reach, "feed-actor");
|
|
4972
|
+
const author = authorOf(rows, actor);
|
|
4973
|
+
const sub = part(rows, reach, "feed-actor-sub-description", 4);
|
|
4974
|
+
const commentary = part(rows, reach, "feed-commentary");
|
|
4975
|
+
const n = (k) => {
|
|
4976
|
+
const v = model?.get(k)?.value;
|
|
4977
|
+
return typeof v === "number" ? v : void 0;
|
|
4978
|
+
};
|
|
4979
|
+
const byType = REACTIONS.map((r) => n(`ReactionType_${r}_${id}`));
|
|
4980
|
+
const reactions = byType.some((v) => v !== void 0) ? byType.reduce((a, v) => a + (v ?? 0), 0) : void 0;
|
|
4981
|
+
const subRow = sub === void 0 ? "" : rows.byId.get(sub.row) ?? "";
|
|
4982
|
+
const posted = sub === void 0 ? void 0 : texts(subRow, subRow.indexOf('"viewName":"feed-actor-sub-description"'))[0];
|
|
4983
|
+
const said = commentary === void 0 ? void 0 : firstIn(rows, commentary.under, (row) => texts(row)[0]);
|
|
4984
|
+
const text5 = said?.v;
|
|
4985
|
+
const post = {
|
|
4986
|
+
id,
|
|
4987
|
+
url: `https://www.linkedin.com/feed/update/${id}/`,
|
|
4988
|
+
...author.fields,
|
|
4989
|
+
...posted !== void 0 ? { posted } : {},
|
|
4990
|
+
...text5 !== void 0 ? { text: text5 } : {},
|
|
4991
|
+
...reactions !== void 0 ? { reactions } : {}
|
|
4992
|
+
};
|
|
4993
|
+
const comments = n(`commentCount-${id}`);
|
|
4994
|
+
const reposts = n(`repostCount-${id}`);
|
|
4995
|
+
if (comments !== void 0) post.comments = comments;
|
|
4996
|
+
if (reposts !== void 0) post.reposts = reposts;
|
|
4997
|
+
const parts = [actor?.row, sub?.row, commentary?.row, said?.id].filter(
|
|
4998
|
+
(x) => x !== void 0
|
|
4999
|
+
);
|
|
5000
|
+
const used = [top, counted, ...author.used, ...parts];
|
|
5001
|
+
return { post, used };
|
|
5002
|
+
}
|
|
5003
|
+
function parsePosts(stream) {
|
|
5004
|
+
if (!stream.includes(POSTS_PAGER) && !stream.includes('"isPartialPage"') && !stream.includes("feed-full-update")) {
|
|
5005
|
+
return {
|
|
5006
|
+
ok: false,
|
|
5007
|
+
code: "SCHEMA_DRIFT",
|
|
5008
|
+
message: "the posts search page could not be read",
|
|
5009
|
+
hint: "the posts search response changed shape; re-capture it"
|
|
5010
|
+
};
|
|
5011
|
+
}
|
|
5012
|
+
const rows = new Rows(stream);
|
|
5013
|
+
const model = readModel(stream);
|
|
5014
|
+
const posts = [];
|
|
5015
|
+
const used = /* @__PURE__ */ new Set();
|
|
5016
|
+
const tops = /* @__PURE__ */ new Set();
|
|
5017
|
+
let unread = 0;
|
|
5018
|
+
for (const m of stream.matchAll(/"viewName":"feed-full-update"/g)) {
|
|
5019
|
+
const top = rows.at(m.index ?? 0);
|
|
5020
|
+
if (top === void 0 || tops.has(top)) continue;
|
|
5021
|
+
tops.add(top);
|
|
5022
|
+
const r = readPost(rows, top, model);
|
|
5023
|
+
for (const u of r.used) used.add(u);
|
|
5024
|
+
if (r.post === void 0) unread++;
|
|
5025
|
+
else if (!posts.some((p) => p.id === r.post?.id)) posts.push(r.post);
|
|
5026
|
+
}
|
|
5027
|
+
if (unread > 0 && posts.length === 0) {
|
|
5028
|
+
return {
|
|
5029
|
+
ok: false,
|
|
5030
|
+
code: "SCHEMA_DRIFT",
|
|
5031
|
+
message: `${unread} posts were listed but none could be read`,
|
|
5032
|
+
hint: "the posts search response changed shape; re-capture it"
|
|
5033
|
+
};
|
|
5034
|
+
}
|
|
5035
|
+
return { ok: true, posts, unread, used };
|
|
5036
|
+
}
|
|
5037
|
+
|
|
5038
|
+
// src/commands/posts-search.ts
|
|
5039
|
+
function liveFetch3(quiet) {
|
|
5040
|
+
const session = loadSession();
|
|
5041
|
+
if (session.state !== "ok")
|
|
5042
|
+
return err("search posts", "AUTH_FAILED", "no LinkedIn session \u2014 run `lnrelay login`");
|
|
5043
|
+
const client = createLiveClient(session.session, void 0, quiet);
|
|
5044
|
+
return async (url, body, spendClass) => {
|
|
5045
|
+
const r = await client.request({
|
|
5046
|
+
url,
|
|
5047
|
+
...body !== void 0 ? { method: "POST", body } : {},
|
|
5048
|
+
spendClass,
|
|
5049
|
+
operation: "search-posts"
|
|
5050
|
+
});
|
|
5051
|
+
if (!r.ok) return r;
|
|
5052
|
+
return { ok: true, raw: r.classification.raw ?? "", json: r.json };
|
|
5053
|
+
};
|
|
5054
|
+
}
|
|
5055
|
+
var PAGING3 = { pageSize: POSTS_PAGE, max: 1e3 };
|
|
5056
|
+
var CHOICES = {
|
|
5057
|
+
sort: { param: "sortBy", values: { recent: "date_posted", relevant: "relevance" } },
|
|
5058
|
+
posted: {
|
|
5059
|
+
param: "datePosted",
|
|
5060
|
+
values: { "24h": "past-24h", day: "past-24h", week: "past-week", month: "past-month" }
|
|
5061
|
+
},
|
|
5062
|
+
type: {
|
|
5063
|
+
param: "contentType",
|
|
5064
|
+
values: {
|
|
5065
|
+
videos: "videos",
|
|
5066
|
+
images: "photos",
|
|
5067
|
+
photos: "photos",
|
|
5068
|
+
jobs: "jobs",
|
|
5069
|
+
live: "liveVideos",
|
|
5070
|
+
articles: "articles",
|
|
5071
|
+
documents: "documents"
|
|
5072
|
+
}
|
|
5073
|
+
},
|
|
5074
|
+
postedBy: { param: "postedBy", values: { "1st": "first", me: "me", first: "first" } }
|
|
5075
|
+
};
|
|
5076
|
+
function choose(name, given) {
|
|
5077
|
+
const { values } = CHOICES[name];
|
|
5078
|
+
const out = [];
|
|
5079
|
+
for (const g of given) {
|
|
5080
|
+
const v = values[g.toLowerCase()];
|
|
5081
|
+
if (v === void 0)
|
|
5082
|
+
return {
|
|
5083
|
+
ok: false,
|
|
5084
|
+
code: "INVALID_INPUT",
|
|
5085
|
+
message: `--${name} '${g}' is not one of: ${Object.keys(values).join(", ")}`
|
|
5086
|
+
};
|
|
5087
|
+
out.push(v);
|
|
5088
|
+
}
|
|
5089
|
+
return out;
|
|
5090
|
+
}
|
|
5091
|
+
async function companies(get, given) {
|
|
5092
|
+
const ids = [];
|
|
5093
|
+
const found = [];
|
|
5094
|
+
for (const v of given) {
|
|
5095
|
+
if (/^\d+$/.test(v)) {
|
|
5096
|
+
ids.push(v);
|
|
5097
|
+
continue;
|
|
5098
|
+
}
|
|
5099
|
+
const res = await get(
|
|
5100
|
+
peopleSearchUrl({ keywords: v, params: {}, start: 0, kind: "COMPANIES" }),
|
|
5101
|
+
void 0,
|
|
5102
|
+
"search"
|
|
5103
|
+
);
|
|
5104
|
+
const hits = res.ok ? parseOrgHits(res.json) : res;
|
|
5105
|
+
if (!hits.ok) return hits;
|
|
5106
|
+
const top = hits.hits[0];
|
|
5107
|
+
if (top === void 0)
|
|
5108
|
+
return { ok: false, code: "INVALID_INPUT", message: `no company on LinkedIn matches "${v}"` };
|
|
5109
|
+
ids.push(top.id);
|
|
5110
|
+
found.push({ given: v, id: top.id, name: top.name });
|
|
5111
|
+
}
|
|
5112
|
+
return { ids, found };
|
|
5113
|
+
}
|
|
5114
|
+
function choices(req) {
|
|
5115
|
+
const filters = {};
|
|
5116
|
+
const picks = [
|
|
5117
|
+
["sort", req.sort !== void 0 ? [req.sort] : void 0],
|
|
5118
|
+
["posted", req.posted !== void 0 ? [req.posted] : void 0],
|
|
5119
|
+
["type", req.type],
|
|
5120
|
+
["postedBy", req.postedBy]
|
|
5121
|
+
];
|
|
5122
|
+
for (const [name, given] of picks) {
|
|
5123
|
+
if (given === void 0 || given.length === 0) continue;
|
|
5124
|
+
const v = choose(name, given);
|
|
5125
|
+
if (!Array.isArray(v)) return v;
|
|
5126
|
+
filters[CHOICES[name].param] = v;
|
|
5127
|
+
}
|
|
5128
|
+
if (req.from !== void 0 && req.from.length > 0) filters.fromMember = req.from;
|
|
5129
|
+
if (req.mentions !== void 0 && req.mentions.length > 0) filters.mentionsMember = req.mentions;
|
|
5130
|
+
if (req.authorIndustry !== void 0 && req.authorIndustry.length > 0)
|
|
5131
|
+
filters.authorIndustry = req.authorIndustry;
|
|
5132
|
+
if (req.authorTitle !== void 0 && req.authorTitle.trim() !== "")
|
|
5133
|
+
filters.authorJobTitle = [req.authorTitle.trim()];
|
|
5134
|
+
for (const r of req.raw ?? []) {
|
|
5135
|
+
const m = r.match(/^([A-Za-z_]+)=(.+)$/);
|
|
5136
|
+
if (m?.[1] === void 0 || m[2] === void 0)
|
|
5137
|
+
return {
|
|
5138
|
+
ok: false,
|
|
5139
|
+
code: "INVALID_INPUT",
|
|
5140
|
+
message: `--filter '${r}' is not key=value[,value]`
|
|
5141
|
+
};
|
|
5142
|
+
filters[m[1]] = m[2].split(",").map((v) => v.trim()).filter((v) => v !== "");
|
|
5143
|
+
}
|
|
5144
|
+
return filters;
|
|
5145
|
+
}
|
|
5146
|
+
async function filtersOf(req, get) {
|
|
5147
|
+
const filters = choices(req);
|
|
5148
|
+
if ("ok" in filters) return filters;
|
|
5149
|
+
const resolved = {};
|
|
5150
|
+
const orgs2 = [
|
|
5151
|
+
["fromCompany", "fromOrganization"],
|
|
5152
|
+
["mentionsCompany", "mentionsOrganization"],
|
|
5153
|
+
["authorCompany", "authorCompany"]
|
|
5154
|
+
];
|
|
5155
|
+
for (const [key, param] of orgs2) {
|
|
5156
|
+
const given = req[key];
|
|
5157
|
+
if (given === void 0 || given.length === 0) continue;
|
|
5158
|
+
const r = await companies(get, given);
|
|
5159
|
+
if ("ok" in r) return r;
|
|
5160
|
+
filters[param] = r.ids;
|
|
5161
|
+
if (r.found.length > 0) resolved[key] = r.found;
|
|
5162
|
+
}
|
|
5163
|
+
return { filters, resolved };
|
|
5164
|
+
}
|
|
5165
|
+
function compactPost(p) {
|
|
5166
|
+
const counts = [
|
|
5167
|
+
p.reactions !== void 0 ? `${p.reactions} reactions` : void 0,
|
|
5168
|
+
p.comments !== void 0 ? `${p.comments} comments` : void 0,
|
|
5169
|
+
p.reposts !== void 0 ? `${p.reposts} reposts` : void 0
|
|
5170
|
+
].filter(Boolean);
|
|
5171
|
+
const text5 = p.text?.replace(/\s+/g, " ");
|
|
5172
|
+
return line([
|
|
5173
|
+
p.id,
|
|
5174
|
+
p.author,
|
|
5175
|
+
p.posted,
|
|
5176
|
+
counts.length > 0 ? counts.join(" \xB7 ") : void 0,
|
|
5177
|
+
text5 !== void 0 && text5.length > 160 ? `${text5.slice(0, 157)}\u2026` : text5,
|
|
5178
|
+
p.url,
|
|
5179
|
+
p.matched !== void 0 ? `matched: ${p.matched.join(" + ")}` : void 0
|
|
5180
|
+
]);
|
|
5181
|
+
}
|
|
5182
|
+
async function runPostsSearch(req, opts = {}, fetch2) {
|
|
5183
|
+
const command = "search posts";
|
|
5184
|
+
const sets = keywordSets(req.keywords);
|
|
5185
|
+
const early = choices(req);
|
|
5186
|
+
if ("ok" in early) return err(command, early.code, early.message, early.hint);
|
|
5187
|
+
const anyFilter = Object.keys(early).length > 0 || [req.fromCompany, req.mentionsCompany, req.authorCompany].some((v) => (v?.length ?? 0) > 0);
|
|
5188
|
+
if (sets.length === 0 && !anyFilter)
|
|
5189
|
+
return err(
|
|
5190
|
+
command,
|
|
5191
|
+
"INVALID_INPUT",
|
|
5192
|
+
"give keywords, a filter, or both",
|
|
5193
|
+
'lnrelay search posts "<keywords>"'
|
|
5194
|
+
);
|
|
5195
|
+
const get = fetch2 ?? liveFetch3(opts.quiet === true);
|
|
5196
|
+
if (typeof get !== "function") return get;
|
|
5197
|
+
const f = await filtersOf(req, get);
|
|
5198
|
+
if ("ok" in f) return err(command, f.code, f.message, f.hint);
|
|
5199
|
+
const first = Math.max(0, req.start ?? 0);
|
|
5200
|
+
const want = Math.max(1, Math.min(req.limit, PAGING3.max - first));
|
|
5201
|
+
const fetchPage = async (keywords, start) => {
|
|
5202
|
+
const body = postsPagerBody({ ...keywords ? { keywords } : {}, filters: f.filters, start });
|
|
5203
|
+
const res = await get(POSTS_URL, body, "search");
|
|
5204
|
+
const page = res.ok ? parsePosts(res.raw) : res;
|
|
5205
|
+
if (!page.ok) return page;
|
|
5206
|
+
const cards = page.posts.length + page.unread;
|
|
5207
|
+
const unknownTypes = page.unread > 0 ? { unreadPostCards: page.unread } : {};
|
|
5208
|
+
return {
|
|
5209
|
+
ok: true,
|
|
5210
|
+
items: page.posts,
|
|
5211
|
+
// No total is given: a short page is the last.
|
|
5212
|
+
...cards < POSTS_PAGE ? { total: start + cards } : {},
|
|
5213
|
+
unknownTypes
|
|
5214
|
+
};
|
|
5215
|
+
};
|
|
5216
|
+
const merged = await searchAll(
|
|
5217
|
+
fetchPage,
|
|
5218
|
+
sets.length > 0 ? sets : [void 0],
|
|
5219
|
+
first,
|
|
5220
|
+
want,
|
|
5221
|
+
PAGING3
|
|
5222
|
+
);
|
|
5223
|
+
if (merged.rows.length === 0 && merged.failure !== void 0) {
|
|
5224
|
+
const fail2 = merged.failure;
|
|
5225
|
+
return err(command, fail2.code, fail2.message, fail2.hint);
|
|
5226
|
+
}
|
|
5227
|
+
const single = sets.length <= 1;
|
|
5228
|
+
return ok("search", {
|
|
5229
|
+
kind: "posts",
|
|
5230
|
+
query: {
|
|
5231
|
+
...sets.length > 0 ? { keywords: single ? sets[0] : sets } : {},
|
|
5232
|
+
filters: f.filters
|
|
5233
|
+
},
|
|
5234
|
+
...Object.keys(f.resolved).length > 0 ? { resolved: f.resolved } : {},
|
|
5235
|
+
items: shape2(merged.rows, opts, compactPost),
|
|
5236
|
+
meta: metaOf(command, merged, single, first)
|
|
5237
|
+
});
|
|
5238
|
+
}
|
|
5239
|
+
|
|
4639
5240
|
// src/commands/registry.ts
|
|
4640
5241
|
var COMMANDS = [
|
|
4641
5242
|
// ─── local / meta — no network, available today ────────────────────────────
|
|
@@ -4697,9 +5298,18 @@ var COMMANDS = [
|
|
|
4697
5298
|
},
|
|
4698
5299
|
{
|
|
4699
5300
|
name: "search",
|
|
4700
|
-
cost: "
|
|
4701
|
-
summary: "Search people
|
|
4702
|
-
usage: 'lnrelay search
|
|
5301
|
+
cost: "1 search call per 50 results (posts: per 20); +1 per name looked up",
|
|
5302
|
+
summary: "Search any kind the search box has: people, jobs, posts, companies, groups, events, courses, products, services, schools. Several keyword sets merge by id.",
|
|
5303
|
+
usage: 'lnrelay search <kind> "<keywords>" ["<more>" ...] [filters] [--limit N] [--start N]\n [--compact | --fields a,b,c]\n kinds: people, jobs (their own flags: see `people`, `jobs`), posts, companies,\n groups, events, courses, products, services, schools\n companies, services: [--location "<place>"] [--network 1st,2nd,3rd+]\n companies: [--industry <ids>] any kind: [--filter key=v1,v2 ...]\n posts: [--sort recent|relevant] [--posted 24h|week|month]\n [--type videos,images,jobs,live,articles,documents] [--posted-by 1st,me]\n [--from <profile-id>] [--mentions <profile-id>] [--from-company "<name|id>"]\n [--mentions-company "<name|id>"] [--author-company "<name|id>"]\n [--author-industry <ids>] [--author-title "<text>"]',
|
|
5304
|
+
audience: ["cli", "mcp"],
|
|
5305
|
+
risk: "read",
|
|
5306
|
+
implemented: true
|
|
5307
|
+
},
|
|
5308
|
+
{
|
|
5309
|
+
name: "search-filters",
|
|
5310
|
+
cost: "1 search call",
|
|
5311
|
+
summary: "Every filter a search kind has for a query, with option ids and live counts: what `search <kind> --filter key=\u2026` takes.",
|
|
5312
|
+
usage: 'lnrelay search-filters <kind> ["<keywords>"] [filters]',
|
|
4703
5313
|
audience: ["cli", "mcp"],
|
|
4704
5314
|
risk: "read",
|
|
4705
5315
|
implemented: true
|
|
@@ -4933,221 +5543,46 @@ var COMMANDS = [
|
|
|
4933
5543
|
},
|
|
4934
5544
|
{
|
|
4935
5545
|
name: "role",
|
|
4936
|
-
cost: "3-4 reads + 1 write",
|
|
4937
|
-
summary: "Add, edit or remove a role in your Experience. Never rewrites your headline; notify network is off unless --notify.",
|
|
4938
|
-
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).',
|
|
4939
|
-
audience: ["cli"],
|
|
4940
|
-
risk: "write",
|
|
4941
|
-
implemented: true
|
|
4942
|
-
},
|
|
4943
|
-
{
|
|
4944
|
-
name: "skill",
|
|
4945
|
-
cost: "4-5 reads + 1 write",
|
|
4946
|
-
summary: "Add a skill to your profile, or remove one.",
|
|
4947
|
-
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.',
|
|
4948
|
-
audience: ["cli"],
|
|
4949
|
-
risk: "write",
|
|
4950
|
-
implemented: true
|
|
4951
|
-
},
|
|
4952
|
-
{
|
|
4953
|
-
name: "react",
|
|
4954
|
-
cost: "1 call \u2014 write",
|
|
4955
|
-
summary: "React to a post or comment, over LinkedIn's SDUI surface. Reversible with --remove.",
|
|
4956
|
-
usage: "lnrelay react <activity-urn | comment-urn> [--type LIKE|PRAISE|EMPATHY|INTEREST|APPRECIATION|ENTERTAINMENT]\n lnrelay react <urn> --remove # take the reaction back",
|
|
4957
|
-
audience: ["cli"],
|
|
4958
|
-
risk: "write",
|
|
4959
|
-
implemented: true
|
|
4960
|
-
}
|
|
4961
|
-
];
|
|
4962
|
-
var commandNames = COMMANDS.map((c) => c.name);
|
|
4963
|
-
function findCommand(name) {
|
|
4964
|
-
return COMMANDS.find((c) => c.name === name);
|
|
4965
|
-
}
|
|
4966
|
-
function helpText() {
|
|
4967
|
-
const lines = ["lnrelay \u2014 deep research over LinkedIn from your own account", "", "Commands:"];
|
|
4968
|
-
const width = Math.max(...commandNames.map((n) => n.length));
|
|
4969
|
-
for (const c of COMMANDS) {
|
|
4970
|
-
const flag = c.implemented ? " " : "\xB7";
|
|
4971
|
-
lines.push(` ${flag} ${c.name.padEnd(width)} ${c.summary} [${c.cost}]`);
|
|
4972
|
-
}
|
|
4973
|
-
lines.push("", " \xB7 = specified in docs/DESIGN.md, not yet implemented");
|
|
4974
|
-
lines.push("", "Run `lnrelay <command> --help` for usage.");
|
|
4975
|
-
return lines.join("\n");
|
|
4976
|
-
}
|
|
4977
|
-
|
|
4978
|
-
// src/engine/sdui-form.ts
|
|
4979
|
-
function balanced(s, start) {
|
|
4980
|
-
const open = s[start];
|
|
4981
|
-
const close = open === "[" ? "]" : "}";
|
|
4982
|
-
let depth = 0;
|
|
4983
|
-
let inString = false;
|
|
4984
|
-
let escaped = false;
|
|
4985
|
-
for (let i = start; i < s.length; i++) {
|
|
4986
|
-
const ch = s[i];
|
|
4987
|
-
if (escaped) escaped = false;
|
|
4988
|
-
else if (ch === "\\") escaped = true;
|
|
4989
|
-
else if (ch === '"') inString = !inString;
|
|
4990
|
-
else if (!inString && ch === open) depth++;
|
|
4991
|
-
else if (!inString && ch === close) {
|
|
4992
|
-
depth--;
|
|
4993
|
-
if (depth === 0) return s.slice(start, i + 1);
|
|
4994
|
-
}
|
|
4995
|
-
}
|
|
4996
|
-
return null;
|
|
4997
|
-
}
|
|
4998
|
-
function parseAt(s, start) {
|
|
4999
|
-
const text4 = start < 0 ? null : balanced(s, start);
|
|
5000
|
-
if (text4 === null) return null;
|
|
5001
|
-
try {
|
|
5002
|
-
return JSON.parse(text4);
|
|
5003
|
-
} catch {
|
|
5004
|
-
return null;
|
|
5005
|
-
}
|
|
5006
|
-
}
|
|
5007
|
-
function plain(v) {
|
|
5008
|
-
const protoCase = String(v.$case);
|
|
5009
|
-
const raw = v[protoCase];
|
|
5010
|
-
if (protoCase === "stringListValue") {
|
|
5011
|
-
return { protoCase, value: raw?.stringValues ?? [] };
|
|
5012
|
-
}
|
|
5013
|
-
if (protoCase === "signedLongValue" && typeof raw === "string" && raw.startsWith("$n")) {
|
|
5014
|
-
return { protoCase, value: { type: "bigint", value: raw.slice(2) } };
|
|
5015
|
-
}
|
|
5016
|
-
return { protoCase, value: raw };
|
|
5017
|
-
}
|
|
5018
|
-
function readModel(stream) {
|
|
5019
|
-
const at = stream.indexOf('"modelStates":[');
|
|
5020
|
-
const entries = parseAt(stream, at === -1 ? -1 : stream.indexOf("[", at));
|
|
5021
|
-
if (entries === null) return null;
|
|
5022
|
-
const model = /* @__PURE__ */ new Map();
|
|
5023
|
-
for (const entry2 of entries) {
|
|
5024
|
-
const id = entry2.key?.key?.value?.id;
|
|
5025
|
-
if (id !== void 0 && entry2.value !== void 0 && !model.has(id)) {
|
|
5026
|
-
model.set(id, plain(entry2.value));
|
|
5027
|
-
}
|
|
5028
|
-
}
|
|
5029
|
-
return model;
|
|
5030
|
-
}
|
|
5031
|
-
function findRequest(stream, requestId) {
|
|
5032
|
-
const at = stream.indexOf(`"requestId":"${requestId}","requestedArguments":`);
|
|
5033
|
-
if (at === -1) return null;
|
|
5034
|
-
const args = parseAt(
|
|
5035
|
-
stream,
|
|
5036
|
-
stream.indexOf("{", stream.indexOf('"requestedArguments":', at))
|
|
5037
|
-
);
|
|
5038
|
-
return args !== null && Array.isArray(args.requestedStateKeys) && args.payload !== void 0 ? args : null;
|
|
5039
|
-
}
|
|
5040
|
-
var unknownExpression = (what) => ({
|
|
5041
|
-
ok: false,
|
|
5042
|
-
code: "SCHEMA_DRIFT",
|
|
5043
|
-
message: `the form computes a value with an expression this tool does not evaluate (${what})`,
|
|
5044
|
-
hint: "Nothing was sent. Re-capture the form to see what it has become."
|
|
5045
|
-
});
|
|
5046
|
-
function boundId(body) {
|
|
5047
|
-
return body?.key?.key?.value?.id;
|
|
5048
|
-
}
|
|
5049
|
-
function str2(node, model) {
|
|
5050
|
-
const e = node.expression;
|
|
5051
|
-
if (e?.$case === "stringValue") return String(e.stringValue);
|
|
5052
|
-
if (e?.$case === "bindableString") {
|
|
5053
|
-
const v = model.get(boundId(e.bindableString) ?? "")?.value;
|
|
5054
|
-
return typeof v === "string" ? v : "";
|
|
5055
|
-
}
|
|
5056
|
-
return null;
|
|
5057
|
-
}
|
|
5058
|
-
function bool2(node, model) {
|
|
5059
|
-
const e = node.expression;
|
|
5060
|
-
const body = e?.[e?.$case ?? ""];
|
|
5061
|
-
switch (e?.$case) {
|
|
5062
|
-
case "booleanExpression":
|
|
5063
|
-
return bool2(body, model);
|
|
5064
|
-
case "booleanValue":
|
|
5065
|
-
return e.booleanValue === true;
|
|
5066
|
-
case "bindableBoolean":
|
|
5067
|
-
return model.get(boundId(e.bindableBoolean) ?? "")?.value === true;
|
|
5068
|
-
case "notExpression": {
|
|
5069
|
-
const a = bool2(body?.a ?? {}, model);
|
|
5070
|
-
return a === null ? null : !a;
|
|
5071
|
-
}
|
|
5072
|
-
case "orExpression":
|
|
5073
|
-
case "andExpression": {
|
|
5074
|
-
const a = bool2(body?.a ?? {}, model);
|
|
5075
|
-
const b = bool2(body?.b ?? {}, model);
|
|
5076
|
-
if (a === null || b === null) return null;
|
|
5077
|
-
return e.$case === "orExpression" ? a || b : a && b;
|
|
5078
|
-
}
|
|
5079
|
-
case "stringEqualsExpression": {
|
|
5080
|
-
const a = str2(body?.a ?? {}, model);
|
|
5081
|
-
const b = str2(body?.b ?? {}, model);
|
|
5082
|
-
if (a === null || b === null) return null;
|
|
5083
|
-
return body.ignoreCase === true ? a.toLowerCase() === b.toLowerCase() : a === b;
|
|
5084
|
-
}
|
|
5085
|
-
default:
|
|
5086
|
-
return null;
|
|
5546
|
+
cost: "3-4 reads + 1 write",
|
|
5547
|
+
summary: "Add, edit or remove a role in your Experience. Never rewrites your headline; notify network is off unless --notify.",
|
|
5548
|
+
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).',
|
|
5549
|
+
audience: ["cli"],
|
|
5550
|
+
risk: "write",
|
|
5551
|
+
implemented: true
|
|
5552
|
+
},
|
|
5553
|
+
{
|
|
5554
|
+
name: "skill",
|
|
5555
|
+
cost: "4-5 reads + 1 write",
|
|
5556
|
+
summary: "Add a skill to your profile, or remove one.",
|
|
5557
|
+
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.',
|
|
5558
|
+
audience: ["cli"],
|
|
5559
|
+
risk: "write",
|
|
5560
|
+
implemented: true
|
|
5561
|
+
},
|
|
5562
|
+
{
|
|
5563
|
+
name: "react",
|
|
5564
|
+
cost: "1 call \u2014 write",
|
|
5565
|
+
summary: "React to a post or comment, over LinkedIn's SDUI surface. Reversible with --remove.",
|
|
5566
|
+
usage: "lnrelay react <activity-urn | comment-urn> [--type LIKE|PRAISE|EMPATHY|INTEREST|APPRECIATION|ENTERTAINMENT]\n lnrelay react <urn> --remove # take the reaction back",
|
|
5567
|
+
audience: ["cli"],
|
|
5568
|
+
risk: "write",
|
|
5569
|
+
implemented: true
|
|
5087
5570
|
}
|
|
5571
|
+
];
|
|
5572
|
+
var commandNames = COMMANDS.map((c) => c.name);
|
|
5573
|
+
function findCommand(name) {
|
|
5574
|
+
return COMMANDS.find((c) => c.name === name);
|
|
5088
5575
|
}
|
|
5089
|
-
function
|
|
5090
|
-
const
|
|
5091
|
-
|
|
5092
|
-
|
|
5093
|
-
|
|
5094
|
-
|
|
5095
|
-
for (const id of keys) {
|
|
5096
|
-
const state = model.get(id);
|
|
5097
|
-
if (state === void 0) continue;
|
|
5098
|
-
let value = state.value;
|
|
5099
|
-
if (state.protoCase === "expression") {
|
|
5100
|
-
const r = resolve(id, state) ?? evaluate(state.value, model);
|
|
5101
|
-
if (!r.ok) return r;
|
|
5102
|
-
value = r.value;
|
|
5103
|
-
}
|
|
5104
|
-
out.push({
|
|
5105
|
-
key: id,
|
|
5106
|
-
namespace: "MemoryNamespace",
|
|
5107
|
-
value,
|
|
5108
|
-
originalProtoCase: state.protoCase,
|
|
5109
|
-
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id } }
|
|
5110
|
-
});
|
|
5576
|
+
function helpText() {
|
|
5577
|
+
const lines = ["lnrelay \u2014 deep research over LinkedIn from your own account", "", "Commands:"];
|
|
5578
|
+
const width = Math.max(...commandNames.map((n) => n.length));
|
|
5579
|
+
for (const c of COMMANDS) {
|
|
5580
|
+
const flag = c.implemented ? " " : "\xB7";
|
|
5581
|
+
lines.push(` ${flag} ${c.name.padEnd(width)} ${c.summary} [${c.cost}]`);
|
|
5111
5582
|
}
|
|
5112
|
-
|
|
5113
|
-
|
|
5114
|
-
|
|
5115
|
-
function requestBody(requestId, args, states2, screen) {
|
|
5116
|
-
const requestedArguments = {
|
|
5117
|
-
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
5118
|
-
requestedStateKeys: args.requestedStateKeys,
|
|
5119
|
-
payload: args.payload,
|
|
5120
|
-
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" }
|
|
5121
|
-
};
|
|
5122
|
-
return {
|
|
5123
|
-
requestId,
|
|
5124
|
-
serverRequest: {
|
|
5125
|
-
requestId,
|
|
5126
|
-
requestedArguments,
|
|
5127
|
-
isApfcEnabled: false,
|
|
5128
|
-
isStreaming: false,
|
|
5129
|
-
rumPageKey: ""
|
|
5130
|
-
},
|
|
5131
|
-
states: states2,
|
|
5132
|
-
requestedArguments: { ...requestedArguments, states: states2, screenId: screen, knownTemplateIds: [] }
|
|
5133
|
-
};
|
|
5134
|
-
}
|
|
5135
|
-
function navBody(screen, payload) {
|
|
5136
|
-
return {
|
|
5137
|
-
clientArguments: {
|
|
5138
|
-
$type: "proto.sdui.actions.requests.RequestedArguments",
|
|
5139
|
-
requestedStateKeys: [],
|
|
5140
|
-
payload,
|
|
5141
|
-
requestMetadata: { $type: "proto.sdui.common.RequestMetadata" },
|
|
5142
|
-
states: [],
|
|
5143
|
-
screenId: screen,
|
|
5144
|
-
knownTemplateIds: []
|
|
5145
|
-
},
|
|
5146
|
-
isModal: true
|
|
5147
|
-
};
|
|
5148
|
-
}
|
|
5149
|
-
function responseErrors(raw) {
|
|
5150
|
-
return raw.match(/"errors":\[([^\]]+)\]/)?.[1]?.slice(0, 300) ?? null;
|
|
5583
|
+
lines.push("", " \xB7 = specified in docs/DESIGN.md, not yet implemented");
|
|
5584
|
+
lines.push("", "Run `lnrelay <command> --help` for usage.");
|
|
5585
|
+
return lines.join("\n");
|
|
5151
5586
|
}
|
|
5152
5587
|
|
|
5153
5588
|
// src/engine/sdui-profile.ts
|
|
@@ -5297,10 +5732,10 @@ function listPositions(stream) {
|
|
|
5297
5732
|
for (; ; ) {
|
|
5298
5733
|
i = stream.indexOf(EDIT_NAV, i);
|
|
5299
5734
|
if (i === -1) break;
|
|
5300
|
-
const
|
|
5735
|
+
const text5 = balanced(stream, i);
|
|
5301
5736
|
i += EDIT_NAV.length;
|
|
5302
|
-
if (
|
|
5303
|
-
const payload = JSON.parse(
|
|
5737
|
+
if (text5 === null) continue;
|
|
5738
|
+
const payload = JSON.parse(text5).requestedArguments?.payload;
|
|
5304
5739
|
const id = payload?.positionId;
|
|
5305
5740
|
if (typeof id !== "string" || seen.has(id) || payload === void 0) continue;
|
|
5306
5741
|
seen.add(id);
|
|
@@ -5503,9 +5938,9 @@ async function send(url, body, token, deps) {
|
|
|
5503
5938
|
} catch (e) {
|
|
5504
5939
|
return { ok: false, code: "FETCH_FAILED", message: e.message };
|
|
5505
5940
|
}
|
|
5506
|
-
const
|
|
5941
|
+
const text5 = await res.text();
|
|
5507
5942
|
if (res.status === 201 || res.status === 200) {
|
|
5508
|
-
const id = res.headers.get("x-restli-id") ?? extractId(
|
|
5943
|
+
const id = res.headers.get("x-restli-id") ?? extractId(text5);
|
|
5509
5944
|
return {
|
|
5510
5945
|
ok: true,
|
|
5511
5946
|
id: id ?? "(unknown)",
|
|
@@ -5532,7 +5967,7 @@ async function send(url, body, token, deps) {
|
|
|
5532
5967
|
ok: false,
|
|
5533
5968
|
code: "FETCH_FAILED",
|
|
5534
5969
|
message: `write failed (${res.status})`,
|
|
5535
|
-
hint:
|
|
5970
|
+
hint: text5.slice(0, 300)
|
|
5536
5971
|
};
|
|
5537
5972
|
}
|
|
5538
5973
|
function extractId(body) {
|
|
@@ -5580,7 +6015,7 @@ function feedTypeFor(bindingKey) {
|
|
|
5580
6015
|
function stateKey(prefix, body) {
|
|
5581
6016
|
return `${prefix}-${body}`;
|
|
5582
6017
|
}
|
|
5583
|
-
function states(
|
|
6018
|
+
function states(text5, body) {
|
|
5584
6019
|
return STATE_PREFIXES.map((prefix) => {
|
|
5585
6020
|
const key = stateKey(prefix, body);
|
|
5586
6021
|
const base = {
|
|
@@ -5589,19 +6024,19 @@ function states(text4, body) {
|
|
|
5589
6024
|
protoKey: { $type: "proto.sdui.Key", value: { $case: "id", id: key } }
|
|
5590
6025
|
};
|
|
5591
6026
|
if (prefix === "commentBoxText") {
|
|
5592
|
-
return { ...base, value:
|
|
6027
|
+
return { ...base, value: text5, originalProtoCase: "stringValue" };
|
|
5593
6028
|
}
|
|
5594
6029
|
if (prefix === "richCommentBoxText") {
|
|
5595
6030
|
return {
|
|
5596
6031
|
...base,
|
|
5597
|
-
value: { text:
|
|
6032
|
+
value: { text: text5, attribute: [], $type: "TextModel", source: "local" },
|
|
5598
6033
|
originalProtoCase: "textModelForWrite"
|
|
5599
6034
|
};
|
|
5600
6035
|
}
|
|
5601
6036
|
return { ...base, value: "", originalProtoCase: "stringValue" };
|
|
5602
6037
|
});
|
|
5603
6038
|
}
|
|
5604
|
-
function commentBody(activityId,
|
|
6039
|
+
function commentBody(activityId, text5, tokens, feedType) {
|
|
5605
6040
|
const body = keyBody(tokens.bindingKey);
|
|
5606
6041
|
const activityUrn = { activityUrn: { activityId } };
|
|
5607
6042
|
const binding = (prefix) => ({
|
|
@@ -5648,17 +6083,17 @@ function commentBody(activityId, text4, tokens, feedType) {
|
|
|
5648
6083
|
isStreaming: false,
|
|
5649
6084
|
rumPageKey: ""
|
|
5650
6085
|
},
|
|
5651
|
-
states: states(
|
|
6086
|
+
states: states(text5, body),
|
|
5652
6087
|
requestedArguments: {
|
|
5653
6088
|
...args,
|
|
5654
|
-
states: states(
|
|
6089
|
+
states: states(text5, body),
|
|
5655
6090
|
screenId: SCREEN_ID3,
|
|
5656
6091
|
knownTemplateIds: []
|
|
5657
6092
|
}
|
|
5658
6093
|
};
|
|
5659
6094
|
}
|
|
5660
6095
|
async function comment(confirmed, client) {
|
|
5661
|
-
const { activityId, text:
|
|
6096
|
+
const { activityId, text: text5, tokens } = confirmed.payload;
|
|
5662
6097
|
if (!keyMatchesPost(tokens.bindingKey, activityId)) {
|
|
5663
6098
|
return {
|
|
5664
6099
|
ok: false,
|
|
@@ -5679,7 +6114,7 @@ async function comment(confirmed, client) {
|
|
|
5679
6114
|
const result = await client.request({
|
|
5680
6115
|
url: COMMENT_URL,
|
|
5681
6116
|
method: "POST",
|
|
5682
|
-
body: commentBody(activityId,
|
|
6117
|
+
body: commentBody(activityId, text5, tokens, feedType),
|
|
5683
6118
|
spendClass: "write",
|
|
5684
6119
|
operation: "comment.create"
|
|
5685
6120
|
});
|
|
@@ -5694,7 +6129,7 @@ async function comment(confirmed, client) {
|
|
|
5694
6129
|
// src/engine/sdui-write.ts
|
|
5695
6130
|
var SDUI_ACTION3 = "https://www.linkedin.com/flagship-web/rsc-action/actions/server-request";
|
|
5696
6131
|
var SCREEN_ID4 = "com.linkedin.sdui.flagshipnav.feed.UpdateDetail";
|
|
5697
|
-
var
|
|
6132
|
+
var REACTIONS2 = [
|
|
5698
6133
|
"LIKE",
|
|
5699
6134
|
"PRAISE",
|
|
5700
6135
|
"EMPATHY",
|
|
@@ -5803,10 +6238,10 @@ var REPLY_URL = `https://www.linkedin.com/voyager/api/voyagerSocialDashNormComme
|
|
|
5803
6238
|
function parentThreadUrn(ref) {
|
|
5804
6239
|
return `urn:li:comment:(${ref.threadType}:${ref.activityId},${ref.commentId})`;
|
|
5805
6240
|
}
|
|
5806
|
-
function replyBody(ref,
|
|
6241
|
+
function replyBody(ref, text5) {
|
|
5807
6242
|
return {
|
|
5808
6243
|
commentary: {
|
|
5809
|
-
text:
|
|
6244
|
+
text: text5,
|
|
5810
6245
|
// The captured reply carried a profileMention, because LinkedIn's UI
|
|
5811
6246
|
// pre-fills "@Author " into the box. We send none: an @mention notifies a
|
|
5812
6247
|
// real person, and inventing one would put words — and a notification —
|
|
@@ -5818,11 +6253,11 @@ function replyBody(ref, text4) {
|
|
|
5818
6253
|
};
|
|
5819
6254
|
}
|
|
5820
6255
|
async function replyToComment(confirmed, client) {
|
|
5821
|
-
const { ref, text:
|
|
6256
|
+
const { ref, text: text5 } = confirmed.payload;
|
|
5822
6257
|
const result = await client.request({
|
|
5823
6258
|
url: REPLY_URL,
|
|
5824
6259
|
method: "POST",
|
|
5825
|
-
body: replyBody(ref,
|
|
6260
|
+
body: replyBody(ref, text5),
|
|
5826
6261
|
spendClass: "write",
|
|
5827
6262
|
operation: "reply"
|
|
5828
6263
|
});
|
|
@@ -6184,8 +6619,8 @@ function whenLine(at, now) {
|
|
|
6184
6619
|
const away = hours < 48 ? `in ${hours} h` : `in ${Math.round(hours / 24)} days`;
|
|
6185
6620
|
return `when ${local} (${zone}) \u2014 ${away}`;
|
|
6186
6621
|
}
|
|
6187
|
-
async function runShare(
|
|
6188
|
-
if (
|
|
6622
|
+
async function runShare(text5, visibility, now = Date.now(), deps = terminalDeps(), via2, media, at, poll, link = {}) {
|
|
6623
|
+
if (text5 === void 0 || text5.trim() === "") {
|
|
6189
6624
|
return err("share", "INVALID_INPUT", "text is required", 'lnrelay share "<text>"');
|
|
6190
6625
|
}
|
|
6191
6626
|
const vis = visibility === "connections" ? "CONNECTIONS" : "PUBLIC";
|
|
@@ -6200,7 +6635,7 @@ async function runShare(text4, visibility, now = Date.now(), deps = terminalDeps
|
|
|
6200
6635
|
via: via2
|
|
6201
6636
|
});
|
|
6202
6637
|
if (pollSpec !== void 0 && "ok" in pollSpec) return pollSpec;
|
|
6203
|
-
const cardUrl = link.card !== false && loaded === void 0 && pollSpec === void 0 && via2 !== "oauth" ? firstUrl(
|
|
6638
|
+
const cardUrl = link.card !== false && loaded === void 0 && pollSpec === void 0 && via2 !== "oauth" ? firstUrl(text5) : null;
|
|
6204
6639
|
const needs = shareNeeds(loaded?.approved.length, scheduledAt, pollSpec, cardUrl);
|
|
6205
6640
|
const ctx = prepare("share", now, needs.voyagerOnly ? "voyager" : via2, needs.calls);
|
|
6206
6641
|
if ("ok" in ctx) return ctx;
|
|
@@ -6209,7 +6644,7 @@ async function runShare(text4, visibility, now = Date.now(), deps = terminalDeps
|
|
|
6209
6644
|
const plan = sharePlan({
|
|
6210
6645
|
author: authorLine(ctx.transport),
|
|
6211
6646
|
transport: ctx.transport.kind,
|
|
6212
|
-
text:
|
|
6647
|
+
text: text5,
|
|
6213
6648
|
visibility: vis,
|
|
6214
6649
|
media: loaded?.approved,
|
|
6215
6650
|
scheduledAt,
|
|
@@ -6232,7 +6667,7 @@ async function runShare(text4, visibility, now = Date.now(), deps = terminalDeps
|
|
|
6232
6667
|
note: "note" in result ? result.note : ctx.note
|
|
6233
6668
|
});
|
|
6234
6669
|
}
|
|
6235
|
-
async function runEditPost(urn,
|
|
6670
|
+
async function runEditPost(urn, text5, now, deps) {
|
|
6236
6671
|
const unapprovable = refuseUnapprovable("edit", "editing", deps);
|
|
6237
6672
|
if (unapprovable !== null) return unapprovable;
|
|
6238
6673
|
const ctx = prepare("edit", now, "voyager");
|
|
@@ -6247,12 +6682,12 @@ async function runEditPost(urn, text4, now, deps) {
|
|
|
6247
6682
|
const before = await lookup(urn, true);
|
|
6248
6683
|
const plan = {
|
|
6249
6684
|
action: "edit your post",
|
|
6250
|
-
payload: { urn, text:
|
|
6685
|
+
payload: { urn, text: text5 },
|
|
6251
6686
|
summary: [
|
|
6252
6687
|
authorLine(ctx.transport),
|
|
6253
6688
|
`post ${urn}`,
|
|
6254
6689
|
...previewLines2(before).map((l) => l.replace(/^content /, "was ")),
|
|
6255
|
-
`new text "${
|
|
6690
|
+
`new text "${text5}"`
|
|
6256
6691
|
],
|
|
6257
6692
|
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",
|
|
6258
6693
|
transport: "voyager"
|
|
@@ -6276,7 +6711,7 @@ function liveProfile(session) {
|
|
|
6276
6711
|
};
|
|
6277
6712
|
}
|
|
6278
6713
|
var PROFILE_HINT = `profile fields: ${Object.keys(PROFILE_FIELDS).join(", ")}`;
|
|
6279
|
-
async function runEditProfile(name,
|
|
6714
|
+
async function runEditProfile(name, text5, now = Date.now(), deps = terminalDeps(), surface) {
|
|
6280
6715
|
const field = PROFILE_FIELDS[name];
|
|
6281
6716
|
if (field === void 0) {
|
|
6282
6717
|
return err(
|
|
@@ -6286,7 +6721,7 @@ async function runEditProfile(name, text4, now = Date.now(), deps = terminalDeps
|
|
|
6286
6721
|
PROFILE_HINT
|
|
6287
6722
|
);
|
|
6288
6723
|
}
|
|
6289
|
-
if (
|
|
6724
|
+
if (text5 === void 0 || text5.trim() === "") {
|
|
6290
6725
|
return err(
|
|
6291
6726
|
"edit",
|
|
6292
6727
|
"INVALID_INPUT",
|
|
@@ -6294,11 +6729,11 @@ async function runEditProfile(name, text4, now = Date.now(), deps = terminalDeps
|
|
|
6294
6729
|
`lnrelay edit ${name} "<text>"`
|
|
6295
6730
|
);
|
|
6296
6731
|
}
|
|
6297
|
-
if (
|
|
6732
|
+
if (text5.length > field.maxLength) {
|
|
6298
6733
|
return err(
|
|
6299
6734
|
"edit",
|
|
6300
6735
|
"INVALID_INPUT",
|
|
6301
|
-
`the ${name} is ${
|
|
6736
|
+
`the ${name} is ${text5.length} characters; LinkedIn allows ${field.maxLength}`
|
|
6302
6737
|
);
|
|
6303
6738
|
}
|
|
6304
6739
|
const unapprovable = refuseUnapprovable("edit", "editing", deps);
|
|
@@ -6314,19 +6749,19 @@ async function runEditProfile(name, text4, now = Date.now(), deps = terminalDeps
|
|
|
6314
6749
|
const form = await profile.open(field, me.vanity);
|
|
6315
6750
|
if (!form.ok) return err("edit", form.code, form.message, form.hint);
|
|
6316
6751
|
const was = currentValue(form, field) ?? "";
|
|
6317
|
-
if (was ===
|
|
6752
|
+
if (was === text5) {
|
|
6318
6753
|
return err("edit", "INVALID_INPUT", `your ${name} already reads exactly that; nothing to save`);
|
|
6319
6754
|
}
|
|
6320
|
-
const built = saveBody(form, field,
|
|
6755
|
+
const built = saveBody(form, field, text5);
|
|
6321
6756
|
if (!built.ok) return err("edit", built.code, built.message, built.hint);
|
|
6322
6757
|
const plan = {
|
|
6323
6758
|
action: `change your ${name}`,
|
|
6324
|
-
payload: { field: name, was, text:
|
|
6759
|
+
payload: { field: name, was, text: text5 },
|
|
6325
6760
|
summary: [
|
|
6326
6761
|
authorLine(ctx.transport),
|
|
6327
6762
|
`field ${name}`,
|
|
6328
6763
|
`was "${was}"`,
|
|
6329
|
-
`new "${
|
|
6764
|
+
`new "${text5}"`
|
|
6330
6765
|
],
|
|
6331
6766
|
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.",
|
|
6332
6767
|
transport: "voyager"
|
|
@@ -6337,7 +6772,7 @@ async function runEditProfile(name, text4, now = Date.now(), deps = terminalDeps
|
|
|
6337
6772
|
if (!sent.ok) return err("edit", sent.code, sent.message, sent.hint);
|
|
6338
6773
|
const after = await profile.open(field, me.vanity);
|
|
6339
6774
|
const reads = after.ok ? currentValue(after, field) : void 0;
|
|
6340
|
-
if (reads !==
|
|
6775
|
+
if (reads !== text5) {
|
|
6341
6776
|
return err(
|
|
6342
6777
|
"edit",
|
|
6343
6778
|
"SCHEMA_DRIFT",
|
|
@@ -6376,8 +6811,8 @@ async function harvest(activityId, session, now) {
|
|
|
6376
6811
|
if (!found.ok) return err("comment", "SCHEMA_DRIFT", found.message, found.hint);
|
|
6377
6812
|
return { ok: true, tokens: { bindingKey: found.bindingKey, trackingId: found.trackingId } };
|
|
6378
6813
|
}
|
|
6379
|
-
async function runComment(postUrn2,
|
|
6380
|
-
if (postUrn2 === void 0 ||
|
|
6814
|
+
async function runComment(postUrn2, text5, now = Date.now(), deps = terminalDeps()) {
|
|
6815
|
+
if (postUrn2 === void 0 || text5 === void 0 || text5.trim() === "") {
|
|
6381
6816
|
return err(
|
|
6382
6817
|
"comment",
|
|
6383
6818
|
"INVALID_INPUT",
|
|
@@ -6414,11 +6849,11 @@ async function runComment(postUrn2, text4, now = Date.now(), deps = terminalDeps
|
|
|
6414
6849
|
if (!("tokens" in harvested)) return harvested;
|
|
6415
6850
|
const plan = {
|
|
6416
6851
|
action: "comment on a post",
|
|
6417
|
-
payload: { activityId, text:
|
|
6852
|
+
payload: { activityId, text: text5, tokens: harvested.tokens },
|
|
6418
6853
|
// The harvested trackingId changes on every render, so --plan and --confirm
|
|
6419
6854
|
// would never agree on a token derived from it. The intent is what's approved.
|
|
6420
|
-
tokenBasis: { activityId, text:
|
|
6421
|
-
summary: [authorLine(ctx.transport), `on ${postUrn2}`, `content "${
|
|
6855
|
+
tokenBasis: { activityId, text: text5 },
|
|
6856
|
+
summary: [authorLine(ctx.transport), `on ${postUrn2}`, `content "${text5}"`],
|
|
6422
6857
|
reversibility: "deletable with `lnrelay delete <comment-urn>`; the author is notified immediately",
|
|
6423
6858
|
transport: "voyager"
|
|
6424
6859
|
};
|
|
@@ -6430,8 +6865,8 @@ async function runComment(postUrn2, text4, now = Date.now(), deps = terminalDeps
|
|
|
6430
6865
|
);
|
|
6431
6866
|
return result.ok ? ok("comment", { on: postUrn2 }) : err("comment", result.code, result.message, result.hint);
|
|
6432
6867
|
}
|
|
6433
|
-
async function runEdit(commentUrn,
|
|
6434
|
-
if (commentUrn === void 0 ||
|
|
6868
|
+
async function runEdit(commentUrn, text5, now = Date.now(), deps = terminalDeps()) {
|
|
6869
|
+
if (commentUrn === void 0 || text5 === void 0 || text5.trim() === "") {
|
|
6435
6870
|
return err(
|
|
6436
6871
|
"edit",
|
|
6437
6872
|
"INVALID_INPUT",
|
|
@@ -6441,11 +6876,11 @@ async function runEdit(commentUrn, text4, now = Date.now(), deps = terminalDeps(
|
|
|
6441
6876
|
}
|
|
6442
6877
|
const ref = parseCommentUrn(commentUrn);
|
|
6443
6878
|
if (ref === null && !commentUrn.startsWith("urn:")) {
|
|
6444
|
-
return runEditProfile(commentUrn,
|
|
6879
|
+
return runEditProfile(commentUrn, text5, now, deps);
|
|
6445
6880
|
}
|
|
6446
6881
|
if (ref === null) {
|
|
6447
6882
|
if (/^urn:li:(share|ugcPost):\d+$/.test(commentUrn)) {
|
|
6448
|
-
return runEditPost(commentUrn,
|
|
6883
|
+
return runEditPost(commentUrn, text5, now, deps);
|
|
6449
6884
|
}
|
|
6450
6885
|
return err(
|
|
6451
6886
|
"edit",
|
|
@@ -6465,8 +6900,8 @@ async function runEdit(commentUrn, text4, now = Date.now(), deps = terminalDeps(
|
|
|
6465
6900
|
if (!("tokens" in harvested)) return harvested;
|
|
6466
6901
|
const plan = {
|
|
6467
6902
|
action: "edit your comment",
|
|
6468
|
-
payload: { urn: commentUrn, text:
|
|
6469
|
-
summary: [authorLine(ctx.transport), `comment ${commentUrn}`, `new text "${
|
|
6903
|
+
payload: { urn: commentUrn, text: text5 },
|
|
6904
|
+
summary: [authorLine(ctx.transport), `comment ${commentUrn}`, `new text "${text5}"`],
|
|
6470
6905
|
reversibility: "editable again, but the previous text is NOT recoverable here and LinkedIn marks the comment as edited",
|
|
6471
6906
|
transport: "voyager"
|
|
6472
6907
|
};
|
|
@@ -6477,11 +6912,11 @@ async function runEdit(commentUrn, text4, now = Date.now(), deps = terminalDeps(
|
|
|
6477
6912
|
UPDATE_OP,
|
|
6478
6913
|
harvested.tokens.trackingId,
|
|
6479
6914
|
createLiveClient(ctx.transport.session),
|
|
6480
|
-
|
|
6915
|
+
text5
|
|
6481
6916
|
);
|
|
6482
6917
|
return result.ok ? ok("edit", { edited: commentUrn }) : err("edit", result.code, result.message, result.hint);
|
|
6483
6918
|
}
|
|
6484
|
-
var
|
|
6919
|
+
var REACTIONS3 = REACTIONS2;
|
|
6485
6920
|
async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps(), remove = false) {
|
|
6486
6921
|
const reaction = type.toUpperCase();
|
|
6487
6922
|
if (postUrn2 === void 0) {
|
|
@@ -6492,12 +6927,12 @@ async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps(),
|
|
|
6492
6927
|
"lnrelay react <urn> [--type LIKE] [--remove]"
|
|
6493
6928
|
);
|
|
6494
6929
|
}
|
|
6495
|
-
if (!
|
|
6930
|
+
if (!REACTIONS3.includes(reaction)) {
|
|
6496
6931
|
return err(
|
|
6497
6932
|
"react",
|
|
6498
6933
|
"INVALID_INPUT",
|
|
6499
6934
|
`unknown reaction '${type}'`,
|
|
6500
|
-
`one of: ${
|
|
6935
|
+
`one of: ${REACTIONS3.join(", ")}`
|
|
6501
6936
|
);
|
|
6502
6937
|
}
|
|
6503
6938
|
const ctx = prepare("react", now, "voyager");
|
|
@@ -6521,8 +6956,8 @@ async function runReact(postUrn2, type, now = Date.now(), deps = terminalDeps(),
|
|
|
6521
6956
|
const result = await react(gated.confirmed, createLiveClient(ctx.transport.session));
|
|
6522
6957
|
return result.ok ? ok("react", { id: result.id, removed: remove }) : err("react", result.code, result.message, result.hint);
|
|
6523
6958
|
}
|
|
6524
|
-
async function runReply(commentUrn,
|
|
6525
|
-
if (commentUrn === void 0 ||
|
|
6959
|
+
async function runReply(commentUrn, text5, now = Date.now(), deps = terminalDeps()) {
|
|
6960
|
+
if (commentUrn === void 0 || text5 === void 0 || text5.trim() === "") {
|
|
6526
6961
|
return err(
|
|
6527
6962
|
"reply",
|
|
6528
6963
|
"INVALID_INPUT",
|
|
@@ -6548,8 +6983,8 @@ async function runReply(commentUrn, text4, now = Date.now(), deps = terminalDeps
|
|
|
6548
6983
|
}
|
|
6549
6984
|
const plan = {
|
|
6550
6985
|
action: "reply to a comment",
|
|
6551
|
-
payload: { ref: parent, text:
|
|
6552
|
-
summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${
|
|
6986
|
+
payload: { ref: parent, text: text5 },
|
|
6987
|
+
summary: [authorLine(ctx.transport), `replying to ${commentUrn}`, `content "${text5}"`],
|
|
6553
6988
|
reversibility: "deletable with `lnrelay delete <the reply urn>`; the comment author is notified immediately",
|
|
6554
6989
|
transport: "voyager"
|
|
6555
6990
|
};
|
|
@@ -6808,6 +7243,254 @@ async function runExperience(quiet = false) {
|
|
|
6808
7243
|
});
|
|
6809
7244
|
}
|
|
6810
7245
|
|
|
7246
|
+
// src/engine/search.ts
|
|
7247
|
+
var SEARCH_KINDS = {
|
|
7248
|
+
companies: "COMPANIES",
|
|
7249
|
+
groups: "GROUPS",
|
|
7250
|
+
events: "EVENTS",
|
|
7251
|
+
courses: "LEARNING",
|
|
7252
|
+
products: "PRODUCTS",
|
|
7253
|
+
services: "SERVICES",
|
|
7254
|
+
schools: "SCHOOLS"
|
|
7255
|
+
};
|
|
7256
|
+
var SEARCH_PAGE = PEOPLE_PAGE;
|
|
7257
|
+
function searchUrl(q2) {
|
|
7258
|
+
return peopleSearchUrl({
|
|
7259
|
+
...q2.keywords !== void 0 ? { keywords: q2.keywords } : {},
|
|
7260
|
+
params: q2.params,
|
|
7261
|
+
start: q2.start,
|
|
7262
|
+
...q2.withFilters === true ? { withFilters: true } : {},
|
|
7263
|
+
kind: SEARCH_KINDS[q2.kind]
|
|
7264
|
+
});
|
|
7265
|
+
}
|
|
7266
|
+
var text4 = (v) => {
|
|
7267
|
+
const t = v?.text;
|
|
7268
|
+
return typeof t === "string" && t.trim() !== "" ? t.trim().replace(/\s+/g, " ") : void 0;
|
|
7269
|
+
};
|
|
7270
|
+
function idOf(entityUrn) {
|
|
7271
|
+
const inner = String(entityUrn ?? "").match(/\((urn:li:[A-Za-z_]+:[^,)]+)/)?.[1];
|
|
7272
|
+
return inner?.split(":").pop();
|
|
7273
|
+
}
|
|
7274
|
+
function cleanUrl2(nav) {
|
|
7275
|
+
if (typeof nav !== "string" || !nav.startsWith("https://")) return void 0;
|
|
7276
|
+
return nav.split("?")[0];
|
|
7277
|
+
}
|
|
7278
|
+
function rowToFound(row) {
|
|
7279
|
+
const id = idOf(row.entityUrn);
|
|
7280
|
+
const name = text4(row.title);
|
|
7281
|
+
if (id === void 0 || name === void 0) return void 0;
|
|
7282
|
+
const found = { id, name };
|
|
7283
|
+
const fields = [
|
|
7284
|
+
["subtitle", text4(row.primarySubtitle)],
|
|
7285
|
+
["detail", text4(row.secondarySubtitle)],
|
|
7286
|
+
["summary", text4(row.summary)],
|
|
7287
|
+
["url", cleanUrl2(row.navigationUrl)]
|
|
7288
|
+
];
|
|
7289
|
+
for (const [k, v] of fields)
|
|
7290
|
+
if (v !== void 0) found[k] = v;
|
|
7291
|
+
if (JSON.stringify(row.badgeIcon ?? null).includes("VERIFIED")) found.verified = true;
|
|
7292
|
+
return found;
|
|
7293
|
+
}
|
|
7294
|
+
var drift5 = (message) => ({
|
|
7295
|
+
ok: false,
|
|
7296
|
+
code: "SCHEMA_DRIFT",
|
|
7297
|
+
message,
|
|
7298
|
+
hint: "the search response changed shape; re-capture it"
|
|
7299
|
+
});
|
|
7300
|
+
function parseResults(json) {
|
|
7301
|
+
const c = clustersOf(json);
|
|
7302
|
+
if (c === void 0 || !Array.isArray(c.elements))
|
|
7303
|
+
return drift5("the search returned no result list");
|
|
7304
|
+
const included = json.included ?? [];
|
|
7305
|
+
const { people: items, unknownTypes, excluded, unresolved } = readItems(c, included, rowToFound);
|
|
7306
|
+
const total = typeof c.paging?.total === "number" ? c.paging.total : void 0;
|
|
7307
|
+
const start = typeof c.paging?.start === "number" ? c.paging.start : 0;
|
|
7308
|
+
const claimedRaw = c.metadata?.totalResultCount;
|
|
7309
|
+
const claimed = typeof claimedRaw === "number" ? claimedRaw : total;
|
|
7310
|
+
if (unresolved > 0 && items.length === 0)
|
|
7311
|
+
return drift5(`${unresolved} results were listed but none could be read`);
|
|
7312
|
+
if (items.length === 0 && total !== void 0 && total > start) {
|
|
7313
|
+
return {
|
|
7314
|
+
ok: false,
|
|
7315
|
+
code: "SCHEMA_DRIFT",
|
|
7316
|
+
message: `LinkedIn claims ${total} results but returned none from ${start}`,
|
|
7317
|
+
hint: 'a failed fetch, not an empty search; do not report "none"'
|
|
7318
|
+
};
|
|
7319
|
+
}
|
|
7320
|
+
return {
|
|
7321
|
+
ok: true,
|
|
7322
|
+
items,
|
|
7323
|
+
...total !== void 0 ? { total } : {},
|
|
7324
|
+
...claimed !== void 0 ? { claimed } : {},
|
|
7325
|
+
start,
|
|
7326
|
+
excluded,
|
|
7327
|
+
unknownTypes
|
|
7328
|
+
};
|
|
7329
|
+
}
|
|
7330
|
+
|
|
7331
|
+
// src/commands/search-kinds.ts
|
|
7332
|
+
var PAGING4 = { pageSize: SEARCH_PAGE, max: 1e3 };
|
|
7333
|
+
var FLAGS = {
|
|
7334
|
+
location: { companies: "companyHqGeo", services: "geoUrn" },
|
|
7335
|
+
industry: { companies: "industryCompanyVertical" },
|
|
7336
|
+
network: { companies: "network", services: "network" }
|
|
7337
|
+
};
|
|
7338
|
+
var NETWORK2 = {
|
|
7339
|
+
"1st": "F",
|
|
7340
|
+
"2nd": "S",
|
|
7341
|
+
"3rd+": "O",
|
|
7342
|
+
F: "F",
|
|
7343
|
+
S: "S",
|
|
7344
|
+
O: "O"
|
|
7345
|
+
};
|
|
7346
|
+
function paramFor(flag, kind) {
|
|
7347
|
+
const param = FLAGS[flag][kind];
|
|
7348
|
+
if (param !== void 0) return param;
|
|
7349
|
+
return {
|
|
7350
|
+
ok: false,
|
|
7351
|
+
code: "INVALID_INPUT",
|
|
7352
|
+
message: `${kind} cannot be filtered by --${flag}`,
|
|
7353
|
+
hint: `--${flag} works for: ${Object.keys(FLAGS[flag]).join(", ")}; other filters are in \`search-filters ${kind}\``
|
|
7354
|
+
};
|
|
7355
|
+
}
|
|
7356
|
+
async function paramsOf(kind, req, get) {
|
|
7357
|
+
const params = {};
|
|
7358
|
+
const resolved = {};
|
|
7359
|
+
if (req.industry !== void 0 && req.industry.length > 0) {
|
|
7360
|
+
const p = paramFor("industry", kind);
|
|
7361
|
+
if (typeof p !== "string") return p;
|
|
7362
|
+
params[p] = req.industry;
|
|
7363
|
+
}
|
|
7364
|
+
if (req.network !== void 0 && req.network.length > 0) {
|
|
7365
|
+
const p = paramFor("network", kind);
|
|
7366
|
+
if (typeof p !== "string") return p;
|
|
7367
|
+
const codes = req.network.map((n) => NETWORK2[n]);
|
|
7368
|
+
if (codes.some((c) => c === void 0))
|
|
7369
|
+
return { ok: false, code: "INVALID_INPUT", message: "--network takes 1st, 2nd, 3rd+" };
|
|
7370
|
+
params[p] = codes;
|
|
7371
|
+
}
|
|
7372
|
+
for (const r of req.raw ?? []) {
|
|
7373
|
+
const m = r.match(/^([A-Za-z_]+)=(.+)$/);
|
|
7374
|
+
if (m?.[1] === void 0 || m[2] === void 0)
|
|
7375
|
+
return {
|
|
7376
|
+
ok: false,
|
|
7377
|
+
code: "INVALID_INPUT",
|
|
7378
|
+
message: `--filter '${r}' is not key=value[,value]`
|
|
7379
|
+
};
|
|
7380
|
+
params[m[1]] = m[2].split(",").map((v) => v.trim()).filter((v) => v !== "");
|
|
7381
|
+
}
|
|
7382
|
+
if (req.location !== void 0 && req.location.trim() !== "") {
|
|
7383
|
+
const p = paramFor("location", kind);
|
|
7384
|
+
if (typeof p !== "string") return p;
|
|
7385
|
+
const place = await resolvePlace(get, req.location.trim());
|
|
7386
|
+
if ("ok" in place) return place;
|
|
7387
|
+
params[p] = [...params[p] ?? [], place.id];
|
|
7388
|
+
resolved.location = place;
|
|
7389
|
+
}
|
|
7390
|
+
return { params, resolved };
|
|
7391
|
+
}
|
|
7392
|
+
function compactFound(f) {
|
|
7393
|
+
return line([
|
|
7394
|
+
f.id,
|
|
7395
|
+
f.name,
|
|
7396
|
+
f.subtitle,
|
|
7397
|
+
f.detail,
|
|
7398
|
+
f.verified ? "verified" : void 0,
|
|
7399
|
+
f.summary !== void 0 && f.summary.length > 120 ? `${f.summary.slice(0, 117)}\u2026` : f.summary,
|
|
7400
|
+
f.url,
|
|
7401
|
+
f.matched !== void 0 ? `matched: ${f.matched.join(" + ")}` : void 0
|
|
7402
|
+
]);
|
|
7403
|
+
}
|
|
7404
|
+
async function runFind(kind, req, opts = {}, fetch2) {
|
|
7405
|
+
const command = `search ${kind}`;
|
|
7406
|
+
const sets = keywordSets(req.keywords);
|
|
7407
|
+
const anyFilter = (req.location ?? "").trim() !== "" || (req.industry?.length ?? 0) > 0 || (req.network?.length ?? 0) > 0 || (req.raw?.length ?? 0) > 0;
|
|
7408
|
+
if (sets.length === 0 && !anyFilter) {
|
|
7409
|
+
return err(
|
|
7410
|
+
command,
|
|
7411
|
+
"INVALID_INPUT",
|
|
7412
|
+
"give keywords, a filter, or both",
|
|
7413
|
+
`lnrelay search ${kind} "<keywords>"`
|
|
7414
|
+
);
|
|
7415
|
+
}
|
|
7416
|
+
const get = fetch2 ?? liveFetch2(command, opts.quiet === true);
|
|
7417
|
+
if (typeof get !== "function") return get;
|
|
7418
|
+
const p = await paramsOf(kind, req, get);
|
|
7419
|
+
if ("ok" in p) return err(command, p.code, p.message, p.hint);
|
|
7420
|
+
const first = Math.max(0, req.start ?? 0);
|
|
7421
|
+
const want = Math.max(1, Math.min(req.limit, PAGING4.max - first));
|
|
7422
|
+
const fetchPage = async (keywords, start) => {
|
|
7423
|
+
const res = await get(
|
|
7424
|
+
searchUrl({ kind, ...keywords ? { keywords } : {}, params: p.params, start }),
|
|
7425
|
+
"search"
|
|
7426
|
+
);
|
|
7427
|
+
const page = res.ok ? parseResults(res.json) : res;
|
|
7428
|
+
if (!page.ok) return page;
|
|
7429
|
+
return {
|
|
7430
|
+
ok: true,
|
|
7431
|
+
items: page.items,
|
|
7432
|
+
...page.total !== void 0 ? { total: page.total } : {},
|
|
7433
|
+
...page.claimed !== void 0 ? { claimed: page.claimed } : {},
|
|
7434
|
+
unknownTypes: page.unknownTypes
|
|
7435
|
+
};
|
|
7436
|
+
};
|
|
7437
|
+
const merged = await searchAll(
|
|
7438
|
+
fetchPage,
|
|
7439
|
+
sets.length > 0 ? sets : [void 0],
|
|
7440
|
+
first,
|
|
7441
|
+
want,
|
|
7442
|
+
PAGING4
|
|
7443
|
+
);
|
|
7444
|
+
if (merged.rows.length === 0 && merged.failure !== void 0) {
|
|
7445
|
+
const f = merged.failure;
|
|
7446
|
+
return err(command, f.code, f.message, f.hint);
|
|
7447
|
+
}
|
|
7448
|
+
const single = sets.length <= 1;
|
|
7449
|
+
return ok("search", {
|
|
7450
|
+
kind,
|
|
7451
|
+
query: { ...sets.length > 0 ? { keywords: single ? sets[0] : sets } : {}, params: p.params },
|
|
7452
|
+
...Object.keys(p.resolved).length > 0 ? { resolved: p.resolved } : {},
|
|
7453
|
+
items: shape2(merged.rows, opts, compactFound),
|
|
7454
|
+
meta: metaOf(command, merged, single, first)
|
|
7455
|
+
});
|
|
7456
|
+
}
|
|
7457
|
+
async function runFindFilters(kind, req, opts = {}, fetch2) {
|
|
7458
|
+
const command = `search-filters ${kind}`;
|
|
7459
|
+
const sets = keywordSets(req.keywords);
|
|
7460
|
+
if (sets.length > 1)
|
|
7461
|
+
return err(
|
|
7462
|
+
command,
|
|
7463
|
+
"INVALID_INPUT",
|
|
7464
|
+
"search-filters takes one keyword set: its counts belong to that one query"
|
|
7465
|
+
);
|
|
7466
|
+
const get = fetch2 ?? liveFetch2(command, opts.quiet === true);
|
|
7467
|
+
if (typeof get !== "function") return get;
|
|
7468
|
+
const p = await paramsOf(kind, req, get);
|
|
7469
|
+
if ("ok" in p) return err(command, p.code, p.message, p.hint);
|
|
7470
|
+
const res = await get(
|
|
7471
|
+
searchUrl({
|
|
7472
|
+
kind,
|
|
7473
|
+
...sets[0] !== void 0 ? { keywords: sets[0] } : {},
|
|
7474
|
+
params: p.params,
|
|
7475
|
+
start: 0,
|
|
7476
|
+
withFilters: true
|
|
7477
|
+
}),
|
|
7478
|
+
"search"
|
|
7479
|
+
);
|
|
7480
|
+
const parsed = res.ok ? parsePeopleFilters(res.json) : res;
|
|
7481
|
+
if (!parsed.ok) return err(command, parsed.code, parsed.message, parsed.hint);
|
|
7482
|
+
return ok("search-filters", {
|
|
7483
|
+
kind,
|
|
7484
|
+
...Object.keys(p.resolved).length > 0 ? { resolved: p.resolved } : {},
|
|
7485
|
+
items: shape2(parsed.filters, opts, (f) => {
|
|
7486
|
+
const how = f.input === "text" ? "free text" : "ids";
|
|
7487
|
+
const options = f.options.map((o) => `${o.value}=${o.label}${o.count !== void 0 ? ` (${o.count})` : ""}`).join(", ");
|
|
7488
|
+
return `${f.key} [${how}]${options !== "" ? `: ${options}` : ""}`;
|
|
7489
|
+
}),
|
|
7490
|
+
meta: { state: "complete", operation: command, returnedCount: parsed.filters.length }
|
|
7491
|
+
});
|
|
7492
|
+
}
|
|
7493
|
+
|
|
6811
7494
|
// src/engine/sdui-skill.ts
|
|
6812
7495
|
var SKILL = {
|
|
6813
7496
|
addScreen: "com.linkedin.sdui.flagshipnav.profile.ProfileSkillAddForm",
|
|
@@ -6829,11 +7512,11 @@ function skillsFromPage(stream) {
|
|
|
6829
7512
|
for (; ; ) {
|
|
6830
7513
|
i = stream.indexOf(EDIT_NAV2, i);
|
|
6831
7514
|
if (i === -1) break;
|
|
6832
|
-
const
|
|
7515
|
+
const text5 = balanced(stream, i);
|
|
6833
7516
|
const end = i;
|
|
6834
7517
|
i += EDIT_NAV2.length;
|
|
6835
|
-
if (
|
|
6836
|
-
const payload = JSON.parse(
|
|
7518
|
+
if (text5 === null) continue;
|
|
7519
|
+
const payload = JSON.parse(text5).requestedArguments?.payload;
|
|
6837
7520
|
const id = payload?.skillId;
|
|
6838
7521
|
if (typeof id !== "string" || payload === void 0 || skills.some((s) => s.skillId === id))
|
|
6839
7522
|
continue;
|
|
@@ -6841,7 +7524,7 @@ function skillsFromPage(stream) {
|
|
|
6841
7524
|
(m) => JSON.parse(`"${m[1]}"`)
|
|
6842
7525
|
);
|
|
6843
7526
|
skills.push({ skillId: id, name: names.length === 1 ? names[0] ?? null : null, payload });
|
|
6844
|
-
from = end +
|
|
7527
|
+
from = end + text5.length;
|
|
6845
7528
|
}
|
|
6846
7529
|
return { ok: true, skills };
|
|
6847
7530
|
}
|
|
@@ -6910,9 +7593,9 @@ async function fetchSkills(vanityName, client) {
|
|
|
6910
7593
|
if (typeof screen !== "string") return screen;
|
|
6911
7594
|
const at = screen.indexOf('"filter":"ProfileSkillCategory_ALL"');
|
|
6912
7595
|
const open = at === -1 ? -1 : screen.lastIndexOf('"payload":{', at);
|
|
6913
|
-
const
|
|
6914
|
-
if (
|
|
6915
|
-
const payload = JSON.parse(
|
|
7596
|
+
const text5 = open === -1 ? null : balanced(screen, open + '"payload":'.length);
|
|
7597
|
+
if (text5 === null) return drift4("the Skills screen carried no list request");
|
|
7598
|
+
const payload = JSON.parse(text5);
|
|
6916
7599
|
const count2 = typeof payload.count === "number" ? payload.count : 10;
|
|
6917
7600
|
const skills = [];
|
|
6918
7601
|
for (let page = 0; page < MAX_PAGES2; page++) {
|
|
@@ -7339,6 +8022,91 @@ function peopleRequest(args) {
|
|
|
7339
8022
|
if (start !== void 0) req.start = start;
|
|
7340
8023
|
return req;
|
|
7341
8024
|
}
|
|
8025
|
+
var KINDS = ["people", "jobs", "posts", ...Object.keys(SEARCH_KINDS)];
|
|
8026
|
+
var afterKind = (args) => ({
|
|
8027
|
+
...args,
|
|
8028
|
+
positionals: args.positionals.slice(1)
|
|
8029
|
+
});
|
|
8030
|
+
function findRequest2(args) {
|
|
8031
|
+
const req = { limit: num(args, "limit") ?? 25 };
|
|
8032
|
+
const keywords = args.positionals.slice(1);
|
|
8033
|
+
if (keywords.length > 0) req.keywords = keywords;
|
|
8034
|
+
const location = str(args, "location");
|
|
8035
|
+
if (location !== void 0) req.location = location;
|
|
8036
|
+
const industry = many(args, "industry");
|
|
8037
|
+
if (industry.length > 0) req.industry = industry;
|
|
8038
|
+
const network = many(args, "network");
|
|
8039
|
+
if (network.length > 0) req.network = network;
|
|
8040
|
+
const raw = list(args, "filter");
|
|
8041
|
+
if (raw.length > 0) req.raw = raw;
|
|
8042
|
+
const start = num(args, "start");
|
|
8043
|
+
if (start !== void 0) req.start = start;
|
|
8044
|
+
return req;
|
|
8045
|
+
}
|
|
8046
|
+
function postsRequest(args) {
|
|
8047
|
+
const req = { limit: num(args, "limit") ?? 20 };
|
|
8048
|
+
const keywords = args.positionals.slice(1);
|
|
8049
|
+
if (keywords.length > 0) req.keywords = keywords;
|
|
8050
|
+
for (const [flag, key] of [
|
|
8051
|
+
["sort", "sort"],
|
|
8052
|
+
["posted", "posted"],
|
|
8053
|
+
["author-title", "authorTitle"]
|
|
8054
|
+
]) {
|
|
8055
|
+
const v = str(args, flag);
|
|
8056
|
+
if (v !== void 0) req[key] = v;
|
|
8057
|
+
}
|
|
8058
|
+
for (const [flag, key] of [
|
|
8059
|
+
["type", "type"],
|
|
8060
|
+
["posted-by", "postedBy"],
|
|
8061
|
+
["from", "from"],
|
|
8062
|
+
["mentions", "mentions"],
|
|
8063
|
+
["author-industry", "authorIndustry"]
|
|
8064
|
+
]) {
|
|
8065
|
+
const v = many(args, flag);
|
|
8066
|
+
if (v.length > 0) req[key] = v;
|
|
8067
|
+
}
|
|
8068
|
+
for (const [flag, key] of [
|
|
8069
|
+
["from-company", "fromCompany"],
|
|
8070
|
+
["mentions-company", "mentionsCompany"],
|
|
8071
|
+
["author-company", "authorCompany"]
|
|
8072
|
+
]) {
|
|
8073
|
+
const v = orgs(args, flag);
|
|
8074
|
+
if (v.length > 0) req[key] = v;
|
|
8075
|
+
}
|
|
8076
|
+
const raw = list(args, "filter");
|
|
8077
|
+
if (raw.length > 0) req.raw = raw;
|
|
8078
|
+
const start = num(args, "start");
|
|
8079
|
+
if (start !== void 0) req.start = start;
|
|
8080
|
+
return req;
|
|
8081
|
+
}
|
|
8082
|
+
function search2(args, filtersOnly) {
|
|
8083
|
+
const command = filtersOnly ? "search-filters" : "search";
|
|
8084
|
+
const kind = args.positionals[0];
|
|
8085
|
+
if (kind === void 0 || !KINDS.includes(kind)) {
|
|
8086
|
+
return err(
|
|
8087
|
+
command,
|
|
8088
|
+
"INVALID_INPUT",
|
|
8089
|
+
`unknown search kind '${kind ?? ""}'`,
|
|
8090
|
+
`one of: ${KINDS.join(", ")} \u2014 e.g. lnrelay ${command} companies "<keywords>"`
|
|
8091
|
+
);
|
|
8092
|
+
}
|
|
8093
|
+
const opts = output(args);
|
|
8094
|
+
if (kind === "people")
|
|
8095
|
+
return filtersOnly ? runPeopleFilters(peopleRequest(afterKind(args)), opts) : runPeople(peopleRequest(afterKind(args)), opts);
|
|
8096
|
+
if (kind === "jobs")
|
|
8097
|
+
return filtersOnly ? runJobFilters(jobsRequest(afterKind(args)), opts) : runJobs(jobsRequest(afterKind(args)), opts);
|
|
8098
|
+
if (kind === "posts") {
|
|
8099
|
+
if (filtersOnly)
|
|
8100
|
+
return err(
|
|
8101
|
+
command,
|
|
8102
|
+
"INVALID_INPUT",
|
|
8103
|
+
"posts filters are fixed: see `lnrelay help search`",
|
|
8104
|
+
"sort, posted, type, posted-by, from, mentions, from-company, mentions-company, author-company, author-industry, author-title"
|
|
8105
|
+
);
|
|
8106
|
+
return runPostsSearch(postsRequest(args), opts);
|
|
8107
|
+
}
|
|
8108
|
+
return filtersOnly ? runFindFilters(kind, findRequest2(args), opts) : runFind(kind, findRequest2(args), opts);
|
|
8109
|
+
}
|
|
7342
8110
|
function via(args) {
|
|
7343
8111
|
const value = str(args, "via");
|
|
7344
8112
|
if (value === void 0) return void 0;
|
|
@@ -7460,17 +8228,9 @@ async function dispatch(argv, now) {
|
|
|
7460
8228
|
case "people-filters":
|
|
7461
8229
|
return runPeopleFilters(peopleRequest(args), output(args));
|
|
7462
8230
|
case "search":
|
|
7463
|
-
|
|
7464
|
-
|
|
7465
|
-
|
|
7466
|
-
output(args)
|
|
7467
|
-
);
|
|
7468
|
-
return runSearch(
|
|
7469
|
-
args.positionals[0],
|
|
7470
|
-
args.positionals[1],
|
|
7471
|
-
num(args, "limit") ?? 10,
|
|
7472
|
-
output(args)
|
|
7473
|
-
);
|
|
8231
|
+
return search2(args, false);
|
|
8232
|
+
case "search-filters":
|
|
8233
|
+
return search2(args, true);
|
|
7474
8234
|
default:
|
|
7475
8235
|
return err(command, "NOT_IMPLEMENTED", `'${command}' has no runner wired`);
|
|
7476
8236
|
}
|
|
@@ -7521,13 +8281,13 @@ function edit(args, now, deps) {
|
|
|
7521
8281
|
if (inline !== void 0) {
|
|
7522
8282
|
return err("edit", "INVALID_INPUT", "pass the new text inline or with --file, not both");
|
|
7523
8283
|
}
|
|
7524
|
-
let
|
|
8284
|
+
let text5;
|
|
7525
8285
|
try {
|
|
7526
|
-
|
|
8286
|
+
text5 = readFileSync3(file, "utf-8").replace(/\n$/, "");
|
|
7527
8287
|
} catch {
|
|
7528
8288
|
return err("edit", "INVALID_INPUT", `cannot read ${file}`);
|
|
7529
8289
|
}
|
|
7530
|
-
return runEdit(target,
|
|
8290
|
+
return runEdit(target, text5, now, deps);
|
|
7531
8291
|
}
|
|
7532
8292
|
function role(args, now, deps) {
|
|
7533
8293
|
const [sub, target] = args.positionals;
|
|
@@ -7667,7 +8427,9 @@ function share3(args, now, deps) {
|
|
|
7667
8427
|
}
|
|
7668
8428
|
export {
|
|
7669
8429
|
dispatch,
|
|
8430
|
+
findRequest2 as findRequest,
|
|
7670
8431
|
jobsRequest,
|
|
7671
|
-
peopleRequest
|
|
8432
|
+
peopleRequest,
|
|
8433
|
+
postsRequest
|
|
7672
8434
|
};
|
|
7673
8435
|
//# sourceMappingURL=cli.js.map
|