@secondlayer/cli 5.1.1 → 5.1.3

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.1",
32446
+ version: "5.1.3",
32447
32447
  description: "CLI for subgraphs and blockchain indexing on Stacks",
32448
32448
  type: "module",
32449
32449
  bin: {
@@ -32486,8 +32486,8 @@ var package_default = {
32486
32486
  dependencies: {
32487
32487
  "@inquirer/prompts": "^8.2.0",
32488
32488
  "@secondlayer/bundler": "^0.3.5",
32489
- "@secondlayer/sdk": "^3.3.2",
32490
- "@secondlayer/shared": "^6.3.1",
32489
+ "@secondlayer/sdk": "^3.5.4",
32490
+ "@secondlayer/shared": "^6.3.2",
32491
32491
  "@secondlayer/stacks": "^2.2.0",
32492
32492
  "@secondlayer/subgraphs": "^2.0.0",
32493
32493
  "@biomejs/js-api": "^0.7.0",
@@ -32551,7 +32551,7 @@ function withErrorHandling(fn, options) {
32551
32551
  }
32552
32552
  async function getTenantClient() {
32553
32553
  const { apiUrl, ephemeralKey } = await resolveActiveTenant();
32554
- return new SecondLayer({ baseUrl: apiUrl, apiKey: ephemeralKey });
32554
+ return new SecondLayer({ tenantBaseUrl: apiUrl, apiKey: ephemeralKey });
32555
32555
  }
32556
32556
  async function listSubgraphsApi() {
32557
32557
  return (await getTenantClient()).subgraphs.list();
@@ -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
 
@@ -37308,7 +37367,8 @@ registerDoctorCommand(program);
37308
37367
  registerConfigCommand(program);
37309
37368
  registerLocalCommand(program);
37310
37369
  registerAccountCommand(program);
37370
+ registerBillingCommand(program);
37311
37371
  program.parse();
37312
37372
 
37313
- //# debugId=7C4F9780AD65C38D64756E2164756E21
37373
+ //# debugId=F71B99A68FBF0A4E64756E2164756E21
37314
37374
  //# sourceMappingURL=cli.js.map