@curviate/cli 0.49.0 → 0.50.0-next.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/CHANGELOG.md +15 -0
- package/README.md +12 -5
- package/dist/{account-2BH2Q6VG.js → account-KGCGUYKF.js} +668 -116
- package/dist/analytics-HRAD4ABO.js +27 -0
- package/dist/beta-consent-364JI6IL.js +81 -0
- package/dist/billing-3SSVRS2Y.js +124 -0
- package/dist/{chunk-V7FJWTZW.js → chunk-25MO7BYN.js} +4 -4
- package/dist/{chunk-RXWODUWA.js → chunk-2W4RN5ON.js} +18 -2
- package/dist/chunk-5S3MJVI5.js +22 -0
- package/dist/chunk-67S4JHZZ.js +339 -0
- package/dist/chunk-73DJ3KNE.js +54 -0
- package/dist/chunk-CQGDMARG.js +525 -0
- package/dist/{chunk-JYKYD57J.js → chunk-DOHBOYXN.js} +1 -1
- package/dist/{chunk-3RCW7URJ.js → chunk-DSGKYZDK.js} +1 -1
- 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-L4CIJT6F.js +144 -0
- package/dist/{chunk-PQWDDSV7.js → chunk-L7JH3W56.js} +1 -1
- package/dist/{chunk-Z7OQSWBD.js → chunk-OE6YFYUM.js} +85 -10
- package/dist/chunk-PPGKQJKU.js +38 -0
- package/dist/{chunk-SA2QHAXG.js → chunk-QM57YDJE.js} +13 -201
- package/dist/{chunk-Y7MZZRYR.js → chunk-RYWWSZUH.js} +14 -2
- package/dist/{chunk-MGB6FE4A.js → chunk-T6GBS5SS.js} +6 -6
- package/dist/{chunk-TEAWYLPO.js → chunk-TE3WBPW6.js} +43 -17
- package/dist/chunk-UL53T4O6.js +52 -0
- package/dist/chunk-UWQPX4AE.js +20 -0
- package/dist/{chunk-5ZGTU4VD.js → chunk-YXVF5UST.js} +77 -4
- package/dist/cli.js +34 -18
- package/dist/{comment-MRDPDA33.js → comment-5JKGNYOY.js} +90 -11
- package/dist/{company-2AEHSGHA.js → company-TXST2VXW.js} +65 -15
- package/dist/{config-NRBKHXES.js → config-TVIQUVNK.js} +53 -4
- package/dist/{connect-4XEBV5V3.js → connect-RBL6U4KV.js} +63 -18
- package/dist/contact-YAHC5QFX.js +32 -0
- package/dist/contact-groups-DKOIBC57.js +399 -0
- package/dist/contact-import-ITSJQV7K.js +336 -0
- package/dist/core-PWMJPPRG.js +46 -0
- package/dist/do-not-contact-WDYIBWYA.js +200 -0
- package/dist/{doctor-BZ4DA7DV.js → doctor-F7JLPTED.js} +65 -11
- package/dist/{document-RKHRWXNT.js → document-BHYAUJ6F.js} +1 -1
- package/dist/{draft-C5N6EOO5.js → draft-TDJJUXLH.js} +60 -14
- package/dist/{enrollment-BNQOUKI7.js → enrollment-Q6UOKHPY.js} +31 -19
- package/dist/{examples-NIMSIXMV.js → examples-DQSVIIXZ.js} +2 -2
- package/dist/{exit-codes-TLMKTLRI.js → exit-codes-7DBETBDT.js} +1 -1
- package/dist/export-HIJSCJS6.js +96 -0
- package/dist/{feed-DFUU7SUJ.js → feed-W56ZTA4Z.js} +13 -10
- package/dist/{group-CSD2OWOZ.js → group-AUALYK5H.js} +18 -10
- package/dist/{inbox-SNSPWI7J.js → inbox-HLZR2ZPV.js} +31 -12
- package/dist/{inboxes-RIRHPS4H.js → inboxes-IZTRD6FE.js} +14 -10
- package/dist/incoming-ULB2RNV4.js +218 -0
- package/dist/{job-6PNXXZNF.js → job-55IKS6LP.js} +65 -13
- package/dist/{login-Y7JBAHCW.js → login-DPZ6CXNO.js} +13 -4
- package/dist/{message-2IK4MBBG.js → message-J44YKRDS.js} +9 -7
- package/dist/{motion-7ATUXO6R.js → motion-SQI5F2EK.js} +39 -117
- package/dist/network-K4QD7APQ.js +235 -0
- package/dist/{notification-VYK5NDEB.js → notification-SEDXZHXO.js} +38 -11
- package/dist/notifications-HGIBRUNQ.js +231 -0
- package/dist/{post-AN6T2OJF.js → post-L467SKIG.js} +92 -12
- package/dist/{profile-UQY64642.js → profile-A2N6RMR2.js} +76 -20
- package/dist/{recruiter-OY4RN5HH.js → recruiter-AR75RHBO.js} +133 -22
- package/dist/{sales-nav-KLODLYMW.js → sales-nav-C2AYFXPV.js} +74 -19
- package/dist/{search-NWP5S6CF.js → search-Z4DZIG4X.js} +55 -23
- package/dist/{setup-YPPFLH2N.js → setup-45BEVX6B.js} +69 -17
- package/dist/team-6QWY4IFP.js +450 -0
- package/dist/tier-2HS3BXDF.js +61 -0
- package/dist/unibox-DHUKG65Z.js +402 -0
- package/dist/{webhook-OHKBL3YS.js → webhook-Q53WUAI2.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,336 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
online,
|
|
4
|
+
preview
|
|
5
|
+
} from "./chunk-CQGDMARG.js";
|
|
6
|
+
import "./chunk-25MO7BYN.js";
|
|
7
|
+
import "./chunk-GOICALYQ.js";
|
|
8
|
+
import {
|
|
9
|
+
sendChunked
|
|
10
|
+
} from "./chunk-UL53T4O6.js";
|
|
11
|
+
import {
|
|
12
|
+
fail,
|
|
13
|
+
listFlag,
|
|
14
|
+
outputOpts,
|
|
15
|
+
usage
|
|
16
|
+
} from "./chunk-T6GBS5SS.js";
|
|
17
|
+
import "./chunk-TCUYH5GO.js";
|
|
18
|
+
import {
|
|
19
|
+
intFlag
|
|
20
|
+
} from "./chunk-NNV2OYEF.js";
|
|
21
|
+
import {
|
|
22
|
+
pageDelayFromFlags,
|
|
23
|
+
readCursorFlag,
|
|
24
|
+
readMaxPagesFlag,
|
|
25
|
+
readableObject,
|
|
26
|
+
readablePage,
|
|
27
|
+
rejectPaginationModifiersWithoutAll,
|
|
28
|
+
streamAll
|
|
29
|
+
} from "./chunk-L4CIJT6F.js";
|
|
30
|
+
import {
|
|
31
|
+
renderSuccess,
|
|
32
|
+
writeNdjsonItem
|
|
33
|
+
} from "./chunk-QM57YDJE.js";
|
|
34
|
+
import "./chunk-YXVF5UST.js";
|
|
35
|
+
import {
|
|
36
|
+
GLOBAL_FLAGS,
|
|
37
|
+
WRITE_SINGLE_FLAGS,
|
|
38
|
+
readOnly
|
|
39
|
+
} from "./chunk-RYWWSZUH.js";
|
|
40
|
+
import "./chunk-73DJ3KNE.js";
|
|
41
|
+
import {
|
|
42
|
+
readFileFlag
|
|
43
|
+
} from "./chunk-TE3WBPW6.js";
|
|
44
|
+
import "./chunk-FDJMAF7D.js";
|
|
45
|
+
import {
|
|
46
|
+
isStdinToken
|
|
47
|
+
} from "./chunk-ZYURL5VK.js";
|
|
48
|
+
import "./chunk-2W4RN5ON.js";
|
|
49
|
+
|
|
50
|
+
// src/commands/contact-import.ts
|
|
51
|
+
import { defineCommand } from "citty";
|
|
52
|
+
import { setTimeout as sleep } from "timers/promises";
|
|
53
|
+
var IMPORT_MAX_ROWS = 1e4;
|
|
54
|
+
var IMPORT_MAX_BODY_BYTES = 9437184;
|
|
55
|
+
var BODY_MARGIN = 16 * 1024;
|
|
56
|
+
var MAX_FILE_BYTES = 256 * 1024 * 1024;
|
|
57
|
+
var POLL_MS = 1500;
|
|
58
|
+
var FORMATS = ["csv", "json", "ndjson"];
|
|
59
|
+
var EXT = { ".csv": "csv", ".json": "json", ".ndjson": "ndjson", ".jsonl": "ndjson" };
|
|
60
|
+
function whereJson(text, err) {
|
|
61
|
+
const msg = err instanceof Error ? err.message : "";
|
|
62
|
+
const lc = /line (\d+) column (\d+)/.exec(msg);
|
|
63
|
+
if (lc) return `line ${lc[1]}, column ${lc[2]}`;
|
|
64
|
+
const pos = /position (\d+)/.exec(msg);
|
|
65
|
+
if (!pos) return "an unknown position";
|
|
66
|
+
const before = text.slice(0, Number(pos[1]));
|
|
67
|
+
const line = before.split("\n").length;
|
|
68
|
+
return `line ${line}, column ${before.length - before.lastIndexOf("\n")}`;
|
|
69
|
+
}
|
|
70
|
+
function csvRecords(text) {
|
|
71
|
+
const records = [];
|
|
72
|
+
let cur = "";
|
|
73
|
+
let quoted = false;
|
|
74
|
+
for (const ch of text) {
|
|
75
|
+
if (ch === '"') quoted = !quoted;
|
|
76
|
+
if (ch === "\n" && !quoted) {
|
|
77
|
+
records.push(cur.replace(/\r$/, ""));
|
|
78
|
+
cur = "";
|
|
79
|
+
} else cur += ch;
|
|
80
|
+
}
|
|
81
|
+
records.push(cur.replace(/\r$/, ""));
|
|
82
|
+
return records.filter((r) => r.trim() !== "");
|
|
83
|
+
}
|
|
84
|
+
function chunkRows(rows, size, maxRows = IMPORT_MAX_ROWS, maxBytes = IMPORT_MAX_BODY_BYTES - BODY_MARGIN) {
|
|
85
|
+
const chunks = [];
|
|
86
|
+
let cur = [];
|
|
87
|
+
let bytes = 0;
|
|
88
|
+
for (const r of rows) {
|
|
89
|
+
const n = size(r);
|
|
90
|
+
if (cur.length > 0 && (cur.length >= maxRows || bytes + n > maxBytes)) {
|
|
91
|
+
chunks.push(cur);
|
|
92
|
+
cur = [];
|
|
93
|
+
bytes = 0;
|
|
94
|
+
}
|
|
95
|
+
cur.push(r);
|
|
96
|
+
bytes += n;
|
|
97
|
+
}
|
|
98
|
+
if (cur.length) chunks.push(cur);
|
|
99
|
+
return chunks;
|
|
100
|
+
}
|
|
101
|
+
function split(text, format) {
|
|
102
|
+
if (format === "csv") {
|
|
103
|
+
const [header, ...rows] = csvRecords(text);
|
|
104
|
+
if (header === void 0) usage("--file: the CSV has no header row.");
|
|
105
|
+
if (rows.length === 0) usage("--file: the CSV has a header and no rows to import.");
|
|
106
|
+
return { header, chunks: chunkRows(rows, (r) => Buffer.byteLength(r) + 1) };
|
|
107
|
+
}
|
|
108
|
+
let objs;
|
|
109
|
+
if (format === "json") {
|
|
110
|
+
let doc;
|
|
111
|
+
try {
|
|
112
|
+
doc = JSON.parse(text);
|
|
113
|
+
} catch (err) {
|
|
114
|
+
usage(`--file: not valid JSON, at ${whereJson(text, err)}.`);
|
|
115
|
+
}
|
|
116
|
+
if (!Array.isArray(doc)) usage("--file: a JSON import is an array of objects, one per Contact.");
|
|
117
|
+
objs = doc;
|
|
118
|
+
} else {
|
|
119
|
+
objs = text.split("\n").flatMap((line, i) => {
|
|
120
|
+
if (line.trim() === "") return [];
|
|
121
|
+
try {
|
|
122
|
+
return [JSON.parse(line)];
|
|
123
|
+
} catch {
|
|
124
|
+
return usage(`--file: line ${i + 1} is not valid JSON.`);
|
|
125
|
+
}
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
const bad = objs.findIndex((o) => o === null || typeof o !== "object" || Array.isArray(o));
|
|
129
|
+
if (bad >= 0) usage(`--file: row ${bad + 1} is not an object.`);
|
|
130
|
+
if (objs.length === 0) usage("--file: no rows to import.");
|
|
131
|
+
return { chunks: chunkRows(objs, (o) => Buffer.byteLength(JSON.stringify(o)) + 1) };
|
|
132
|
+
}
|
|
133
|
+
function mapping(f) {
|
|
134
|
+
const pairs = listFlag("map", f.map);
|
|
135
|
+
if (!pairs.length) return void 0;
|
|
136
|
+
const out = {};
|
|
137
|
+
for (const p of pairs) {
|
|
138
|
+
const at = p.indexOf("=");
|
|
139
|
+
if (at <= 0 || at === p.length - 1) usage('--map takes header=target, for example --map "LinkedIn Profile=linkedin_url".');
|
|
140
|
+
out[p.slice(0, at)] = p.slice(at + 1);
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
var DELIMITERS = { ",": ",", comma: ",", ";": ";", semicolon: ";", tab: " ", "\\t": " ", " ": " " };
|
|
145
|
+
var COUNTS = ["created", "updated", "unchanged", "skipped"];
|
|
146
|
+
async function runImport(c, f) {
|
|
147
|
+
const file = f.file;
|
|
148
|
+
if (file === void 0 || file.trim() === "") usage("--file is required: a CSV, JSON or NDJSON file, or - for stdin.");
|
|
149
|
+
const dash = isStdinToken(file);
|
|
150
|
+
let format = f.format;
|
|
151
|
+
if (format === void 0) {
|
|
152
|
+
format = dash ? void 0 : EXT[(/\.[^./\\]+$/.exec(file.toLowerCase()) ?? [""])[0]];
|
|
153
|
+
if (format === void 0) usage(dash ? "--format is required with --file -: csv, json or ndjson." : "--format could not be told from the file name: pass csv, json or ndjson.");
|
|
154
|
+
}
|
|
155
|
+
if (!FORMATS.includes(format)) usage(`--format takes one of ${FORMATS.join(", ")}.`);
|
|
156
|
+
if (f.list !== void 0 && f["list-name"] !== void 0) usage("--list and --list-name cannot be combined: name the list (cl_...) or a list to create by name.");
|
|
157
|
+
if (f.delimiter !== void 0 && format !== "csv") usage("--delimiter applies to a CSV file.");
|
|
158
|
+
const base = {};
|
|
159
|
+
if (f.list !== void 0) base["list_id"] = f.list;
|
|
160
|
+
if (f["list-name"] !== void 0) base["list_name"] = f["list-name"];
|
|
161
|
+
const tags = listFlag("tag", f.tag);
|
|
162
|
+
if (tags.length) base["tags"] = tags;
|
|
163
|
+
const removeTags = listFlag("remove-tag", f["remove-tag"]);
|
|
164
|
+
if (removeTags.length) base["remove_tags"] = removeTags;
|
|
165
|
+
const map = mapping(f);
|
|
166
|
+
if (map) base["mapping"] = map;
|
|
167
|
+
if (f.delimiter !== void 0) {
|
|
168
|
+
const d = DELIMITERS[f.delimiter];
|
|
169
|
+
if (d === void 0) usage("--delimiter takes comma, semicolon or tab.");
|
|
170
|
+
base["delimiter"] = d;
|
|
171
|
+
}
|
|
172
|
+
const text = await readFileFlag("file", file, { allowBom: true, maxBytes: MAX_FILE_BYTES, others: f });
|
|
173
|
+
const { header, chunks } = split(text, format);
|
|
174
|
+
const bodyOf = (rows) => ({ ...base, ...header !== void 0 ? { csv: [header, ...rows].join("\n") } : { rows } });
|
|
175
|
+
const total = chunks.reduce((n, x) => n + x.length, 0);
|
|
176
|
+
if (f.preview) return preview("contacts.imports.create", chunks.length > 1 ? { imports: chunks.length, rows: total } : {}, bodyOf(chunks[0]));
|
|
177
|
+
const wait = !(f["no-wait"] === true || f.wait === false);
|
|
178
|
+
const poll = async (made) => {
|
|
179
|
+
let imp = made;
|
|
180
|
+
while (wait && imp.status !== "completed" && imp.status !== "failed") {
|
|
181
|
+
imp = readableObject(await c.contacts.imports.get(String(imp.id)));
|
|
182
|
+
if (imp.status !== "completed" && imp.status !== "failed") await sleep(POLL_MS);
|
|
183
|
+
}
|
|
184
|
+
return imp;
|
|
185
|
+
};
|
|
186
|
+
const done = [];
|
|
187
|
+
const offsets = [];
|
|
188
|
+
let at = 0;
|
|
189
|
+
await sendChunked(
|
|
190
|
+
chunks,
|
|
191
|
+
async (rows) => {
|
|
192
|
+
const made = readableObject(await c.contacts.imports.create(bodyOf(rows)));
|
|
193
|
+
const imp = await poll(made);
|
|
194
|
+
offsets.push(at);
|
|
195
|
+
at += rows.length;
|
|
196
|
+
done.push(imp);
|
|
197
|
+
if (imp.status === "failed") throw await failedImport(imp);
|
|
198
|
+
return imp;
|
|
199
|
+
},
|
|
200
|
+
f,
|
|
201
|
+
"rows"
|
|
202
|
+
);
|
|
203
|
+
const counts = Object.fromEntries(COUNTS.map((k) => [k, done.reduce((n, i) => n + (i.counts?.[k] ?? 0), 0)]));
|
|
204
|
+
const skipped = [];
|
|
205
|
+
for (const [k, imp] of done.entries()) {
|
|
206
|
+
if (!wait || !(imp.counts?.["skipped"] ?? 0)) continue;
|
|
207
|
+
for (const r of await skippedRows(c, imp)) skipped.push({ row: offsets[k] + r.row, reason: r.reason ?? null, field: r.field ?? null });
|
|
208
|
+
}
|
|
209
|
+
const summary = { imports: done.map((i) => ({ id: i.id, status: i.status })), total_rows: total, ...wait ? { counts, skipped } : {} };
|
|
210
|
+
renderSuccess(summary, outputOpts(f), process);
|
|
211
|
+
}
|
|
212
|
+
async function failedImport(imp) {
|
|
213
|
+
const { CurviateError } = await import("@curviate/sdk");
|
|
214
|
+
return new CurviateError({ code: imp.failure?.code ?? "INTERNAL", message: imp.failure?.message ?? "The import failed.", status: 422 });
|
|
215
|
+
}
|
|
216
|
+
async function skippedRows(c, imp) {
|
|
217
|
+
if (imp.report) return imp.report.filter((r) => r.outcome === "skipped");
|
|
218
|
+
const rows = [];
|
|
219
|
+
let cursor;
|
|
220
|
+
do {
|
|
221
|
+
const page = await c.contacts.imports.rows(String(imp.id), { outcome: "skipped", limit: 100, ...cursor ? { cursor } : {} });
|
|
222
|
+
rows.push(...page.items ?? []);
|
|
223
|
+
cursor = page.cursor;
|
|
224
|
+
} while (cursor);
|
|
225
|
+
return rows;
|
|
226
|
+
}
|
|
227
|
+
var importCmd = defineCommand({
|
|
228
|
+
meta: {
|
|
229
|
+
name: "import",
|
|
230
|
+
description: `Import Contacts from a CSV, JSON (an array of objects) or NDJSON file. The format comes from the extension; with --file - pass --format. A file above ${IMPORT_MAX_ROWS} rows or ${(IMPORT_MAX_BODY_BYTES / 1048576).toFixed(0)} MiB is split into several imports, run one after the other (a CSV's header is repeated), each awaited unless --no-wait; the first refused or failed import stops the run. Only the file's structure is checked here; the server skips bad rows and reports why. Re-importing merges: a Contact already there is updated or left as it is. Needs Automate.`,
|
|
231
|
+
risk: "write",
|
|
232
|
+
rules: {
|
|
233
|
+
changes: "Contacts are created or updated, joined to --list and tagged with --tag. Nothing is sent to LinkedIn or to the people.",
|
|
234
|
+
visible_to: "Your Team.",
|
|
235
|
+
budget_rows: [],
|
|
236
|
+
retry: "Safe to repeat: Contacts converge, a second run reports them `unchanged`. A run stopped part way: read `curviate contact imports list`, then import the rest.",
|
|
237
|
+
undo: "Cannot be undone as a whole. `curviate contact delete --import IMPORT_ID` deletes every Contact in its report, those it only updated included; Tags and list membership are undone with `curviate contact tags remove` and `curviate contact lists remove`."
|
|
238
|
+
},
|
|
239
|
+
errors: {
|
|
240
|
+
CONTACT_LIMIT_REACHED: "the Team is at its Contact cap; rows past it are skipped.",
|
|
241
|
+
IMPORT_QUEUE_FULL: "too many imports are queued (429); wait, then run it again.",
|
|
242
|
+
NAME_TAKEN: "--list-name names a list that exists."
|
|
243
|
+
},
|
|
244
|
+
output: ["One report: `imports` (id and status each), `total_rows`, summed `counts` (created, updated, unchanged, skipped) and `skipped` rows with their number in the file, a reason and the field. With --no-wait: the imports' ids and statuses only."],
|
|
245
|
+
seeAlso: ["curviate contact imports get", "curviate contact list"],
|
|
246
|
+
examples: [
|
|
247
|
+
'curviate contact import --file prospects.csv --list-name "Q4 prospects" --tag conference',
|
|
248
|
+
'curviate contact import --file prospects.csv --map "LinkedIn Profile=linkedin_url" --list cl_YOUR_LIST_ID --no-wait',
|
|
249
|
+
"curviate contact import --file - --format ndjson --list cl_YOUR_LIST_ID"
|
|
250
|
+
]
|
|
251
|
+
},
|
|
252
|
+
args: {
|
|
253
|
+
...WRITE_SINGLE_FLAGS,
|
|
254
|
+
file: { type: "string", stdinArg: true, required: true, description: "The file: a path, or - to read it from stdin (then --format is required)." },
|
|
255
|
+
format: { type: "string", description: "csv | json | ndjson. Default: from the file extension (.csv, .json, .ndjson)." },
|
|
256
|
+
list: { type: "string", description: "Add every imported Contact to this Contact list (cl_...)." },
|
|
257
|
+
"list-name": { type: "string", description: "Add them to the list of this name (up to 100 characters), creating it. Not with --list." },
|
|
258
|
+
tag: { type: "string", description: "Put this Tag on every imported Contact (up to 64 characters); repeatable." },
|
|
259
|
+
"remove-tag": { type: "string", description: "Take this Tag off every imported Contact; repeatable." },
|
|
260
|
+
map: { type: "string", description: 'Map a file header to a Contact field: header=target, for example "LinkedIn Profile=linkedin_url"; repeatable.' },
|
|
261
|
+
delimiter: { type: "string", description: "A CSV's separator: comma, semicolon or tab. Default: found by the server." },
|
|
262
|
+
"no-wait": { type: "boolean", description: "Print the imports' ids without waiting for them to finish. Stops only on a refused request." }
|
|
263
|
+
},
|
|
264
|
+
run: online(runImport)
|
|
265
|
+
});
|
|
266
|
+
var ID = { type: "positional", description: "Import id (imp_...)." };
|
|
267
|
+
var importsList = defineCommand({
|
|
268
|
+
meta: { name: "list", description: "List your Team's imports, newest first: status, counts and failure.", risk: "read", examples: ["curviate contact imports list"] },
|
|
269
|
+
args: { ...readOnly(GLOBAL_FLAGS) },
|
|
270
|
+
run: online(async (c, f) => {
|
|
271
|
+
rejectPaginationModifiersWithoutAll(f, process);
|
|
272
|
+
const params = {};
|
|
273
|
+
if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
|
|
274
|
+
const cursor = readCursorFlag(f, process);
|
|
275
|
+
if (cursor) params["cursor"] = cursor;
|
|
276
|
+
try {
|
|
277
|
+
if (f.all) {
|
|
278
|
+
const next = (p) => c.contacts.imports.list(p);
|
|
279
|
+
for await (const item of streamAll(next, params, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
|
|
280
|
+
} else {
|
|
281
|
+
renderSuccess(readablePage(await c.contacts.imports.list(params)), outputOpts(f), process);
|
|
282
|
+
}
|
|
283
|
+
} catch (err) {
|
|
284
|
+
await fail(err, f);
|
|
285
|
+
}
|
|
286
|
+
})
|
|
287
|
+
});
|
|
288
|
+
var importsGet = defineCommand({
|
|
289
|
+
meta: {
|
|
290
|
+
name: "get",
|
|
291
|
+
description: "One import: its status, counts, the columns it mapped or ignored, and its failure. With --outcome, its rows instead: one per row of the file with what happened (created, updated, unchanged, skipped), the reason and the field. Import records are kept for a limited time.",
|
|
292
|
+
risk: "read",
|
|
293
|
+
examples: ["curviate contact imports get imp_YOUR_IMPORT_ID", "curviate contact imports get imp_YOUR_IMPORT_ID --outcome skipped"]
|
|
294
|
+
},
|
|
295
|
+
args: {
|
|
296
|
+
...readOnly(GLOBAL_FLAGS),
|
|
297
|
+
id: ID,
|
|
298
|
+
outcome: { type: "string", description: "Read the rows instead: comma list of created, updated, unchanged, skipped." }
|
|
299
|
+
},
|
|
300
|
+
run: online(async (c, f) => {
|
|
301
|
+
const id = String(f.id ?? "");
|
|
302
|
+
try {
|
|
303
|
+
if (f.outcome === void 0) return renderSuccess(readableObject(await c.contacts.imports.get(id)), outputOpts(f), process);
|
|
304
|
+
rejectPaginationModifiersWithoutAll(f, process);
|
|
305
|
+
const params = { outcome: listFlag("outcome", f.outcome).join(",") };
|
|
306
|
+
if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
|
|
307
|
+
const cursor = readCursorFlag(f, process);
|
|
308
|
+
if (cursor) params["cursor"] = cursor;
|
|
309
|
+
if (f.all) {
|
|
310
|
+
const next = (p) => c.contacts.imports.rows(id, p);
|
|
311
|
+
for await (const item of streamAll(next, params, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
|
|
312
|
+
} else {
|
|
313
|
+
renderSuccess(readablePage(await c.contacts.imports.rows(id, params)), outputOpts(f), process);
|
|
314
|
+
}
|
|
315
|
+
} catch (err) {
|
|
316
|
+
await fail(err, f);
|
|
317
|
+
}
|
|
318
|
+
})
|
|
319
|
+
});
|
|
320
|
+
var contactImportCommand = importCmd;
|
|
321
|
+
var contactImportsCommand = defineCommand({
|
|
322
|
+
meta: { name: "imports", description: "Your Team's import records." },
|
|
323
|
+
subCommands: { list: importsList, get: importsGet },
|
|
324
|
+
async run() {
|
|
325
|
+
const { showHelp } = await import("./examples-DQSVIIXZ.js");
|
|
326
|
+
await showHelp(contactImportsCommand, ["curviate", "contact", "imports"]);
|
|
327
|
+
}
|
|
328
|
+
});
|
|
329
|
+
export {
|
|
330
|
+
IMPORT_MAX_BODY_BYTES,
|
|
331
|
+
IMPORT_MAX_ROWS,
|
|
332
|
+
chunkRows,
|
|
333
|
+
contactImportCommand,
|
|
334
|
+
contactImportsCommand,
|
|
335
|
+
csvRecords
|
|
336
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
DESCRIPTIONS,
|
|
4
|
+
lazy
|
|
5
|
+
} from "./chunk-73DJ3KNE.js";
|
|
6
|
+
|
|
7
|
+
// src/commands/core.ts
|
|
8
|
+
import { defineCommand } from "citty";
|
|
9
|
+
var coreCommand = defineCommand({
|
|
10
|
+
meta: {
|
|
11
|
+
name: "core",
|
|
12
|
+
description: DESCRIPTIONS.core,
|
|
13
|
+
rules: {
|
|
14
|
+
notes: [
|
|
15
|
+
"Writes reach LinkedIn immediately and are seen by the people they touch.",
|
|
16
|
+
"A retry after a timeout can repeat a write: requests carry no idempotency key. Read the current state before retrying.",
|
|
17
|
+
"Budget rows, ceilings and what is left: `curviate account get <account_id>`."
|
|
18
|
+
]
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
subCommands: {
|
|
22
|
+
profile: lazy("profile", () => import("./profile-A2N6RMR2.js").then((m) => m.profileCommand)),
|
|
23
|
+
company: lazy("company", () => import("./company-TXST2VXW.js").then((m) => m.companyCommand)),
|
|
24
|
+
job: lazy("job", () => import("./job-55IKS6LP.js").then((m) => m.jobCommand)),
|
|
25
|
+
connect: lazy("connect", () => import("./connect-RBL6U4KV.js").then((m) => m.connectCommand)),
|
|
26
|
+
search: lazy("search", () => import("./search-Z4DZIG4X.js").then((m) => m.searchCommand)),
|
|
27
|
+
inbox: lazy("inbox", () => import("./inbox-HLZR2ZPV.js").then((m) => m.inboxCommand)),
|
|
28
|
+
inboxes: lazy("inboxes", () => import("./inboxes-IZTRD6FE.js").then((m) => m.inboxesCommand)),
|
|
29
|
+
message: lazy("message", () => import("./message-J44YKRDS.js").then((m) => m.messageCommand)),
|
|
30
|
+
post: lazy("post", () => import("./post-L467SKIG.js").then((m) => m.postCommand)),
|
|
31
|
+
comment: lazy("comment", () => import("./comment-5JKGNYOY.js").then((m) => m.commentCommand)),
|
|
32
|
+
"sales-nav": lazy("sales-nav", () => import("./sales-nav-C2AYFXPV.js").then((m) => m.salesNavCommand)),
|
|
33
|
+
recruiter: lazy("recruiter", () => import("./recruiter-AR75RHBO.js").then((m) => m.recruiterCommand)),
|
|
34
|
+
group: lazy("group", () => import("./group-AUALYK5H.js").then((m) => m.groupCommand)),
|
|
35
|
+
feed: lazy("feed", () => import("./feed-W56ZTA4Z.js").then((m) => m.feedCommand)),
|
|
36
|
+
notification: lazy("coreNotification", () => import("./notification-SEDXZHXO.js").then((m) => m.notificationCommand)),
|
|
37
|
+
draft: lazy("draft", () => import("./draft-TDJJUXLH.js").then((m) => m.draftCommand))
|
|
38
|
+
},
|
|
39
|
+
async run() {
|
|
40
|
+
const { showHelp } = await import("./examples-DQSVIIXZ.js");
|
|
41
|
+
await showHelp(coreCommand, ["curviate", "core"]);
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
export {
|
|
45
|
+
coreCommand
|
|
46
|
+
};
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
fail,
|
|
4
|
+
outputOpts,
|
|
5
|
+
rootClient,
|
|
6
|
+
usage
|
|
7
|
+
} from "./chunk-T6GBS5SS.js";
|
|
8
|
+
import {
|
|
9
|
+
buildPreviewOutput
|
|
10
|
+
} from "./chunk-TCUYH5GO.js";
|
|
11
|
+
import {
|
|
12
|
+
intFlag
|
|
13
|
+
} from "./chunk-NNV2OYEF.js";
|
|
14
|
+
import {
|
|
15
|
+
pageDelayFromFlags,
|
|
16
|
+
readCursorFlag,
|
|
17
|
+
readMaxPagesFlag,
|
|
18
|
+
readableObject,
|
|
19
|
+
readablePage,
|
|
20
|
+
rejectPaginationModifiersWithoutAll,
|
|
21
|
+
streamAll
|
|
22
|
+
} from "./chunk-L4CIJT6F.js";
|
|
23
|
+
import {
|
|
24
|
+
renderSuccess,
|
|
25
|
+
writeNdjsonItem
|
|
26
|
+
} from "./chunk-QM57YDJE.js";
|
|
27
|
+
import "./chunk-YXVF5UST.js";
|
|
28
|
+
import {
|
|
29
|
+
GLOBAL_FLAGS,
|
|
30
|
+
READ_SINGLE_FLAGS,
|
|
31
|
+
WRITE_SINGLE_FLAGS,
|
|
32
|
+
readOnly
|
|
33
|
+
} from "./chunk-RYWWSZUH.js";
|
|
34
|
+
import {
|
|
35
|
+
DESCRIPTIONS
|
|
36
|
+
} from "./chunk-73DJ3KNE.js";
|
|
37
|
+
import "./chunk-ZYURL5VK.js";
|
|
38
|
+
|
|
39
|
+
// src/commands/do-not-contact.ts
|
|
40
|
+
import { defineCommand } from "citty";
|
|
41
|
+
var REASONS = ["asked_to_stop", "existing_customer", "competitor", "partner", "employee", "other"];
|
|
42
|
+
var online = (fn) => async ({ args }) => {
|
|
43
|
+
const f = args;
|
|
44
|
+
await fn(await rootClient(f), f);
|
|
45
|
+
};
|
|
46
|
+
var preview = (method, args, body = {}) => void process.stdout.write(JSON.stringify(buildPreviewOutput({ method, args, body })) + "\n");
|
|
47
|
+
var reason = (f, requiredFlag) => {
|
|
48
|
+
if (f.reason === void 0) return requiredFlag ? usage(`--reason is required: one of ${REASONS.join(", ")}.`) : void 0;
|
|
49
|
+
if (!REASONS.includes(f.reason)) usage(`--reason takes one of ${REASONS.join(", ")}.`);
|
|
50
|
+
return f.reason;
|
|
51
|
+
};
|
|
52
|
+
async function runList(c, f) {
|
|
53
|
+
rejectPaginationModifiersWithoutAll(f, process);
|
|
54
|
+
const params = {};
|
|
55
|
+
if (f.query !== void 0) {
|
|
56
|
+
if (f.query.trim() === "") usage("--query was given an empty value.");
|
|
57
|
+
params["q"] = f.query;
|
|
58
|
+
}
|
|
59
|
+
if (f.limit !== void 0) params["limit"] = intFlag("limit", f.limit, 1, 100);
|
|
60
|
+
const cursor = readCursorFlag(f, process);
|
|
61
|
+
if (cursor) params["cursor"] = cursor;
|
|
62
|
+
try {
|
|
63
|
+
if (f.all) {
|
|
64
|
+
const page = (p) => c.doNotContact.list(p);
|
|
65
|
+
for await (const item of streamAll(page, params, { maxPages: readMaxPagesFlag(f, process), out: process, pageDelayMs: pageDelayFromFlags(f) })) writeNdjsonItem(process, item, f.fields);
|
|
66
|
+
} else {
|
|
67
|
+
renderSuccess(readablePage(await c.doNotContact.list(params)), outputOpts(f), process);
|
|
68
|
+
}
|
|
69
|
+
} catch (err) {
|
|
70
|
+
await fail(err, f);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
async function runGet(c, f) {
|
|
74
|
+
try {
|
|
75
|
+
renderSuccess(readableObject(await c.doNotContact.get(String(f.id ?? ""))), outputOpts(f), process);
|
|
76
|
+
} catch (err) {
|
|
77
|
+
await fail(err, f);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
async function runAdd(c, f) {
|
|
81
|
+
if (f.contact === void 0 === (f["linkedin-url"] === void 0)) usage("name the person with exactly one of --contact (con_...) or --linkedin-url.");
|
|
82
|
+
for (const [flag, v] of [["contact", f.contact], ["linkedin-url", f["linkedin-url"]]]) if (v !== void 0 && v.trim() === "") usage(`--${flag} was given an empty value.`);
|
|
83
|
+
const body = f.contact !== void 0 ? { contact_id: f.contact } : { linkedin_url: f["linkedin-url"] };
|
|
84
|
+
const why = reason(f, false);
|
|
85
|
+
if (why) body["reason"] = why;
|
|
86
|
+
if (f.preview) return preview("doNotContact.add", {}, body);
|
|
87
|
+
try {
|
|
88
|
+
renderSuccess(readableObject(await c.doNotContact.add(body)), outputOpts(f), process);
|
|
89
|
+
} catch (err) {
|
|
90
|
+
await fail(err, f);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function runUpdate(c, f) {
|
|
94
|
+
const body = { reason: reason(f, true) };
|
|
95
|
+
if (f.preview) return preview("doNotContact.update", { id: f.id }, body);
|
|
96
|
+
try {
|
|
97
|
+
renderSuccess(readableObject(await c.doNotContact.update(String(f.id ?? ""), body)), outputOpts(f), process);
|
|
98
|
+
} catch (err) {
|
|
99
|
+
await fail(err, f);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async function runRemove(c, f) {
|
|
103
|
+
if (f.preview) return preview("doNotContact.remove", { id: f.id });
|
|
104
|
+
try {
|
|
105
|
+
await c.doNotContact.remove(String(f.id ?? ""));
|
|
106
|
+
renderSuccess({}, outputOpts(f), process);
|
|
107
|
+
} catch (err) {
|
|
108
|
+
await fail(err, f);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
var ID = { type: "positional", description: "Entry id (dnc_...), from `curviate do-not-contact list`." };
|
|
112
|
+
var REASON_ARG = { type: "string", description: `Why: ${REASONS.join(" | ")}.` };
|
|
113
|
+
var listCmd = defineCommand({
|
|
114
|
+
meta: {
|
|
115
|
+
name: "list",
|
|
116
|
+
description: "List your Team's do-not-contact list, newest first. No Motion contacts a person on it and writes toward them are refused (exit 10); a reply in a conversation they wrote in stays allowed. An entry whose Contact was deleted still applies.",
|
|
117
|
+
risk: "read",
|
|
118
|
+
examples: ["curviate do-not-contact list", "curviate do-not-contact list --query jane"]
|
|
119
|
+
},
|
|
120
|
+
args: { ...readOnly(GLOBAL_FLAGS), query: { type: "string", description: "Only entries whose Contact name matches this text." } },
|
|
121
|
+
run: online(runList)
|
|
122
|
+
});
|
|
123
|
+
var getCmd = defineCommand({
|
|
124
|
+
meta: { name: "get", description: "One do-not-contact entry: the person, the reason, and who added it.", risk: "read", examples: ["curviate do-not-contact get dnc_YOUR_ENTRY_ID"] },
|
|
125
|
+
args: { ...readOnly(READ_SINGLE_FLAGS), id: ID },
|
|
126
|
+
run: online(runGet)
|
|
127
|
+
});
|
|
128
|
+
var addCmd = defineCommand({
|
|
129
|
+
meta: {
|
|
130
|
+
name: "add",
|
|
131
|
+
description: "Put one person on the list, by Contact id or LinkedIn URL (a URL of someone who is not a Contact yet creates the Contact from stored data). No Motion contacts them afterwards and writes toward them are refused. One person per call; loop for many. Any member may add. Needs Automate.",
|
|
132
|
+
risk: "write",
|
|
133
|
+
rules: {
|
|
134
|
+
changes: "The person joins the list; Motions skip them and writes toward them are refused.",
|
|
135
|
+
visible_to: "Your Team.",
|
|
136
|
+
budget_rows: [],
|
|
137
|
+
retry: "Safe: a person already on the list answers with their existing entry.",
|
|
138
|
+
undo: "`curviate do-not-contact remove <id>` (Owners and Managers)."
|
|
139
|
+
},
|
|
140
|
+
errors: { TIER_REQUIRED: "your plan does not include Do-not-contact writes (Automate).", RESOURCE_NOT_FOUND: "no Contact has this id." },
|
|
141
|
+
seeAlso: ["curviate do-not-contact list"],
|
|
142
|
+
examples: ["curviate do-not-contact add --contact con_YOUR_CONTACT_ID --reason asked_to_stop", "curviate do-not-contact add --linkedin-url https://www.linkedin.com/in/jane-doe"]
|
|
143
|
+
},
|
|
144
|
+
args: {
|
|
145
|
+
...WRITE_SINGLE_FLAGS,
|
|
146
|
+
contact: { type: "string", description: "The Contact (con_...). Not with --linkedin-url." },
|
|
147
|
+
"linkedin-url": { type: "string", description: "The person's LinkedIn profile URL, in any spelling. Not with --contact." },
|
|
148
|
+
reason: REASON_ARG
|
|
149
|
+
},
|
|
150
|
+
run: online(runAdd)
|
|
151
|
+
});
|
|
152
|
+
var updateCmd = defineCommand({
|
|
153
|
+
meta: {
|
|
154
|
+
name: "update",
|
|
155
|
+
description: "Change the reason on an entry. Needs Automate.",
|
|
156
|
+
risk: "write",
|
|
157
|
+
rules: {
|
|
158
|
+
changes: "The entry's reason.",
|
|
159
|
+
visible_to: "Your Team.",
|
|
160
|
+
budget_rows: [],
|
|
161
|
+
retry: "Safe: the same call leaves the same reason.",
|
|
162
|
+
undo: "Update again with the old reason."
|
|
163
|
+
},
|
|
164
|
+
errors: { TIER_REQUIRED: "your plan does not include Do-not-contact writes (Automate).", RESOURCE_NOT_FOUND: "no such entry." },
|
|
165
|
+
examples: ["curviate do-not-contact update dnc_YOUR_ENTRY_ID --reason existing_customer"]
|
|
166
|
+
},
|
|
167
|
+
args: { ...WRITE_SINGLE_FLAGS, id: ID, reason: { ...REASON_ARG, required: true } },
|
|
168
|
+
run: online(runUpdate)
|
|
169
|
+
});
|
|
170
|
+
var removeCmd = defineCommand({
|
|
171
|
+
meta: {
|
|
172
|
+
name: "remove",
|
|
173
|
+
description: "Take a person off the list: Motions and writes may reach them again. Owners and Managers only.",
|
|
174
|
+
risk: "high",
|
|
175
|
+
rules: {
|
|
176
|
+
changes: "The entry is deleted; Motions may enroll the person and writes toward them are allowed again.",
|
|
177
|
+
visible_to: "The person, if a Motion or write then reaches them on LinkedIn.",
|
|
178
|
+
budget_rows: [],
|
|
179
|
+
retry: "Safe: a second call answers RESOURCE_NOT_FOUND.",
|
|
180
|
+
undo: "`curviate do-not-contact add` again.",
|
|
181
|
+
blast_radius: "One person."
|
|
182
|
+
},
|
|
183
|
+
errors: { INSUFFICIENT_ROLE: "removing is for Owners and Managers.", RESOURCE_NOT_FOUND: "no such entry (already removed)." },
|
|
184
|
+
seeAlso: ["curviate do-not-contact list", "curviate do-not-contact add"],
|
|
185
|
+
examples: ["curviate do-not-contact remove dnc_YOUR_ENTRY_ID"]
|
|
186
|
+
},
|
|
187
|
+
args: { ...WRITE_SINGLE_FLAGS, id: ID },
|
|
188
|
+
run: online(runRemove)
|
|
189
|
+
});
|
|
190
|
+
var doNotContactCommand = defineCommand({
|
|
191
|
+
meta: { name: "do-not-contact", description: DESCRIPTIONS["do-not-contact"] },
|
|
192
|
+
subCommands: { list: listCmd, get: getCmd, add: addCmd, update: updateCmd, remove: removeCmd },
|
|
193
|
+
async run() {
|
|
194
|
+
const { showHelp } = await import("./examples-DQSVIIXZ.js");
|
|
195
|
+
await showHelp(doNotContactCommand, ["curviate", "do-not-contact"]);
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
export {
|
|
199
|
+
doNotContactCommand
|
|
200
|
+
};
|