@secondlayer/cli 8.2.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 +157 -18
- package/dist/cli.js.map +8 -7
- package/package.json +3 -3
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.
|
|
32357
|
+
version: "8.4.0",
|
|
32358
32358
|
repository: {
|
|
32359
32359
|
type: "git",
|
|
32360
32360
|
url: "git+https://github.com/ryanwaits/secondlayer.git",
|
|
@@ -32403,8 +32403,8 @@ var package_default = {
|
|
|
32403
32403
|
dependencies: {
|
|
32404
32404
|
"@inquirer/prompts": "^8.2.0",
|
|
32405
32405
|
"@secondlayer/bundler": "^0.3.7",
|
|
32406
|
-
"@secondlayer/sdk": "^
|
|
32407
|
-
"@secondlayer/shared": "^6.
|
|
32406
|
+
"@secondlayer/sdk": "^6.2.0",
|
|
32407
|
+
"@secondlayer/shared": "^6.12.0",
|
|
32408
32408
|
"@secondlayer/stacks": "^2.3.0",
|
|
32409
32409
|
"@secondlayer/subgraphs": "^3.5.0",
|
|
32410
32410
|
"@biomejs/js-api": "^0.7.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();
|
|
@@ -36379,17 +36379,25 @@ function dumpsClient(dumpsUrl) {
|
|
|
36379
36379
|
dumpsBaseUrl
|
|
36380
36380
|
});
|
|
36381
36381
|
}
|
|
36382
|
-
function parseTypes(value) {
|
|
36382
|
+
function parseTypes(value, flag = "--types") {
|
|
36383
36383
|
if (!value)
|
|
36384
36384
|
return;
|
|
36385
36385
|
const parts = value.split(",").map((s) => s.trim());
|
|
36386
36386
|
for (const p of parts) {
|
|
36387
36387
|
if (!VALID_TYPES.includes(p)) {
|
|
36388
|
-
throw new Error(`invalid
|
|
36388
|
+
throw new Error(`invalid ${flag} value "${p}"; expected one of: ${VALID_TYPES.join(", ")}`);
|
|
36389
36389
|
}
|
|
36390
36390
|
}
|
|
36391
36391
|
return parts;
|
|
36392
36392
|
}
|
|
36393
|
+
function parseList(value) {
|
|
36394
|
+
if (value === undefined)
|
|
36395
|
+
return;
|
|
36396
|
+
const parts = value.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
36397
|
+
if (parts.length === 0)
|
|
36398
|
+
return;
|
|
36399
|
+
return parts.length === 1 ? parts[0] : parts;
|
|
36400
|
+
}
|
|
36393
36401
|
function parseLimit(value) {
|
|
36394
36402
|
if (value === undefined)
|
|
36395
36403
|
return;
|
|
@@ -36410,7 +36418,7 @@ function parseHeight(value, name) {
|
|
|
36410
36418
|
}
|
|
36411
36419
|
function registerStreamsCommand(program2) {
|
|
36412
36420
|
const streams = program2.command("streams").description("Read raw chain events from Streams (requires SL_API_KEY)");
|
|
36413
|
-
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 () => {
|
|
36414
36422
|
try {
|
|
36415
36423
|
const tip = await client().tip();
|
|
36416
36424
|
writeData(JSON.stringify(tip, null, 2));
|
|
@@ -36419,15 +36427,19 @@ function registerStreamsCommand(program2) {
|
|
|
36419
36427
|
process.exit(1);
|
|
36420
36428
|
}
|
|
36421
36429
|
});
|
|
36422
|
-
streams.command("events").description("List events (cursor-paginated; one page per call)").option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")})`).option("--
|
|
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", `
|
|
36423
36431
|
Examples:
|
|
36424
36432
|
$ sl streams events --types stx_transfer,print --limit 50
|
|
36425
|
-
$ sl streams events --contract-id SP00....token
|
|
36433
|
+
$ sl streams events --not-types print --contract-id SP00....token,SP01....token
|
|
36434
|
+
$ sl streams events --sender SP1...,SP2... --from-block 150000 --to-block 160000
|
|
36426
36435
|
$ sl streams events --cursor 150000:3`).action(async (options2) => {
|
|
36427
36436
|
try {
|
|
36428
36437
|
const envelope = await client().events.list({
|
|
36429
36438
|
types: parseTypes(options2.types),
|
|
36430
|
-
|
|
36439
|
+
notTypes: parseTypes(options2.notTypes, "--not-types"),
|
|
36440
|
+
contractId: parseList(options2.contractId),
|
|
36441
|
+
sender: parseList(options2.sender),
|
|
36442
|
+
recipient: parseList(options2.recipient),
|
|
36431
36443
|
cursor: options2.cursor,
|
|
36432
36444
|
fromHeight: parseHeight(options2.fromBlock, "--from-block"),
|
|
36433
36445
|
toHeight: parseHeight(options2.toBlock, "--to-block"),
|
|
@@ -36439,19 +36451,21 @@ Examples:
|
|
|
36439
36451
|
process.exit(1);
|
|
36440
36452
|
}
|
|
36441
36453
|
});
|
|
36442
|
-
streams.command("consume").description("Long-running pull from a cursor; emits one event per line (jsonl) until SIGINT or --max-pages").option("--types <types>", `comma-separated event types (${VALID_TYPES.join(", ")})`).option("--
|
|
36454
|
+
streams.command("consume").description("Long-running pull from a cursor; emits one event per line (jsonl) until SIGINT or --max-pages").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("--batch-size <n>", "events per batch (1-1000, default 100)", "100").option("--max-pages <n>", "stop after N pages (default: run until SIGINT)").addHelpText("after", `
|
|
36443
36455
|
Examples:
|
|
36444
36456
|
$ sl streams consume --types print --cursor 150000:0
|
|
36445
|
-
$ sl streams consume --types
|
|
36457
|
+
$ sl streams consume --not-types print --sender SP1...,SP2... --batch-size 500 --max-pages 10`).action(async (options2) => {
|
|
36446
36458
|
try {
|
|
36447
|
-
const types6 = parseTypes(options2.types);
|
|
36448
36459
|
const batchSize = parseLimit(options2.batchSize) ?? 100;
|
|
36449
36460
|
const maxPages = options2.maxPages ? Number.parseInt(options2.maxPages, 10) : undefined;
|
|
36450
36461
|
note("# streaming events to stdout (jsonl); next_cursor printed to stderr");
|
|
36451
36462
|
await client().events.consume({
|
|
36452
36463
|
fromCursor: options2.cursor,
|
|
36453
|
-
types:
|
|
36454
|
-
|
|
36464
|
+
types: parseTypes(options2.types),
|
|
36465
|
+
notTypes: parseTypes(options2.notTypes, "--not-types"),
|
|
36466
|
+
contractId: parseList(options2.contractId),
|
|
36467
|
+
sender: parseList(options2.sender),
|
|
36468
|
+
recipient: parseList(options2.recipient),
|
|
36455
36469
|
batchSize,
|
|
36456
36470
|
mode: "tail",
|
|
36457
36471
|
maxPages,
|
|
@@ -36472,7 +36486,7 @@ Examples:
|
|
|
36472
36486
|
process.exit(1);
|
|
36473
36487
|
}
|
|
36474
36488
|
});
|
|
36475
|
-
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) => {
|
|
36476
36490
|
try {
|
|
36477
36491
|
const envelope = await client().reorgs.list({
|
|
36478
36492
|
since: options2.since,
|
|
@@ -36517,7 +36531,7 @@ Examples:
|
|
|
36517
36531
|
process.exit(1);
|
|
36518
36532
|
}
|
|
36519
36533
|
});
|
|
36520
|
-
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) => {
|
|
36521
36535
|
try {
|
|
36522
36536
|
const height = parseHeight(heightArg, "<height>");
|
|
36523
36537
|
if (height === undefined)
|
|
@@ -36586,6 +36600,96 @@ Examples:
|
|
|
36586
36600
|
}
|
|
36587
36601
|
});
|
|
36588
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
|
+
}
|
|
36589
36693
|
// src/commands/doctor.ts
|
|
36590
36694
|
init_config();
|
|
36591
36695
|
|
|
@@ -37986,6 +38090,40 @@ function registerProjectCommand(program2) {
|
|
|
37986
38090
|
}
|
|
37987
38091
|
});
|
|
37988
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
|
+
});
|
|
37989
38127
|
}
|
|
37990
38128
|
function handleProjectError(err) {
|
|
37991
38129
|
if (err instanceof CliHttpError) {
|
|
@@ -38043,6 +38181,7 @@ registerSubgraphsCommand(program);
|
|
|
38043
38181
|
registerSubscriptionsCommand(program);
|
|
38044
38182
|
registerStreamsCommand(program);
|
|
38045
38183
|
registerDatasetsCommand(program);
|
|
38184
|
+
registerIndexCommand(program);
|
|
38046
38185
|
program.commandsGroup("Project & codegen:");
|
|
38047
38186
|
registerProjectCommand(program);
|
|
38048
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) => {
|
|
@@ -38067,5 +38206,5 @@ program.commandsGroup("Account:");
|
|
|
38067
38206
|
registerAccountCommand(program);
|
|
38068
38207
|
program.parse();
|
|
38069
38208
|
|
|
38070
|
-
//# debugId=
|
|
38209
|
+
//# debugId=11A747050F90401664756E2164756E21
|
|
38071
38210
|
//# sourceMappingURL=cli.js.map
|