@secondlayer/cli 8.5.2 → 8.6.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/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 resolve3 } from "node:path";
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 = resolve3(rootDir, "packages/indexer/src/index.ts");
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 resolve4 } from "node:path";
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 = resolve4(rootDir, "packages/worker/src/index.ts");
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 resolve5 } from "node:path";
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 = resolve5(rootDir, "packages/api/src/index.ts");
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 resolve6 } from "node:path";
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 = resolve6(rootDir, "packages/subgraphs/src/service.ts");
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 resolve7 } from "node:path";
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", resolve7(packagesDir, "packages/api/src/index.ts")], {
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", resolve7(packagesDir, "packages/indexer/src/index.ts")], {
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", resolve7(packagesDir, "packages/worker/src/index.ts")], {
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
- resolve7(packagesDir, "packages/subgraphs/src/service.ts")
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", resolve7(packagesDir, "packages/api/src/index.ts")], {
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", resolve7(packagesDir, "packages/indexer/src/index.ts")], {
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", resolve7(packagesDir, "packages/worker/src/index.ts")], {
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", resolve7(packagesDir, "packages/subgraphs/src/service.ts")], {
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 = resolve7(packagesDir, "packages/shared/src/db/migrate.ts");
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(resolve9, reject) {
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
- resolve9(result);
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(resolve9, reject) {
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
- resolve9(result);
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(resolve9) {
19161
+ var p = new Promise(function(resolve10) {
19162
19162
  process.nextTick(function() {
19163
19163
  if (queue.idle()) {
19164
- resolve9();
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
- resolve9();
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((resolve9, reject) => {
19631
+ return new Promise((resolve10, reject) => {
19632
19632
  this._stat(filepath, this._fsStatSettings, (error2, stats) => {
19633
- return error2 === null ? resolve9(stats) : reject(error2);
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((resolve9, reject) => {
19655
+ return new Promise((resolve10, reject) => {
19656
19656
  this._walkAsync(root, options2, (error2, entries2) => {
19657
19657
  if (error2 === null) {
19658
- resolve9(entries2);
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((resolve9, reject) => {
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", () => resolve9(entries2));
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 resolve9 } from "node:path";
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(resolve10, reject) {
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
- resolve10(is2);
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((resolve10, reject) => {
26093
+ const step = (i2) => new Promise((resolve11, reject) => {
26094
26094
  if (i2 === pathEnv.length)
26095
- return opt.all && found.length ? resolve10(found) : reject(getNotFoundError(cmd));
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
- resolve10(subStep(p2, i2, 0));
26100
+ resolve11(subStep(p2, i2, 0));
26101
26101
  });
26102
- const subStep = (p2, i2, ii) => new Promise((resolve10, reject) => {
26102
+ const subStep = (p2, i2, ii) => new Promise((resolve11, reject) => {
26103
26103
  if (ii === pathExt.length)
26104
- return resolve10(step(i2 + 1));
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 resolve10(p2 + ext);
26111
+ return resolve11(p2 + ext);
26112
26112
  }
26113
- return resolve10(subStep(p2, i2, ii + 1));
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((resolve10, reject) => {
27052
- Object.assign(methods, { resolve: resolve10, reject });
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 resolve10 = promise.resolve.bind(promise);
31396
- return { resolve: resolve10, promises: promises2 };
31397
- }, waitForConcurrentStreams = async ({ resolve: resolve10, promises: promises2 }, subprocess) => {
31398
- resolve10();
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.5.2",
32357
+ version: "8.6.0",
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.10.0",
32407
- "@secondlayer/shared": "^6.23.0",
32406
+ "@secondlayer/sdk": "^6.14.0",
32407
+ "@secondlayer/shared": "^6.25.0",
32408
32408
  "@secondlayer/stacks": "^2.3.0",
32409
- "@secondlayer/subgraphs": "^3.7.3",
32409
+ "@secondlayer/subgraphs": "^3.8.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("Build and optionally POST a signed Standard Webhooks fixture").option("--signing-secret <secret>", "Signing secret override").option("--post", "POST the fixture to the subscription URL").option("--json", "Output as JSON").action(async (idOrName, options) => {
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);
@@ -36037,11 +36047,11 @@ Synced — exiting watch.`));
36037
36047
  handleApiError(err, "generate subgraph spec");
36038
36048
  }
36039
36049
  });
36040
- subgraphs.command("codegen <file>").description("Generate an ORM schema (Prisma or Drizzle) for a subgraph's tables — point it at your BYO database").option("--target <orm>", "ORM target: prisma | drizzle", "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) => {
36050
+ 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
36051
  try {
36042
36052
  const target = options2.target ?? "prisma";
36043
- if (target !== "prisma" && target !== "drizzle") {
36044
- error(`Unsupported --target "${target}" (supported: prisma, drizzle). For Kysely, run kysely-codegen against your database.`);
36053
+ if (target !== "prisma" && target !== "drizzle" && target !== "kysely") {
36054
+ error(`Unsupported --target "${target}" (supported: prisma, drizzle, kysely).`);
36045
36055
  process.exit(1);
36046
36056
  }
36047
36057
  const absPath = resolve2(file);
@@ -36051,7 +36061,11 @@ Synced — exiting watch.`));
36051
36061
  }
36052
36062
  const { readFile: readFile3 } = await import("node:fs/promises");
36053
36063
  const { bundleSubgraphCode } = await import("@secondlayer/bundler");
36054
- const { generatePrismaSchema, generateDrizzleSchema } = await import("@secondlayer/subgraphs");
36064
+ const {
36065
+ generatePrismaSchema,
36066
+ generateDrizzleSchema,
36067
+ generateKyselySchema
36068
+ } = await import("@secondlayer/subgraphs");
36055
36069
  const source = await readFile3(absPath, "utf8");
36056
36070
  const bundled = await bundleSubgraphCode(source);
36057
36071
  const def = {
@@ -36062,7 +36076,7 @@ Synced — exiting watch.`));
36062
36076
  schema: bundled.schema,
36063
36077
  handlers: {}
36064
36078
  };
36065
- const out = target === "drizzle" ? generateDrizzleSchema(def, { schemaName: options2.schema }) : generatePrismaSchema(def, {
36079
+ const out = target === "drizzle" ? generateDrizzleSchema(def, { schemaName: options2.schema }) : target === "kysely" ? generateKyselySchema(def, { schemaName: options2.schema }) : generatePrismaSchema(def, {
36066
36080
  schemaName: options2.schema,
36067
36081
  datasourceEnv: options2.env,
36068
36082
  modelsOnly: options2.modelsOnly
@@ -36070,7 +36084,8 @@ Synced — exiting watch.`));
36070
36084
  if (options2.output) {
36071
36085
  await writeTextFile(resolve2(options2.output), out);
36072
36086
  success(`Wrote ${target} schema to ${options2.output}`);
36073
- info("Next: point its datasource at your BYO database, then `prisma generate`.");
36087
+ 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.";
36088
+ info(`Next: ${next}`);
36074
36089
  } else {
36075
36090
  process.stdout.write(out);
36076
36091
  }
@@ -36382,20 +36397,9 @@ init_resolve_auth();
36382
36397
  import { mkdir as mkdir3, writeFile as writeFile3 } from "node:fs/promises";
36383
36398
  import { dirname as dirname6, join as join8 } from "node:path";
36384
36399
  import { createStreamsClient } from "@secondlayer/sdk";
36400
+ import { STREAMS_EVENT_TYPES } from "@secondlayer/shared";
36385
36401
  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
- ];
36402
+ var VALID_TYPES = STREAMS_EVENT_TYPES;
36399
36403
  function readApiKey() {
36400
36404
  const key = resolveEnvKey();
36401
36405
  if (!key) {
@@ -36664,7 +36668,9 @@ Examples:
36664
36668
  }
36665
36669
  // src/commands/index-api.ts
36666
36670
  init_output();
36671
+ init_fs();
36667
36672
  init_resolve_auth();
36673
+ import { resolve as resolve3 } from "node:path";
36668
36674
  import { Index } from "@secondlayer/sdk";
36669
36675
  var DEFAULT_BASE_URL4 = "https://api.secondlayer.tools";
36670
36676
  function client3() {
@@ -36716,6 +36722,31 @@ function emitOne(doc, label, json) {
36716
36722
  }
36717
36723
  function registerIndexCommand(program2) {
36718
36724
  const index = program2.command("index").description("Query the decoded Index layer (L2 events + contract calls)");
36725
+ 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) => {
36726
+ try {
36727
+ const target = o.target ?? "kysely";
36728
+ if (target !== "prisma" && target !== "kysely" && target !== "drizzle" && target !== "json-schema") {
36729
+ error(`Unsupported --target "${target}" (supported: prisma, kysely, drizzle, json-schema).`);
36730
+ process.exit(1);
36731
+ }
36732
+ const { generateIndexSchema } = await import("@secondlayer/subgraphs");
36733
+ const tables = o.tables ? o.tables.split(",").map((t) => t.trim()).filter(Boolean) : undefined;
36734
+ const out = generateIndexSchema(target, {
36735
+ schemaName: o.schema,
36736
+ tables,
36737
+ datasourceEnv: o.env
36738
+ });
36739
+ if (o.output) {
36740
+ await writeTextFile(resolve3(o.output), out);
36741
+ success(`Wrote ${target} Index schema to ${o.output}`);
36742
+ } else {
36743
+ process.stdout.write(out);
36744
+ }
36745
+ } catch (err) {
36746
+ error(`Failed to generate Index schema: ${err}`);
36747
+ process.exit(1);
36748
+ }
36749
+ });
36719
36750
  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
36751
  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
36752
  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 +38095,7 @@ init_output();
38064
38095
  import { existsSync as existsSync5 } from "node:fs";
38065
38096
  import { mkdir as mkdir4, readFile as readFile3, writeFile as writeFile4 } from "node:fs/promises";
38066
38097
  import { homedir as homedir5 } from "node:os";
38067
- import { dirname as dirname12, join as join11, parse as parsePath2, resolve as resolve8 } from "node:path";
38098
+ import { dirname as dirname12, join as join11, parse as parsePath2, resolve as resolve9 } from "node:path";
38068
38099
  import { z as z3 } from "zod/v4";
38069
38100
  var ProjectFileSchema = z3.object({
38070
38101
  slug: z3.string().min(1)
@@ -38072,8 +38103,8 @@ var ProjectFileSchema = z3.object({
38072
38103
  var FILENAME = "project";
38073
38104
  var DIRNAME = ".secondlayer";
38074
38105
  async function readActiveProject(cwd, globalDefault) {
38075
- let dir = resolve8(cwd);
38076
- const home = resolve8(homedir5());
38106
+ let dir = resolve9(cwd);
38107
+ const home = resolve9(homedir5());
38077
38108
  const fsRoot = parsePath2(dir).root;
38078
38109
  while (true) {
38079
38110
  const candidate = join11(dir, DIRNAME, FILENAME);
@@ -38102,7 +38133,7 @@ async function readActiveProject(cwd, globalDefault) {
38102
38133
  return null;
38103
38134
  }
38104
38135
  async function writeActiveProject(slug, cwd) {
38105
- const dir = join11(resolve8(cwd), DIRNAME);
38136
+ const dir = join11(resolve9(cwd), DIRNAME);
38106
38137
  await mkdir4(dir, { recursive: true });
38107
38138
  const file = join11(dir, FILENAME);
38108
38139
  await writeFile4(file, `${JSON.stringify({ slug }, null, 2)}
@@ -38397,5 +38428,5 @@ registerAccountCommand(program);
38397
38428
  registerKeysCommand(program);
38398
38429
  program.parse();
38399
38430
 
38400
- //# debugId=4DE21216DA94981F64756E2164756E21
38431
+ //# debugId=4B510B33E0FD574464756E2164756E21
38401
38432
  //# sourceMappingURL=cli.js.map