@helm-ai/cli 0.25.0 → 0.27.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 +70 -5
- 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 = "0.
|
|
28
|
+
var version = "0.27.0";
|
|
29
29
|
|
|
30
30
|
// src/commands/auth.ts
|
|
31
31
|
import prompts from "prompts";
|
|
@@ -446,6 +446,19 @@ var HelmClient = class _HelmClient {
|
|
|
446
446
|
refresh: async (id) => {
|
|
447
447
|
const data = await this.request("refresh_subscription", "POST", { id });
|
|
448
448
|
return data.subscription;
|
|
449
|
+
},
|
|
450
|
+
// Payment links sent for a subscription, while they wait on the customer.
|
|
451
|
+
links: async (filters = {}) => {
|
|
452
|
+
const data = await this.request("list_subscription_checkouts", "GET", filters);
|
|
453
|
+
return data.checkouts ?? [];
|
|
454
|
+
},
|
|
455
|
+
cancelLink: async (id) => {
|
|
456
|
+
const data = await this.request("cancel_subscription_checkout", "POST", { id });
|
|
457
|
+
return data.checkout;
|
|
458
|
+
},
|
|
459
|
+
renewLink: async (id) => {
|
|
460
|
+
const data = await this.request("renew_subscription_checkout", "POST", { id });
|
|
461
|
+
return data;
|
|
449
462
|
}
|
|
450
463
|
};
|
|
451
464
|
estimates = {
|
|
@@ -1867,7 +1880,7 @@ function registerProjectCommands(parent) {
|
|
|
1867
1880
|
return;
|
|
1868
1881
|
}
|
|
1869
1882
|
});
|
|
1870
|
-
cmd.command("create").description("Create a project").requiredOption("-n, --name <name>", "project name (required)").option("-d, --description <text>").option("-a, --account <id>", "link to account ID or name").option("--stage <stage>", "active|
|
|
1883
|
+
cmd.command("create").description("Create a project").requiredOption("-n, --name <name>", "project name (required)").option("-d, --description <text>").option("-a, --account <id>", "link to account ID or name").option("--stage <stage>", "planning|active|on_hold|review|completed|archived", "active").option("--visibility <vis>", "public|private", "private").option("-p, --profile <name>").action(async (opts) => {
|
|
1871
1884
|
try {
|
|
1872
1885
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
1873
1886
|
const project = await client.projects.create({
|
|
@@ -2491,6 +2504,15 @@ function recurring(r) {
|
|
|
2491
2504
|
if (n > 1) return `${base}/${n}${INTERVAL_SHORT[r.billing_interval] ?? r.billing_interval}`;
|
|
2492
2505
|
return `${base}/${INTERVAL_SHORT[r.billing_interval] ?? r.billing_interval}`;
|
|
2493
2506
|
}
|
|
2507
|
+
function printLink(url, expiresAt) {
|
|
2508
|
+
console.log("Send this link to the customer:");
|
|
2509
|
+
console.log(url);
|
|
2510
|
+
console.log(
|
|
2511
|
+
`
|
|
2512
|
+
It shows as awaiting payment until they pay` + (expiresAt ? `, and expires ${new Date(expiresAt).toLocaleString()}.` : ".") + `
|
|
2513
|
+
See waiting links with: helm-ai subscription links`
|
|
2514
|
+
);
|
|
2515
|
+
}
|
|
2494
2516
|
function statusOf(r) {
|
|
2495
2517
|
return r.cancel_at_period_end && r.status !== "canceled" ? `${r.status} (ending)` : r.status;
|
|
2496
2518
|
}
|
|
@@ -2561,9 +2583,7 @@ function registerSubscriptionCommands(parent) {
|
|
|
2561
2583
|
method: opts.checkout ? "checkout" : "auto"
|
|
2562
2584
|
});
|
|
2563
2585
|
if (result.method === "checkout") {
|
|
2564
|
-
|
|
2565
|
-
console.log(result.checkout_url);
|
|
2566
|
-
console.log("\nThe subscription appears in Helm once they complete payment.");
|
|
2586
|
+
printLink(result.checkout_url, result.expires_at);
|
|
2567
2587
|
} else {
|
|
2568
2588
|
console.log(`\u2713 Subscription started (${result.subscription.stripe_subscription_id})`);
|
|
2569
2589
|
}
|
|
@@ -2572,6 +2592,51 @@ function registerSubscriptionCommands(parent) {
|
|
|
2572
2592
|
process.exitCode = 1;
|
|
2573
2593
|
}
|
|
2574
2594
|
});
|
|
2595
|
+
cmd.command("links").alias("pending").description("Payment links sent for a subscription that have not been paid").option("-s, --status <status>", "open|expired|completed|canceled|all (default: open and expired)").option("-c, --contact <id>").option("-a, --account <id>").option("-l, --limit <n>", "max rows", (v) => parseInt(v, 10), 50).option("-o, --output <format>").option("-p, --profile <name>").action(async (opts) => {
|
|
2596
|
+
try {
|
|
2597
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2598
|
+
const rows = await client.subscriptions.links({
|
|
2599
|
+
status: opts.status,
|
|
2600
|
+
contact_id: opts.contact,
|
|
2601
|
+
account_id: opts.account,
|
|
2602
|
+
limit: opts.limit
|
|
2603
|
+
});
|
|
2604
|
+
console.log(render(rows, [
|
|
2605
|
+
{ header: "Status", get: (r) => r.status },
|
|
2606
|
+
// "(removed)" only when the record is gone, not when a name is missing.
|
|
2607
|
+
{ header: "Customer", get: (r) => r.contact_name ?? (r.contact_id ? "" : "(removed)"), truncate: 24 },
|
|
2608
|
+
{ header: "Product", get: (r) => r.product_name ?? (r.product_id ? "" : "(removed)"), truncate: 24 },
|
|
2609
|
+
{ header: "Amount", get: (r) => recurring(r) },
|
|
2610
|
+
{ header: "Sent", get: (r) => r.created_at.slice(0, 10) },
|
|
2611
|
+
{ header: "Expires (UTC)", get: (r) => r.expires_at?.replace("T", " ").slice(0, 16) ?? "" },
|
|
2612
|
+
{ header: "Link", get: (r) => r.checkout_url, truncate: 40 },
|
|
2613
|
+
{ header: "ID", get: (r) => r.id, truncate: 8 }
|
|
2614
|
+
], opts.output ?? defaultFormat()));
|
|
2615
|
+
} catch (err) {
|
|
2616
|
+
console.error(formatErrorForCli(err));
|
|
2617
|
+
process.exitCode = 1;
|
|
2618
|
+
}
|
|
2619
|
+
});
|
|
2620
|
+
cmd.command("cancel-link <id>").description("Withdraw an unpaid payment link so it can no longer be paid").option("-p, --profile <name>").action(async (id, opts) => {
|
|
2621
|
+
try {
|
|
2622
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2623
|
+
await client.subscriptions.cancelLink(id);
|
|
2624
|
+
console.log("\u2713 Link canceled");
|
|
2625
|
+
} catch (err) {
|
|
2626
|
+
console.error(formatErrorForCli(err));
|
|
2627
|
+
process.exitCode = 1;
|
|
2628
|
+
}
|
|
2629
|
+
});
|
|
2630
|
+
cmd.command("resend-link <id>").description("Replace an unpaid or expired payment link with a fresh one on the same terms").option("-p, --profile <name>").action(async (id, opts) => {
|
|
2631
|
+
try {
|
|
2632
|
+
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|
|
2633
|
+
const result = await client.subscriptions.renewLink(id);
|
|
2634
|
+
if (result.method === "checkout") printLink(result.checkout_url, result.expires_at);
|
|
2635
|
+
} catch (err) {
|
|
2636
|
+
console.error(formatErrorForCli(err));
|
|
2637
|
+
process.exitCode = 1;
|
|
2638
|
+
}
|
|
2639
|
+
});
|
|
2575
2640
|
cmd.command("cancel <id>").description("Cancel a subscription (at the end of the current period by default)").option("--now", "end it immediately instead of at the period end").option("-p, --profile <name>").action(async (id, opts) => {
|
|
2576
2641
|
try {
|
|
2577
2642
|
const client = HelmClient.fromProfile(resolveProfile(opts.profile));
|