@secondlayer/cli 8.3.0 → 8.4.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 CHANGED
@@ -32354,7 +32354,7 @@ var {
32354
32354
  // package.json
32355
32355
  var package_default = {
32356
32356
  name: "@secondlayer/cli",
32357
- version: "8.3.0",
32357
+ version: "8.4.0",
32358
32358
  repository: {
32359
32359
  type: "git",
32360
32360
  url: "git+https://github.com/ryanwaits/secondlayer.git",
@@ -32403,7 +32403,7 @@ var package_default = {
32403
32403
  dependencies: {
32404
32404
  "@inquirer/prompts": "^8.2.0",
32405
32405
  "@secondlayer/bundler": "^0.3.7",
32406
- "@secondlayer/sdk": "^6.0.0",
32406
+ "@secondlayer/sdk": "^6.2.0",
32407
32407
  "@secondlayer/shared": "^6.12.0",
32408
32408
  "@secondlayer/stacks": "^2.3.0",
32409
32409
  "@secondlayer/subgraphs": "^3.5.0",
@@ -35733,7 +35733,7 @@ Stopped watching.`);
35733
35733
  });
35734
35734
  await new Promise(() => {});
35735
35735
  });
35736
- subgraphs.command("deploy <file>").description("Deploy a subgraph definition file").option("--start-block <n>", "Override the subgraph definition startBlock for this deploy").option("--dry-run", "Validate and preview deploy without writing changes").option("-y, --yes", "Skip the reindex confirmation prompt").option("--database-url <url>", "BYO data plane: write the subgraph's schema/rows to your own Postgres. With --dry-run, prints the DDL + grant script and verifies the connection.").option("--strict", "Run `tsc --noEmit` against the handler before deploy (slower; catches TS type errors)").action(async (file, options2) => {
35736
+ subgraphs.command("deploy <file>").alias("update").description("Deploy a subgraph definition file (alias: update — deploy is create-or-update)").option("--start-block <n>", "Override the subgraph definition startBlock for this deploy").option("--dry-run", "Validate and preview deploy without writing changes").option("-y, --yes", "Skip the reindex confirmation prompt").option("--database-url <url>", "BYO data plane: write the subgraph's schema/rows to your own Postgres. With --dry-run, prints the DDL + grant script and verifies the connection.").option("--strict", "Run `tsc --noEmit` against the handler before deploy (slower; catches TS type errors)").action(async (file, options2) => {
35737
35737
  try {
35738
35738
  const absPath = resolve2(file);
35739
35739
  const config = await loadConfig();
@@ -36418,7 +36418,7 @@ function parseHeight(value, name) {
36418
36418
  }
36419
36419
  function registerStreamsCommand(program2) {
36420
36420
  const streams = program2.command("streams").description("Read raw chain events from Streams (requires SL_API_KEY)");
36421
- streams.command("tip").description("Print current canonical tip").action(async () => {
36421
+ streams.command("tip").description("Print current canonical tip").option("--json", "Output as JSON (streams always emits JSON)").action(async () => {
36422
36422
  try {
36423
36423
  const tip = await client().tip();
36424
36424
  writeData(JSON.stringify(tip, null, 2));
@@ -36427,7 +36427,7 @@ function registerStreamsCommand(program2) {
36427
36427
  process.exit(1);
36428
36428
  }
36429
36429
  });
36430
- streams.command("events").description("List events (cursor-paginated; one page per call)").option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")})`).option("--not-types <types>", "comma-separated event types to exclude").option("--contract-id <ids>", "comma-separated contract identifier(s)").option("--sender <addrs>", "comma-separated sender principal(s)").option("--recipient <addrs>", "comma-separated recipient principal(s)").option("--cursor <cursor>", "start cursor (block_height:event_index)").option("--from-block <n>", "filter to blocks >= n").option("--to-block <n>", "filter to blocks <= n").option("--limit <n>", "page size (1-1000, default 100)", "100").addHelpText("after", `
36430
+ streams.command("events").description("List events (cursor-paginated; one page per call)").option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")})`).option("--not-types <types>", "comma-separated event types to exclude").option("--contract-id <ids>", "comma-separated contract identifier(s)").option("--sender <addrs>", "comma-separated sender principal(s)").option("--recipient <addrs>", "comma-separated recipient principal(s)").option("--cursor <cursor>", "start cursor (block_height:event_index)").option("--from-block <n>", "filter to blocks >= n").option("--to-block <n>", "filter to blocks <= n").option("--limit <n>", "page size (1-1000, default 100)", "100").option("--json", "Output as JSON (streams always emits JSON)").addHelpText("after", `
36431
36431
  Examples:
36432
36432
  $ sl streams events --types stx_transfer,print --limit 50
36433
36433
  $ sl streams events --not-types print --contract-id SP00....token,SP01....token
@@ -36486,7 +36486,7 @@ Examples:
36486
36486
  process.exit(1);
36487
36487
  }
36488
36488
  });
36489
- streams.command("reorgs").description("List recent reorgs (cursor-paginated)").requiredOption("--since <cursor>", "start cursor (block_height:event_index)").option("--limit <n>", "page size (default 100)", "100").action(async (options2) => {
36489
+ streams.command("reorgs").description("List recent reorgs (cursor-paginated)").requiredOption("--since <cursor>", "start cursor (block_height:event_index)").option("--limit <n>", "page size (default 100)", "100").option("--json", "Output as JSON (streams always emits JSON)").action(async (options2) => {
36490
36490
  try {
36491
36491
  const envelope = await client().reorgs.list({
36492
36492
  since: options2.since,
@@ -36531,7 +36531,7 @@ Examples:
36531
36531
  process.exit(1);
36532
36532
  }
36533
36533
  });
36534
- streams.command("canonical <height>").description("Canonical block metadata at a given height").action(async (heightArg) => {
36534
+ streams.command("canonical <height>").description("Canonical block metadata at a given height").option("--json", "Output as JSON (streams always emits JSON)").action(async (heightArg) => {
36535
36535
  try {
36536
36536
  const height = parseHeight(heightArg, "<height>");
36537
36537
  if (height === undefined)
@@ -36600,6 +36600,96 @@ Examples:
36600
36600
  }
36601
36601
  });
36602
36602
  }
36603
+ // src/commands/index-api.ts
36604
+ init_output();
36605
+ init_resolve_auth();
36606
+ import { Index } from "@secondlayer/sdk";
36607
+ var DEFAULT_BASE_URL3 = "https://api.secondlayer.tools";
36608
+ function client3() {
36609
+ return new Index({
36610
+ baseUrl: process.env.SL_API_URL ?? DEFAULT_BASE_URL3,
36611
+ apiKey: resolveEnvKey()
36612
+ });
36613
+ }
36614
+ function fail(action, err) {
36615
+ const message = err instanceof Error ? err.message : String(err);
36616
+ error(`Failed to ${action}: ${message}`);
36617
+ if (/\b403\b/.test(message) || /forbidden/i.test(message)) {
36618
+ note("The Index API requires a Build+ tier key (free-tier keys are rejected).");
36619
+ }
36620
+ process.exit(1);
36621
+ }
36622
+ function rangeParams(o) {
36623
+ return {
36624
+ contractId: o.contractId,
36625
+ fromHeight: o.fromHeight ? Number.parseInt(o.fromHeight, 10) : undefined,
36626
+ toHeight: o.toHeight ? Number.parseInt(o.toHeight, 10) : undefined,
36627
+ cursor: o.cursor,
36628
+ limit: o.limit ? Number.parseInt(o.limit, 10) : undefined
36629
+ };
36630
+ }
36631
+ function emit(env, json) {
36632
+ output({
36633
+ json,
36634
+ data: env,
36635
+ human: () => {
36636
+ writeData(JSON.stringify(env, null, 2));
36637
+ if (env.next_cursor)
36638
+ note(`next_cursor: ${env.next_cursor}`);
36639
+ }
36640
+ });
36641
+ }
36642
+ function registerIndexCommand(program2) {
36643
+ const index = program2.command("index").description("Query the decoded Index layer (L2 events + contract calls)");
36644
+ const rangeFlags = (cmd) => cmd.option("--contract-id <id>", "Filter by contract id").option("--from-height <n>", "Start block height (inclusive)").option("--to-height <n>", "End block height (inclusive)").option("--cursor <cursor>", "Resume token from a previous next_cursor").option("--limit <n>", "Rows per page").option("--json", "Print the full envelope as JSON");
36645
+ rangeFlags(index.command("ft-transfers")).description("List decoded SIP-010 fungible-token transfers").option("--sender <principal>", "Filter by sender").option("--recipient <principal>", "Filter by recipient").action(async (o) => {
36646
+ try {
36647
+ emit(await client3().ftTransfers.list({
36648
+ ...rangeParams(o),
36649
+ sender: o.sender,
36650
+ recipient: o.recipient
36651
+ }), o.json);
36652
+ } catch (err) {
36653
+ fail("list ft transfers", err);
36654
+ }
36655
+ });
36656
+ rangeFlags(index.command("nft-transfers")).description("List decoded SIP-009 non-fungible-token transfers").option("--sender <principal>", "Filter by sender").option("--recipient <principal>", "Filter by recipient").option("--asset-identifier <id>", "Filter by asset identifier").action(async (o) => {
36657
+ try {
36658
+ emit(await client3().nftTransfers.list({
36659
+ ...rangeParams(o),
36660
+ sender: o.sender,
36661
+ recipient: o.recipient,
36662
+ assetIdentifier: o.assetIdentifier
36663
+ }), o.json);
36664
+ } catch (err) {
36665
+ fail("list nft transfers", err);
36666
+ }
36667
+ });
36668
+ rangeFlags(index.command("events")).description("List decoded events by type (stx_*, ft/nft mint/burn, print, …)").requiredOption("--event-type <type>", "Decoded event type (required)").option("--sender <principal>", "Filter by sender").option("--recipient <principal>", "Filter by recipient").option("--asset-identifier <id>", "Filter by asset identifier").action(async (o) => {
36669
+ try {
36670
+ emit(await client3().events.list({
36671
+ eventType: o.eventType,
36672
+ ...rangeParams(o),
36673
+ sender: o.sender,
36674
+ recipient: o.recipient,
36675
+ assetIdentifier: o.assetIdentifier
36676
+ }), o.json);
36677
+ } catch (err) {
36678
+ fail("list events", err);
36679
+ }
36680
+ });
36681
+ rangeFlags(index.command("contract-calls")).description("List decoded contract calls (function, args, result)").option("--function-name <name>", "Filter by called function").option("--sender <principal>", "Filter by caller").action(async (o) => {
36682
+ try {
36683
+ emit(await client3().contractCalls.list({
36684
+ ...rangeParams(o),
36685
+ functionName: o.functionName,
36686
+ sender: o.sender
36687
+ }), o.json);
36688
+ } catch (err) {
36689
+ fail("list contract calls", err);
36690
+ }
36691
+ });
36692
+ }
36603
36693
  // src/commands/doctor.ts
36604
36694
  init_config();
36605
36695
 
@@ -38000,6 +38090,40 @@ function registerProjectCommand(program2) {
38000
38090
  }
38001
38091
  });
38002
38092
  });
38093
+ project.command("delete <slug>").alias("rm").description("Delete a project").option("-y, --yes", "Skip confirmation").action(async (slug, options2 = {}) => {
38094
+ if (!options2.yes) {
38095
+ if (!process.stdin.isTTY) {
38096
+ error("Interactive prompt unavailable (stdin is not a TTY). Re-run with -y to skip confirmation.");
38097
+ process.exit(1);
38098
+ }
38099
+ const { confirm: confirm6 } = await import("@inquirer/prompts");
38100
+ let ok = false;
38101
+ try {
38102
+ ok = await confirm6({
38103
+ message: `Delete project "${slug}"? This cannot be undone.`
38104
+ });
38105
+ } catch {
38106
+ error("Interactive prompt unavailable. Re-run with -y to skip confirmation.");
38107
+ process.exit(1);
38108
+ }
38109
+ if (!ok) {
38110
+ info("Cancelled");
38111
+ return;
38112
+ }
38113
+ }
38114
+ try {
38115
+ await httpPlatform(`/api/projects/${encodeURIComponent(slug)}`, {
38116
+ method: "DELETE"
38117
+ });
38118
+ success(`Deleted project "${slug}"`);
38119
+ } catch (err) {
38120
+ if (err instanceof CliHttpError && err.status === 404) {
38121
+ info(`Project "${slug}" not found (already deleted?)`);
38122
+ return;
38123
+ }
38124
+ handleProjectError(err);
38125
+ }
38126
+ });
38003
38127
  }
38004
38128
  function handleProjectError(err) {
38005
38129
  if (err instanceof CliHttpError) {
@@ -38057,6 +38181,7 @@ registerSubgraphsCommand(program);
38057
38181
  registerSubscriptionsCommand(program);
38058
38182
  registerStreamsCommand(program);
38059
38183
  registerDatasetsCommand(program);
38184
+ registerIndexCommand(program);
38060
38185
  program.commandsGroup("Project & codegen:");
38061
38186
  registerProjectCommand(program);
38062
38187
  var configureGenerate = (cmd) => cmd.option("-c, --config <path>", "Path to config file").option("-o, --output <path>", "Output file path (required when using direct files)").option("-k, --api-key <key>", "Stacks node API key for direct RPC URLs").option("-w, --watch", "Watch for changes").action(async (files, options3) => {
@@ -38081,5 +38206,5 @@ program.commandsGroup("Account:");
38081
38206
  registerAccountCommand(program);
38082
38207
  program.parse();
38083
38208
 
38084
- //# debugId=67F4C351C45DEDAA64756E2164756E21
38209
+ //# debugId=11A747050F90401664756E2164756E21
38085
38210
  //# sourceMappingURL=cli.js.map