@curviate/cli 0.49.0 → 0.50.0-next.1
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/CHANGELOG.md +26 -0
- package/README.md +12 -5
- package/dist/{account-2BH2Q6VG.js → account-U7UJIE3H.js} +784 -116
- package/dist/analytics-MZU2WKON.js +27 -0
- package/dist/beta-consent-67IDUV3K.js +81 -0
- package/dist/billing-QAW75YE7.js +124 -0
- package/dist/{chunk-RXWODUWA.js → chunk-2W4RN5ON.js} +18 -2
- package/dist/{chunk-MGB6FE4A.js → chunk-3Z6PXS6N.js} +6 -6
- package/dist/chunk-5S3MJVI5.js +22 -0
- package/dist/{chunk-V7FJWTZW.js → chunk-6LBOGIVE.js} +4 -4
- package/dist/{chunk-Z7OQSWBD.js → chunk-6PLDAEMO.js} +85 -10
- package/dist/chunk-73DJ3KNE.js +54 -0
- package/dist/{chunk-3RCW7URJ.js → chunk-A57ZILRU.js} +1 -1
- package/dist/chunk-AVI7J47S.js +52 -0
- package/dist/{chunk-JYKYD57J.js → chunk-CKVCBGQX.js} +1 -1
- package/dist/chunk-EIA66ESN.js +339 -0
- package/dist/{chunk-YLSJ4HKU.js → chunk-ENBIMEKS.js} +26 -1
- package/dist/{chunk-LCGXJGPB.js → chunk-GHMRPX5H.js} +7 -1
- package/dist/chunk-GOICALYQ.js +28 -0
- package/dist/{chunk-PQWDDSV7.js → chunk-L7JH3W56.js} +1 -1
- package/dist/chunk-LCPPXOPN.js +528 -0
- package/dist/chunk-LRMPS4UQ.js +144 -0
- package/dist/{chunk-5ZGTU4VD.js → chunk-LULN3II2.js} +78 -5
- package/dist/chunk-PPGKQJKU.js +38 -0
- package/dist/chunk-Q3ZPRFUX.js +20 -0
- package/dist/{chunk-SA2QHAXG.js → chunk-QM57YDJE.js} +13 -201
- package/dist/{chunk-Y7MZZRYR.js → chunk-RYWWSZUH.js} +14 -2
- package/dist/{chunk-TEAWYLPO.js → chunk-TYNVJDYK.js} +49 -18
- package/dist/cli.js +34 -18
- package/dist/{comment-MRDPDA33.js → comment-6NRZILAS.js} +90 -11
- package/dist/{company-2AEHSGHA.js → company-VXE7IEPT.js} +65 -15
- package/dist/{config-NRBKHXES.js → config-3WP7OD35.js} +53 -4
- package/dist/{connect-4XEBV5V3.js → connect-FBK6UWZP.js} +63 -18
- package/dist/contact-HFPZ3KGL.js +32 -0
- package/dist/contact-groups-AI4MLGQS.js +399 -0
- package/dist/contact-import-54Y7EMU2.js +336 -0
- package/dist/core-RLMWMQEI.js +46 -0
- package/dist/do-not-contact-LQ5V6SPE.js +200 -0
- package/dist/{doctor-BZ4DA7DV.js → doctor-KKRL7TEF.js} +65 -11
- package/dist/{document-RKHRWXNT.js → document-GFRWPQFV.js} +1 -1
- package/dist/{draft-C5N6EOO5.js → draft-VSWZOCDR.js} +60 -14
- package/dist/{enrollment-BNQOUKI7.js → enrollment-OACCSBM5.js} +31 -19
- package/dist/{examples-NIMSIXMV.js → examples-JJB4DZKK.js} +2 -2
- package/dist/{exit-codes-TLMKTLRI.js → exit-codes-7DBETBDT.js} +1 -1
- package/dist/export-AQHAFVAB.js +96 -0
- package/dist/{feed-DFUU7SUJ.js → feed-HY4HT75U.js} +13 -10
- package/dist/{group-CSD2OWOZ.js → group-A3SMBFU5.js} +18 -10
- package/dist/{inbox-SNSPWI7J.js → inbox-YHUO2RPI.js} +31 -12
- package/dist/{inboxes-RIRHPS4H.js → inboxes-GKLMHPDR.js} +14 -10
- package/dist/incoming-NHROOOIZ.js +218 -0
- package/dist/{job-6PNXXZNF.js → job-QBW3PGWL.js} +65 -13
- package/dist/{login-Y7JBAHCW.js → login-GWIYHKYO.js} +13 -4
- package/dist/{message-2IK4MBBG.js → message-BFLN2VHS.js} +9 -7
- package/dist/{motion-7ATUXO6R.js → motion-LTWU2GPC.js} +39 -117
- package/dist/network-CNSBX2SR.js +235 -0
- package/dist/{notification-VYK5NDEB.js → notification-DCCFJPXU.js} +38 -11
- package/dist/notifications-AQBXBK4K.js +231 -0
- package/dist/{post-AN6T2OJF.js → post-PINZHSPS.js} +92 -12
- package/dist/{profile-UQY64642.js → profile-MJQJSNYR.js} +76 -20
- package/dist/{recruiter-OY4RN5HH.js → recruiter-X6GX4A2G.js} +133 -22
- package/dist/{sales-nav-KLODLYMW.js → sales-nav-44GYWDYE.js} +74 -19
- package/dist/{search-NWP5S6CF.js → search-SULIN6TB.js} +55 -23
- package/dist/{setup-YPPFLH2N.js → setup-ZQRHMRMB.js} +69 -17
- package/dist/team-TM6LRUY5.js +450 -0
- package/dist/tier-Z3U6AT7H.js +61 -0
- package/dist/unibox-BIMI2KY5.js +402 -0
- package/dist/{webhook-OHKBL3YS.js → webhook-EHXRTHBG.js} +257 -27
- package/package.json +2 -2
- package/dist/chunk-D2S5OCYU.js +0 -38
- package/dist/core-RGU2SCBN.js +0 -46
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
fail,
|
|
4
|
+
outputOpts
|
|
5
|
+
} from "./chunk-3Z6PXS6N.js";
|
|
6
|
+
|
|
7
|
+
// src/lib/chunks.ts
|
|
8
|
+
async function sendInChunks(ids, size, send, f) {
|
|
9
|
+
const chunks = [];
|
|
10
|
+
for (let k = 0; k < ids.length; k += size) chunks.push(ids.slice(k, k + size));
|
|
11
|
+
return sendChunked(chunks, send, f, "ids");
|
|
12
|
+
}
|
|
13
|
+
async function sendChunked(chunks, send, f, unit) {
|
|
14
|
+
const total = chunks.length;
|
|
15
|
+
const all = chunks.reduce((n, c) => n + c.length, 0);
|
|
16
|
+
const done = [];
|
|
17
|
+
let accepted = 0;
|
|
18
|
+
for (let k = 0; k < total; k++) {
|
|
19
|
+
const chunk = chunks[k];
|
|
20
|
+
try {
|
|
21
|
+
done.push(await send(chunk));
|
|
22
|
+
accepted += chunk.length;
|
|
23
|
+
} catch (err) {
|
|
24
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
25
|
+
const progress = {
|
|
26
|
+
chunks: { sent: k, total },
|
|
27
|
+
items: { accepted, total: all },
|
|
28
|
+
failed_chunk: { index: k + 1, first_row: accepted + 1, last_row: accepted + chunk.length }
|
|
29
|
+
};
|
|
30
|
+
if (!(err instanceof CurviateError)) {
|
|
31
|
+
process.stderr.write(`Chunk ${k + 1} of ${total} failed; ${accepted} of ${all} ${unit} were sent before it. Nothing after it was sent.
|
|
32
|
+
`);
|
|
33
|
+
return fail(err, f);
|
|
34
|
+
}
|
|
35
|
+
const { getExitCode } = await import("./exit-codes-7DBETBDT.js");
|
|
36
|
+
const e = err.toJSON();
|
|
37
|
+
if (outputOpts(f).json) process.stdout.write(JSON.stringify({ error: e, progress }) + "\n");
|
|
38
|
+
process.stderr.write(
|
|
39
|
+
`error [${e.code}] ${e.message}
|
|
40
|
+
Chunk ${k + 1} of ${total} failed (${unit} ${progress.failed_chunk.first_row} to ${progress.failed_chunk.last_row}); ${accepted} of ${all} ${unit} were sent before it. Nothing after it was sent.
|
|
41
|
+
`
|
|
42
|
+
);
|
|
43
|
+
process.exit(getExitCode(err));
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return done;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export {
|
|
50
|
+
sendInChunks,
|
|
51
|
+
sendChunked
|
|
52
|
+
};
|
|
@@ -0,0 +1,339 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
print,
|
|
4
|
+
rate,
|
|
5
|
+
table
|
|
6
|
+
} from "./chunk-5S3MJVI5.js";
|
|
7
|
+
import {
|
|
8
|
+
writeExport
|
|
9
|
+
} from "./chunk-PPGKQJKU.js";
|
|
10
|
+
import {
|
|
11
|
+
fail,
|
|
12
|
+
listFlag,
|
|
13
|
+
outputOpts,
|
|
14
|
+
rootClient,
|
|
15
|
+
usage
|
|
16
|
+
} from "./chunk-3Z6PXS6N.js";
|
|
17
|
+
import {
|
|
18
|
+
intFlag
|
|
19
|
+
} from "./chunk-NNV2OYEF.js";
|
|
20
|
+
import {
|
|
21
|
+
pageDelayFromFlags,
|
|
22
|
+
readCursorFlag,
|
|
23
|
+
readMaxPagesFlag,
|
|
24
|
+
readablePage,
|
|
25
|
+
rejectPaginationModifiersWithoutAll,
|
|
26
|
+
streamAll
|
|
27
|
+
} from "./chunk-LRMPS4UQ.js";
|
|
28
|
+
import {
|
|
29
|
+
renderSuccess,
|
|
30
|
+
writeNdjsonItem
|
|
31
|
+
} from "./chunk-QM57YDJE.js";
|
|
32
|
+
import {
|
|
33
|
+
downloadBinary
|
|
34
|
+
} from "./chunk-LULN3II2.js";
|
|
35
|
+
import {
|
|
36
|
+
GLOBAL_FLAGS,
|
|
37
|
+
READ_SINGLE_FLAGS,
|
|
38
|
+
readOnly
|
|
39
|
+
} from "./chunk-RYWWSZUH.js";
|
|
40
|
+
import {
|
|
41
|
+
DESCRIPTIONS
|
|
42
|
+
} from "./chunk-73DJ3KNE.js";
|
|
43
|
+
|
|
44
|
+
// src/commands/analytics.ts
|
|
45
|
+
import { defineCommand } from "citty";
|
|
46
|
+
var DATE = /^\d{4}-\d{2}-\d{2}$/;
|
|
47
|
+
function windowParams(f) {
|
|
48
|
+
const q = {};
|
|
49
|
+
for (const k of ["from", "to"]) {
|
|
50
|
+
const v = f[k];
|
|
51
|
+
if (v === void 0) continue;
|
|
52
|
+
if (!DATE.test(v)) usage(`--${k} takes a date, YYYY-MM-DD.`);
|
|
53
|
+
q[k] = v;
|
|
54
|
+
}
|
|
55
|
+
if (f.range !== void 0) q["range"] = f.range;
|
|
56
|
+
if (f.timezone !== void 0) q["timezone"] = f.timezone;
|
|
57
|
+
if (f.bucket !== void 0) q["bucket"] = f.bucket;
|
|
58
|
+
return q;
|
|
59
|
+
}
|
|
60
|
+
function grammarParams(f) {
|
|
61
|
+
const q = {};
|
|
62
|
+
if (f.include !== void 0) q["include"] = listFlag("include", f.include);
|
|
63
|
+
if (f.sort !== void 0) q["sort"] = listFlag("sort", f.sort);
|
|
64
|
+
if (f.limit !== void 0) q["limit"] = intFlag("limit", f.limit);
|
|
65
|
+
if (f.compare !== void 0) q["compare"] = f.compare;
|
|
66
|
+
return q;
|
|
67
|
+
}
|
|
68
|
+
function filterParams(f, keys) {
|
|
69
|
+
const q = {};
|
|
70
|
+
if (keys.includes("motions") && f.motions !== void 0) q["motion_id"] = listFlag("motions", f.motions);
|
|
71
|
+
if (keys.includes("accounts") && f.accounts !== void 0) q["account_id"] = listFlag("accounts", f.accounts);
|
|
72
|
+
if (keys.includes("origin") && f.origin !== void 0) q["origin"] = listFlag("origin", f.origin);
|
|
73
|
+
return q;
|
|
74
|
+
}
|
|
75
|
+
var outcomes = (s) => `acceptance ${rate(s?.["acceptance"], "accepted", "sent")} \xB7 reply ${rate(s?.["reply"], "replied", "messaged")} \xB7 InMail reply ${rate(s?.["inmail_reply"], "replied", "inmailed")} \xB7 replies ${s?.["replies"] ?? "-"}`;
|
|
76
|
+
var rowsTable = (label, id, name, items) => Array.isArray(items) && items.length ? table(
|
|
77
|
+
[label, "NAME", "ACCEPTANCE", "REPLY", "INMAIL REPLY", "REPLIES"],
|
|
78
|
+
items.map((r) => [r[id], r[name], rate(r["acceptance"], "accepted", "sent"), rate(r["reply"], "replied", "messaged"), rate(r["inmail_reply"], "replied", "inmailed"), r["replies"]])
|
|
79
|
+
) : null;
|
|
80
|
+
var reasons = (r) => Object.entries(r ?? {}).flatMap(([k, m]) => Object.entries(m ?? {}).map(([code, n]) => `${k} ${code} ${n}`)).join(", ");
|
|
81
|
+
function windowLines(body) {
|
|
82
|
+
const w = body["window"] ?? {};
|
|
83
|
+
const lines = [`${w["from"]} to ${w["to"]} (${w["timezone"]})`];
|
|
84
|
+
if (w["counts_only_through"]) lines.push(`daily counts only through ${w["counts_only_through"]}: step, variant and seen detail covers the days after it`);
|
|
85
|
+
return lines;
|
|
86
|
+
}
|
|
87
|
+
function renderOverview(body) {
|
|
88
|
+
const out = [...windowLines(body)];
|
|
89
|
+
const profile = body["profile"];
|
|
90
|
+
if (profile) out.push(`${profile["name"]} \xB7 ${profile["status"]}${profile["status_reason"] ? ` (${profile["status_reason"]})` : ""}`);
|
|
91
|
+
const metrics = body["metrics"];
|
|
92
|
+
if (metrics) out.push(`connections ${metrics["connections"]} \xB7 followers ${metrics["followers"]} \xB7 profile viewers 90d ${metrics["profile_viewers_90d"]} \xB7 search appearances ${metrics["search_appearances_week"]} (as of ${metrics["as_of"]})`);
|
|
93
|
+
const s = body["totals"] ?? body["performance"];
|
|
94
|
+
if (s) out.push(outcomes(s));
|
|
95
|
+
const steps = body["steps"];
|
|
96
|
+
if (Array.isArray(steps) && steps.length) {
|
|
97
|
+
out.push(table(
|
|
98
|
+
["STEP", "ACTION", "EXECUTED", "SKIPPED", "FAILED", "ACCEPTANCE", "REPLY", "SEEN"],
|
|
99
|
+
steps.map((t) => [t["step_id"], t["action"] ?? t["kind"], t["executed"], t["skipped"], t["failed"], rate(t["acceptance"], "accepted", "sent"), rate(t["reply"], "replied", "messaged"), rate(t["seen"], "seen", "sent")])
|
|
100
|
+
));
|
|
101
|
+
for (const t of steps) if (reasons(t["reasons"])) out.push(` ${t["step_id"]}: ${reasons(t["reasons"])}`);
|
|
102
|
+
}
|
|
103
|
+
const paths = body["paths"];
|
|
104
|
+
if (Array.isArray(paths) && paths.length) {
|
|
105
|
+
out.push(table(
|
|
106
|
+
["PATH", "ACCEPTANCE", "REPLY", "INMAIL REPLY", "REPLIES"],
|
|
107
|
+
paths.map((p) => {
|
|
108
|
+
const t = p["totals"] ?? {};
|
|
109
|
+
return [p["path"], rate(t["acceptance"], "accepted", "sent"), rate(t["reply"], "replied", "messaged"), rate(t["inmail_reply"], "replied", "inmailed"), t["replies"]];
|
|
110
|
+
})
|
|
111
|
+
));
|
|
112
|
+
const through = body["window"]?.["paths_through"];
|
|
113
|
+
if (through) out.push(`paths cover days after ${through}`);
|
|
114
|
+
}
|
|
115
|
+
const limits = body["limits"]?.["rows"];
|
|
116
|
+
if (Array.isArray(limits) && limits.length) out.push(table(["BUDGET ROW", "USED", "CEILING", "LEFT"], limits.map((r) => [r["budget_row"], r["used"], r["effective_ceiling"], r["remaining"]])));
|
|
117
|
+
out.push(rowsTable("MOTION", "motion_id", "name", body["motions"]));
|
|
118
|
+
out.push(rowsTable("ACCOUNT", "account_id", "account_name", body["accounts"]));
|
|
119
|
+
for (const fl of body["flags"] ?? []) out.push(`${fl["code"]}: ${fl["message"]}${fl["next"] ? ` (${fl["next"]})` : ""}`);
|
|
120
|
+
print(out.filter((x) => !!x).join("\n"));
|
|
121
|
+
}
|
|
122
|
+
function renderActivity(body) {
|
|
123
|
+
const out = [...windowLines(body), table(["BUDGET ROW", "USED", "FAILED", "REFUSED"], (body["types"] ?? []).map((t) => [t["budget_row"], t["used"], t["failed"], t["refused"]]))];
|
|
124
|
+
for (const a of body["accounts"] ?? []) out.push(`${a["account_name"] ?? a["account_id"]}: ${(a["types"] ?? []).map((t) => `${t["budget_row"]} ${t["used"]}`).join(", ")}`);
|
|
125
|
+
print(out.join("\n"));
|
|
126
|
+
}
|
|
127
|
+
async function runGet(c, f) {
|
|
128
|
+
const view = f.view ?? "motions";
|
|
129
|
+
if (view !== "motions" && view !== "activity") usage("--view takes motions or activity.");
|
|
130
|
+
if (view === "activity") {
|
|
131
|
+
const motionOnly = ["motion", "motions", "origin", "include", "sort", "limit", "compare", "version"].find((k) => f[k] !== void 0);
|
|
132
|
+
if (motionOnly) usage(`--${motionOnly} reads Motions: --view activity takes the window and --accounts only.`);
|
|
133
|
+
}
|
|
134
|
+
if (f.version !== void 0 && f.motion === void 0) usage("--version needs --motion.");
|
|
135
|
+
const q = { ...windowParams(f), ...filterParams(f, view === "activity" ? ["accounts"] : ["accounts", "origin"]) };
|
|
136
|
+
try {
|
|
137
|
+
if (view === "activity") {
|
|
138
|
+
const body2 = await c.analytics.activity(q);
|
|
139
|
+
return outputOpts(f).json ? renderSuccess(body2, outputOpts(f), process) : renderActivity(body2);
|
|
140
|
+
}
|
|
141
|
+
Object.assign(q, grammarParams(f));
|
|
142
|
+
if (f.version !== void 0) q["version"] = intFlag("version", f.version);
|
|
143
|
+
let body;
|
|
144
|
+
if (f.motion !== void 0) body = await c.analytics.motions.get(f.motion, q);
|
|
145
|
+
else body = await c.analytics.motions.list({ ...q, ...filterParams(f, ["motions"]) });
|
|
146
|
+
return outputOpts(f).json ? renderSuccess(body, outputOpts(f), process) : renderOverview(body);
|
|
147
|
+
} catch (err) {
|
|
148
|
+
await fail(err, f);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async function runEvents(c, f) {
|
|
152
|
+
rejectPaginationModifiersWithoutAll(f, process);
|
|
153
|
+
if (f.step !== void 0 && f.motion === void 0) usage("--step needs --motion: a step id names a step of one Motion.");
|
|
154
|
+
const q = { ...filterParams(f, ["origin"]) };
|
|
155
|
+
if (f.motion !== void 0) q["motion_id"] = f.motion;
|
|
156
|
+
if (f.step !== void 0) q["step_id"] = f.step;
|
|
157
|
+
if (f.contact !== void 0) q["contact_id"] = f.contact;
|
|
158
|
+
if (f.accounts !== void 0) q["account_id"] = listFlag("accounts", f.accounts).join(",");
|
|
159
|
+
if (f.kind !== void 0) q["kind"] = listFlag("kind", f.kind);
|
|
160
|
+
if (f.limit !== void 0) q["limit"] = intFlag("limit", f.limit, 1, 100);
|
|
161
|
+
const cursor = readCursorFlag(f, process);
|
|
162
|
+
if (cursor) q["cursor"] = cursor;
|
|
163
|
+
try {
|
|
164
|
+
if (f.all) {
|
|
165
|
+
const page2 = (p) => c.analytics.events.list(p);
|
|
166
|
+
for await (const item of streamAll(page2, q, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
const page = readablePage(await c.analytics.events.list(q));
|
|
170
|
+
if (outputOpts(f).json) return renderSuccess(page, outputOpts(f), process);
|
|
171
|
+
print(table(
|
|
172
|
+
["AT", "KIND", "ORIGIN", "MOTION", "STEP", "OUTCOME", "REASON", "CONTACT"],
|
|
173
|
+
page.items.map((e) => [e["occurred_at"], e["kind"], e["origin"], e["motion_name"], e["step_id"], e["outcome"], e["reason"] ? `${e["reason"]}: ${e["reason_message"] ?? ""}` : null, e["contact"]?.["full_name"]])
|
|
174
|
+
));
|
|
175
|
+
if (page["cursor"]) print(`next page: --cursor ${String(page["cursor"])}`);
|
|
176
|
+
} catch (err) {
|
|
177
|
+
await fail(err, f);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
var ANALYTICS_TABLES = ["daily", "accounts", "motions", "enrollments"];
|
|
181
|
+
var JOB_ENTITIES = ["motion_activity", "account_activity", "account_metrics"];
|
|
182
|
+
async function runExport(c, f) {
|
|
183
|
+
if (f.json) usage("export commands take no --json: pass --format json.");
|
|
184
|
+
const tables = f.table === void 0 ? [] : listFlag("table", f.table);
|
|
185
|
+
const entity = tables.length === 1 && JOB_ENTITIES.includes(tables[0]) ? tables[0] : "analytics";
|
|
186
|
+
if (entity !== "analytics" && !f.job) usage(`--table ${entity} is built by a background job: add --job.`);
|
|
187
|
+
const unknown = tables.find((t) => !ANALYTICS_TABLES.includes(t) && t !== entity);
|
|
188
|
+
if (unknown !== void 0) usage(`--table takes ${ANALYTICS_TABLES.join(", ")}, or one of ${JOB_ENTITIES.join(", ")} with --job.`);
|
|
189
|
+
const format = f.format ?? "csv";
|
|
190
|
+
const filters = { ...windowParams(f), ...filterParams(f, ["motions", "accounts", "origin"]) };
|
|
191
|
+
try {
|
|
192
|
+
if (f.job) {
|
|
193
|
+
const exp = await c.exports.create({ entity, tables: tables.length ? tables : ANALYTICS_TABLES, format, filters });
|
|
194
|
+
renderSuccess(exp, outputOpts(f), process);
|
|
195
|
+
process.stderr.write(`Export ${exp["id"]} is ${exp["status"]}. Read it with \`curviate export get ${exp["id"]}\`, then \`curviate export download ${exp["id"]} -o <file>\` once ready.
|
|
196
|
+
`);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if (f.output === void 0 && process.stdout.isTTY && tables.length !== 1) usage("several tables come as one ZIP file: pass -o <file>, or one --table.");
|
|
200
|
+
const bytes = await downloadBinary(() => c.analytics.export({ ...filters, format, ...tables.length ? { table: tables } : {} }));
|
|
201
|
+
await writeExport(f.output, new Uint8Array(bytes));
|
|
202
|
+
} catch (err) {
|
|
203
|
+
await fail(err, f);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
var online = (fn) => async ({ args }) => {
|
|
207
|
+
const f = args;
|
|
208
|
+
await fn(await rootClient(f), f);
|
|
209
|
+
};
|
|
210
|
+
var WINDOW_ARGS = {
|
|
211
|
+
from: {
|
|
212
|
+
type: "string",
|
|
213
|
+
description: "First day, YYYY-MM-DD, inclusive, in --timezone. A Motion read (with or without --motion) or an Account overview may start more than a year back: up to `window.counts_only_through` the figures come from daily counts (UTC days, no step, variant or seen detail), and `paths` cover only the days after `window.paths_through`. --view activity and the activity exports keep their own cap, named in the refusal."
|
|
214
|
+
},
|
|
215
|
+
to: { type: "string", description: "Last day, YYYY-MM-DD, inclusive, in --timezone (default today). Same rules as --from." },
|
|
216
|
+
range: { type: "string", description: "Instead of --from/--to: 7d, 30d, 90d, 12m or all." },
|
|
217
|
+
timezone: { type: "string", description: "IANA zone the days are read in (default UTC)." },
|
|
218
|
+
bucket: { type: "string", description: "Daily series grouping: auto, day, week or month." }
|
|
219
|
+
};
|
|
220
|
+
var FILTER_ARGS = {
|
|
221
|
+
accounts: { type: "string", description: "Only these Accounts: a comma list of ids (acc_...). Never filled from your profile's default Account." },
|
|
222
|
+
origin: { type: "string", description: "Who sent the actions: a comma list of motion, unibox, api; direct is an alias for unibox and api." }
|
|
223
|
+
};
|
|
224
|
+
var GRAMMAR_ARGS = {
|
|
225
|
+
include: { type: "string", description: "Sections to return, comma list (for example performance,motions,accounts,steps,variants,paths,flags)." },
|
|
226
|
+
sort: { type: "string", description: "Order of the Motion and Account lists, comma list of sent, acceptance.rate, reply.rate, inmail_reply.rate, last_activity_at, name; a leading - sorts descending." },
|
|
227
|
+
limit: { type: "string", description: "How many Motions and Accounts to return." },
|
|
228
|
+
compare: { type: "string", description: "previous_period: add the same number of days before --from to every rate (`previous`, `delta`)." }
|
|
229
|
+
};
|
|
230
|
+
var getCmd = defineCommand({
|
|
231
|
+
meta: {
|
|
232
|
+
name: "get",
|
|
233
|
+
description: "Motion outcomes over a window: invitations, acceptance, messages, reply and InMail reply as outcomes so far, with each Motion and Account. With --motion: one Motion's steps, paths and Accounts. With --view activity: the budget rows your Accounts used. Each Contact counts once per Account.",
|
|
234
|
+
risk: "read",
|
|
235
|
+
output: [
|
|
236
|
+
"acceptance: invitations accepted over invitations sent in the window, so far.",
|
|
237
|
+
"reply: people who replied over people messaged; InMail reply the same for InMails. Rates move as replies and acceptances arrive; `maturing` counts what was sent under 7 days ago and `low_sample` marks fewer than 30.",
|
|
238
|
+
"seen (--motion): messages read or replied over messages sent, per message step.",
|
|
239
|
+
"A compact table by default; --json (or piped) prints the API body."
|
|
240
|
+
],
|
|
241
|
+
seeAlso: ["curviate analytics events list", "curviate account overview", "Judgement on reading the numbers: https://github.com/curviate/curviate-plugin"],
|
|
242
|
+
examples: [
|
|
243
|
+
"curviate analytics get --range 30d",
|
|
244
|
+
"curviate analytics get --motion mot_YOUR_MOTION_ID --include steps,paths --range 90d",
|
|
245
|
+
"curviate analytics get --view activity --from 2026-10-01 --to 2026-10-28"
|
|
246
|
+
]
|
|
247
|
+
},
|
|
248
|
+
args: {
|
|
249
|
+
...readOnly(READ_SINGLE_FLAGS),
|
|
250
|
+
view: { type: "string", description: "motions (default): Motion outcomes; activity: budget rows used, not with --motion." },
|
|
251
|
+
motion: { type: "string", description: "One Motion (mot_...): its steps, paths and Accounts." },
|
|
252
|
+
motions: { type: "string", description: "Without --motion: only these Motions, comma list (mot_...)." },
|
|
253
|
+
version: { type: "string", description: "With --motion: only this Sequence version." },
|
|
254
|
+
...WINDOW_ARGS,
|
|
255
|
+
...FILTER_ARGS,
|
|
256
|
+
...GRAMMAR_ARGS
|
|
257
|
+
},
|
|
258
|
+
run: online(runGet)
|
|
259
|
+
});
|
|
260
|
+
var eventsListCmd = defineCommand({
|
|
261
|
+
meta: {
|
|
262
|
+
name: "list",
|
|
263
|
+
description: "The records behind the numbers, newest first: steps executed or failed, invitations accepted, replies; each reason with its sentence. Metadata only, never message text.",
|
|
264
|
+
risk: "read",
|
|
265
|
+
examples: [
|
|
266
|
+
"curviate analytics events list --motion mot_YOUR_MOTION_ID --step opener",
|
|
267
|
+
"curviate analytics events list --contact con_YOUR_CONTACT_ID --origin unibox,api --all"
|
|
268
|
+
]
|
|
269
|
+
},
|
|
270
|
+
args: {
|
|
271
|
+
...readOnly(GLOBAL_FLAGS),
|
|
272
|
+
motion: { type: "string", description: "Only this Motion's records (mot_...)." },
|
|
273
|
+
step: { type: "string", description: "With --motion: only this step's records." },
|
|
274
|
+
contact: { type: "string", description: "Only this Contact's records (con_...): its Motion records and its direct ones." },
|
|
275
|
+
kind: { type: "string", description: "Comma list of step.executed, step.failed, invite.accepted, message.replied." },
|
|
276
|
+
accounts: FILTER_ARGS.accounts,
|
|
277
|
+
origin: FILTER_ARGS.origin
|
|
278
|
+
},
|
|
279
|
+
run: online(runEvents)
|
|
280
|
+
});
|
|
281
|
+
var exportCmd = defineCommand({
|
|
282
|
+
meta: {
|
|
283
|
+
name: "export",
|
|
284
|
+
description: "Export the Analytics tables (daily, accounts, motions, enrollments) under the same window and filters: streamed now, or with --job built in the background (then `curviate export get` and `curviate export download`). One table is one file; several are one ZIP. Never message text. Owners and Managers only.",
|
|
285
|
+
risk: "read",
|
|
286
|
+
output: ["Data only on stdout or the --output file (mode 0600); with --job the export record."],
|
|
287
|
+
errors: { INSUFFICIENT_ROLE: "Members cannot export: ask an Owner or Manager.", EXPORT_IN_PROGRESS: "your Team already has an export running; read it with `curviate export get <export_id>`." },
|
|
288
|
+
seeAlso: ["curviate export get", "curviate export download"],
|
|
289
|
+
examples: [
|
|
290
|
+
"curviate analytics export --table enrollments --format csv --range 30d -o enrollments.csv",
|
|
291
|
+
"curviate analytics export --table daily,accounts,motions,enrollments --format csv --range 90d --job"
|
|
292
|
+
]
|
|
293
|
+
},
|
|
294
|
+
args: {
|
|
295
|
+
"api-key": GLOBAL_FLAGS["api-key"],
|
|
296
|
+
profile: GLOBAL_FLAGS.profile,
|
|
297
|
+
team: GLOBAL_FLAGS.team,
|
|
298
|
+
"base-url": GLOBAL_FLAGS["base-url"],
|
|
299
|
+
timeout: GLOBAL_FLAGS.timeout,
|
|
300
|
+
table: { type: "string", description: "Comma list of daily, accounts, motions, enrollments (default all four); or, with --job, one of motion_activity, account_activity, account_metrics." },
|
|
301
|
+
format: { type: "string", description: "csv (default), json or ndjson (ndjson takes one table)." },
|
|
302
|
+
output: { type: "string", alias: "o", description: "File to write (mode 0600), or - for stdout (default)." },
|
|
303
|
+
job: { type: "boolean", description: "Build it in the background and print the export record instead of streaming it." },
|
|
304
|
+
motions: { type: "string", description: "Only these Motions, comma list (mot_...)." },
|
|
305
|
+
...WINDOW_ARGS,
|
|
306
|
+
...FILTER_ARGS,
|
|
307
|
+
json: { type: "boolean", description: "Not taken by exports: pass --format json." }
|
|
308
|
+
},
|
|
309
|
+
run: online(runExport)
|
|
310
|
+
});
|
|
311
|
+
var eventsCommand = defineCommand({
|
|
312
|
+
meta: { name: "events", description: "The records behind the analytics numbers." },
|
|
313
|
+
subCommands: { list: eventsListCmd },
|
|
314
|
+
async run() {
|
|
315
|
+
const { showHelp } = await import("./examples-JJB4DZKK.js");
|
|
316
|
+
await showHelp(eventsCommand, ["curviate", "analytics", "events"]);
|
|
317
|
+
}
|
|
318
|
+
});
|
|
319
|
+
var analyticsCommand = defineCommand({
|
|
320
|
+
meta: { name: "analytics", description: DESCRIPTIONS.analytics },
|
|
321
|
+
subCommands: {
|
|
322
|
+
get: getCmd,
|
|
323
|
+
events: eventsCommand,
|
|
324
|
+
export: exportCmd
|
|
325
|
+
},
|
|
326
|
+
async run() {
|
|
327
|
+
const { showHelp } = await import("./examples-JJB4DZKK.js");
|
|
328
|
+
await showHelp(analyticsCommand, ["curviate", "analytics"]);
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
export {
|
|
333
|
+
windowParams,
|
|
334
|
+
grammarParams,
|
|
335
|
+
renderOverview,
|
|
336
|
+
WINDOW_ARGS,
|
|
337
|
+
GRAMMAR_ARGS,
|
|
338
|
+
analyticsCommand
|
|
339
|
+
};
|
|
@@ -51,7 +51,32 @@ async function readlineSync(prompt, opts = {}) {
|
|
|
51
51
|
}
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
async function readHiddenToEof(prompt, stdin = process.stdin) {
|
|
55
|
+
return new Promise((resolve, reject) => {
|
|
56
|
+
process.stderr.write(prompt);
|
|
57
|
+
stdin.setRawMode?.(true);
|
|
58
|
+
stdin.resume();
|
|
59
|
+
stdin.setEncoding("utf8");
|
|
60
|
+
let input = "";
|
|
61
|
+
const done = (fn) => {
|
|
62
|
+
stdin.setRawMode?.(false);
|
|
63
|
+
stdin.pause();
|
|
64
|
+
stdin.removeListener("data", onData);
|
|
65
|
+
process.stderr.write("\n");
|
|
66
|
+
fn();
|
|
67
|
+
};
|
|
68
|
+
const onData = (chunk) => {
|
|
69
|
+
for (const char of chunk) {
|
|
70
|
+
if (char === "") return done(() => resolve(input));
|
|
71
|
+
if (char === "") return done(() => reject(new Error("Interrupted.")));
|
|
72
|
+
input += char === "\r" ? "\n" : char;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
stdin.on("data", onData);
|
|
76
|
+
});
|
|
77
|
+
}
|
|
54
78
|
|
|
55
79
|
export {
|
|
56
|
-
readlineSync
|
|
80
|
+
readlineSync,
|
|
81
|
+
readHiddenToEof
|
|
57
82
|
};
|
|
@@ -263,10 +263,16 @@ function slimAccountGet(data) {
|
|
|
263
263
|
seat_id: d["seat_id"] ?? null,
|
|
264
264
|
connected_at: d["connected_at"] ?? null,
|
|
265
265
|
external_id: d["external_id"] ?? null,
|
|
266
|
+
// where it connects from, with the checked/detected country and the flags (country_mismatch, zone_moved)
|
|
266
267
|
connection_location: d["connection_location"] ?? null,
|
|
268
|
+
// the ramp (enabled, state, factor, week) and the activity window's zone with its state
|
|
269
|
+
warm_up: d["warm_up"] ?? null,
|
|
270
|
+
activity_window: d["activity_window"] ?? null,
|
|
267
271
|
last_checked_at: d["last_checked_at"] ?? null,
|
|
268
272
|
quotas: d["quotas"] ?? [],
|
|
269
|
-
account_states: d["account_states"] ?? []
|
|
273
|
+
account_states: d["account_states"] ?? [],
|
|
274
|
+
// absent without Automate: shown only when the API sends them
|
|
275
|
+
...d["save_connections_as_contacts"] !== void 0 ? { save_connections_as_contacts: d["save_connections_as_contacts"], save_connections_paused_reason: d["save_connections_paused_reason"] ?? null } : {}
|
|
270
276
|
};
|
|
271
277
|
}
|
|
272
278
|
function slimJob(data) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/lib/write-atomic.ts
|
|
4
|
+
import { closeSync, openSync, renameSync, unlinkSync, writeSync, fchmodSync } from "fs";
|
|
5
|
+
import { basename, dirname, join } from "path";
|
|
6
|
+
function writeAtomic(path, bytes) {
|
|
7
|
+
const tmp = join(dirname(path), `.${basename(path)}.${process.pid}.tmp`);
|
|
8
|
+
let fd;
|
|
9
|
+
try {
|
|
10
|
+
fd = openSync(tmp, "wx", 384);
|
|
11
|
+
fchmodSync(fd, 384);
|
|
12
|
+
writeSync(fd, bytes);
|
|
13
|
+
closeSync(fd);
|
|
14
|
+
fd = void 0;
|
|
15
|
+
renameSync(tmp, path);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
if (fd !== void 0) closeSync(fd);
|
|
18
|
+
try {
|
|
19
|
+
unlinkSync(tmp);
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
throw err;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export {
|
|
27
|
+
writeAtomic
|
|
28
|
+
};
|
|
@@ -6,7 +6,7 @@ var MAX_AGE_CEILING_SECONDS = 31536e3;
|
|
|
6
6
|
var RETRIEVAL_FLAGS = {
|
|
7
7
|
mode: {
|
|
8
8
|
type: "string",
|
|
9
|
-
description: "How willing this read is to reach LinkedIn: auto (default, a stored copy while it is fresh), live (always fetch), refill (a stored copy at any age,
|
|
9
|
+
description: "How willing this read is to reach LinkedIn: auto (default, a stored copy while it is fresh), live (always fetch), refill (a stored copy at any age: fetches at most once, until swept; a record nothing links to and nobody has read lately is deleted, and the next read fetches it again), cache_only (never fetch; a store miss is refused rather than fetched). Not combinable with --max-age under cache_only."
|
|
10
10
|
},
|
|
11
11
|
"max-age": {
|
|
12
12
|
type: "string",
|