@secondlayer/cli 5.1.0 → 5.1.2

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 CHANGED
@@ -32443,7 +32443,7 @@ var {
32443
32443
  // package.json
32444
32444
  var package_default = {
32445
32445
  name: "@secondlayer/cli",
32446
- version: "5.1.0",
32446
+ version: "5.1.2",
32447
32447
  description: "CLI for subgraphs and blockchain indexing on Stacks",
32448
32448
  type: "module",
32449
32449
  bin: {
@@ -32640,6 +32640,65 @@ function registerAccountCommand(program2) {
32640
32640
  ]));
32641
32641
  }, { action: "manage profile" }));
32642
32642
  }
32643
+ // src/commands/billing.ts
32644
+ init_http();
32645
+ init_output();
32646
+ function registerBillingCommand(program2) {
32647
+ const billing = program2.command("billing").description("Inspect billing state");
32648
+ billing.command("status").description("Show your current plan, Stripe subscription, trial, and discounts").action(async () => {
32649
+ let res;
32650
+ try {
32651
+ res = await httpPlatform("/api/billing/status");
32652
+ } catch (err) {
32653
+ if (err instanceof CliHttpError) {
32654
+ error(err.message);
32655
+ process.exit(1);
32656
+ }
32657
+ throw err;
32658
+ }
32659
+ const rows = [];
32660
+ rows.push(["Plan", res.plan]);
32661
+ rows.push([
32662
+ "Customer",
32663
+ res.stripeCustomerId ?? dim("(none — no subscription yet)")
32664
+ ]);
32665
+ if (!res.subscription) {
32666
+ rows.push(["Subscription", dim("(none)")]);
32667
+ console.log(formatKeyValue(rows));
32668
+ return;
32669
+ }
32670
+ const sub = res.subscription;
32671
+ rows.push(["Subscription", `${sub.id} (${sub.status})`]);
32672
+ if (sub.tier)
32673
+ rows.push(["Tier", sub.tier]);
32674
+ if (sub.amountCents !== null && sub.interval) {
32675
+ const dollars = (sub.amountCents / 100).toFixed(2);
32676
+ rows.push(["Price", `$${dollars} / ${sub.interval}`]);
32677
+ }
32678
+ if (sub.trialEnd) {
32679
+ const days = Math.max(0, Math.round((new Date(sub.trialEnd).getTime() - Date.now()) / 86400000));
32680
+ rows.push([
32681
+ "Trial ends",
32682
+ `${formatDate(sub.trialEnd)} (${days}d remaining)`
32683
+ ]);
32684
+ }
32685
+ if (sub.currentPeriodEnd) {
32686
+ rows.push(["Renews", formatDate(sub.currentPeriodEnd)]);
32687
+ }
32688
+ if (sub.cancelAtPeriodEnd) {
32689
+ rows.push(["Cancels at period end", "yes"]);
32690
+ }
32691
+ if (sub.discount) {
32692
+ const off = sub.discount.percentOff !== null ? `${sub.discount.percentOff}% off` : sub.discount.amountOff !== null ? `$${(sub.discount.amountOff / 100).toFixed(2)} off` : "discount";
32693
+ const label = sub.discount.code ? `${sub.discount.code} (${sub.discount.name ?? "coupon"})` : sub.discount.name ?? "applied";
32694
+ rows.push(["Discount", `${label} — ${off}, ${sub.discount.duration}`]);
32695
+ }
32696
+ console.log(formatKeyValue(rows));
32697
+ });
32698
+ }
32699
+ function formatDate(iso) {
32700
+ return new Date(iso).toISOString().slice(0, 10);
32701
+ }
32643
32702
  // src/commands/config.ts
32644
32703
  init_config();
32645
32704
 
@@ -34631,18 +34690,42 @@ var SUBGRAPH_TEMPLATE_DESCRIPTIONS = {
34631
34690
  "bns-names": "BNS-V2 name ownership and lifecycle"
34632
34691
  };
34633
34692
  function generateSubgraphTemplate(name, slug = "basic") {
34634
- switch (slug) {
34635
- case "sip-010-balances":
34636
- return sip010Balances(name);
34637
- case "sbtc-flows":
34638
- return sbtcFlows(name);
34639
- case "pox-stacking":
34640
- return poxStacking(name);
34641
- case "bns-names":
34642
- return bnsNames(name);
34643
- default:
34644
- return basic(name);
34645
- }
34693
+ const body = (() => {
34694
+ switch (slug) {
34695
+ case "sip-010-balances":
34696
+ return sip010Balances(name);
34697
+ case "sbtc-flows":
34698
+ return sbtcFlows(name);
34699
+ case "pox-stacking":
34700
+ return poxStacking(name);
34701
+ case "bns-names":
34702
+ return bnsNames(name);
34703
+ default:
34704
+ return basic(name);
34705
+ }
34706
+ })();
34707
+ return `${nextStepsHeader(name)}
34708
+ ${body}`;
34709
+ }
34710
+ function nextStepsHeader(name) {
34711
+ return `// ───────────────────────────────────────────────────────────────────
34712
+ // What to do next
34713
+ //
34714
+ // 1. Edit the source filter + schema below to match what you want to track.
34715
+ // 2. Edit the handler at the bottom — it runs once per matching event.
34716
+ // 3. Deploy: sl subgraphs deploy ${name}.ts
34717
+ // (You'll be prompted to log in if this is your first remote deploy.)
34718
+ // 4. Wait for sync: sl subgraphs status ${name}
34719
+ // Mainnet backfill from genesis can take an hour or more depending on
34720
+ // your filter scope. Use --start-block to skip ahead.
34721
+ // 5. Query: sl subgraphs query ${name} <table-name>
34722
+ // Or hit the auto-generated REST endpoint listed in the deploy output.
34723
+ //
34724
+ // Bind a typed Subscription to any table you write here — see
34725
+ // https://www.secondlayer.tools/docs/subscriptions
34726
+ // ───────────────────────────────────────────────────────────────────
34727
+
34728
+ `;
34646
34729
  }
34647
34730
  function basic(name) {
34648
34731
  return `import { defineSubgraph } from "@secondlayer/subgraphs";
@@ -37284,7 +37367,8 @@ registerDoctorCommand(program);
37284
37367
  registerConfigCommand(program);
37285
37368
  registerLocalCommand(program);
37286
37369
  registerAccountCommand(program);
37370
+ registerBillingCommand(program);
37287
37371
  program.parse();
37288
37372
 
37289
- //# debugId=CEAA7239644824A064756E2164756E21
37373
+ //# debugId=7CC6836B298FCA6D64756E2164756E21
37290
37374
  //# sourceMappingURL=cli.js.map