@erdoai/cli 0.177.2 → 0.178.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/dist/index.js +215 -28
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -57,6 +57,72 @@ function describeRefreshWrites(strategy, mode, key, liveMode) {
|
|
|
57
57
|
// src/index.ts
|
|
58
58
|
import { readFileSync as readFileSync4, writeFileSync as writeFileSync3 } from "fs";
|
|
59
59
|
import { basename } from "path";
|
|
60
|
+
|
|
61
|
+
// src/csv.ts
|
|
62
|
+
function parseCSV(text) {
|
|
63
|
+
const rows = [];
|
|
64
|
+
let row = [];
|
|
65
|
+
let field = "";
|
|
66
|
+
let quoted = false;
|
|
67
|
+
let closed = false;
|
|
68
|
+
let line = 1;
|
|
69
|
+
let quoteLine = 0;
|
|
70
|
+
let i = text.charCodeAt(0) === 65279 ? 1 : 0;
|
|
71
|
+
const endRow = () => {
|
|
72
|
+
row.push(field);
|
|
73
|
+
field = "";
|
|
74
|
+
closed = false;
|
|
75
|
+
if (row.some((cell) => cell.trim() !== "")) rows.push(row);
|
|
76
|
+
row = [];
|
|
77
|
+
};
|
|
78
|
+
for (; i < text.length; i++) {
|
|
79
|
+
const c = text[i];
|
|
80
|
+
if (quoted) {
|
|
81
|
+
if (c === '"') {
|
|
82
|
+
if (text[i + 1] === '"') {
|
|
83
|
+
field += '"';
|
|
84
|
+
i++;
|
|
85
|
+
} else {
|
|
86
|
+
quoted = false;
|
|
87
|
+
closed = true;
|
|
88
|
+
}
|
|
89
|
+
} else {
|
|
90
|
+
if (c === "\n" || c === "\r" && text[i + 1] !== "\n") line++;
|
|
91
|
+
field += c;
|
|
92
|
+
}
|
|
93
|
+
continue;
|
|
94
|
+
}
|
|
95
|
+
if (c === ",") {
|
|
96
|
+
row.push(field);
|
|
97
|
+
field = "";
|
|
98
|
+
closed = false;
|
|
99
|
+
} else if (c === "\n") {
|
|
100
|
+
endRow();
|
|
101
|
+
line++;
|
|
102
|
+
} else if (c === "\r") {
|
|
103
|
+
if (text[i + 1] === "\n") i++;
|
|
104
|
+
endRow();
|
|
105
|
+
line++;
|
|
106
|
+
} else if (closed) {
|
|
107
|
+
throw new Error(`CSV line ${line}: unexpected text after a closing quote; a quoted field must end at a comma or line end (write a literal quote as "")`);
|
|
108
|
+
} else if (c === '"') {
|
|
109
|
+
if (field !== "") {
|
|
110
|
+
throw new Error(`CSV line ${line}: a quote inside an unquoted field; quote the whole field and write the literal quote as ""`);
|
|
111
|
+
}
|
|
112
|
+
quoted = true;
|
|
113
|
+
quoteLine = line;
|
|
114
|
+
} else {
|
|
115
|
+
field += c;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
if (quoted) {
|
|
119
|
+
throw new Error(`CSV line ${quoteLine}: a quoted field is never closed; the file ends inside it, so every line after it would be read as part of that one cell`);
|
|
120
|
+
}
|
|
121
|
+
if (field !== "" || row.length > 0 || closed) endRow();
|
|
122
|
+
return rows;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
// src/index.ts
|
|
60
126
|
import { password, select } from "@inquirer/prompts";
|
|
61
127
|
import { Command as Command2, Option as Option2 } from "commander";
|
|
62
128
|
|
|
@@ -1318,6 +1384,7 @@ var ErdoClient = class {
|
|
|
1318
1384
|
if (params?.scope) q.set("scope", params.scope);
|
|
1319
1385
|
if (params?.orderBy) q.set("order_by", params.orderBy);
|
|
1320
1386
|
if (params?.includeAutomation) q.set("include_automation", "true");
|
|
1387
|
+
if (params?.origin) q.set("origin", params.origin);
|
|
1321
1388
|
if (params?.limit !== void 0) q.set("limit", String(params.limit));
|
|
1322
1389
|
if (params?.offset !== void 0) q.set("offset", String(params.offset));
|
|
1323
1390
|
const qs = q.toString();
|
|
@@ -1366,8 +1433,12 @@ var ErdoClient = class {
|
|
|
1366
1433
|
setProviderLeadSource(input) {
|
|
1367
1434
|
return this.request("PUT", "/v1/provider-lead-sources", input, false);
|
|
1368
1435
|
}
|
|
1369
|
-
|
|
1370
|
-
|
|
1436
|
+
importLeadSourceRows(input) {
|
|
1437
|
+
return this.request("POST", "/v1/provider-lead-sources/import", input, false);
|
|
1438
|
+
}
|
|
1439
|
+
deleteProviderLeadSource(by) {
|
|
1440
|
+
const q = new URLSearchParams("name" in by ? { name: by.name } : { provider: by.provider, account_id: by.accountId });
|
|
1441
|
+
if (by.ifUpdatedAt) q.set("if_updated_at", by.ifUpdatedAt);
|
|
1371
1442
|
return this.request(
|
|
1372
1443
|
"DELETE",
|
|
1373
1444
|
`/v1/provider-lead-sources?${q.toString()}`
|
|
@@ -1560,6 +1631,7 @@ var ErdoClient = class {
|
|
|
1560
1631
|
if (params?.priority) q.set("priority", params.priority);
|
|
1561
1632
|
if (params?.limit) q.set("limit", String(params.limit));
|
|
1562
1633
|
if (params?.offset) q.set("offset", String(params.offset));
|
|
1634
|
+
if (params?.waitingForStart) q.set("waiting_for_start", "true");
|
|
1563
1635
|
const qs = q.toString();
|
|
1564
1636
|
return this.request("GET", `/v1/lead-next-actions${qs ? `?${qs}` : ""}`);
|
|
1565
1637
|
}
|
|
@@ -3237,10 +3309,21 @@ managed.command("list").description("List the client orgs your org manages").act
|
|
|
3237
3309
|
fail(e);
|
|
3238
3310
|
}
|
|
3239
3311
|
});
|
|
3240
|
-
managed.command("create").description("Provision a new client org managed by your org").requiredOption("--name <name>", "display name for the new managed org").option("--slug <slug>", "desired slug (a unique suffix is appended if it collides)").
|
|
3312
|
+
managed.command("create").description("Provision a new client org managed by your org").requiredOption("--name <name>", "display name for the new managed org").option("--slug <slug>", "desired slug (a unique suffix is appended if it collides, unless --exact-slug)").option(
|
|
3313
|
+
"--exact-slug",
|
|
3314
|
+
"make the call safe to retry: use --slug exactly as given; if you already manage an org with that slug it is returned and nothing is created, and a slug held by any other org is refused"
|
|
3315
|
+
).option("--timezone <iana>", "IANA timezone for the new org, e.g. Europe/London (default heartbeats run in it; UTC if omitted)").action(async (opts) => {
|
|
3241
3316
|
try {
|
|
3242
|
-
|
|
3243
|
-
|
|
3317
|
+
if (opts.exactSlug && !opts.slug) {
|
|
3318
|
+
throw new Error("--exact-slug needs --slug");
|
|
3319
|
+
}
|
|
3320
|
+
const o = await new ErdoClient().createManagedOrganization({
|
|
3321
|
+
name: opts.name,
|
|
3322
|
+
slug: opts.slug,
|
|
3323
|
+
exact_slug: opts.exactSlug ? true : void 0,
|
|
3324
|
+
timezone: opts.timezone
|
|
3325
|
+
});
|
|
3326
|
+
console.log(o.created ? `Created managed org: ${o.name}` : `Managed org already exists, nothing created: ${o.name}`);
|
|
3244
3327
|
console.log(`slug: ${o.slug}
|
|
3245
3328
|
id: ${o.id}`);
|
|
3246
3329
|
process.stderr.write(
|
|
@@ -4698,7 +4781,7 @@ async function resolveConversationPersona(client, selector) {
|
|
|
4698
4781
|
throw new Error(`No enabled agent matches "${selector}"`);
|
|
4699
4782
|
}
|
|
4700
4783
|
var conversationsCmd = program.command("threads").description("List and open conversations with people and named agents");
|
|
4701
|
-
conversationsCmd.command("list").description("List conversations with the latest message, speaker, unread status and open questions").option("-s, --scope <scope>", "own (default) | org | shared | all \u2014 org/shared require org membership").option("--order-by <order>", "created_at (default) | activity (last message time) \u2014 scope=org/shared only").option("--include-automation", "include automation/heartbeat-sourced threads \u2014 scope=org/shared only").option("-l, --limit <n>", "max conversations (default 20, max 100)", (v) => parseInt(v, 10)).option("--offset <n>", "pagination offset", (v) => parseInt(v, 10)).action(async (opts) => {
|
|
4784
|
+
conversationsCmd.command("list").description("List conversations with the latest message, speaker, unread status and open questions").option("-s, --scope <scope>", "own (default) | org | shared | all \u2014 org/shared require org membership").option("--order-by <order>", "created_at (default) | activity (last message time) \u2014 scope=org/shared only").option("--include-automation", "include automation/heartbeat-sourced threads \u2014 scope=org/shared only").option("--origin <origin>", "person (default) | erdo (automation and Shortcut runs) | all \u2014 scope=org/shared only").option("-l, --limit <n>", "max conversations (default 20, max 100)", (v) => parseInt(v, 10)).option("--offset <n>", "pagination offset", (v) => parseInt(v, 10)).action(async (opts) => {
|
|
4702
4785
|
try {
|
|
4703
4786
|
const { threads, total } = await new ErdoClient().listThreads(opts);
|
|
4704
4787
|
for (const thread of threads) {
|
|
@@ -7671,8 +7754,8 @@ voiceWidgetsCmd.command("realtime-model <widget> <model>").description("Choose t
|
|
|
7671
7754
|
}
|
|
7672
7755
|
});
|
|
7673
7756
|
var datasetsCmd = program.command("datasets").description("Datasets");
|
|
7674
|
-
var providerLeadSourcesCmd = program.command("provider-lead-sources").description("Manage LinkedIn lead
|
|
7675
|
-
providerLeadSourcesCmd.command("list").description("List
|
|
7757
|
+
var providerLeadSourcesCmd = program.command("provider-lead-sources").description("Manage lead sources: LinkedIn lead forms, Google Sheets, webhooks and imports written into a lead dataset");
|
|
7758
|
+
providerLeadSourcesCmd.command("list").description("List lead source declarations").option("--provider <provider>", "filter by ad platform provider").option("--account-id <id>", "filter by provider ad account id").action(async (opts) => {
|
|
7676
7759
|
try {
|
|
7677
7760
|
print(await new ErdoClient().listProviderLeadSources({ provider: opts.provider, account_id: opts.accountId }));
|
|
7678
7761
|
} catch (e) {
|
|
@@ -7686,7 +7769,9 @@ providerLeadSourcesCmd.command("forms").description("List LinkedIn lead forms av
|
|
|
7686
7769
|
fail(e);
|
|
7687
7770
|
}
|
|
7688
7771
|
});
|
|
7689
|
-
providerLeadSourcesCmd.command("set").description(
|
|
7772
|
+
providerLeadSourcesCmd.command("set").description(
|
|
7773
|
+
"Save a lead source from JSON or flags. A LinkedIn source names a connection, ad account and forms; a google_sheets, webhook or import source names itself and carries a column mapping (use --file). --dry-run previews what it would write and saves nothing."
|
|
7774
|
+
).option("-f, --file <path>", "one JSON declaration object; use - to read from stdin").option("--dataset <slug>", "lead dataset slug").option("--provider <provider>", "linkedin_ads, google_sheets, webhook or import", "linkedin_ads").option("--connection-id <id>", "native integration id from erdo integrations status linkedin_ads_sync or GET /v1/integrations").option("--account-id <id>", "numeric LinkedIn ad account id").option("--form <id>", "LinkedIn lead gen form id (repeatable)", collect, []).option("--name <name>", "a google_sheets, webhook or import source's name").option("--sheet-url <url>", "a google_sheets source's tab, as its address in the browser (open to anyone with the link)").option("--dry-run", "preview what the source would write; save nothing").option("--rotate-secret", "issue a webhook source a new secret").option("--disabled", "save the declaration disabled").option("--create-only", "refuse the save if a source with this name already exists").action(async (opts) => {
|
|
7690
7775
|
try {
|
|
7691
7776
|
let input;
|
|
7692
7777
|
if (opts.file) {
|
|
@@ -7698,34 +7783,120 @@ providerLeadSourcesCmd.command("set").description("Replace a provider lead form
|
|
|
7698
7783
|
connection_id: opts.connectionId,
|
|
7699
7784
|
account_id: opts.accountId,
|
|
7700
7785
|
forms: opts.form,
|
|
7701
|
-
...opts.
|
|
7786
|
+
...opts.name ? { name: opts.name } : {},
|
|
7787
|
+
...opts.sheetUrl ? { sheet_url: opts.sheetUrl } : {}
|
|
7702
7788
|
};
|
|
7703
7789
|
}
|
|
7790
|
+
if (opts.disabled) input.enabled = false;
|
|
7791
|
+
if (opts.dryRun) input.dry_run = true;
|
|
7792
|
+
if (opts.rotateSecret) input.rotate_secret = true;
|
|
7793
|
+
if (opts.createOnly) input.create_only = true;
|
|
7704
7794
|
const dataset = typeof input.dataset === "string" ? input.dataset.trim() : "";
|
|
7705
7795
|
const provider = typeof input.provider === "string" ? input.provider.trim() : "";
|
|
7706
|
-
const connectionID = typeof input.connection_id === "string" ? input.connection_id.trim() : "";
|
|
7707
|
-
const accountID = typeof input.account_id === "string" ? input.account_id.trim() : "";
|
|
7708
|
-
const forms = Array.isArray(input.forms) ? input.forms.filter((form) => typeof form === "string" && form.trim().length > 0) : [];
|
|
7709
7796
|
if (!dataset) throw new Error("dataset must be a non-empty string");
|
|
7710
7797
|
if (!provider) throw new Error("provider must be a non-empty string");
|
|
7711
|
-
if (
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
connection_id: connectionID,
|
|
7719
|
-
|
|
7720
|
-
|
|
7721
|
-
|
|
7798
|
+
if (provider === "linkedin_ads") {
|
|
7799
|
+
const connectionID = typeof input.connection_id === "string" ? input.connection_id.trim() : "";
|
|
7800
|
+
const accountID = typeof input.account_id === "string" ? input.account_id.trim() : "";
|
|
7801
|
+
const forms = Array.isArray(input.forms) ? input.forms.filter((form) => typeof form === "string" && form.trim().length > 0) : [];
|
|
7802
|
+
if (!connectionID) throw new Error("connection_id must be a non-empty string");
|
|
7803
|
+
if (!accountID) throw new Error("account_id must be a non-empty string");
|
|
7804
|
+
if (forms.length === 0) throw new Error("forms must contain at least one form");
|
|
7805
|
+
print(await new ErdoClient().setProviderLeadSource({ ...input, dataset, provider: "linkedin_ads", connection_id: connectionID, account_id: accountID, forms }));
|
|
7806
|
+
return;
|
|
7807
|
+
}
|
|
7808
|
+
if (provider !== "google_sheets" && provider !== "webhook" && provider !== "import") {
|
|
7809
|
+
throw new Error("provider must be linkedin_ads, google_sheets, webhook or import");
|
|
7810
|
+
}
|
|
7811
|
+
const name = typeof input.name === "string" ? input.name.trim() : "";
|
|
7812
|
+
if (!name) throw new Error("name must be a non-empty string");
|
|
7813
|
+
if (typeof input.mapping !== "object" || input.mapping === null) throw new Error("mapping is required: put the declaration in a JSON file and pass --file");
|
|
7814
|
+
delete input.connection_id;
|
|
7815
|
+
delete input.account_id;
|
|
7816
|
+
delete input.forms;
|
|
7817
|
+
const saved = await new ErdoClient().setProviderLeadSource({ ...input, dataset, provider, name });
|
|
7818
|
+
print(saved);
|
|
7819
|
+
if (saved.webhook_secret) {
|
|
7820
|
+
process.stderr.write("The webhook secret is shown once. Store it now; send it as the X-Erdo-Lead-Source-Secret header.\n");
|
|
7821
|
+
}
|
|
7722
7822
|
} catch (e) {
|
|
7723
7823
|
fail(e);
|
|
7724
7824
|
}
|
|
7725
7825
|
});
|
|
7726
|
-
providerLeadSourcesCmd.command("
|
|
7826
|
+
providerLeadSourcesCmd.command("import <name> <file>").description(
|
|
7827
|
+
"Import a CSV file into an import lead source. Every row is written as history: never alerted on, billed or followed up until started. Without --commit this is a dry run that previews the file and writes nothing."
|
|
7828
|
+
).option("--commit", "write the rows (without it, only a preview)").option("--default-submitted-at <date>", "when these people got in touch, for rows the file does not date (YYYY-MM-DD or RFC 3339)").option("--start-follow-up", "after writing, start follow-up on each lead the import created (with --commit)").action(async (name, file, opts) => {
|
|
7727
7829
|
try {
|
|
7728
|
-
|
|
7830
|
+
if (opts.startFollowUp && !opts.commit) throw new Error("--start-follow-up needs --commit");
|
|
7831
|
+
if (!file.toLowerCase().endsWith(".csv")) throw new Error("import reads CSV; export the sheet or workbook as CSV first");
|
|
7832
|
+
const records = parseCSV(readFileSync4(file, "utf8"));
|
|
7833
|
+
if (records.length === 0) throw new Error("the file is empty");
|
|
7834
|
+
const [header, ...rows] = records;
|
|
7835
|
+
const client = new ErdoClient();
|
|
7836
|
+
const batch = 1e3;
|
|
7837
|
+
const totals = { rows: rows.length, created: 0, existing: 0, already_written: 0, refused: 0, no_contact: 0, unreadable: 0, history: 0, test: 0 };
|
|
7838
|
+
const skipped = {};
|
|
7839
|
+
const created = /* @__PURE__ */ new Set();
|
|
7840
|
+
let preview;
|
|
7841
|
+
for (let start = 0; start < rows.length || start === 0; start += batch) {
|
|
7842
|
+
const result = await client.importLeadSourceRows({
|
|
7843
|
+
name,
|
|
7844
|
+
header,
|
|
7845
|
+
rows: rows.slice(start, start + batch),
|
|
7846
|
+
dry_run: !opts.commit,
|
|
7847
|
+
...opts.defaultSubmittedAt ? { default_submitted_at: opts.defaultSubmittedAt } : {}
|
|
7848
|
+
});
|
|
7849
|
+
if (result.preview) {
|
|
7850
|
+
preview ??= result.preview;
|
|
7851
|
+
totals.history += result.preview.history;
|
|
7852
|
+
totals.already_written += result.preview.already_written;
|
|
7853
|
+
totals.test += result.preview.test;
|
|
7854
|
+
for (const [reason, n] of Object.entries(result.preview.skipped)) skipped[reason] = (skipped[reason] ?? 0) + n;
|
|
7855
|
+
} else {
|
|
7856
|
+
totals.created += result.created;
|
|
7857
|
+
totals.existing += result.existing;
|
|
7858
|
+
totals.already_written += result.already_written;
|
|
7859
|
+
totals.refused += result.refused;
|
|
7860
|
+
totals.no_contact += result.no_contact;
|
|
7861
|
+
totals.unreadable += result.unreadable;
|
|
7862
|
+
for (const lead of result.created_leads) created.add(lead);
|
|
7863
|
+
}
|
|
7864
|
+
if (rows.length === 0) break;
|
|
7865
|
+
}
|
|
7866
|
+
if (!opts.commit) {
|
|
7867
|
+
print({ dry_run: true, rows: totals.rows, history: totals.history, already_written: totals.already_written, test: totals.test, skipped, not_read: preview?.not_read ?? [], missing_fields: preview?.missing_fields ?? [], sample: preview?.sample ?? [] });
|
|
7868
|
+
process.stderr.write(`Dry run: nothing written. ${totals.history} rows would be written as history. Run again with --commit to write them.
|
|
7869
|
+
`);
|
|
7870
|
+
return;
|
|
7871
|
+
}
|
|
7872
|
+
const started = [];
|
|
7873
|
+
const notStarted = [];
|
|
7874
|
+
if (opts.startFollowUp && created.size > 0) {
|
|
7875
|
+
const sources = await client.listProviderLeadSources({ provider: "import" });
|
|
7876
|
+
const source = sources.provider_lead_sources.find((s) => s.name === name);
|
|
7877
|
+
if (!source) throw new Error(`lead source ${name} was not found after the import`);
|
|
7878
|
+
for (const lead of created) {
|
|
7879
|
+
try {
|
|
7880
|
+
await client.recordLeadNextAction(source.dataset, lead, { kind: "start", note: `Imported through ${name}` });
|
|
7881
|
+
started.push(lead);
|
|
7882
|
+
} catch (e) {
|
|
7883
|
+
notStarted.push({ lead, error: e instanceof Error ? e.message : String(e) });
|
|
7884
|
+
}
|
|
7885
|
+
}
|
|
7886
|
+
}
|
|
7887
|
+
print({ ...totals, created_leads: [...created], ...opts.startFollowUp ? { follow_up_started: started.length, follow_up_not_started: notStarted } : {} });
|
|
7888
|
+
} catch (e) {
|
|
7889
|
+
fail(e);
|
|
7890
|
+
}
|
|
7891
|
+
});
|
|
7892
|
+
providerLeadSourcesCmd.command("delete").description("Delete a lead source, by --name or by --provider and --account-id. Leads already written stay").option("--name <name>", "a google_sheets, webhook or import source's name").option("--provider <provider>", "ad platform provider", "linkedin_ads").option("--account-id <id>", "numeric provider ad account id").option("--if-updated-at <time>", "delete only the source with this updated_at from list").action(async (opts) => {
|
|
7893
|
+
try {
|
|
7894
|
+
if (opts.name) {
|
|
7895
|
+
print(await new ErdoClient().deleteProviderLeadSource({ name: opts.name, ifUpdatedAt: opts.ifUpdatedAt }));
|
|
7896
|
+
return;
|
|
7897
|
+
}
|
|
7898
|
+
if (!opts.accountId) throw new Error("pass --name, or --provider and --account-id");
|
|
7899
|
+
print(await new ErdoClient().deleteProviderLeadSource({ provider: opts.provider, accountId: opts.accountId, ifUpdatedAt: opts.ifUpdatedAt }));
|
|
7729
7900
|
} catch (e) {
|
|
7730
7901
|
fail(e);
|
|
7731
7902
|
}
|
|
@@ -9039,7 +9210,10 @@ leadNextActionsCmd.command("list").description(
|
|
|
9039
9210
|
).option("--dataset <slug>", "narrow to one lead dataset").option(
|
|
9040
9211
|
"--status <status>",
|
|
9041
9212
|
"queued, pending_approval, executing, executed, approved (a text or call somebody said yes to, not yet carried out), rejected, expired, superseded, failed or recorded"
|
|
9042
|
-
).option("--priority <priority>", "high, medium or low").option("-l, --limit <n>", "maximum suggestions to return (default 50, maximum 200)", (v) => parseInt(v, 10)).option("--offset <n>", "skip that many suggestions, for paging", (v) => parseInt(v, 10)).option(
|
|
9213
|
+
).option("--priority <priority>", "high, medium or low").option("-l, --limit <n>", "maximum suggestions to return (default 50, maximum 200)", (v) => parseInt(v, 10)).option("--offset <n>", "skip that many suggestions, for paging", (v) => parseInt(v, 10)).option(
|
|
9214
|
+
"--waiting-for-start",
|
|
9215
|
+
"with --dataset, list the leads the follow-up engine leaves until somebody starts them, and why"
|
|
9216
|
+
).option("--json", "print the raw JSON result instead of a table").action(
|
|
9043
9217
|
async (opts) => {
|
|
9044
9218
|
try {
|
|
9045
9219
|
const res = await new ErdoClient().listLeadNextActions({
|
|
@@ -9047,12 +9221,25 @@ leadNextActionsCmd.command("list").description(
|
|
|
9047
9221
|
status: opts.status,
|
|
9048
9222
|
priority: opts.priority,
|
|
9049
9223
|
limit: opts.limit,
|
|
9050
|
-
offset: opts.offset
|
|
9224
|
+
offset: opts.offset,
|
|
9225
|
+
waitingForStart: opts.waitingForStart
|
|
9051
9226
|
});
|
|
9052
9227
|
if (opts.json) {
|
|
9053
9228
|
print(res);
|
|
9054
9229
|
return;
|
|
9055
9230
|
}
|
|
9231
|
+
if (opts.waitingForStart) {
|
|
9232
|
+
const waiting = res.waiting_for_start ?? [];
|
|
9233
|
+
if (waiting.length === 0) {
|
|
9234
|
+
console.log("No lead is waiting for somebody to start follow-up.");
|
|
9235
|
+
} else {
|
|
9236
|
+
printAlignedTable(
|
|
9237
|
+
["lead", "reason"],
|
|
9238
|
+
waiting.map((w) => [w.lead_reference, w.reason])
|
|
9239
|
+
);
|
|
9240
|
+
}
|
|
9241
|
+
console.log("");
|
|
9242
|
+
}
|
|
9056
9243
|
const items = res.next_actions ?? [];
|
|
9057
9244
|
if (items.length === 0) {
|
|
9058
9245
|
console.log("No lead next actions match.");
|