@secondlayer/cli 8.5.2 → 8.6.1
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/README.md +1 -0
- package/dist/cli.js +139 -78
- package/dist/cli.js.map +6 -6
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -147,6 +147,7 @@ deliveries/...) operates on both kinds.
|
|
|
147
147
|
| Command | What it does |
|
|
148
148
|
|---|---|
|
|
149
149
|
| `sl contracts generate [files...]` (alias `gen`) | Generate TS interfaces from Clarity contracts |
|
|
150
|
+
| `sl context` | Print a headless orientation snapshot — account, Streams + Index tips, your subgraphs, subscriptions, and in-flight reindex operations. CLI counterpart to the MCP `secondlayer://context` resource |
|
|
150
151
|
| `sl init` | Scaffold `secondlayer.config.ts` |
|
|
151
152
|
| `sl doctor` / `sl status` | Reachability + health checks |
|
|
152
153
|
| `sl account get` / `sl account update` | Show or update display name / bio / slug |
|
package/dist/cli.js
CHANGED
|
@@ -13378,11 +13378,11 @@ var init_manager = __esm(() => {
|
|
|
13378
13378
|
});
|
|
13379
13379
|
|
|
13380
13380
|
// src/services/indexer.ts
|
|
13381
|
-
import { dirname as dirname7, resolve as
|
|
13381
|
+
import { dirname as dirname7, resolve as resolve4 } from "node:path";
|
|
13382
13382
|
async function startIndexer(options2) {
|
|
13383
13383
|
const port = options2.port ?? 3700;
|
|
13384
13384
|
const rootDir = dirname7(dirname7(dirname7(dirname7(import.meta.dir))));
|
|
13385
|
-
const indexerPath =
|
|
13385
|
+
const indexerPath = resolve4(rootDir, "packages/indexer/src/index.ts");
|
|
13386
13386
|
await serviceManager.start(SERVICE_NAME, ["bun", "run", "--watch", indexerPath], {
|
|
13387
13387
|
port,
|
|
13388
13388
|
env: {
|
|
@@ -13398,10 +13398,10 @@ var init_indexer = __esm(() => {
|
|
|
13398
13398
|
});
|
|
13399
13399
|
|
|
13400
13400
|
// src/services/worker.ts
|
|
13401
|
-
import { dirname as dirname8, resolve as
|
|
13401
|
+
import { dirname as dirname8, resolve as resolve5 } from "node:path";
|
|
13402
13402
|
async function startWorker(options2) {
|
|
13403
13403
|
const rootDir = dirname8(dirname8(dirname8(dirname8(import.meta.dir))));
|
|
13404
|
-
const workerPath =
|
|
13404
|
+
const workerPath = resolve5(rootDir, "packages/worker/src/index.ts");
|
|
13405
13405
|
await serviceManager.start(SERVICE_NAME2, ["bun", "run", "--watch", workerPath], {
|
|
13406
13406
|
onStdout: options2.onLog,
|
|
13407
13407
|
onStderr: options2.onLog
|
|
@@ -13413,11 +13413,11 @@ var init_worker = __esm(() => {
|
|
|
13413
13413
|
});
|
|
13414
13414
|
|
|
13415
13415
|
// src/services/api.ts
|
|
13416
|
-
import { dirname as dirname9, resolve as
|
|
13416
|
+
import { dirname as dirname9, resolve as resolve6 } from "node:path";
|
|
13417
13417
|
async function startApi(options2) {
|
|
13418
13418
|
const port = options2.port ?? 3800;
|
|
13419
13419
|
const rootDir = dirname9(dirname9(dirname9(dirname9(import.meta.dir))));
|
|
13420
|
-
const apiPath =
|
|
13420
|
+
const apiPath = resolve6(rootDir, "packages/api/src/index.ts");
|
|
13421
13421
|
await serviceManager.start(SERVICE_NAME3, ["bun", "run", "--watch", apiPath], {
|
|
13422
13422
|
port,
|
|
13423
13423
|
env: {
|
|
@@ -13433,10 +13433,10 @@ var init_api2 = __esm(() => {
|
|
|
13433
13433
|
});
|
|
13434
13434
|
|
|
13435
13435
|
// src/services/subgraph-processor.ts
|
|
13436
|
-
import { dirname as dirname10, resolve as
|
|
13436
|
+
import { dirname as dirname10, resolve as resolve7 } from "node:path";
|
|
13437
13437
|
async function startSubgraphProcessor(options2) {
|
|
13438
13438
|
const rootDir = dirname10(dirname10(dirname10(dirname10(import.meta.dir))));
|
|
13439
|
-
const servicePath =
|
|
13439
|
+
const servicePath = resolve7(rootDir, "packages/subgraphs/src/service.ts");
|
|
13440
13440
|
await serviceManager.start(SERVICE_NAME4, ["bun", "run", "--watch", servicePath], {
|
|
13441
13441
|
env: {
|
|
13442
13442
|
SUBGRAPH_CONCURRENCY: String(options2.concurrency ?? 5)
|
|
@@ -13471,7 +13471,7 @@ __export(exports_dev_impl, {
|
|
|
13471
13471
|
isDevAlreadyRunning: () => isDevAlreadyRunning
|
|
13472
13472
|
});
|
|
13473
13473
|
import { mkdirSync as mkdirSync4 } from "node:fs";
|
|
13474
|
-
import { dirname as dirname11, join as join10, resolve as
|
|
13474
|
+
import { dirname as dirname11, join as join10, resolve as resolve8 } from "node:path";
|
|
13475
13475
|
async function isDevAlreadyRunning() {
|
|
13476
13476
|
if (await isDevRunning()) {
|
|
13477
13477
|
const running = await getRunningServices();
|
|
@@ -13552,7 +13552,7 @@ async function runBackground(options2) {
|
|
|
13552
13552
|
const packagesDir = dirname11(dirname11(dirname11(dirname11(import.meta.dir))));
|
|
13553
13553
|
const env = { DATABASE_URL: databaseUrl, DEV_MODE: "true" };
|
|
13554
13554
|
const apiLogFile = getLogFile("api");
|
|
13555
|
-
const apiProc = Bun.spawn(["bun", "run",
|
|
13555
|
+
const apiProc = Bun.spawn(["bun", "run", resolve8(packagesDir, "packages/api/src/index.ts")], {
|
|
13556
13556
|
env: { ...process.env, ...env, PORT: String(apiPort) },
|
|
13557
13557
|
stdout: Bun.file(apiLogFile),
|
|
13558
13558
|
stderr: Bun.file(apiLogFile)
|
|
@@ -13565,7 +13565,7 @@ async function runBackground(options2) {
|
|
|
13565
13565
|
};
|
|
13566
13566
|
console.log(green(" ✓ API"), dim(`http://localhost:${apiPort}`));
|
|
13567
13567
|
const indexerLogFile = getLogFile("indexer");
|
|
13568
|
-
const indexerProc = Bun.spawn(["bun", "run",
|
|
13568
|
+
const indexerProc = Bun.spawn(["bun", "run", resolve8(packagesDir, "packages/indexer/src/index.ts")], {
|
|
13569
13569
|
env: { ...process.env, ...env, PORT: String(indexerPort) },
|
|
13570
13570
|
stdout: Bun.file(indexerLogFile),
|
|
13571
13571
|
stderr: Bun.file(indexerLogFile)
|
|
@@ -13579,7 +13579,7 @@ async function runBackground(options2) {
|
|
|
13579
13579
|
console.log(green(" ✓ Indexer"), dim(`http://localhost:${indexerPort}`));
|
|
13580
13580
|
if (options2.worker) {
|
|
13581
13581
|
const workerLogFile = getLogFile("worker");
|
|
13582
|
-
const workerProc = Bun.spawn(["bun", "run",
|
|
13582
|
+
const workerProc = Bun.spawn(["bun", "run", resolve8(packagesDir, "packages/worker/src/index.ts")], {
|
|
13583
13583
|
env: { ...process.env, ...env },
|
|
13584
13584
|
stdout: Bun.file(workerLogFile),
|
|
13585
13585
|
stderr: Bun.file(workerLogFile)
|
|
@@ -13597,7 +13597,7 @@ async function runBackground(options2) {
|
|
|
13597
13597
|
const subgraphsProc = Bun.spawn([
|
|
13598
13598
|
"bun",
|
|
13599
13599
|
"run",
|
|
13600
|
-
|
|
13600
|
+
resolve8(packagesDir, "packages/subgraphs/src/service.ts")
|
|
13601
13601
|
], {
|
|
13602
13602
|
env: { ...process.env, ...env },
|
|
13603
13603
|
stdout: Bun.file(subgraphsLogFile),
|
|
@@ -13909,7 +13909,7 @@ async function restartDev() {
|
|
|
13909
13909
|
};
|
|
13910
13910
|
const apiPort = config.ports.api;
|
|
13911
13911
|
const apiLogFile = getLogFile("api");
|
|
13912
|
-
const apiProc = Bun.spawn(["bun", "run",
|
|
13912
|
+
const apiProc = Bun.spawn(["bun", "run", resolve8(packagesDir, "packages/api/src/index.ts")], {
|
|
13913
13913
|
env: { ...process.env, ...env, PORT: String(apiPort) },
|
|
13914
13914
|
stdout: Bun.file(apiLogFile),
|
|
13915
13915
|
stderr: Bun.file(apiLogFile)
|
|
@@ -13923,7 +13923,7 @@ async function restartDev() {
|
|
|
13923
13923
|
console.log(green(" ✓ API"), dim(`http://localhost:${apiPort}`));
|
|
13924
13924
|
const indexerPort = config.ports.indexer;
|
|
13925
13925
|
const indexerLogFile = getLogFile("indexer");
|
|
13926
|
-
const indexerProc = Bun.spawn(["bun", "run",
|
|
13926
|
+
const indexerProc = Bun.spawn(["bun", "run", resolve8(packagesDir, "packages/indexer/src/index.ts")], {
|
|
13927
13927
|
env: { ...process.env, ...env, PORT: String(indexerPort) },
|
|
13928
13928
|
stdout: Bun.file(indexerLogFile),
|
|
13929
13929
|
stderr: Bun.file(indexerLogFile)
|
|
@@ -13937,7 +13937,7 @@ async function restartDev() {
|
|
|
13937
13937
|
console.log(green(" ✓ Indexer"), dim(`http://localhost:${indexerPort}`));
|
|
13938
13938
|
if (state.services.worker) {
|
|
13939
13939
|
const workerLogFile = getLogFile("worker");
|
|
13940
|
-
const workerProc = Bun.spawn(["bun", "run",
|
|
13940
|
+
const workerProc = Bun.spawn(["bun", "run", resolve8(packagesDir, "packages/worker/src/index.ts")], {
|
|
13941
13941
|
env: { ...process.env, ...env },
|
|
13942
13942
|
stdout: Bun.file(workerLogFile),
|
|
13943
13943
|
stderr: Bun.file(workerLogFile)
|
|
@@ -13952,7 +13952,7 @@ async function restartDev() {
|
|
|
13952
13952
|
}
|
|
13953
13953
|
if (state.services.subgraphs) {
|
|
13954
13954
|
const subgraphsLogFile = getLogFile("subgraphs");
|
|
13955
|
-
const subgraphsProc = Bun.spawn(["bun", "run",
|
|
13955
|
+
const subgraphsProc = Bun.spawn(["bun", "run", resolve8(packagesDir, "packages/subgraphs/src/service.ts")], {
|
|
13956
13956
|
env: { ...process.env, ...env },
|
|
13957
13957
|
stdout: Bun.file(subgraphsLogFile),
|
|
13958
13958
|
stderr: Bun.file(subgraphsLogFile)
|
|
@@ -14097,7 +14097,7 @@ async function ensureDevPostgres(dataDir) {
|
|
|
14097
14097
|
}
|
|
14098
14098
|
async function runMigrations(databaseUrl) {
|
|
14099
14099
|
const packagesDir = dirname11(dirname11(dirname11(dirname11(import.meta.dir))));
|
|
14100
|
-
const migrateScript =
|
|
14100
|
+
const migrateScript = resolve8(packagesDir, "packages/shared/src/db/migrate.ts");
|
|
14101
14101
|
const result = await Bun.$`DATABASE_URL=${databaseUrl} bun run ${migrateScript}`.quiet().nothrow();
|
|
14102
14102
|
if (result.exitCode !== 0) {
|
|
14103
14103
|
throw new Error(`Migration failed: ${result.stderr.toString()}`);
|
|
@@ -19132,42 +19132,42 @@ var require_queue = __commonJS((exports, module) => {
|
|
|
19132
19132
|
queue.drained = drained;
|
|
19133
19133
|
return queue;
|
|
19134
19134
|
function push(value) {
|
|
19135
|
-
var p = new Promise(function(
|
|
19135
|
+
var p = new Promise(function(resolve10, reject) {
|
|
19136
19136
|
pushCb(value, function(err, result) {
|
|
19137
19137
|
if (err) {
|
|
19138
19138
|
reject(err);
|
|
19139
19139
|
return;
|
|
19140
19140
|
}
|
|
19141
|
-
|
|
19141
|
+
resolve10(result);
|
|
19142
19142
|
});
|
|
19143
19143
|
});
|
|
19144
19144
|
p.catch(noop5);
|
|
19145
19145
|
return p;
|
|
19146
19146
|
}
|
|
19147
19147
|
function unshift(value) {
|
|
19148
|
-
var p = new Promise(function(
|
|
19148
|
+
var p = new Promise(function(resolve10, reject) {
|
|
19149
19149
|
unshiftCb(value, function(err, result) {
|
|
19150
19150
|
if (err) {
|
|
19151
19151
|
reject(err);
|
|
19152
19152
|
return;
|
|
19153
19153
|
}
|
|
19154
|
-
|
|
19154
|
+
resolve10(result);
|
|
19155
19155
|
});
|
|
19156
19156
|
});
|
|
19157
19157
|
p.catch(noop5);
|
|
19158
19158
|
return p;
|
|
19159
19159
|
}
|
|
19160
19160
|
function drained() {
|
|
19161
|
-
var p = new Promise(function(
|
|
19161
|
+
var p = new Promise(function(resolve10) {
|
|
19162
19162
|
process.nextTick(function() {
|
|
19163
19163
|
if (queue.idle()) {
|
|
19164
|
-
|
|
19164
|
+
resolve10();
|
|
19165
19165
|
} else {
|
|
19166
19166
|
var previousDrain = queue.drain;
|
|
19167
19167
|
queue.drain = function() {
|
|
19168
19168
|
if (typeof previousDrain === "function")
|
|
19169
19169
|
previousDrain();
|
|
19170
|
-
|
|
19170
|
+
resolve10();
|
|
19171
19171
|
queue.drain = previousDrain;
|
|
19172
19172
|
};
|
|
19173
19173
|
}
|
|
@@ -19628,9 +19628,9 @@ var require_stream3 = __commonJS((exports) => {
|
|
|
19628
19628
|
});
|
|
19629
19629
|
}
|
|
19630
19630
|
_getStat(filepath) {
|
|
19631
|
-
return new Promise((
|
|
19631
|
+
return new Promise((resolve10, reject) => {
|
|
19632
19632
|
this._stat(filepath, this._fsStatSettings, (error2, stats) => {
|
|
19633
|
-
return error2 === null ?
|
|
19633
|
+
return error2 === null ? resolve10(stats) : reject(error2);
|
|
19634
19634
|
});
|
|
19635
19635
|
});
|
|
19636
19636
|
}
|
|
@@ -19652,10 +19652,10 @@ var require_async5 = __commonJS((exports) => {
|
|
|
19652
19652
|
this._readerStream = new stream_1.default(this._settings);
|
|
19653
19653
|
}
|
|
19654
19654
|
dynamic(root, options2) {
|
|
19655
|
-
return new Promise((
|
|
19655
|
+
return new Promise((resolve10, reject) => {
|
|
19656
19656
|
this._walkAsync(root, options2, (error2, entries2) => {
|
|
19657
19657
|
if (error2 === null) {
|
|
19658
|
-
|
|
19658
|
+
resolve10(entries2);
|
|
19659
19659
|
} else {
|
|
19660
19660
|
reject(error2);
|
|
19661
19661
|
}
|
|
@@ -19665,10 +19665,10 @@ var require_async5 = __commonJS((exports) => {
|
|
|
19665
19665
|
async static(patterns, options2) {
|
|
19666
19666
|
const entries2 = [];
|
|
19667
19667
|
const stream2 = this._readerStream.static(patterns, options2);
|
|
19668
|
-
return new Promise((
|
|
19668
|
+
return new Promise((resolve10, reject) => {
|
|
19669
19669
|
stream2.once("error", reject);
|
|
19670
19670
|
stream2.on("data", (entry) => entries2.push(entry));
|
|
19671
|
-
stream2.once("end", () =>
|
|
19671
|
+
stream2.once("end", () => resolve10(entries2));
|
|
19672
19672
|
});
|
|
19673
19673
|
}
|
|
19674
19674
|
}
|
|
@@ -21874,7 +21874,7 @@ var init_commands = __esm(() => {
|
|
|
21874
21874
|
});
|
|
21875
21875
|
|
|
21876
21876
|
// ../../node_modules/@antfu/ni/dist/shared/ni.B5qNAuoI.mjs
|
|
21877
|
-
import path4, { join as join12, dirname as dirname13, resolve as
|
|
21877
|
+
import path4, { join as join12, dirname as dirname13, resolve as resolve10 } from "node:path";
|
|
21878
21878
|
import process$1 from "node:process";
|
|
21879
21879
|
import require$$0 from "readline";
|
|
21880
21880
|
import require$$2 from "events";
|
|
@@ -26023,12 +26023,12 @@ var require_isexe = __commonJS((exports, module) => {
|
|
|
26023
26023
|
if (typeof Promise !== "function") {
|
|
26024
26024
|
throw new TypeError("callback not provided");
|
|
26025
26025
|
}
|
|
26026
|
-
return new Promise(function(
|
|
26026
|
+
return new Promise(function(resolve11, reject) {
|
|
26027
26027
|
isexe(path5, options3 || {}, function(er, is2) {
|
|
26028
26028
|
if (er) {
|
|
26029
26029
|
reject(er);
|
|
26030
26030
|
} else {
|
|
26031
|
-
|
|
26031
|
+
resolve11(is2);
|
|
26032
26032
|
}
|
|
26033
26033
|
});
|
|
26034
26034
|
});
|
|
@@ -26090,27 +26090,27 @@ var require_which = __commonJS((exports, module) => {
|
|
|
26090
26090
|
opt = {};
|
|
26091
26091
|
const { pathEnv, pathExt, pathExtExe } = getPathInfo(cmd, opt);
|
|
26092
26092
|
const found = [];
|
|
26093
|
-
const step = (i2) => new Promise((
|
|
26093
|
+
const step = (i2) => new Promise((resolve11, reject) => {
|
|
26094
26094
|
if (i2 === pathEnv.length)
|
|
26095
|
-
return opt.all && found.length ?
|
|
26095
|
+
return opt.all && found.length ? resolve11(found) : reject(getNotFoundError(cmd));
|
|
26096
26096
|
const ppRaw = pathEnv[i2];
|
|
26097
26097
|
const pathPart = /^".*"$/.test(ppRaw) ? ppRaw.slice(1, -1) : ppRaw;
|
|
26098
26098
|
const pCmd = path5.join(pathPart, cmd);
|
|
26099
26099
|
const p2 = !pathPart && /^\.[\\\/]/.test(cmd) ? cmd.slice(0, 2) + pCmd : pCmd;
|
|
26100
|
-
|
|
26100
|
+
resolve11(subStep(p2, i2, 0));
|
|
26101
26101
|
});
|
|
26102
|
-
const subStep = (p2, i2, ii) => new Promise((
|
|
26102
|
+
const subStep = (p2, i2, ii) => new Promise((resolve11, reject) => {
|
|
26103
26103
|
if (ii === pathExt.length)
|
|
26104
|
-
return
|
|
26104
|
+
return resolve11(step(i2 + 1));
|
|
26105
26105
|
const ext = pathExt[ii];
|
|
26106
26106
|
isexe(p2 + ext, { pathExt: pathExtExe }, (er, is2) => {
|
|
26107
26107
|
if (!er && is2) {
|
|
26108
26108
|
if (opt.all)
|
|
26109
26109
|
found.push(p2 + ext);
|
|
26110
26110
|
else
|
|
26111
|
-
return
|
|
26111
|
+
return resolve11(p2 + ext);
|
|
26112
26112
|
}
|
|
26113
|
-
return
|
|
26113
|
+
return resolve11(subStep(p2, i2, ii + 1));
|
|
26114
26114
|
});
|
|
26115
26115
|
});
|
|
26116
26116
|
return cb ? step(0).then((res) => cb(null, res), cb) : step(0);
|
|
@@ -27048,8 +27048,8 @@ var init_validation = __esm(() => {
|
|
|
27048
27048
|
// ../../node_modules/execa/lib/utils/deferred.js
|
|
27049
27049
|
var createDeferred = () => {
|
|
27050
27050
|
const methods = {};
|
|
27051
|
-
const promise = new Promise((
|
|
27052
|
-
Object.assign(methods, { resolve:
|
|
27051
|
+
const promise = new Promise((resolve11, reject) => {
|
|
27052
|
+
Object.assign(methods, { resolve: resolve11, reject });
|
|
27053
27053
|
});
|
|
27054
27054
|
return Object.assign(promise, methods);
|
|
27055
27055
|
};
|
|
@@ -31392,10 +31392,10 @@ var initializeConcurrentStreams = () => ({
|
|
|
31392
31392
|
const promises2 = weakMap.get(stream2);
|
|
31393
31393
|
const promise = createDeferred();
|
|
31394
31394
|
promises2.push(promise);
|
|
31395
|
-
const
|
|
31396
|
-
return { resolve:
|
|
31397
|
-
}, waitForConcurrentStreams = async ({ resolve:
|
|
31398
|
-
|
|
31395
|
+
const resolve11 = promise.resolve.bind(promise);
|
|
31396
|
+
return { resolve: resolve11, promises: promises2 };
|
|
31397
|
+
}, waitForConcurrentStreams = async ({ resolve: resolve11, promises: promises2 }, subprocess) => {
|
|
31398
|
+
resolve11();
|
|
31399
31399
|
const [isSubprocessExit] = await Promise.race([
|
|
31400
31400
|
Promise.allSettled([true, subprocess]),
|
|
31401
31401
|
Promise.all([false, ...promises2])
|
|
@@ -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.6.1",
|
|
32358
32358
|
repository: {
|
|
32359
32359
|
type: "git",
|
|
32360
32360
|
url: "git+https://github.com/ryanwaits/secondlayer.git",
|
|
@@ -32403,10 +32403,10 @@ var package_default = {
|
|
|
32403
32403
|
dependencies: {
|
|
32404
32404
|
"@inquirer/prompts": "^8.2.0",
|
|
32405
32405
|
"@secondlayer/bundler": "^0.3.7",
|
|
32406
|
-
"@secondlayer/sdk": "^6.
|
|
32407
|
-
"@secondlayer/shared": "^6.
|
|
32406
|
+
"@secondlayer/sdk": "^6.16.0",
|
|
32407
|
+
"@secondlayer/shared": "^6.27.0",
|
|
32408
32408
|
"@secondlayer/stacks": "^2.3.0",
|
|
32409
|
-
"@secondlayer/subgraphs": "^3.
|
|
32409
|
+
"@secondlayer/subgraphs": "^3.10.0",
|
|
32410
32410
|
"@biomejs/js-api": "^0.7.0",
|
|
32411
32411
|
"@biomejs/wasm-nodejs": "^1.9.0",
|
|
32412
32412
|
esbuild: "^0.19.0",
|
|
@@ -34127,7 +34127,7 @@ Examples:
|
|
|
34127
34127
|
handleApiError(err, "diagnose subscription");
|
|
34128
34128
|
}
|
|
34129
34129
|
});
|
|
34130
|
-
subscriptions.command("test <idOrName>").description("
|
|
34130
|
+
subscriptions.command("test <idOrName>").description("Inspect a webhook fixture; --post sends a logged test delivery via the server (--local POSTs client-side instead)").option("--signing-secret <secret>", "Signing secret override (--local only)").option("--post", "Send a test delivery via the server (logged, all formats)").option("--local", "With --post: POST the fixture client-side (not logged)").option("--json", "Output as JSON").action(async (idOrName, options) => {
|
|
34131
34131
|
try {
|
|
34132
34132
|
const signingSecret = resolveSigningSecret(options);
|
|
34133
34133
|
const client = await getSubscriptionClient();
|
|
@@ -34139,8 +34139,18 @@ Examples:
|
|
|
34139
34139
|
row,
|
|
34140
34140
|
signingSecret
|
|
34141
34141
|
});
|
|
34142
|
+
if (options.post && !options.local) {
|
|
34143
|
+
const result = await client.subscriptions.test(detail.id);
|
|
34144
|
+
if (options.json) {
|
|
34145
|
+
printJson(result);
|
|
34146
|
+
return;
|
|
34147
|
+
}
|
|
34148
|
+
console.log(dim("Server test delivery:"));
|
|
34149
|
+
console.log(JSON.stringify(result, null, 2));
|
|
34150
|
+
return;
|
|
34151
|
+
}
|
|
34142
34152
|
let postResult = null;
|
|
34143
|
-
if (options.post) {
|
|
34153
|
+
if (options.post && options.local) {
|
|
34144
34154
|
const res = await fetch(detail.url, {
|
|
34145
34155
|
method: "POST",
|
|
34146
34156
|
headers: fixture.headers,
|
|
@@ -34165,7 +34175,7 @@ Curl:`));
|
|
|
34165
34175
|
console.log(fixture.curl);
|
|
34166
34176
|
if (postResult) {
|
|
34167
34177
|
console.log(dim(`
|
|
34168
|
-
POST result:`));
|
|
34178
|
+
POST result (client-side, not logged):`));
|
|
34169
34179
|
console.log(`Status: ${postResult.status}`);
|
|
34170
34180
|
if (postResult.body)
|
|
34171
34181
|
console.log(postResult.body);
|
|
@@ -34620,6 +34630,7 @@ import {
|
|
|
34620
34630
|
import { dirname as dirname5, join as join7, resolve as resolve2 } from "node:path";
|
|
34621
34631
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
34622
34632
|
import { confirm as confirm3 } from "@inquirer/prompts";
|
|
34633
|
+
import { ByoBreakingChangeError } from "@secondlayer/sdk";
|
|
34623
34634
|
|
|
34624
34635
|
// src/generators/subgraph-scaffold.ts
|
|
34625
34636
|
init_format();
|
|
@@ -35659,6 +35670,27 @@ ${dim("Columns")}`);
|
|
|
35659
35670
|
const deployTarget = context.bundled ? "tenant API" : "local database";
|
|
35660
35671
|
info(`Dry run only. No ${deployTarget} changes were made.`);
|
|
35661
35672
|
}
|
|
35673
|
+
function printByoBreakingPlan(details) {
|
|
35674
|
+
error("Refusing breaking schema change on BYO subgraph (no data dropped).");
|
|
35675
|
+
console.log(`
|
|
35676
|
+
Breaking changes:`);
|
|
35677
|
+
for (const r of details.reasons)
|
|
35678
|
+
console.log(` ${red("✗")} ${r}`);
|
|
35679
|
+
console.log(`
|
|
35680
|
+
To rebuild manually, run on YOUR database:`);
|
|
35681
|
+
console.log(` ${details.plan.dropStatement}`);
|
|
35682
|
+
console.log(` ${details.plan.statements.join(`;
|
|
35683
|
+
`)}`);
|
|
35684
|
+
console.log(`
|
|
35685
|
+
Grant (first deploy only):`);
|
|
35686
|
+
for (const line of details.plan.grantScript.split(`
|
|
35687
|
+
`)) {
|
|
35688
|
+
console.log(` ${dim(line)}`);
|
|
35689
|
+
}
|
|
35690
|
+
console.log(`
|
|
35691
|
+
${yellow("This DROPS all rows in that schema, then rebuilds it. Re-deploy after.")}`);
|
|
35692
|
+
console.log(dim("(--force destructive rebuild not yet supported — manual DROP required.)"));
|
|
35693
|
+
}
|
|
35662
35694
|
function formatSubgraphSync(sync) {
|
|
35663
35695
|
const targetBlock = sync.targetBlock ?? sync.chainTip;
|
|
35664
35696
|
const totalBlocks = sync.totalBlocks;
|
|
@@ -35920,6 +35952,14 @@ Stopped watching.`);
|
|
|
35920
35952
|
await closeDb();
|
|
35921
35953
|
}
|
|
35922
35954
|
} catch (err) {
|
|
35955
|
+
if (err instanceof ByoBreakingChangeError) {
|
|
35956
|
+
printByoBreakingPlan(err.details);
|
|
35957
|
+
process.exit(1);
|
|
35958
|
+
}
|
|
35959
|
+
if (err && typeof err === "object" && err.code === "BYO_BREAKING_CHANGE" && err.details) {
|
|
35960
|
+
printByoBreakingPlan(err.details);
|
|
35961
|
+
process.exit(1);
|
|
35962
|
+
}
|
|
35923
35963
|
error(`Failed to deploy subgraph: ${err}`);
|
|
35924
35964
|
process.exit(1);
|
|
35925
35965
|
}
|
|
@@ -36037,11 +36077,11 @@ Synced — exiting watch.`));
|
|
|
36037
36077
|
handleApiError(err, "generate subgraph spec");
|
|
36038
36078
|
}
|
|
36039
36079
|
});
|
|
36040
|
-
subgraphs.command("codegen <file>").description("Generate an ORM schema (Prisma or
|
|
36080
|
+
subgraphs.command("codegen <file>").description("Generate an ORM schema (Prisma, Drizzle, or Kysely) for a subgraph's tables — point it at your BYO database").option("--target <orm>", "ORM target: prisma | drizzle | kysely", "prisma").option("--schema <name>", "Postgres schema name (defaults to subgraph_<name>)").option("--env <var>", "datasource url env var", "DATABASE_URL").option("--models-only", "Emit only Prisma models (compose via prismaSchemaFolder)").option("-o, --output <path>", "Write to a file (defaults to stdout)").action(async (file, options2) => {
|
|
36041
36081
|
try {
|
|
36042
36082
|
const target = options2.target ?? "prisma";
|
|
36043
|
-
if (target !== "prisma" && target !== "drizzle") {
|
|
36044
|
-
error(`Unsupported --target "${target}" (supported: prisma, drizzle
|
|
36083
|
+
if (target !== "prisma" && target !== "drizzle" && target !== "kysely") {
|
|
36084
|
+
error(`Unsupported --target "${target}" (supported: prisma, drizzle, kysely).`);
|
|
36045
36085
|
process.exit(1);
|
|
36046
36086
|
}
|
|
36047
36087
|
const absPath = resolve2(file);
|
|
@@ -36051,7 +36091,11 @@ Synced — exiting watch.`));
|
|
|
36051
36091
|
}
|
|
36052
36092
|
const { readFile: readFile3 } = await import("node:fs/promises");
|
|
36053
36093
|
const { bundleSubgraphCode } = await import("@secondlayer/bundler");
|
|
36054
|
-
const {
|
|
36094
|
+
const {
|
|
36095
|
+
generatePrismaSchema,
|
|
36096
|
+
generateDrizzleSchema,
|
|
36097
|
+
generateKyselySchema
|
|
36098
|
+
} = await import("@secondlayer/subgraphs");
|
|
36055
36099
|
const source = await readFile3(absPath, "utf8");
|
|
36056
36100
|
const bundled = await bundleSubgraphCode(source);
|
|
36057
36101
|
const def = {
|
|
@@ -36062,7 +36106,7 @@ Synced — exiting watch.`));
|
|
|
36062
36106
|
schema: bundled.schema,
|
|
36063
36107
|
handlers: {}
|
|
36064
36108
|
};
|
|
36065
|
-
const out = target === "drizzle" ? generateDrizzleSchema(def, { schemaName: options2.schema }) : generatePrismaSchema(def, {
|
|
36109
|
+
const out = target === "drizzle" ? generateDrizzleSchema(def, { schemaName: options2.schema }) : target === "kysely" ? generateKyselySchema(def, { schemaName: options2.schema }) : generatePrismaSchema(def, {
|
|
36066
36110
|
schemaName: options2.schema,
|
|
36067
36111
|
datasourceEnv: options2.env,
|
|
36068
36112
|
modelsOnly: options2.modelsOnly
|
|
@@ -36070,7 +36114,8 @@ Synced — exiting watch.`));
|
|
|
36070
36114
|
if (options2.output) {
|
|
36071
36115
|
await writeTextFile(resolve2(options2.output), out);
|
|
36072
36116
|
success(`Wrote ${target} schema to ${options2.output}`);
|
|
36073
|
-
|
|
36117
|
+
const next = target === "prisma" ? "point its datasource at your BYO database, then `prisma generate`." : target === "drizzle" ? "point your Drizzle connection at your BYO database (treat tables read-only)." : "import the `DB` type into `new Kysely<DB>()` against your BYO database.";
|
|
36118
|
+
info(`Next: ${next}`);
|
|
36074
36119
|
} else {
|
|
36075
36120
|
process.stdout.write(out);
|
|
36076
36121
|
}
|
|
@@ -36382,20 +36427,9 @@ init_resolve_auth();
|
|
|
36382
36427
|
import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
|
|
36383
36428
|
import { dirname as dirname6, join as join8 } from "node:path";
|
|
36384
36429
|
import { createStreamsClient } from "@secondlayer/sdk";
|
|
36430
|
+
import { STREAMS_EVENT_TYPES } from "@secondlayer/shared";
|
|
36385
36431
|
var DEFAULT_BASE_URL2 = "https://api.secondlayer.tools";
|
|
36386
|
-
var VALID_TYPES =
|
|
36387
|
-
"stx_transfer",
|
|
36388
|
-
"stx_mint",
|
|
36389
|
-
"stx_burn",
|
|
36390
|
-
"stx_lock",
|
|
36391
|
-
"ft_transfer",
|
|
36392
|
-
"ft_mint",
|
|
36393
|
-
"ft_burn",
|
|
36394
|
-
"nft_transfer",
|
|
36395
|
-
"nft_mint",
|
|
36396
|
-
"nft_burn",
|
|
36397
|
-
"print"
|
|
36398
|
-
];
|
|
36432
|
+
var VALID_TYPES = STREAMS_EVENT_TYPES;
|
|
36399
36433
|
function readApiKey() {
|
|
36400
36434
|
const key = resolveEnvKey();
|
|
36401
36435
|
if (!key) {
|
|
@@ -36664,7 +36698,9 @@ Examples:
|
|
|
36664
36698
|
}
|
|
36665
36699
|
// src/commands/index-api.ts
|
|
36666
36700
|
init_output();
|
|
36701
|
+
init_fs();
|
|
36667
36702
|
init_resolve_auth();
|
|
36703
|
+
import { resolve as resolve3 } from "node:path";
|
|
36668
36704
|
import { Index } from "@secondlayer/sdk";
|
|
36669
36705
|
var DEFAULT_BASE_URL4 = "https://api.secondlayer.tools";
|
|
36670
36706
|
function client3() {
|
|
@@ -36716,6 +36752,31 @@ function emitOne(doc, label, json) {
|
|
|
36716
36752
|
}
|
|
36717
36753
|
function registerIndexCommand(program2) {
|
|
36718
36754
|
const index = program2.command("index").description("Query the decoded Index layer (L2 events + contract calls)");
|
|
36755
|
+
index.command("codegen").description("Generate a typed schema (Prisma, Kysely, Drizzle, or JSON-Schema) for the Index domain tables — point it at your BYO database mirror").option("--target <orm>", "prisma | kysely | drizzle | json-schema", "kysely").option("--schema <name>", "Postgres schema to qualify table names with").option("--tables <list>", "Comma-separated subset of Index tables (default: all)").option("--env <var>", "Prisma datasource url env var", "DATABASE_URL").option("-o, --output <path>", "Write to a file (defaults to stdout)").action(async (o) => {
|
|
36756
|
+
try {
|
|
36757
|
+
const target = o.target ?? "kysely";
|
|
36758
|
+
if (target !== "prisma" && target !== "kysely" && target !== "drizzle" && target !== "json-schema") {
|
|
36759
|
+
error(`Unsupported --target "${target}" (supported: prisma, kysely, drizzle, json-schema).`);
|
|
36760
|
+
process.exit(1);
|
|
36761
|
+
}
|
|
36762
|
+
const { generateIndexSchema } = await import("@secondlayer/subgraphs");
|
|
36763
|
+
const tables = o.tables ? o.tables.split(",").map((t) => t.trim()).filter(Boolean) : undefined;
|
|
36764
|
+
const out = generateIndexSchema(target, {
|
|
36765
|
+
schemaName: o.schema,
|
|
36766
|
+
tables,
|
|
36767
|
+
datasourceEnv: o.env
|
|
36768
|
+
});
|
|
36769
|
+
if (o.output) {
|
|
36770
|
+
await writeTextFile(resolve3(o.output), out);
|
|
36771
|
+
success(`Wrote ${target} Index schema to ${o.output}`);
|
|
36772
|
+
} else {
|
|
36773
|
+
process.stdout.write(out);
|
|
36774
|
+
}
|
|
36775
|
+
} catch (err) {
|
|
36776
|
+
error(`Failed to generate Index schema: ${err}`);
|
|
36777
|
+
process.exit(1);
|
|
36778
|
+
}
|
|
36779
|
+
});
|
|
36719
36780
|
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");
|
|
36720
36781
|
const heightFlags = (cmd) => cmd.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");
|
|
36721
36782
|
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) => {
|
|
@@ -38064,7 +38125,7 @@ init_output();
|
|
|
38064
38125
|
import { existsSync as existsSync5 } from "node:fs";
|
|
38065
38126
|
import { mkdir as mkdir4, readFile as readFile3, writeFile as writeFile4 } from "node:fs/promises";
|
|
38066
38127
|
import { homedir as homedir5 } from "node:os";
|
|
38067
|
-
import { dirname as dirname12, join as join11, parse as parsePath2, resolve as
|
|
38128
|
+
import { dirname as dirname12, join as join11, parse as parsePath2, resolve as resolve9 } from "node:path";
|
|
38068
38129
|
import { z as z3 } from "zod/v4";
|
|
38069
38130
|
var ProjectFileSchema = z3.object({
|
|
38070
38131
|
slug: z3.string().min(1)
|
|
@@ -38072,8 +38133,8 @@ var ProjectFileSchema = z3.object({
|
|
|
38072
38133
|
var FILENAME = "project";
|
|
38073
38134
|
var DIRNAME = ".secondlayer";
|
|
38074
38135
|
async function readActiveProject(cwd, globalDefault) {
|
|
38075
|
-
let dir =
|
|
38076
|
-
const home =
|
|
38136
|
+
let dir = resolve9(cwd);
|
|
38137
|
+
const home = resolve9(homedir5());
|
|
38077
38138
|
const fsRoot = parsePath2(dir).root;
|
|
38078
38139
|
while (true) {
|
|
38079
38140
|
const candidate = join11(dir, DIRNAME, FILENAME);
|
|
@@ -38102,7 +38163,7 @@ async function readActiveProject(cwd, globalDefault) {
|
|
|
38102
38163
|
return null;
|
|
38103
38164
|
}
|
|
38104
38165
|
async function writeActiveProject(slug, cwd) {
|
|
38105
|
-
const dir = join11(
|
|
38166
|
+
const dir = join11(resolve9(cwd), DIRNAME);
|
|
38106
38167
|
await mkdir4(dir, { recursive: true });
|
|
38107
38168
|
const file = join11(dir, FILENAME);
|
|
38108
38169
|
await writeFile4(file, `${JSON.stringify({ slug }, null, 2)}
|
|
@@ -38397,5 +38458,5 @@ registerAccountCommand(program);
|
|
|
38397
38458
|
registerKeysCommand(program);
|
|
38398
38459
|
program.parse();
|
|
38399
38460
|
|
|
38400
|
-
//# debugId=
|
|
38461
|
+
//# debugId=2E1CD81E99BBC74264756E2164756E21
|
|
38401
38462
|
//# sourceMappingURL=cli.js.map
|