@secondlayer/cli 16.1.1 → 16.3.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 +56 -32
- package/dist/cli.js.map +8 -8
- package/package.json +5 -5
package/dist/cli.js
CHANGED
|
@@ -2288,6 +2288,24 @@ function resolveDataPlaneKey() {
|
|
|
2288
2288
|
return resolveAccountKey();
|
|
2289
2289
|
return resolveApiKey();
|
|
2290
2290
|
}
|
|
2291
|
+
async function resolveHostedAuth() {
|
|
2292
|
+
if (isMerchantUrl()) {
|
|
2293
|
+
const accountKey = resolveAccountKey();
|
|
2294
|
+
if (accountKey) {
|
|
2295
|
+
return {
|
|
2296
|
+
apiUrl: resolveApiUrl(),
|
|
2297
|
+
ephemeralKey: accountKey,
|
|
2298
|
+
fromEnv: true
|
|
2299
|
+
};
|
|
2300
|
+
}
|
|
2301
|
+
}
|
|
2302
|
+
return resolveAuth();
|
|
2303
|
+
}
|
|
2304
|
+
function assertInstanceOrAccountKey(url = resolveApiUrl()) {
|
|
2305
|
+
if (resolveAccountKey())
|
|
2306
|
+
return;
|
|
2307
|
+
assertInstanceUrl(url);
|
|
2308
|
+
}
|
|
2291
2309
|
var init_resolve_auth = __esm(() => {
|
|
2292
2310
|
init_session();
|
|
2293
2311
|
});
|
|
@@ -29057,11 +29075,11 @@ async function deleteSubgraphApi(name, options) {
|
|
|
29057
29075
|
async function deploySubgraphApi(data) {
|
|
29058
29076
|
return (await getPlatformClient()).subgraphs.deploy(data);
|
|
29059
29077
|
}
|
|
29060
|
-
async function
|
|
29061
|
-
return (await getPlatformClient()).subgraphs.
|
|
29078
|
+
async function querySubgraphTableRows(name, table, params = {}) {
|
|
29079
|
+
return (await getPlatformClient()).subgraphs.rows(name, table, params);
|
|
29062
29080
|
}
|
|
29063
29081
|
async function querySubgraphTableCount(name, table, params = {}) {
|
|
29064
|
-
return (await getPlatformClient()).subgraphs.
|
|
29082
|
+
return (await getPlatformClient()).subgraphs.count(name, table, params);
|
|
29065
29083
|
}
|
|
29066
29084
|
async function getSubgraphGaps(name, opts) {
|
|
29067
29085
|
return (await getPlatformClient()).subgraphs.gaps(name, opts);
|
|
@@ -200022,7 +200040,7 @@ ${result.meta.total} gap(s), ${result.meta.totalMissingBlocks} total missing blo
|
|
|
200022
200040
|
handleApiError(err, "get subgraph gaps");
|
|
200023
200041
|
}
|
|
200024
200042
|
});
|
|
200025
|
-
subgraphs.command("query <name> <table>").description("Query a subgraph table").option("--sort <column>", "Sort by column").option("--order <dir>", "Sort direction (asc|desc)", "asc").option("--limit <n>", "Max rows to return", "20").option("--
|
|
200043
|
+
subgraphs.command("query <name> <table>").description("Query a subgraph table").option("--sort <column>", "Sort by column").option("--order <dir>", "Sort direction (asc|desc)", "asc").option("--limit <n>", "Max rows to return", "20").option("--cursor <token>", "Resume from a previous page's next_cursor").option("--fields <cols>", "Comma-separated columns to include").option("--filter <kv...>", "Filter as key=value (supports .gte/.lte/.gt/.lt/.neq suffixes)").option("--count", "Return row count only").option("--json", "Output as JSON").addHelpText("after", `
|
|
200026
200044
|
Examples:
|
|
200027
200045
|
$ secondlayer subgraphs query my-graph balances --filter holder=SP2J6ZY... --limit 50
|
|
200028
200046
|
$ secondlayer subgraphs query my-graph transfers --filter amount.gte=1000 --sort _block_height --order desc
|
|
@@ -200035,16 +200053,10 @@ Examples:
|
|
|
200035
200053
|
error(err instanceof Error ? err.message : String(err));
|
|
200036
200054
|
process.exit(1);
|
|
200037
200055
|
}
|
|
200038
|
-
const params = {
|
|
200039
|
-
sort: options.sort,
|
|
200040
|
-
order: options.sort ? options.order : undefined,
|
|
200041
|
-
limit: Number.parseInt(options.limit, 10),
|
|
200042
|
-
offset: options.offset ? Number.parseInt(options.offset, 10) : undefined,
|
|
200043
|
-
fields: options.fields,
|
|
200044
|
-
filters
|
|
200045
|
-
};
|
|
200046
200056
|
if (options.count) {
|
|
200047
|
-
const result = await querySubgraphTableCount(name, table,
|
|
200057
|
+
const result = await querySubgraphTableCount(name, table, {
|
|
200058
|
+
filters
|
|
200059
|
+
});
|
|
200048
200060
|
if (options.json) {
|
|
200049
200061
|
console.log(JSON.stringify(result, null, 2));
|
|
200050
200062
|
} else {
|
|
@@ -200052,20 +200064,28 @@ Examples:
|
|
|
200052
200064
|
}
|
|
200053
200065
|
return;
|
|
200054
200066
|
}
|
|
200055
|
-
const
|
|
200067
|
+
const params = {
|
|
200068
|
+
sort: options.sort,
|
|
200069
|
+
order: options.sort ? options.order : undefined,
|
|
200070
|
+
limit: Number.parseInt(options.limit, 10),
|
|
200071
|
+
fields: options.fields,
|
|
200072
|
+
filters,
|
|
200073
|
+
cursor: options.cursor
|
|
200074
|
+
};
|
|
200075
|
+
const { rows: resultRows, next_cursor } = await querySubgraphTableRows(name, table, params);
|
|
200056
200076
|
if (options.json) {
|
|
200057
|
-
console.log(JSON.stringify(rows, null, 2));
|
|
200077
|
+
console.log(JSON.stringify({ rows: resultRows, next_cursor }, null, 2));
|
|
200058
200078
|
return;
|
|
200059
200079
|
}
|
|
200060
|
-
if (
|
|
200080
|
+
if (resultRows.length === 0) {
|
|
200061
200081
|
console.log(dim("No rows found"));
|
|
200062
200082
|
return;
|
|
200063
200083
|
}
|
|
200064
|
-
const firstRow =
|
|
200084
|
+
const firstRow = resultRows[0];
|
|
200065
200085
|
if (!firstRow)
|
|
200066
200086
|
return;
|
|
200067
200087
|
const columns = Object.keys(firstRow);
|
|
200068
|
-
const tableRows =
|
|
200088
|
+
const tableRows = resultRows.map((row) => columns.map((col) => {
|
|
200069
200089
|
const val = row[col];
|
|
200070
200090
|
if (val === null || val === undefined)
|
|
200071
200091
|
return dim("-");
|
|
@@ -200075,7 +200095,10 @@ Examples:
|
|
|
200075
200095
|
}));
|
|
200076
200096
|
console.log(formatTable(columns, tableRows));
|
|
200077
200097
|
console.log(dim(`
|
|
200078
|
-
${
|
|
200098
|
+
${resultRows.length} row(s)`));
|
|
200099
|
+
if (next_cursor) {
|
|
200100
|
+
console.log(dim(`next_cursor: ${next_cursor}`));
|
|
200101
|
+
}
|
|
200079
200102
|
} catch (err) {
|
|
200080
200103
|
handleApiError(err, "query subgraph");
|
|
200081
200104
|
}
|
|
@@ -204289,7 +204312,7 @@ var {
|
|
|
204289
204312
|
// package.json
|
|
204290
204313
|
var package_default = {
|
|
204291
204314
|
name: "@secondlayer/cli",
|
|
204292
|
-
version: "16.
|
|
204315
|
+
version: "16.3.0",
|
|
204293
204316
|
description: "Run a Stacks index on your own hardware — set it up, restore verified history, and keep it current.",
|
|
204294
204317
|
repository: {
|
|
204295
204318
|
type: "git",
|
|
@@ -204328,12 +204351,12 @@ var package_default = {
|
|
|
204328
204351
|
"@inquirer/prompts": "^8.2.0",
|
|
204329
204352
|
"@opentui/core": "^0.5.3",
|
|
204330
204353
|
"@opentui/react": "^0.5.3",
|
|
204331
|
-
"@secondlayer/bundler": "^0.6.
|
|
204332
|
-
"@secondlayer/scaffold": "^1.6.
|
|
204333
|
-
"@secondlayer/sdk": "^
|
|
204354
|
+
"@secondlayer/bundler": "^0.6.1",
|
|
204355
|
+
"@secondlayer/scaffold": "^1.6.1",
|
|
204356
|
+
"@secondlayer/sdk": "^11.0.0",
|
|
204334
204357
|
"@secondlayer/shared": "^11.8.1",
|
|
204335
204358
|
"@secondlayer/stacks": "^6.1.0",
|
|
204336
|
-
"@secondlayer/subgraphs": "^
|
|
204359
|
+
"@secondlayer/subgraphs": "^6.1.0",
|
|
204337
204360
|
esbuild: "^0.28.2",
|
|
204338
204361
|
react: "^19.1.0",
|
|
204339
204362
|
"smol-toml": "^1.8.0",
|
|
@@ -206793,7 +206816,7 @@ async function createChainWebhook(name, opts) {
|
|
|
206793
206816
|
secondlayer webhooks get ${name}`);
|
|
206794
206817
|
}
|
|
206795
206818
|
async function getWebhookClient() {
|
|
206796
|
-
const { apiUrl, ephemeralKey } = await
|
|
206819
|
+
const { apiUrl, ephemeralKey } = await resolveHostedAuth();
|
|
206797
206820
|
return new SecondLayer4({ baseUrl: apiUrl, apiKey: ephemeralKey });
|
|
206798
206821
|
}
|
|
206799
206822
|
function addWebhookScaffold(parent, commandSpec, opts) {
|
|
@@ -207127,13 +207150,14 @@ async function representativeRow(client, sub, subgraph) {
|
|
|
207127
207150
|
};
|
|
207128
207151
|
}
|
|
207129
207152
|
try {
|
|
207130
|
-
const rows = await client.subgraphs.
|
|
207153
|
+
const { rows } = await client.subgraphs.rows(sub.subgraphName, sub.tableName, {
|
|
207131
207154
|
sort: "_block_height",
|
|
207132
207155
|
order: "desc",
|
|
207133
207156
|
limit: 1
|
|
207134
207157
|
});
|
|
207135
|
-
|
|
207136
|
-
|
|
207158
|
+
const row = rows[0];
|
|
207159
|
+
if (row && typeof row === "object")
|
|
207160
|
+
return row;
|
|
207137
207161
|
} catch {}
|
|
207138
207162
|
return buildSyntheticRow(subgraph, sub.tableName);
|
|
207139
207163
|
}
|
|
@@ -207458,7 +207482,7 @@ POST result (client-side, not logged):`));
|
|
|
207458
207482
|
}
|
|
207459
207483
|
function registerWebhooksCommand(program) {
|
|
207460
207484
|
const webhooks = program.command("webhooks").alias("hooks").description("Manage webhooks: a signed POST to a URL you run");
|
|
207461
|
-
webhooks.hook("preAction", () =>
|
|
207485
|
+
webhooks.hook("preAction", () => assertInstanceOrAccountKey());
|
|
207462
207486
|
attachWebhookSubcommands(webhooks);
|
|
207463
207487
|
}
|
|
207464
207488
|
// src/commands/devnet.ts
|
|
@@ -207857,8 +207881,8 @@ async function renderStatus(limit) {
|
|
|
207857
207881
|
const rows = [];
|
|
207858
207882
|
for (const sg of subs) {
|
|
207859
207883
|
for (const table of sg.tables ?? []) {
|
|
207860
|
-
const res = await jget(`${API_URL}/
|
|
207861
|
-
for (const row of res?.
|
|
207884
|
+
const res = await jget(`${API_URL}/v1/subgraphs/${sg.name}/${table}?_limit=${limit}&_sort=_block_height&_order=desc`);
|
|
207885
|
+
for (const row of res?.rows ?? []) {
|
|
207862
207886
|
const summary = Object.entries(row).filter(([k]) => !SYS_COLS.has(k)).map(([, v]) => shortVal(v)).join(" ");
|
|
207863
207887
|
rows.push({ block: Number(row._block_height ?? 0), table, summary });
|
|
207864
207888
|
}
|
|
@@ -209666,5 +209690,5 @@ registerCreditsCommand(program);
|
|
|
209666
209690
|
registerArchiveCommand(program);
|
|
209667
209691
|
program.parse();
|
|
209668
209692
|
|
|
209669
|
-
//# debugId=
|
|
209693
|
+
//# debugId=0A6B47175E9A5E8864756E2164756E21
|
|
209670
209694
|
//# sourceMappingURL=cli.js.map
|