@floomhq/signaldash 0.7.0 → 0.9.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/bin/sd.mjs +27 -25
- package/package.json +1 -1
package/bin/sd.mjs
CHANGED
|
@@ -276,36 +276,38 @@ export async function cmdStatus(dependencies = {}) {
|
|
|
276
276
|
|
|
277
277
|
export async function cmdConnections(outPath, dependencies = {}) {
|
|
278
278
|
const log = dependencies.log || console.log;
|
|
279
|
-
const error = dependencies.error || console.error;
|
|
280
279
|
const request = dependencies.request || api;
|
|
281
280
|
const { chalk, ora } = await ui();
|
|
282
|
-
const spin = ora({ text: "Fetching your LinkedIn connections...", indent: 2 }).start();
|
|
283
|
-
const r = await request("/li/connections", {});
|
|
284
|
-
if (r.status >= 300) { spin.fail(r.json.error || "failed"); process.exitCode = 1; return; }
|
|
285
|
-
const rows = r.json.connections || [];
|
|
286
|
-
spin.succeed(`${rows.length} connections`);
|
|
287
281
|
const { writeFileSync: wf } = await import("node:fs");
|
|
288
|
-
const esc = v => `"${String(v ?? "").replace(/"/g, '""')}"`;
|
|
289
|
-
const csv = ["name,headline,public_id,profile_url,connected_at",
|
|
290
|
-
...rows.map(c => [c.name, c.headline, c.public_id, c.profile_url, c.connected_at].map(esc).join(","))].join("\n");
|
|
291
282
|
const file = outPath || "linkedin-connections.csv";
|
|
292
|
-
wf(file, csv);
|
|
293
|
-
log(" " + chalk.green("+") + " saved " + chalk.cyan(file));
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
function printHelp(log = console.log) {
|
|
298
|
-
log(`SignalDash — secure LinkedIn + WhatsApp access for your agent.
|
|
299
283
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
284
|
+
// Background drip-sync: one page (~100 connections) per ~90s, server-side.
|
|
285
|
+
// A burst export of a large network looks robotic to LinkedIn; this paces it
|
|
286
|
+
// like a human and survives restarts, so the user just waits for the file.
|
|
287
|
+
const start = await request("/li/connections/sync", {});
|
|
288
|
+
if (start.status >= 300) {
|
|
289
|
+
(dependencies.error || console.error)(start.json.error || "could not start sync");
|
|
290
|
+
process.exitCode = 1; return;
|
|
291
|
+
}
|
|
292
|
+
const spin = ora({ text: "Syncing connections (paced to keep your account safe)...", indent: 2 }).start();
|
|
293
|
+
let done = false;
|
|
294
|
+
for (;;) {
|
|
295
|
+
const st = await request("/li/connections/sync", undefined, { method: "GET" });
|
|
296
|
+
const s2 = st.json || {};
|
|
297
|
+
spin.text = `Synced ${s2.fetched ?? 0} connections (${s2.pages ?? 0} pages)...`;
|
|
298
|
+
if (s2.status === "complete") { done = true; break; }
|
|
299
|
+
if (s2.status === "failed" || s2.status === "paused") { spin.warn(`sync ${s2.status}: ${s2.error || ""}`); break; }
|
|
300
|
+
await new Promise(r => setTimeout(r, 15000));
|
|
301
|
+
}
|
|
302
|
+
const dl = await request("/li/connections/download", undefined, { method: "GET" });
|
|
303
|
+
const rows = (dl.json && dl.json.connections) || [];
|
|
304
|
+
if (!rows.length) { spin.fail("nothing fetched yet, run again later to resume"); process.exitCode = 1; return; }
|
|
305
|
+
if (done) spin.succeed(`${rows.length} connections`);
|
|
306
|
+
const esc = v => `"${String(v ?? "").replace(/"/g, '""')}"`;
|
|
307
|
+
wf(file, ["name,headline,public_id,profile_url,connected_at",
|
|
308
|
+
...rows.map(c => [c.name, c.headline, c.public_id, c.profile_url, c.connected_at].map(esc).join(","))].join("\n"));
|
|
309
|
+
log(" " + chalk.green("+") + " saved " + chalk.cyan(file));
|
|
310
|
+
if (!done) log(" " + chalk.dim("sync still running; run this again later to get the rest"));
|
|
309
311
|
}
|
|
310
312
|
|
|
311
313
|
export async function main(argv = process.argv.slice(2), dependencies = {}) {
|