@helm-ai/cli 1.5.0 → 1.6.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/dist/cli.js +183 -24
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -25,7 +25,7 @@ function renderSplash(ctx) {
|
|
|
25
25
|
}
|
|
26
26
|
|
|
27
27
|
// src/version.ts
|
|
28
|
-
var version = "1.
|
|
28
|
+
var version = "1.6.0";
|
|
29
29
|
|
|
30
30
|
// src/commands/auth.ts
|
|
31
31
|
import prompts from "prompts";
|
|
@@ -905,6 +905,26 @@ var HelmClient = class _HelmClient {
|
|
|
905
905
|
const data = await this.request("create_sequence_email", "POST", { sequence_id: sequenceId, ...input });
|
|
906
906
|
return data.step;
|
|
907
907
|
},
|
|
908
|
+
update: async (sequenceId, updates) => {
|
|
909
|
+
const data = await this.request("update_email_sequence", "POST", { sequence_id: sequenceId, ...updates });
|
|
910
|
+
return data.sequence;
|
|
911
|
+
},
|
|
912
|
+
delete: async (sequenceId) => {
|
|
913
|
+
const data = await this.request("delete_email_sequence", "POST", { sequence_id: sequenceId });
|
|
914
|
+
return data;
|
|
915
|
+
},
|
|
916
|
+
updateEmail: async (sequenceId, emailId, updates) => {
|
|
917
|
+
const data = await this.request("update_sequence_email", "POST", { id: emailId, sequence_id: sequenceId, ...updates });
|
|
918
|
+
return data.step;
|
|
919
|
+
},
|
|
920
|
+
removeEmail: async (sequenceId, emailId) => {
|
|
921
|
+
const data = await this.request("delete_sequence_email", "POST", { id: emailId, sequence_id: sequenceId });
|
|
922
|
+
return data;
|
|
923
|
+
},
|
|
924
|
+
reorderEmails: async (sequenceId, orderedEmailIds) => {
|
|
925
|
+
const data = await this.request("reorder_sequence_emails", "POST", { sequence_id: sequenceId, ordered_step_ids: orderedEmailIds });
|
|
926
|
+
return data;
|
|
927
|
+
},
|
|
908
928
|
enrollments: async (sequenceId, filters = {}) => {
|
|
909
929
|
const data = await this.request("list_sequence_enrollments", "GET", { sequence_id: sequenceId, ...filters });
|
|
910
930
|
return data.enrollments ?? [];
|
|
@@ -1774,13 +1794,13 @@ function registerDealCommands(parent) {
|
|
|
1774
1794
|
process.exitCode = 1;
|
|
1775
1795
|
return;
|
|
1776
1796
|
}
|
|
1777
|
-
const { confirmed } = await prompts2({
|
|
1797
|
+
const { confirmed: confirmed2 } = await prompts2({
|
|
1778
1798
|
type: "confirm",
|
|
1779
1799
|
name: "confirmed",
|
|
1780
1800
|
message: `Delete deal ${id}? This cannot be undone.`,
|
|
1781
1801
|
initial: false
|
|
1782
1802
|
});
|
|
1783
|
-
if (!
|
|
1803
|
+
if (!confirmed2) {
|
|
1784
1804
|
console.log("Aborted.");
|
|
1785
1805
|
return;
|
|
1786
1806
|
}
|
|
@@ -1868,13 +1888,13 @@ function registerPipelineCommands(parent) {
|
|
|
1868
1888
|
process.exitCode = 1;
|
|
1869
1889
|
return;
|
|
1870
1890
|
}
|
|
1871
|
-
const { confirmed } = await prompts3({
|
|
1891
|
+
const { confirmed: confirmed2 } = await prompts3({
|
|
1872
1892
|
type: "confirm",
|
|
1873
1893
|
name: "confirmed",
|
|
1874
1894
|
message: `Delete pipeline ${id}? This cannot be undone.`,
|
|
1875
1895
|
initial: false
|
|
1876
1896
|
});
|
|
1877
|
-
if (!
|
|
1897
|
+
if (!confirmed2) {
|
|
1878
1898
|
console.log("Aborted.");
|
|
1879
1899
|
return;
|
|
1880
1900
|
}
|
|
@@ -1935,13 +1955,13 @@ function registerPipelineCommands(parent) {
|
|
|
1935
1955
|
process.exitCode = 1;
|
|
1936
1956
|
return;
|
|
1937
1957
|
}
|
|
1938
|
-
const { confirmed } = await prompts3({
|
|
1958
|
+
const { confirmed: confirmed2 } = await prompts3({
|
|
1939
1959
|
type: "confirm",
|
|
1940
1960
|
name: "confirmed",
|
|
1941
1961
|
message: `Delete stage ${stageId}?`,
|
|
1942
1962
|
initial: false
|
|
1943
1963
|
});
|
|
1944
|
-
if (!
|
|
1964
|
+
if (!confirmed2) {
|
|
1945
1965
|
console.log("Aborted.");
|
|
1946
1966
|
return;
|
|
1947
1967
|
}
|
|
@@ -2453,13 +2473,13 @@ Refusing to void without confirmation in a non-interactive shell. Re-run with -y
|
|
|
2453
2473
|
process.exitCode = 1;
|
|
2454
2474
|
return;
|
|
2455
2475
|
}
|
|
2456
|
-
const { confirmed } = await prompts4({
|
|
2476
|
+
const { confirmed: confirmed2 } = await prompts4({
|
|
2457
2477
|
type: "confirm",
|
|
2458
2478
|
name: "confirmed",
|
|
2459
2479
|
message: `${check.impact} Void these hours?`,
|
|
2460
2480
|
initial: false
|
|
2461
2481
|
});
|
|
2462
|
-
if (!
|
|
2482
|
+
if (!confirmed2) {
|
|
2463
2483
|
console.log("Aborted.");
|
|
2464
2484
|
return;
|
|
2465
2485
|
}
|
|
@@ -4592,8 +4612,8 @@ async function readJsonSource(path) {
|
|
|
4592
4612
|
for await (const chunk of process.stdin) chunks.push(chunk);
|
|
4593
4613
|
raw = Buffer.concat(chunks).toString("utf8");
|
|
4594
4614
|
} else {
|
|
4595
|
-
const { readFileSync:
|
|
4596
|
-
raw =
|
|
4615
|
+
const { readFileSync: readFileSync7 } = await import("fs");
|
|
4616
|
+
raw = readFileSync7(path, "utf8");
|
|
4597
4617
|
}
|
|
4598
4618
|
try {
|
|
4599
4619
|
return JSON.parse(raw);
|
|
@@ -4688,8 +4708,8 @@ function registerWorkflowCommands(parent) {
|
|
|
4688
4708
|
try {
|
|
4689
4709
|
let triggerData;
|
|
4690
4710
|
if (opts.dataFile) {
|
|
4691
|
-
const { readFileSync:
|
|
4692
|
-
triggerData = JSON.parse(
|
|
4711
|
+
const { readFileSync: readFileSync7 } = await import("fs");
|
|
4712
|
+
triggerData = JSON.parse(readFileSync7(opts.dataFile, "utf8"));
|
|
4693
4713
|
} else if (opts.data) {
|
|
4694
4714
|
triggerData = JSON.parse(opts.data);
|
|
4695
4715
|
}
|
|
@@ -4755,10 +4775,47 @@ function registerWorkflowCommands(parent) {
|
|
|
4755
4775
|
}
|
|
4756
4776
|
|
|
4757
4777
|
// src/commands/sequence.ts
|
|
4778
|
+
import { readFileSync as readFileSync5 } from "fs";
|
|
4779
|
+
import prompts5 from "prompts";
|
|
4758
4780
|
import { stringify as yamlStringify2 } from "yaml";
|
|
4759
4781
|
var collect2 = (value, prev) => prev.concat([value]);
|
|
4782
|
+
var UNITS = ["minutes", "hours", "days"];
|
|
4783
|
+
function readBodies(opts) {
|
|
4784
|
+
if (opts.text !== void 0 && opts.textFile) throw new Error("Use --text or --text-file, not both.");
|
|
4785
|
+
if (opts.html !== void 0 && opts.htmlFile) throw new Error("Use --html or --html-file, not both.");
|
|
4786
|
+
if (opts.textFile === "-" && opts.htmlFile === "-") throw new Error("Only one of --text-file and --html-file can read stdin (-).");
|
|
4787
|
+
const read = (path) => readFileSync5(path === "-" ? 0 : path, "utf8");
|
|
4788
|
+
return {
|
|
4789
|
+
text: opts.textFile ? read(opts.textFile) : opts.text,
|
|
4790
|
+
html: opts.htmlFile ? read(opts.htmlFile) : opts.html
|
|
4791
|
+
};
|
|
4792
|
+
}
|
|
4793
|
+
function parseDelay(delay, unit) {
|
|
4794
|
+
const out = {};
|
|
4795
|
+
if (delay !== void 0) {
|
|
4796
|
+
const n = Number(delay);
|
|
4797
|
+
if (!Number.isInteger(n) || n < 0) throw new Error("--delay must be a whole number of 0 or more.");
|
|
4798
|
+
out.delay_value = n;
|
|
4799
|
+
}
|
|
4800
|
+
if (unit !== void 0) {
|
|
4801
|
+
if (!UNITS.includes(unit)) throw new Error("--unit must be minutes, hours or days.");
|
|
4802
|
+
out.delay_unit = unit;
|
|
4803
|
+
}
|
|
4804
|
+
return out;
|
|
4805
|
+
}
|
|
4806
|
+
async function confirmed(message, yes) {
|
|
4807
|
+
if (yes) return true;
|
|
4808
|
+
if (!process.stdin.isTTY) {
|
|
4809
|
+
console.error("Refusing without confirmation in a non-interactive shell. Re-run with -y/--yes.");
|
|
4810
|
+
process.exitCode = 1;
|
|
4811
|
+
return false;
|
|
4812
|
+
}
|
|
4813
|
+
const { ok } = await prompts5({ type: "confirm", name: "ok", message, initial: false });
|
|
4814
|
+
if (!ok) console.log("Aborted.");
|
|
4815
|
+
return !!ok;
|
|
4816
|
+
}
|
|
4760
4817
|
function registerSequenceCommands(parent) {
|
|
4761
|
-
const cmd = parent.command("sequence").alias("sequences").description("Operate email sequences (read, enroll, lifecycle)");
|
|
4818
|
+
const cmd = parent.command("sequence").alias("sequences").description("Operate email sequences (read, build, edit, enroll, lifecycle)");
|
|
4762
4819
|
cmd.command("list").description("List email sequences").option("--status <status>", "draft|live|paused|archived").option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
4763
4820
|
try {
|
|
4764
4821
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
@@ -4863,20 +4920,22 @@ Next: add emails with
|
|
|
4863
4920
|
return;
|
|
4864
4921
|
}
|
|
4865
4922
|
});
|
|
4866
|
-
cmd.command("add-email <id>").description("Add an email to a sequence (appends to the end)").requiredOption("--subject <subject>", "email subject line").option("--text <body>", "plain-text body (provide
|
|
4923
|
+
cmd.command("add-email <id>").description("Add an email to a sequence (appends to the end)").requiredOption("--subject <subject>", "email subject line").option("--text <body>", "plain-text body (provide a text and/or HTML body)").option("--html <body>", "HTML body (provide a text and/or HTML body)").option("--text-file <path>", "read the plain-text body from a file (- for stdin)").option("--html-file <path>", "read the HTML body from a file (- for stdin)").requiredOption("--delay <n>", "wait before this email, with --unit (0 = on enrollment)").option("--unit <unit>", "minutes|hours|days", "days").option("--position <n>", "1-based insert position (omit to append)").option("-p, --profile <name>").action(async (id, opts) => {
|
|
4867
4924
|
try {
|
|
4868
|
-
|
|
4869
|
-
|
|
4925
|
+
const { text, html } = readBodies(opts);
|
|
4926
|
+
if (!text && !html) {
|
|
4927
|
+
console.error("Provide a body with --text/--text-file and/or --html/--html-file.");
|
|
4870
4928
|
process.exitCode = 1;
|
|
4871
4929
|
return;
|
|
4872
4930
|
}
|
|
4931
|
+
const delay = parseDelay(opts.delay, opts.unit);
|
|
4873
4932
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
4874
4933
|
const step = await client.sequences.addEmail(id, {
|
|
4875
4934
|
subject: opts.subject,
|
|
4876
|
-
text_body:
|
|
4877
|
-
html_body:
|
|
4878
|
-
delay_value:
|
|
4879
|
-
delay_unit:
|
|
4935
|
+
text_body: text,
|
|
4936
|
+
html_body: html,
|
|
4937
|
+
delay_value: delay.delay_value ?? 0,
|
|
4938
|
+
delay_unit: delay.delay_unit ?? "days",
|
|
4880
4939
|
position: opts.position != null ? Number(opts.position) : void 0
|
|
4881
4940
|
});
|
|
4882
4941
|
console.log(`\u2713 Added email #${step.position}: "${step.subject}" (after ${step.delay_value ?? 0} ${step.delay_unit ?? opts.unit})`);
|
|
@@ -4886,6 +4945,106 @@ Next: add emails with
|
|
|
4886
4945
|
return;
|
|
4887
4946
|
}
|
|
4888
4947
|
});
|
|
4948
|
+
cmd.command("emails <id>").description("List a sequence's emails in order, with the IDs the edit commands take").option("-o, --output <format>").option("-p, --profile <name>").action(async (id, opts) => {
|
|
4949
|
+
try {
|
|
4950
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
4951
|
+
const { steps } = await client.sequences.get(id);
|
|
4952
|
+
const rows = [...steps ?? []].sort((a, b) => a.position - b.position);
|
|
4953
|
+
console.log(render(rows, [
|
|
4954
|
+
{ header: "#", get: (r) => String(r.position) },
|
|
4955
|
+
{ header: "Subject", get: (r) => r.subject },
|
|
4956
|
+
{ header: "Wait", get: (r) => `${r.delay_value ?? 0} ${r.delay_unit ?? "days"}` },
|
|
4957
|
+
{ header: "ID", get: (r) => r.id }
|
|
4958
|
+
], opts.output ?? defaultFormat()));
|
|
4959
|
+
} catch (err) {
|
|
4960
|
+
console.error(formatErrorForCli(err));
|
|
4961
|
+
process.exitCode = 1;
|
|
4962
|
+
return;
|
|
4963
|
+
}
|
|
4964
|
+
});
|
|
4965
|
+
cmd.command("update-email <id> <emailId>").description("Edit an email in a sequence (only the options you pass change)").option("--subject <subject>", "new subject line").option("--text <body>", "new plain-text body").option("--html <body>", "new HTML body").option("--text-file <path>", "read the new plain-text body from a file (- for stdin)").option("--html-file <path>", "read the new HTML body from a file (- for stdin)").option("--delay <n>", "new wait before this email").option("--unit <unit>", "minutes|hours|days").option("-p, --profile <name>").action(async (id, emailId, opts) => {
|
|
4966
|
+
try {
|
|
4967
|
+
const { text, html } = readBodies(opts);
|
|
4968
|
+
const delay = parseDelay(opts.delay, opts.unit);
|
|
4969
|
+
const updates = {
|
|
4970
|
+
...opts.subject !== void 0 ? { subject: opts.subject } : {},
|
|
4971
|
+
...text !== void 0 ? { text_body: text } : {},
|
|
4972
|
+
...html !== void 0 ? { html_body: html } : {},
|
|
4973
|
+
...delay
|
|
4974
|
+
};
|
|
4975
|
+
if (Object.keys(updates).length === 0) {
|
|
4976
|
+
console.error("Nothing to change. Pass --subject, a body, --delay or --unit.");
|
|
4977
|
+
process.exitCode = 1;
|
|
4978
|
+
return;
|
|
4979
|
+
}
|
|
4980
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
4981
|
+
const step = await client.sequences.updateEmail(id, emailId, updates);
|
|
4982
|
+
console.log(`\u2713 Updated email #${step.position}: "${step.subject}" (after ${step.delay_value ?? 0} ${step.delay_unit ?? "days"})`);
|
|
4983
|
+
} catch (err) {
|
|
4984
|
+
console.error(formatErrorForCli(err));
|
|
4985
|
+
process.exitCode = 1;
|
|
4986
|
+
return;
|
|
4987
|
+
}
|
|
4988
|
+
});
|
|
4989
|
+
cmd.command("remove-email <id> <emailId>").description("Remove an email from a sequence (the rest close up the gap)").option("-y, --yes", "skip confirmation").option("-p, --profile <name>").action(async (id, emailId, opts) => {
|
|
4990
|
+
try {
|
|
4991
|
+
if (!await confirmed(`Remove email ${emailId} from the sequence? This cannot be undone.`, opts.yes)) return;
|
|
4992
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
4993
|
+
await client.sequences.removeEmail(id, emailId);
|
|
4994
|
+
console.log(`\u2713 Removed email ${emailId}`);
|
|
4995
|
+
} catch (err) {
|
|
4996
|
+
console.error(formatErrorForCli(err));
|
|
4997
|
+
process.exitCode = 1;
|
|
4998
|
+
return;
|
|
4999
|
+
}
|
|
5000
|
+
});
|
|
5001
|
+
cmd.command("reorder <id> <emailIds...>").description("Set the order of a sequence's emails (list every email ID, first to last)").option("-p, --profile <name>").action(async (id, emailIds, opts) => {
|
|
5002
|
+
try {
|
|
5003
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
5004
|
+
await client.sequences.reorderEmails(id, emailIds);
|
|
5005
|
+
console.log(`\u2713 Reordered ${emailIds.length} emails`);
|
|
5006
|
+
} catch (err) {
|
|
5007
|
+
console.error(formatErrorForCli(err));
|
|
5008
|
+
process.exitCode = 1;
|
|
5009
|
+
return;
|
|
5010
|
+
}
|
|
5011
|
+
});
|
|
5012
|
+
cmd.command("update <id>").description("Change a sequence's settings (only the options you pass change)").option("-n, --name <name>", "new name").option("--description <text>", "new description").option("--sender <id>", "sender identity UUID").option("--exit-on-reply", "stop sending when a contact replies").option("--no-exit-on-reply", "keep sending after a contact replies").option("--exit-on-bounce", "stop sending after a bounce").option("--no-exit-on-bounce", "keep sending after a bounce").option("--transactional", "billing/account mail: still sends to marketing unsubscribes, no unsubscribe footer").option("--no-transactional", "marketing mail: honors unsubscribes, adds the unsubscribe footer").option("-p, --profile <name>").action(async (id, opts) => {
|
|
5013
|
+
try {
|
|
5014
|
+
const updates = Object.fromEntries(Object.entries({
|
|
5015
|
+
name: opts.name,
|
|
5016
|
+
description: opts.description,
|
|
5017
|
+
sender_identity_id: opts.sender,
|
|
5018
|
+
exit_on_reply: opts.exitOnReply,
|
|
5019
|
+
exit_on_bounce: opts.exitOnBounce,
|
|
5020
|
+
is_transactional: opts.transactional
|
|
5021
|
+
}).filter(([, v]) => v !== void 0));
|
|
5022
|
+
if (Object.keys(updates).length === 0) {
|
|
5023
|
+
console.error("Nothing to change. Pass at least one option (see --help).");
|
|
5024
|
+
process.exitCode = 1;
|
|
5025
|
+
return;
|
|
5026
|
+
}
|
|
5027
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
5028
|
+
const seq = await client.sequences.update(id, updates);
|
|
5029
|
+
console.log(`\u2713 Updated sequence "${seq.name ?? id}"`);
|
|
5030
|
+
} catch (err) {
|
|
5031
|
+
console.error(formatErrorForCli(err));
|
|
5032
|
+
process.exitCode = 1;
|
|
5033
|
+
return;
|
|
5034
|
+
}
|
|
5035
|
+
});
|
|
5036
|
+
cmd.command("delete <id>").description("Permanently delete a sequence, its emails and its enrollments").option("-y, --yes", "skip confirmation").option("-p, --profile <name>").action(async (id, opts) => {
|
|
5037
|
+
try {
|
|
5038
|
+
if (!await confirmed(`Delete sequence ${id}, its emails and enrollments? This cannot be undone. (archive keeps them)`, opts.yes)) return;
|
|
5039
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
5040
|
+
await client.sequences.delete(id);
|
|
5041
|
+
console.log(`\u2713 Deleted sequence ${id}`);
|
|
5042
|
+
} catch (err) {
|
|
5043
|
+
console.error(formatErrorForCli(err));
|
|
5044
|
+
process.exitCode = 1;
|
|
5045
|
+
return;
|
|
5046
|
+
}
|
|
5047
|
+
});
|
|
4889
5048
|
const setStatus = (verb, status, desc) => {
|
|
4890
5049
|
cmd.command(`${verb} <id>`).description(desc).option("-p, --profile <name>").action(async (id, opts) => {
|
|
4891
5050
|
try {
|
|
@@ -4924,7 +5083,7 @@ Next: add emails with
|
|
|
4924
5083
|
}
|
|
4925
5084
|
|
|
4926
5085
|
// src/commands/email.ts
|
|
4927
|
-
import { readFileSync as
|
|
5086
|
+
import { readFileSync as readFileSync6 } from "fs";
|
|
4928
5087
|
function registerEmailCommands(parent) {
|
|
4929
5088
|
const cmd = parent.command("email").description("Draft and revise email from your own address");
|
|
4930
5089
|
cmd.command("identities").alias("addresses").description("List the addresses you can send from").option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
@@ -4956,7 +5115,7 @@ function registerEmailCommands(parent) {
|
|
|
4956
5115
|
const splitAddrs = (v) => (v ?? "").split(",").map((s) => s.trim()).filter(Boolean);
|
|
4957
5116
|
let body = opts.body;
|
|
4958
5117
|
if (opts.bodyFile) {
|
|
4959
|
-
body =
|
|
5118
|
+
body = readFileSync6(opts.bodyFile === "-" ? 0 : opts.bodyFile, "utf8");
|
|
4960
5119
|
}
|
|
4961
5120
|
if (!body && !opts.html) {
|
|
4962
5121
|
throw new Error("--body, --body-file, or --html is required");
|
|
@@ -5017,7 +5176,7 @@ function registerEmailCommands(parent) {
|
|
|
5017
5176
|
const splitAddrs = (v) => v.split(",").map((s) => s.trim()).filter(Boolean);
|
|
5018
5177
|
let body = opts.body;
|
|
5019
5178
|
if (opts.bodyFile) {
|
|
5020
|
-
body =
|
|
5179
|
+
body = readFileSync6(opts.bodyFile === "-" ? 0 : opts.bodyFile, "utf8");
|
|
5021
5180
|
}
|
|
5022
5181
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
5023
5182
|
const draft = await client.email.updateDraft({
|